Exemplo n.º 1
0
        /// <summary>
        /// A constructor for a standard chess board.
        /// </summary>
        public Board(int _x, int _y, GameType _gt, ChessPiece.piece_colour _turn, int _TurnsSinceCapture)
        {
            turn = _turn;
            gt   = _gt;

            this.board = new List <List <Piece> >();
            //First, set the whole board to null
            for (int x = 0; x < _x; x++)
            {
                board.Add(new List <Piece>());
                for (int y = 0; y < _y; y++)
                {
                    board[x].Add(null);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="m"></param>
        /// <returns>True if the king has been slain, false otherwise.</returns>
        public bool MakeMove(move m)
        {
            bool returnable = false;

            //Hold the piece we're moving in memory
            Piece movingPiece = (ChessPiece)board[m.from.Item1][m.from.Item2];

            //See what you're killing
            if (!(board[m.to.Item1][m.to.Item2] is null))
            {
                //If its a king, make sure to return true at the end
                if (((ChessPiece)board[m.to.Item1][m.to.Item2]).t == ChessPiece.piece_type.KING)
                {
                    returnable = true;
                }
                TurnsSinceCapture = 0;
            }
            //Put the piece in its new position, overwriting the old space
            board[m.to.Item1][m.to.Item2] = movingPiece;
            //Remove the piece being moved from its original position
            board[m.from.Item1][m.from.Item2] = null;

            //Change turn
            if (this.turn == ChessPiece.piece_colour.BLACK)
            {
                this.turn = ChessPiece.piece_colour.WHITE;
            }
            else
            {
                this.turn = ChessPiece.piece_colour.BLACK;
            }

            //50 turn rule
            if (TurnsSinceCapture > 50)
            {
                //Signifies a draw
                returnable = true;
            }
            this.TurnsSinceCapture++;

            return(returnable);
        }
Exemplo n.º 3
0
 public Board(int _x, int _y, GameType _gt, ChessPiece.piece_colour _turn) : this(_x, _y, _gt, _turn, 0)
 {
 }