Exemplo n.º 1
0
        private void HandleKingsideCastling(Square origin, Square destination)
        {
            var kingsideRookSquare = GetKingsideRookSquare(origin);

            if (!destination.DistanceOfFilesIsOneTo(kingsideRookSquare)) return;
            if (origin.Color != kingsideRookSquare.Color) return;
            if (origin.DistanceOfFilesIsNotTwoTo(destination)) return;
            if (!(kingsideRookSquare.Occupier is Rook)) return;

            Board.SetSquare(kingsideRookSquare.File, kingsideRookSquare.Rank, new NullPiece(Board));
            Board.SetSquare(origin.File + 1, origin.Rank, kingsideRookSquare.Occupier);
        }
Exemplo n.º 2
0
        private void HandleQueensideCastling(Square origin, Square destination)
        {
            var queensideRookSquare = GetQueensideRookSquare(origin);

            if (!destination.DistanceOfFilesIsTwoTo(queensideRookSquare)) return;
            if (origin.Color != queensideRookSquare.Color) return;
            if (origin.DistanceOfFilesIsNotTwoTo(destination)) return;
            if (!(queensideRookSquare.Occupier is Rook)) return;

            Board.SetSquare(queensideRookSquare.File, queensideRookSquare.Rank, new NullPiece(Board));
            Board.SetSquare(origin.File - 1, queensideRookSquare.Rank, queensideRookSquare.Occupier);
        }