Ejemplo n.º 1
0
        private void UnCastle(Move move)
        {
            //The king is moved back.
            //Placing the rook on the corner square.
            var    king = (King)move.Piece;
            Square fromRookSquare = null, toRookSquare = null;

            if (move.ToSquare.File == File.G)
            {
                fromRookSquare = Board.Square(File.H, king.Square.Rank);
                toRookSquare   = Board.Square(File.F, king.Square.Rank);
                CurrentPlayer.CanCastleKingSide = true;
            }
            if (move.ToSquare.File == File.C)
            {
                fromRookSquare = Board.Square(0, king.Square.Rank);
                toRookSquare   = Board.Square(File.D, king.Square.Rank);
                CurrentPlayer.CanCastleQueenSide = true;
            }
            Debug.Assert(fromRookSquare != null && toRookSquare != null);
            var rook = (Rook)toRookSquare.Piece;

            toRookSquare.Piece = null;
            fromRookSquare.SetPiece(rook);
            king.HasCastled = false;
        }
Ejemplo n.º 2
0
        private void Castle(Move move)
        {
            var    king = (King)move.Piece;
            Square fromRookSquare = null, toRookSquare = null;

            if (king.Square.File == File.G)
            {
                fromRookSquare = Board.Square(File.H, king.Square.Rank);
                toRookSquare   = Board.Square(File.F, king.Square.Rank);
                CurrentPlayer.CanCastleKingSide = false;
            }
            if (king.Square.File == File.C)
            {
                fromRookSquare = Board.Square(0, king.Square.Rank);
                toRookSquare   = Board.Square(File.D, king.Square.Rank);
                CurrentPlayer.CanCastleQueenSide = false;
            }
            Debug.Assert(fromRookSquare != null && toRookSquare != null);
            var rook = (Rook)fromRookSquare.Piece;

            fromRookSquare.Piece = null;
            toRookSquare.SetPiece(rook);
            king.HasCastled = true;
        }