示例#1
0
        static void TargetLossTestCore(Func <GameState, GameState> testProc, int expectedHealth)
        {
            GameState       state        = GetDefaultEffectState();
            TargettedAction damageAction = new TargettedAction(Factory.DamageAction, TargettingInfo.From(state.Party[0], state.Enemies[0]));

            state = state.WithDelayedActions(DelayedAction.Create(damageAction).WithCT(90).Yield());
            state = testProc(state);

            GameEngine engine = Factory.CreateDefaultGameEngine(state);

            for (int i = 0; i < 10; ++i)
            {
                engine.Process();
            }

            if (expectedHealth != -1)
            {
                Assert.Equal(expectedHealth, engine.CurrentState.Enemies[0].Health.Current);
            }
        }
示例#2
0
        public void DelayedEffectApplies()
        {
            GameState       state        = GetDefaultEffectState();
            TargettedAction damageAction = new TargettedAction(Factory.DamageAction, TargettingInfo.From(state.Party[0], state.Enemies[0]));

            state = state.WithDelayedActions(DelayedAction.Create(damageAction).WithCT(90).Yield());

            bool       delayedEffectFired = false;
            GameEngine engine             = Factory.CreateDefaultGameEngine(state);

            engine.DelayedActions += (o, e) => delayedEffectFired = true;

            for (int i = 0; i < 10; ++i)
            {
                engine.Process();
            }

            Assert.Equal(0, engine.CurrentState.Enemies[0].Health.Current);
            Assert.True(delayedEffectFired);
        }
        public void DelayedActionTakeActionsAndDisappear()
        {
            var acted = new HashSet <long> ();

            GameState       state      = Factory.DefaultGameState;
            TargettedAction testAction = new TargettedAction(new Action(ActionType.None, 0), TargettingInfo.Empty);

            state = state.WithDelayedActions(DelayedAction.Create(testAction).WithCT(90).Yield());
            long delayedActionID = state.DelayedActions[0].ID;

            GameEngine engine = Factory.CreateDefaultGameEngine(state);

            engine.DelayedActions += (s, a) => acted.Add(a.Action.ID);

            for (int i = 0; i < 10; ++i)
            {
                Assert.True(engine.Process());
            }

            Assert.Single(acted);
            Assert.Contains(acted, x => x == delayedActionID);
            Assert.Empty(engine.CurrentState.DelayedActions);
        }