Exemplo n.º 1
0
        public Grid Play(PlayerInBattle playerInBattle, Move move)
        {
            // 1- We play the move
            var currentBattle = playerInBattle.Battle;
            var game          = typeMapping.GetGame(currentBattle.GameType);
            var oldState      = currentBattle.CurrentState.NextPlayerToPlay;
            var newState      = game.Play(currentBattle.CurrentState, move);

            // 2- If the grid has change, we persit the new state
            currentBattle.CurrentState = newState;
            if (newState.DeservePersistence(oldState))
            {
                //See what we want to do....
                repoPlayerInBattle.Persist(playerInBattle);
            }

            // 3- We return the new state to the client
            return(newState);
        }