Example #1
0
        public void DamageSkillDamages()
        {
            GameState       state        = GetDefaultEffectState();
            EffectEngine    effectEngine = Factory.EffectEngine;
            TargettedAction damageAction = new TargettedAction(Factory.DamageAction, TargettingInfo.From(state.Party[0], state.Enemies[0]));

            state = effectEngine.Apply(damageAction, state);

            Assert.Equal(0, state.Enemies[0].Health.Current);
        }
Example #2
0
        public void EffectsCanBeOfMultipleTypes()
        {
            GameState       state           = GetDefaultEffectState();
            Action          multiAction     = new Action(ActionType.Damage | ActionType.Effect, 200, "Burning");
            TargettedAction targettedAction = new TargettedAction(multiAction, TargettingInfo.From(state.Party[0], state.Enemies[0]));

            EffectEngine effectEngine = Factory.EffectEngine;

            state = effectEngine.Apply(targettedAction, state);

            Assert.Equal(0, state.Enemies[0].Health.Current);
            Assert.True(state.Enemies[0].HasEffect("Burning"));
        }
Example #3
0
        public void MultipleStatusEffectApplications_ExtendDuration()
        {
            GameState       state        = GetDefaultEffectState();
            TargettedAction statusAction = new TargettedAction(Factory.StatusEffectAction, TargettingInfo.From(state.Party[0], state.Enemies[0]));

            EffectEngine effectEngine = Factory.EffectEngine;

            state = effectEngine.Apply(statusAction, state);
            state = effectEngine.Apply(statusAction, state);

            Assert.True(state.Enemies[0].HasEffect("Chilled"));
            Assert.Single(state.DelayedActions);
            Assert.True(state.DelayedActions[0].TargetAction.Action.Type == ActionType.RemoveEffect);
            Assert.True(state.DelayedActions[0].TargetAction.Action.EffectName == "Chilled");

            // Two Time.ActionAmount total (100 -> 0 -> -100)
            Assert.True(state.DelayedActions[0].CT == -Time.ActionAmount);
        }
Example #4
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);
            }
        }
Example #5
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);
        }
Example #7
0
        public void StatusEffectSkill_AddsEffect_AndRemovesAfterDuration()
        {
            GameState       state        = GetDefaultEffectState();
            TargettedAction statusAction = new TargettedAction(Factory.StatusEffectAction, TargettingInfo.From(state.Party[0], state.Enemies[0]));

            EffectEngine effectEngine = Factory.EffectEngine;

            state = effectEngine.Apply(statusAction, state);

            Assert.True(state.Enemies[0].HasEffect("Chilled"));
            Assert.Single(state.DelayedActions);
            Assert.Contains(state.DelayedActions, x => x.TargetAction.Action.Type == ActionType.RemoveEffect && x.TargetAction.Action.EffectName == "Chilled");

            GameEngine engine = Factory.CreateGameEngine(state, effectEngine: effectEngine);

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

            Assert.False(engine.CurrentState.Enemies[0].HasEffect("Chilled"));
            Assert.Empty(engine.CurrentState.DelayedActions);
        }
Example #8
0
 public GameState Apply(TargettedAction targetAction, GameState state)
 {
     ActionsUsed.Add(targetAction.Action);
     return(state);
 }