public void SkillsCanApplyEffectWithDelay() { Skill skill = Factory.TestDelayedSkill; TestEffectEngine effectEngine = new TestEffectEngine(); GameState state = Factory.DefaultGameState; state = state.UpdateCharacter(state.Party[0].WithSkills(skill.Yield()).WithCT(Time.ActionAmount)); SkillEngine engine = new SkillEngine(effectEngine); state = engine.ApplyTargettedSkill(new TargettedSkill(skill, TargettingInfo.Self(state.Party[0])), state); Assert.Empty(effectEngine.ActionsUsed); Assert.Contains(state.DelayedActions, x => x.SourceSkill.Skill.CosmeticName == skill.CosmeticName); Assert.Equal(50, state.DelayedActions[0].CT); Assert.True(state.Party[0].IsCasting); CastingInfo castingInfo = state.Party[0].Casting; Assert.Equal(state.Party[0].Skills[0], castingInfo.Skill); Assert.Equal(skill.Delay, castingInfo.Duration); Assert.Equal(0, castingInfo.StartingTick); Assert.Equal(-50, state.Party[0].CT); }
public void CooldownDisappearsAfterTime() { Skill skill = Factory.TestSkillCooldown; TestEffectEngine effectEngine = new TestEffectEngine(); GameState state = Factory.DefaultGameState; state = state.UpdateCharacter(state.Party[0].WithSkills(skill.Yield())); SkillEngine skillEngine = new SkillEngine(effectEngine); state = skillEngine.ApplyTargettedSkill(new TargettedSkill(skill, TargettingInfo.Self(state.Party[0])), state); GameEngine engine = Factory.CreateGameEngine(state, skillEngine: skillEngine); Assert.False(engine.CurrentState.Party[0].Skills[0].Available); for (int i = 0; i < Time.ActionAmount; ++i) { engine.Process(); } Assert.DoesNotContain(engine.CurrentState.DelayedActions, x => x.TargetAction.Action.Type == ActionType.Cooldown); Assert.True(engine.CurrentState.Party[0].Skills[0].Available); }
public void SkillsCanApplyEffectDirectly() { Skill skill = Factory.TestSkill; TestEffectEngine effectEngine = new TestEffectEngine(); GameState state = Factory.DefaultGameState; state = state.UpdateCharacter(state.Party[0].WithSkills(skill.Yield()).WithCT(Time.ActionAmount)); SkillEngine engine = new SkillEngine(effectEngine); state = engine.ApplyTargettedSkill(new TargettedSkill(skill, TargettingInfo.Self(state.Party[0])), state); Assert.False(state.Party[0].IsCasting); Assert.Single(effectEngine.ActionsUsed); Assert.Equal(0, state.Party[0].CT); }
public void CooldownPreventsReuse() { Skill skill = Factory.TestSkillCooldown; TestEffectEngine effectEngine = new TestEffectEngine(); GameState state = Factory.DefaultGameState; state = state.UpdateCharacter(state.Party[0].WithSkills(skill.Yield())); SkillEngine engine = new SkillEngine(effectEngine); state = engine.ApplyTargettedSkill(new TargettedSkill(skill, TargettingInfo.Self(state.Party[0])), state); Assert.Single(state.DelayedActions); Assert.Contains(state.DelayedActions, x => x.TargetAction.Action.Type == ActionType.Cooldown); Assert.False(state.Party[0].Skills[0].Available); Assert.Equal(25, state.DelayedActions[0].CT); Assert.Throws <InvalidOperationException> (() => engine.ApplyTargettedSkill(new TargettedSkill(state.Party[0].Skills[0], TargettingInfo.Self(state.Party[0])), state)); }
public void ActiveCharacterCanUseSkill() { GameState state = Factory.DefaultGameState; state = state.UpdateCharacter(state.Party[0].WithCT(Time.ActionAmount)); state = state.WithActivePlayerID(state.Party[0].ID); Skill skill = Factory.TestSkill; TestSkillEngine skillEngine = new TestSkillEngine(); GameEngine engine = Factory.CreateGameEngine(state, skillEngine: skillEngine); Skill skillReportedUsed = null; engine.SkillUsed += (o, s) => skillReportedUsed = s.Skill; engine.ProcessActivePlayerAction(new TargettedSkill(skill, TargettingInfo.Self(state.Party[0]))); Assert.Single(skillEngine.SkillsUsed); Assert.Contains(skillEngine.SkillsUsed, x => x.ID == skill.ID); Assert.Equal(skillReportedUsed, skillEngine.SkillsUsed.First()); }
public void SkillCasting_RemovingCasting_WhenComplete() { Skill skill = Factory.TestDelayedSkill; TestEffectEngine effectEngine = new TestEffectEngine(); GameState state = Factory.DefaultGameState; state = state.UpdateCharacter(state.Party[0].WithSkills(skill.Yield()).WithCT(Time.ActionAmount)); SkillEngine skillEngine = new SkillEngine(effectEngine); state = skillEngine.ApplyTargettedSkill(new TargettedSkill(skill, TargettingInfo.Self(state.Party[0])), state); Assert.True(state.Party[0].IsCasting); GameEngine engine = Factory.CreateGameEngine(state, skillEngine: skillEngine); for (int i = 0; i < Time.ActionAmount; ++i) { engine.Process(); } Assert.False(engine.CurrentState.Party[0].IsCasting); }
public void CharacterBehavior_ReturnsSkill_GivenToSkillEngine() { GameState state = Factory.DefaultGameState; state = state.UpdateCharacter(state.Party[0].WithCT(99)); Skill skill = Factory.TestSkill; TestCharacterBehavior characterBehavior = new TestCharacterBehavior(); characterBehavior.SkillToReturn = new TargettedSkill(skill, TargettingInfo.Self(state.Party[0])); TestSkillEngine skillEngine = new TestSkillEngine(); GameEngine engine = Factory.CreateGameEngine(state, characterBehavior, skillEngine); Skill skillReportedUsed = null; engine.SkillUsed += (o, s) => skillReportedUsed = s.Skill; engine.Process(); Assert.Single(skillEngine.SkillsUsed); Assert.Contains(skillEngine.SkillsUsed, x => x.ID == skill.ID); Assert.Equal(skillReportedUsed, skillEngine.SkillsUsed.First()); }
public void SkillFailsIfInvokerDoesNotHave() { Skill skill = Factory.TestSkill; TestEffectEngine effectEngine = new TestEffectEngine(); GameState state = Factory.DefaultGameState; SkillEngine engine = new SkillEngine(effectEngine); Assert.Throws <InvalidOperationException> (() => engine.ApplyTargettedSkill(new TargettedSkill(skill, TargettingInfo.Self(state.Party[0])), state)); }