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 bool MovingOneSquareLeftOrRight(Square origin, Square destination)
 {
     return (origin.DistanceOfRanksIsZeroTo(destination)
            && origin.DistanceOfFilesIsOneTo(destination));
 }
Exemplo n.º 3
0
 private bool MovingOneSquareDiagonally(Square origin, Square destination)
 {
     return (origin.DistanceOfRanksIsOneTo(destination)
             && origin.DistanceOfFilesIsOneTo(destination));
 }
Exemplo n.º 4
0
 private bool MovingTwoRanksAndOneFile(Square origin, Square destination)
 {
     return (origin.DistanceOfRanksIsTwoTo(destination)
             && origin.DistanceOfFilesIsOneTo(destination));
 }