public void CastSpell_CorrectlyReflectsSpells([Values(MagicType.Fire, MagicType.Ice, MagicType.Lightning)] MagicType spellType, [Values(true, false)] bool reflectAll) { 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); MagicType reflectType = reflectAll ? MagicType.All : spellType; 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(_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 5 health from being hit by their own spell!"); }
public void BattleManager_CorrectlyCalculatesMagicalDamageForShield([Values(MagicType.Fire, MagicType.Ice)] MagicType spellMagicType) { int shieldResistance = 10; IronBattleShield shield = new IronBattleShield((shieldResistance * 2) + 1, 0, shieldResistance); _humanPlayer1.SetBattleShield(shield); _logger.SubscribeAll(_humanPlayer1.BattleShield); _humanPlayer1.SetMagicResistance(shieldResistance); _humanPlayer1.SetStrength(_enemyPlayer1.MaxHealth + _enemyPlayer1.Defense); _humanPlayer1.SetMove(_basicAttackMove); _humanPlayer1.SetMoveTarget(_enemyPlayer1); _enemyPlayer1.SetSpeed(1); _enemyPlayer1.SetMagicStrength(shieldResistance * 2); Spell spell = new Spell("foo", spellMagicType, SpellType.Attack, TargetType.SingleEnemy, 0, 0); _enemyPlayer1.AddSpell(spell); _enemyPlayer1.SetMove(spell); _chanceService.PushEventsOccur(true, false); //attack hits, not misses _humanTeam = new Team(_menuManager, _humanPlayer1); _enemyTeam = new Team(_menuManager, _enemyPlayer1); _battleManager.Battle(_humanTeam, _enemyTeam); List <EventLog> logs = _logger.Logs; Assert.AreEqual(1, logs.Count); MagicalDamageTakenEventArgs e = logs[0].E as MagicalDamageTakenEventArgs; Assert.NotNull(e); Assert.AreEqual(shieldResistance, e.Damage); Assert.AreEqual(spellMagicType, e.MagicType); }