public bool IsSatisfied(PieceMovement input)
        {
            if (PositionComparer.FileDistanceAbs(input.From, input.To) == 0)
            {
                int rankDistance = PositionComparer.RankDistance(input.From, input.To);

                if (input.Piece.Color == PieceColor.White &&
                    rankDistance < 0 && rankDistance >= (input.Piece.HasMoved ? -1 : -2))
                {
                    return(true);
                }

                if (input.Piece.Color == PieceColor.Black &&
                    rankDistance > 0 && rankDistance <= (input.Piece.HasMoved ? 1 : 2))
                {
                    return(true);
                }
            }
            else if (PositionComparer.FileDistanceAbs(input.From, input.To) == 1 &&
                     PositionComparer.RankDistanceAbs(input.From, input.To) == 1)
            {
                Square squareDestination = _board.GetSquare(input.To.Id);
                if (!squareDestination.IsEmpty && squareDestination.Piece.Color != input.Piece.Color)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        public bool IsSatisfied(PieceMovement input)
        {
            if (PositionComparer.FileDistanceAbs(input.From, input.To) == PositionComparer.RankDistanceAbs(input.From, input.To))
            {
                return(true);
            }

            return(false);
        }
Example #3
0
 public bool IsSatisfied(PieceMovement candidate)
 {
     if (PositionComparer.FileDistanceAbs(candidate.From, candidate.To) <= 1 &&
         PositionComparer.RankDistanceAbs(candidate.From, candidate.To) <= 1)
     {
         return(true);
     }
     else
     {
         CastlingMovementSpecification castlingMovementSpecification = CastlingMovementSpecification.Create(_board);
         return(castlingMovementSpecification.IsSatisfied(candidate));
     }
 }
        public bool IsSatisfied(PieceMovement candidate)
        {
            if (PositionComparer.FileDistanceAbs(candidate.From, candidate.To) <= 1 &&
                PositionComparer.RankDistanceAbs(candidate.From, candidate.To) <= 1)
            {
                return(false);
            }

            if (candidate.From.FileIndex == candidate.To.FileIndex ||
                candidate.From.RankIndex == candidate.To.RankIndex)
            {
                return(StraightMovementIsSatisfied(candidate));
            }
            else
            {
                return(DiagonalMovementIsSatisfied(candidate));
            }
        }