예제 #1
0
def regular_fight(hero: Hero, enemy: Enemy):
    while True:
        enemy.take_damage(hero.attack())
        print_entity_name_and_health('Enemy', enemy.health)

        if not enemy.is_alive():
            print_has_been_slain('Enemy')
            break

        hero.take_damage(enemy.attack())
        print_hero_takes_damage(hero, enemy)
        print_entity_name_and_health(hero.name, hero.health)

        if not hero.is_alive():
            print_has_been_slain(hero.known_as())
            break
    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)