public void CoordinateToIdOn4x4Board(int x, int y, int n) { // |_|1|_|2| // |3|_|4|_| // |_|5|_|6| // |7|_|8|_| SquareId.FromPosition(x, y, 4).Should().Be(new SquareId(n)); }
public void NonPlayableCoordinatesShouldThrow() { // |_|.|_|.| // |.|x|.|_| // |_|.|_|.| // |.|_|.|_| Action fromPosition = () => SquareId.FromPosition(1, 1, 4); fromPosition.Should().Throw <ManualValidationException>(); }
public void DoMove(UserId currentUserId, GameId gameId, SquareId from, SquareId to) { _unitOfWork.WithGameTransaction(tran => { var(game, gameState) = FindGameAndState(gameId); _playGameDomainService.DoMove(game, gameState, currentUserId, from, to); _gameRepository.Save(game); _gameStateRepository.Save(gameState); tran.Commit(); }); }
public void DoMove(Game game, GameState gameState, UserId currentUserId, SquareId from, SquareId to) { game.ValidateCanDoMove(currentUserId); var moveResult = gameState.AddMove(from, to, game.Turn !.Player.Color, game.Settings); switch (moveResult) { case GameState.MoveResult.NextTurn: game.NextTurn(currentUserId, _clock.UtcNow()); break; case GameState.MoveResult.MoreCapturesAvailable: break; // No need to do anything, the user will do the next move. case GameState.MoveResult.GameOver: game.WinGame(currentUserId, _clock.UtcNow()); break; default: throw new InvalidOperationException("Unknown MoveResult"); } }
public void CoordinateToIdOn8x8Board(int x, int y, int n) { SquareId.FromPosition(x, y, 8).Should().Be(new SquareId(n)); }
private SquareId Pos(int x, int y) => SquareId.FromPosition(x, y, 4);