protected void PrintStatusAddedMessage(IFighter fighter, CriticalChanceMultiplierStatus status) { string increaseOrDecrease = (status.Multiplier > 1.0) ? "an increased" : "a decreased"; string output = $"{fighter.DisplayName} has {increaseOrDecrease} chance for scoring critical hits for {GetDurationString(status)}!"; _output.WriteLine(output); }
protected void PrintStatusAddedMessage(object sender, StatusAddedEventArgs e) { Status status = e.Status; IFighter senderAsFighter = sender as IFighter; if (senderAsFighter == null) { throw new InvalidOperationException("BattleManager.PrintStatusAddedMessage() should only subscribe to instances of IFighter"); } CriticalChanceMultiplierStatus criticalChanceStatus = status as CriticalChanceMultiplierStatus; StatMultiplierStatus statMultiplierStatus = status as StatMultiplierStatus; MagicMultiplierStatus magicMultiplierStatus = status as MagicMultiplierStatus; MagicResistanceMultiplierStatus resistanceMultiplierStatus = status as MagicResistanceMultiplierStatus; ReflectStatus reflectStatus = status as ReflectStatus; SpellCostMultiplierStatus spellCostMultiplierStatus = status as SpellCostMultiplierStatus; AutoEvadeStatus autoEvadeStatus = status as AutoEvadeStatus; CounterAttackStatus counterAttackStatus = status as CounterAttackStatus; BlindStatus blindStatus = status as BlindStatus; if (criticalChanceStatus != null) { PrintStatusAddedMessage(senderAsFighter, criticalChanceStatus); } if (statMultiplierStatus != null) { PrintStatusAddedMessage(senderAsFighter, statMultiplierStatus); } if (magicMultiplierStatus != null) { PrintStatusAddedMessage(senderAsFighter, magicMultiplierStatus); } if (resistanceMultiplierStatus != null) { PrintStatusAddedMessage(senderAsFighter, resistanceMultiplierStatus); } if (reflectStatus != null) { PrintStatusAddedMessage(senderAsFighter, reflectStatus); } if (spellCostMultiplierStatus != null) { PrintStatusAddedMessage(senderAsFighter, spellCostMultiplierStatus); } if (autoEvadeStatus != null) { PrintStatusAddedMessage(senderAsFighter, autoEvadeStatus); } if (counterAttackStatus != null) { PrintStatusAddedMessage(senderAsFighter, counterAttackStatus); } if (blindStatus != null) { PrintStatusAddedMessage(senderAsFighter, blindStatus); } }
public override bool AreEqual(Status status) { bool areEqual = false; CriticalChanceMultiplierStatus criticalChanceMultiplierStatus = status as CriticalChanceMultiplierStatus; if (criticalChanceMultiplierStatus != null) { areEqual = base.AreEqual(criticalChanceMultiplierStatus); } return(areEqual); }
public void Team_AddStatusMethod_CorrectlyAssignsStatusesToFighters([Values(2, 4)] int numberOfFighters) { IList <IFighter> fighters = new List <IFighter>(); for (var i = 0; i < numberOfFighters; ++i) { fighters.Add(TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1)); } Team team = new Team(TestMenuManager.GetTestMenuManager(), fighters.ToArray()); Status status = new CriticalChanceMultiplierStatus(2, 1.5); team.AddStatus(status); foreach (IFighter fighter in fighters) { Assert.AreEqual(1, fighter.Statuses.Count); Assert.IsTrue(status.AreEqual(fighter.Statuses[0])); } }
public void Team_AddStatusMethod_CorrectlyDoesNotAssignsStatusToDefeatedFighters([Values(3, 5)] int numberOfFighters) { IList <IFighter> fighters = new List <IFighter>(); numberOfFighters += 2; for (var i = 0; i < numberOfFighters; ++i) { fighters.Add(TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1)); } int lastIndex = numberOfFighters - 1; fighters[0].PhysicalDamage(fighters[0].MaxHealth); fighters[lastIndex].PhysicalDamage(fighters[lastIndex].MaxHealth); Team team = new Team(TestMenuManager.GetTestMenuManager(), fighters.ToArray()); Status status = new CriticalChanceMultiplierStatus(2, 1.5); team.AddStatus(status); for (var i = 0; i < numberOfFighters; ++i) { IFighter fighter = fighters[i]; if (i == 0 || i == lastIndex) { Assert.AreEqual(0, fighter.Statuses.Count); } else { Assert.AreEqual(1, fighter.Statuses.Count); Assert.IsTrue(status.AreEqual(fighter.Statuses[0])); } } }