class TestHero(unittest.TestCase): def setUp(self): self.monster = Monster() def test_damage_true(self): self.assertEqual(self.monster.damage(), 208) def test_damage_false(self): self.assertEqual(self.monster.damage(), 196) def test_spell_true(self): self.assertEqual(self.monster.spell(), 161) def test_spell_false(self): self.assertEqual(self.monster.spell(), 342)
import random as rnd from Hero import Hero from Monster import Monster hero = Hero() monster = Monster() hero.damage() hero.spell() monster.damage() monster.spell() class Battle: def __init__(self): self.chest = rnd.randint(1, 6) self.mon_hp = monster.hp self.hero_hp = hero.hp self.mon_punch = monster.punch self.hero_punch = hero.punch self.hero_cast = hero.cast self.mon_cast = monster.cast def battle(self): while self.hero_hp > 1: while self.mon_hp > 1: self.mon_hp -= (self.hero_punch + self.hero_cast) self.hero_hp -= (self.mon_punch + self.mon_cast) else: if self.hero_hp > 0 and self.mon_hp <= 0: if self.chest == 1:
from Hero import Hero from Monster import Monster from Battle import Battle battle = Battle() hero = Hero() monster = Monster() print('----------------------------------') print(hero.damage()) print(hero.spell()) print('----------------------------------') print(monster.damage()) print(monster.spell()) print('----------------------------------') print(battle.battle())