def reset_hero_attributes(hero: Hero): from items.weapon import Weapon from items.spell import Spell hero.health = hero.MAX_HEALTH hero.mana = hero.MAX_MANA hero.weapon = Weapon.create_weapon(random.choice(WEAPON_NAMES)) hero.spell = Spell.create_spell(random.choice(SPELL_NAMES))
def test_if_attack_with_spell_range_works_when_cast_range_is_0(self): health = 1 hero = Hero() hero.spell = Spell(cast_range=0) enemy = Enemy(health=health) attack_with_spell_range(hero, enemy) self.assertEqual(enemy.health, health)
def test_if_attack_with_spell_range_works_when_enemy_is_killed_during_the_attack(self): health = 1 hero = Hero() hero.spell = Spell(damage=1, cast_range=1) enemy = Enemy(health=health) exp = 0 attack_with_spell_range(hero, enemy) self.assertEqual(enemy.health, exp)
def test_if_attack_by_spell_returns_spell_damage(self): h = Hero() h.spell = Spell('Fireball', 10, 5, 1) self.assertEqual(h.attack(), 10)
def test_if_attack_returns_weapon_damagae_if_it_is_stronger(self): h = Hero() h.spell = Spell('Fireball', 10, 5, 1) h.weapon = Weapon('Bat', 20) self.assertEqual(h.attack(), 20)