예제 #1
0
        public static GameInstance FNoCopy(GameInstance state, UctAction action)
        {
            Actions++;
            ActionCounts[action.Type]++;

            Constants.WriteLogLine(action);

            if (Constants.RecordReplays)
            {
                ReplayRecorder.Instance.Actions.Add(action);
            }

            GameInvariants.AssertValidAction(state, action);

            switch (action.Type)
            {
            case UctActionType.Null:
                // do nothing
                break;

            case UctActionType.EndTurn:
                state.State.LastTeamColor = state.CurrentTeam;
                state.TurnManager.NextMobOrNewTurn();
                break;

            case UctActionType.AbilityUse:
                FastUse(state, action.AbilityId, action.MobId, action.TargetId);
                break;

            case UctActionType.AttackMove:
                FastMove(state, action.MobId, action.Coord);
                FastUse(state, action.AbilityId, action.MobId, action.TargetId);
                break;

            case UctActionType.Move:
            case UctActionType.DefensiveMove:
                FastMove(state, action.MobId, action.Coord);
                break;

            default:
                throw new InvalidOperationException($"Invalid value of {action.Type}");
            }

            return(state);
        }
예제 #2
0
        /// <summary>
        /// Asnychronously run a given action, notifying all of the subscribers.
        /// </summary>
        public async Task SlowPlayAction(GameInstance game, UctAction action)
        {
            Debug.Assert(game == _gameInstance, "instance == _gameInstance");

            foreach (var subscriber in _subscribers)
            {
                subscriber.ActionApplied(action);
            }

            switch (action.Type)
            {
            case UctActionType.AbilityUse:
                await SlowBroadcastAction(action);

                break;

            case UctActionType.EndTurn:
                break;

            case UctActionType.AttackMove:
                GameInvariants.AssertValidMoveAction(_gameInstance, action);

                await SlowBroadcastAction(action.ToPureMove());
                await SlowBroadcastAction(action.ToPureAbilityUse());

                break;

            case UctActionType.DefensiveMove:
            case UctActionType.Move:
                GameInvariants.AssertValidMoveAction(_gameInstance, action);

                await SlowBroadcastAction(action.ToPureMove());

                break;

            case UctActionType.Null:
                break;
            }
        }