Beispiel #1
0
 public static bool NoShipsInPath(int shipLength, Board board, int x, int y, int yEndPoint)
 {
     for (int i = 0; i < shipLength; i++)
     {
         int addToYCoord = (yEndPoint == 0) ? 0 : i;
         int addToXCoord = (addToYCoord == 0) ? i : 0;
         if ((!board.IsSpaceEmpty(x + addToXCoord, y + addToYCoord, board) && i != 0) || (!board.IsSpaceEmpty(x, y, board) && i == 0))
         {
             Errors.ErrorMessage = "That direction goes through another ship, please choose a different direction";
             return(false);
         }
     }
     return(true);
 }