public virtual void Validate(Game game, MoveCoordinates moveCoordinates) { if (!IsValid) { throw new ValidationException(Message); } }
public void ValidateMove(Game game, MoveCoordinates coordinates) { if (!this.moveValidationList.IsValid) { throw new ValidationException(string.Join("; ", this.moveValidationList.Messages)); } }
public void Validate(Game game, MoveCoordinates moveCoordinates) { foreach (var validation in this) { validation.Validate(game, moveCoordinates); } }
public override void Validate(Game game, MoveCoordinates coordinates) { if (game.GameStatus != GameStatuses.InProgress) { this.IsValid = false; this.Message = "Game is already finished. If player wants to move, game must be in progress."; } else { this.IsValid = true; } }
public override void Validate(Game game, MoveCoordinates coordinates) { if (coordinates.Row >= game.Board.Size || coordinates.Column >= game.Board.Size) { this.Message = $"Given coordinates: [{coordinates.Row}, {coordinates.Column}] are outside of board." + $" Board size is {game.Board.Size}x{game.Board.Size}"; this.IsValid = false; } else { this.IsValid = true; } }
public override void Validate(Game game, MoveCoordinates coordinates) { try { var cellValue = game.Board[coordinates.Row, coordinates.Column]; if (cellValue != Symbols.Empty) { this.Message = $"Position row:{coordinates.Row}, column:{coordinates.Column} is already occupied by: {cellValue.ToString()}"; this.IsValid = false; } else { this.IsValid = true; } } catch (Exception exc) { this.IsValid = false; this.Message = $"Was not able to validate if cell is available due to exception: {exc.ToString()}"; } }