private bool IsPathBlockedByAnyPiece(GameModel game, IChessPiece movingPiece, Position destination) { var transition = movingPiece.GetTransitionToDestination(destination); var nextPosition = movingPiece.Position + transition; while (!nextPosition.Equals(destination)) { if (game.MovingPlayer.Pieces.PieceAtPosition(nextPosition) != null || game.WaitingPlayer.Pieces.PieceAtPosition(nextPosition) != null) { return(true); } nextPosition += transition; } return(false); }
public static List <Position> GetPathToDestination(this IChessPiece piece, Position destination) { var result = new List <Position>(); var transition = piece.GetTransitionToDestination(destination); if (transition == null) { return(null); } var nextPosition = piece.Position + transition; while (!nextPosition.Equals(destination)) { result.Add(nextPosition); nextPosition += transition; } return(result); }