public void CastSpell_SpellsVanishIfReflectedTwice([Values(MagicType.Fire, MagicType.Ice, MagicType.Lightning)] MagicType spellType, [Values(true, false)] bool reflectAll) { const int spellCost = 5; const int spellPower = 5; Spell spell = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower); BattleMove runawayMove = MoveFactory.Get(BattleMoveType.Runaway); MagicType reflectType = reflectAll ? MagicType.All : spellType; ReflectStatus status = new ReflectStatus(1, reflectType); _human.SetHealth(100); _human.SetMana(spellCost); _human.AddStatus(status); _human.AddSpell(spell); _human.SetMove(spell, 1); _human.SetMove(runawayMove); _human.SetMoveTarget(_enemy); _enemy.AddStatus(status); _enemy.SetHealth(100); _battleManager.Battle(_humanTeam, _enemyTeam); Assert.AreEqual(_enemy.MaxHealth, _enemy.CurrentHealth, "enemy should still have full health, the spell should have disappeared without hurting anyone!"); Assert.AreEqual(_human.MaxHealth, _human.CurrentHealth, "the human should still have full health, the spell should have disappeared without hurting anyone"); }
public void CastSpell_CorrectlyReflectsSpells_WithCorrectMultiplier([Values(MagicType.Water, MagicType.Earth, MagicType.Wind)] MagicType spellType, [Values(true, false)] bool reflectAll) { const int spellCost = 5; const int spellPower = 5; const int expectedRemainingHealth = 100 - (spellPower * 2); Spell spell = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower); BattleMove runawayMove = MoveFactory.Get(BattleMoveType.Runaway); MagicType reflectType = reflectAll ? MagicType.All : spellType; ReflectStatus status = new ReflectStatus(1, reflectType, 2); _human.SetHealth(100); _human.SetMana(spellCost); _human.AddSpell(spell); _human.SetMove(spell, 1); _human.SetMove(runawayMove); _human.SetMoveTarget(_enemy); _enemy.AddStatus(status); _enemy.SetHealth(100); _battleManager.Battle(_humanTeam, _enemyTeam); Assert.AreEqual(_enemy.MaxHealth, _enemy.CurrentHealth, "enemy should still have full health, the spell should have been reflected!"); Assert.AreEqual(expectedRemainingHealth, _human.CurrentHealth, $"the human should have lost {spellPower * 2} health from being hit by their own spell reflected at double the power!"); }
public void CastSpell_CorrectlyDoesNotReflectsSpells_ReflectStatus_DoesNotMatchAttackingType( [Values(MagicType.Fire, MagicType.Ice, MagicType.Lightning)] MagicType spellType, [Values(MagicType.Wind, MagicType.Earth, MagicType.Water)] MagicType reflectType) { const int spellCost = 5; const int spellPower = 5; const int expectedRemainingHealth = 100 - spellPower; Spell spell = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower); BattleMove runawayMove = MoveFactory.Get(BattleMoveType.Runaway); ReflectStatus status = new ReflectStatus(1, reflectType); _human.SetHealth(100); _human.SetMana(spellCost); _human.SetMagicStrength(0); _human.SetMagicBonus(spellType, 0); _human.SetMagicResistance(0); _human.SetResistanceBonus(spellType, 0); _human.AddSpell(spell); _human.SetMove(spell, 1); _human.SetMove(runawayMove); _human.SetMoveTarget(_enemy); _enemy.AddStatus(status); _enemy.SetHealth(100); _battleManager.Battle(_humanTeam, _enemyTeam); Assert.AreEqual(_human.MaxHealth, _human.CurrentHealth, "human should still have full health, the spell should not have been reflected!"); Assert.AreEqual(expectedRemainingHealth, _enemy.CurrentHealth, "the enemy should have lost 5 health from being hit by the spell!"); }
public void FighterOnRoundEnd_CorrectlyRemovesStatusesWithTurnCounter0([Values(1, 2, 3)] int turnCount) { ReflectStatus status = new ReflectStatus(turnCount, MagicType.Ice); _humanFighter.AddStatus(status); _logger.Subscribe(EventType.StatusRemoved, _humanFighter); for (var i = 0; i < turnCount; ++i) { _humanFighter.OnTurnEnded(new TurnEndedEventArgs(_humanFighter)); } _humanFighter.OnRoundEnded(new RoundEndedEventArgs(_humanTeam, _humanFighter)); List <EventLog> logs = _logger.Logs; Assert.AreEqual(1, logs.Count); EventLog log = logs[0]; Assert.AreEqual(EventType.StatusRemoved, log.Type); Assert.AreEqual(_humanFighter, log.Sender); StatusRemovedEventArgs args = log.E as StatusRemovedEventArgs; Assert.NotNull(args); Assert.IsTrue(status.AreEqual(args.Status)); }
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); } }
protected void PrintStatusAddedMessage(IFighter fighter, ReflectStatus status) { MagicType reflectType = status.MagicType; string output = $"{fighter.DisplayName} has gained reflect status"; if (reflectType != MagicType.All) { output = $"{output} against {reflectType.ToString().ToLower()} magic"; } output = $"{output} for {GetDurationString(status)}!"; _output.WriteLine(output); }
public void FighterStatusCounterRemovesStatuses_WhenCounterReaches0([Values(1, 2, 3)] int turnCount) { ReflectStatus status = new ReflectStatus(turnCount, MagicType.Ice); _humanFighter.AddStatus(status); for (var i = 0; i < turnCount; ++i) { _humanFighter.OnTurnEnded(new TurnEndedEventArgs(_humanFighter)); } _humanFighter.OnRoundEnded(new RoundEndedEventArgs(_humanTeam, _humanFighter)); Assert.AreEqual(0, _humanFighter.Statuses.Count); }