示例#1
0
        public Board(uint turn)
        {
            this.turn = turn;

            // Create squares
            for (uint y = 0; y < BOARD_SIZE_Y; y++)
            {
                for (uint x = 0; x < BOARD_SIZE_X; x++)
                {
                    squares[x, y] = new Square(x, y);
                }
            }
        }
示例#2
0
 // Set the input square to an exact copy of this square.
 public void Copy(Square oldSquare)
 {
     posX = oldSquare.posX;
     posY = oldSquare.posY;
     whiteCover = oldSquare.whiteCover;
     blackCover = oldSquare.blackCover;
     if (oldSquare.piece != null)
     {
         piece = oldSquare.piece.getCopyPiece();
         piece.Copy(oldSquare.piece);
     }
     else
     {
         piece = null;
     }
 }
示例#3
0
        // --- Constructor ---
        public Board()
        {
            //Set turn
            turn = 1;

            // Create squares
            for (uint y = 0; y < BOARD_SIZE_Y; y++)
            {
                for (uint x = 0; x < BOARD_SIZE_X; x++)
                {
                    squares[x, y] = new Square(x, y);
                }
            }

            // Create white pieces
            squares[0, 0].setPiece(new Rook(0, 0, COLOUR_WHITE));
            squares[1, 0].setPiece(new Knight(1, 0, COLOUR_WHITE));
            squares[2, 0].setPiece(new Bishop(2, 0, COLOUR_WHITE));
            squares[3, 0].setPiece(new Queen(3, 0, COLOUR_WHITE));
            squares[4, 0].setPiece(new King(4, 0, COLOUR_WHITE));
            squares[5, 0].setPiece(new Bishop(5, 0, COLOUR_WHITE));
            squares[6, 0].setPiece(new Knight(6, 0, COLOUR_WHITE));
            squares[7, 0].setPiece(new Rook(7, 0, COLOUR_WHITE));
            for (uint x = 0; x < BOARD_SIZE_X; x++)
            {
                squares[x, 1].setPiece(new Pawn(x, 1, COLOUR_WHITE));
            }

            // Create black pieces
            squares[0, BOARD_SIZE_Y - 1].setPiece(new Rook(0, BOARD_SIZE_Y - 1, COLOUR_BLACK));
            squares[1, BOARD_SIZE_Y - 1].setPiece(new Knight(1, BOARD_SIZE_Y - 1, COLOUR_BLACK));
            squares[2, BOARD_SIZE_Y - 1].setPiece(new Bishop(2, BOARD_SIZE_Y - 1, COLOUR_BLACK));
            squares[3, BOARD_SIZE_Y - 1].setPiece(new Queen(3, BOARD_SIZE_Y - 1, COLOUR_BLACK));
            squares[4, BOARD_SIZE_Y - 1].setPiece(new King(4, BOARD_SIZE_Y - 1, COLOUR_BLACK));
            squares[5, BOARD_SIZE_Y - 1].setPiece(new Bishop(5, BOARD_SIZE_Y - 1, COLOUR_BLACK));
            squares[6, BOARD_SIZE_Y - 1].setPiece(new Knight(6, BOARD_SIZE_Y - 1, COLOUR_BLACK));
            squares[7, BOARD_SIZE_Y - 1].setPiece(new Rook(7, BOARD_SIZE_Y - 1, COLOUR_BLACK));
            for (uint x = 0; x < BOARD_SIZE_X; x++)
            {
                squares[x, BOARD_SIZE_Y - 2].setPiece(new Pawn(x, BOARD_SIZE_Y - 2, COLOUR_BLACK));
            }

            updateCover();
        }
示例#4
0
 // Empties the board of pieces. Used in load
 public void clearBoard()
 {
     for (uint y = 0; y < BOARD_SIZE_Y; y++)
     {
         for (uint x = 0; x < BOARD_SIZE_X; x++)
         {
             squares[x, y] = new Square(x, y);
         }
     }
 }