public void InjectedAbilities_AnAbilityInjectsANewAbility_InjectedAbilityIsResolvedWithoutPhaseChange() { bool isInjectedResolved = false; MockAbility injectedAbility = new MockAbility(() => isInjectedResolved = true); MockAbility FirstAbility = new MockAbility(() => this.EventManager.Raise(new EnqueueAbilityEvent(injectedAbility))); this.EventManager.Raise(new EnqueueAbilityEvent(FirstAbility)); this.EventManager.Raise(new PhaseChangedEvent(Phases.Draw, Phases.Main)); this.Engine.Update(); this.Engine.Update(); Assert.IsTrue(isInjectedResolved); }
public void FireAbility_HasValidTarget_Resolves() { bool hasfired = false; bool resolvesEventTriggered = false; Ability abi = new MockAbility(() => hasfired = true); abi.EventManager = this.EventManager; this.EventManager.Register(new Trigger<AbilityResolvesEvent>(_ => resolvesEventTriggered = true)); UnitEntity unit = new MockUnit(); abi.SetTarget(0, new XmasUniversal[] { unit }); this.ActionManager.Queue(abi); this.ActionManager.ExecuteActions(); Assert.IsTrue(hasfired); Assert.IsTrue(resolvesEventTriggered); }
public void InjectedAbilities_TwoAbilitiesFirstAbilityTriggerAnotherAbility_AbilityIsResolvedBeforeLastAbility() { //Given that two spells are on the stack, if one of those spells trigger something then the triggered ability must be resolved before the last spell //For instance if a player summons a creature and another kill something else in responds //The death of that creature might trigger something that prevents the creature from being summoned. bool secondAbilityFired = false; bool isSecondAbilityFired = false; MockAbility injectedAbility = new MockAbility(() => isSecondAbilityFired = secondAbilityFired); MockAbility FirstAbility = new MockAbility(() => this.EventManager.Raise(new EnqueueAbilityEvent(injectedAbility))); MockAbility SecondAbility = new MockAbility(() => secondAbilityFired = true); this.EventManager.Raise(new EnqueueAbilityEvent(SecondAbility)); this.EventManager.Raise(new EnqueueAbilityEvent(FirstAbility)); this.EventManager.Raise(new PhaseChangedEvent(Phases.Draw,Phases.Main)); this.Engine.Update(); this.Engine.Update(); Assert.IsFalse(isSecondAbilityFired); }
public void FireAbility_TargetConditionFalse_DoesNotResolve() { bool hasfired = false; bool resolvesEventTriggered = false; bool targetBecomesInvalid = true; Ability abi = new MockAbility(() => hasfired = true); abi.EventManager = this.EventManager; this.EventManager.Register(new Trigger<AbilityResolvesEvent>(_ => resolvesEventTriggered = true)); this.EventManager.Register(new Trigger<AbilityTargetInvalidEvent>(_ => targetBecomesInvalid = true)); UnitEntity unit = new MockUnit(); abi.SetTarget(0, new XmasUniversal[] { unit }); abi.SetTargetCondition(0, _ => false); this.ActionManager.Queue(abi); this.ActionManager.ExecuteActions(); Assert.IsFalse(hasfired); Assert.IsFalse(resolvesEventTriggered); Assert.IsTrue(targetBecomesInvalid); }
public void Targets_HasOneOnFirstTargetZeroOnSecondTargetTwoOnThirdTarget_ReturnsCorrectTargets() { UnitEntity first = new MockUnit(); UnitEntity Third1 = new MockUnit(); UnitEntity Third2 = new MockUnit(); Ability abi = new MockAbility(null); abi.SetTarget(0, new object[] { first }); abi.SetTarget(2, new object[] { Third1, Third2 }); var targets = abi.Targets; int secondcount = 0; Assert.AreEqual(first, targets[0][0]); Assert.AreEqual(secondcount, targets[1].Length); Assert.AreEqual(Third1, targets[2][0]); Assert.AreEqual(Third2, targets[2][1]); }