title: Chess Validation Move input wanted
body: <p>So, I have gotten quite far in my mission to finish a chess game in c++. However, I have hit a bit of a small issue I would like to get some input on, please. </p>
  
  <p>SITUATION:</p>
  
  <p>My PAWN, KING, KNIGHT move validations work perfect. But;
  When moving a piece(such as a white ROOK) it follows most of the rules. For example, it will only move vertical or horizontal, it will not pass another white piece, it will not replace a white piece, and lastly it WILL replace a black (opposing) piece.</p>
  
  <p>The problem is when moving it past a another black piece, it allows passing in order to replace a piece that's past it. So lets say we have a white piece at x=2,y=6 and black piece at x=2,y=4, and another black piece at x=2,y=3. The White piece will be allowed to move to move to x=2,y=3, which should not be allowed. Would love to get some input on how to fix this. Current code below.</p>
  
  <pre><code>bool Rook:: canMove(int startx, int starty, int endx, int endy)
  {
      int i;
      if(board[endx][endy] !=NULL &amp;&amp; board[endx][endy]-&gt;color==color)
          return false;
      if (startx == ends) //Collision Detection...
      {
          // Horizontal move
          if (starty &lt; endy)
          {
              // Move down
              for (i = starty + 1; i &lt;= endy; ++i)
                  if (board[startx][i] != NULL &amp;&amp; board[startx][i]-&gt;color==color)
                      return false;
  
          }
          else
          {
              // Move up
              for (i = starty - 1; i &gt;= endy; --i)
                  if (board[startx][i] != NULL &amp;&amp; board[startx][i]-&gt;color==color) //cant allow passing of non color piece
                      return false;
          }
      }
      else if (starty == endy)
      {
          // Vertical move
          if (startx &lt; endx)
          {
              // Move right
              for (i = startx + 1; i &lt;= endx; ++i)
                  if (board[i][starty] != NULL &amp;&amp; board[i][starty]-&gt;color==color)
                      return false;
          }
          else
          {
              // Move left
              for (i = startx - 1; i &gt;= endx; --i)
                  if (board[i][starty] != NULL &amp;&amp; board[i][starty]-&gt;color==color)
                      return false;
          }
      }
      else
      {
          // Not a valid rook move (neither horizontal nor vertical)
          return false;
      }
  
      return true;
  }
  </code></pre>