Esempio n. 1
0
        public override void setToolOptions(Tool[,] board, bool iswhiteTurn, int countGameMovments, int row, int column)
        {
            int options = 0;

            Location[] queenOptions = new Location[32];
            Bishop     bishop       = new Bishop(getName(), getColor(), isFirstMove());
            Rook       rook         = new Rook(getName(), getColor(), isFirstMove());

            bishop.setToolOptions(board, iswhiteTurn, countGameMovments, row, column);
            Location[] toolOptions1 = bishop.getToolOptions();
            if (toolOptions1 != null)
            {
                foreach (Location move in toolOptions1)
                {
                    queenOptions[options] = move;
                    options++;
                }
            }
            rook.setToolOptions(board, iswhiteTurn, countGameMovments, row, column);
            Location[] toolOptions2 = rook.getToolOptions();
            if (toolOptions2 != null)
            {
                foreach (Location move in toolOptions2)
                {
                    queenOptions[options] = move;
                    options++;
                }
            }
            this.toolOptions = queenOptions;
        }
Esempio n. 2
0
        public void crowningPawn()
        {
            string color = isWhiteTurn ? "W" : "B";

            if (destinationRow == 0 && isWhiteTurn || destinationRow == 7 && !isWhiteTurn)
            {
                Console.WriteLine("Please enter a number Which represents the tool you want to crown");
                Console.WriteLine("1-Queen,  2-Rook,  3-bishop,  4-Knight");
                string input = Console.ReadLine();
                switch (input)
                {
                case "1": board[destinationRow, destinationColumn] = new Queen(isWhiteTurn ? "WQ" : "BQ", color, false); break;

                case "2": board[destinationRow, destinationColumn] = new Rook(isWhiteTurn ? "WR" : "BR", color, false); break;

                case "3": board[destinationRow, destinationColumn] = new Bishop(isWhiteTurn ? "WB" : "BB", color, false); break;

                case "4": board[destinationRow, destinationColumn] = new Knight(isWhiteTurn ? "WN" : "BN", color, false); break;

                default:
                    board[destinationRow, destinationColumn] = new Queen(isWhiteTurn ? "WQ" : "BQ", color, false); break;
                }
                board[destinationRow, destinationColumn].setToolSLocation(destinationRow, destinationColumn);
            }
        }
Esempio n. 3
0
 public Tool getToolByIndex(int correntRow, int correntColumn)
 {
     if (board[correntRow, correntColumn] is Pawn)
     {
         Pawn pawn = ((Pawn)board[correntRow, correntColumn]);
         return(pawn);
     }
     if (board[correntRow, correntColumn] is King)
     {
         King king = ((King)board[correntRow, correntColumn]);
         return(king);
     }
     if (board[correntRow, correntColumn] is Queen)
     {
         Queen queen = ((Queen)board[correntRow, correntColumn]);
         return(queen);
     }
     if (board[correntRow, correntColumn] is Knight)
     {
         Knight knight = ((Knight)board[correntRow, correntColumn]);
         return(knight);
     }
     if (board[correntRow, correntColumn] is Rook)
     {
         Rook rook = ((Rook)board[correntRow, correntColumn]);
         return(rook);
     }
     if (board[correntRow, correntColumn] is Bishop)
     {
         Bishop bishop = ((Bishop)board[correntRow, correntColumn]);
         return(bishop);
     }
     return(null);
 }
Esempio n. 4
0
 public Tool[,] createBoard()
 {
     for (int i = 0; i < board.GetLength(0); i++)
     {
         for (int j = 0; j < board.GetLength(1); j++)
         {
             if (i == 2)
             {
                 i = 5;
             }
             if (i == 0)
             {
                 if (j == 0)
                 {
                     board[i, j] = new Rook("BR", "B", true);
                 }
                 if (j == 1)
                 {
                     board[i, j] = new Knight("BN", "B", true);
                 }
                 if (j == 2)
                 {
                     board[i, j] = new Bishop("BB", "B", true);
                 }
                 if (j == 3)
                 {
                     board[i, j] = new Queen("BQ", "B", true);
                 }
                 if (j == 4)
                 {
                     board[i, j] = new King("BK", "B", true);
                 }
                 if (j == 5)
                 {
                     board[i, j] = new Bishop("BB", "B", true);
                 }
                 if (j == 6)
                 {
                     board[i, j] = new Knight("BN", "B", true);
                 }
                 if (j == 7)
                 {
                     board[i, j] = new Rook("BR", "B", true);
                 }
             }
             else if (i == 1)
             {
                 board[i, j] = new Pawn("BP", "B", true);
             }
             else if (i == 6)
             {
                 board[i, j] = new Pawn("WP", "W", true);
             }
             else if (i == 7)
             {
                 if (j == 0)
                 {
                     board[i, j] = new Rook("WR", "W", true);
                 }
                 if (j == 1)
                 {
                     board[i, j] = new Knight("WN", "W", true);
                 }
                 if (j == 2)
                 {
                     board[i, j] = new Bishop("WB", "W", true);
                 }
                 if (j == 3)
                 {
                     board[i, j] = new Queen("WQ", "W", true);
                 }
                 if (j == 4)
                 {
                     board[i, j] = new King("WK", "W", true);
                 }
                 if (j == 5)
                 {
                     board[i, j] = new Bishop("WB", "W", true);
                 }
                 if (j == 6)
                 {
                     board[i, j] = new Knight("WN", "W", true);
                 }
                 if (j == 7)
                 {
                     board[i, j] = new Rook("WR", "W", true);
                 }
             }
         }
     }
     return(board);
 }