コード例 #1
0
 public virtual void Validate(Game game, MoveCoordinates moveCoordinates)
 {
     if (!IsValid)
     {
         throw new ValidationException(Message);
     }
 }
コード例 #2
0
ファイル: Judge.cs プロジェクト: alaniemieckota/TicTacToe
 public void ValidateMove(Game game, MoveCoordinates coordinates)
 {
     if (!this.moveValidationList.IsValid)
     {
         throw new ValidationException(string.Join("; ", this.moveValidationList.Messages));
     }
 }
コード例 #3
0
 public void Validate(Game game, MoveCoordinates moveCoordinates)
 {
     foreach (var validation in this)
     {
         validation.Validate(game, moveCoordinates);
     }
 }
コード例 #4
0
 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;
     }
 }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
 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()}";
     }
 }