Esempio n. 1
0
        public Game DoMove(Guid gameId, Move move)
        {
            var game = GameMechanics.Persistence.LoadGame(gameId);

            if (!GameMechanics.Rules.IsValidMove(game.GetCurrentState(), move))
            {
                throw new GameRulesBrokenException("That is not a valid move at this point!");
            }

            var newState = GameMechanics.Rules.GetNewStateAfterMove(game.GetCurrentState(), move);

            game.States.Add(newState);

            GameMechanics.Persistence.SaveGame(game);

            return game;
        }
Esempio n. 2
0
 // This is wrong! Any move is considered valid!
 public bool IsValidMove(GameState gameState, Move move)
 {
     return true;
 }
Esempio n. 3
0
 // This is correct! But none of the ApplyMove calls are... :-(
 public GameState GetNewStateAfterMove(GameState currentState, Move move)
 {
     return move.ApplyMove(currentState);
 }