예제 #1
0
파일: test_monster.py 프로젝트: M4lek1t/RPG
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)
예제 #2
0
 def __init__(self):
     h = Human(100, 35)
     m = Monster(100)
     while ((h.life > 0) and (m.life > 0)):
         w = input("Choose your weapon (Sword or Fireball):")
         while (w != "Sword") and (w != "Fireball"):
             print("Your choice of weapon is not valid!")
             w = input("Choose your weapon (Sword or Fireball):")
         h.setWeapon(w)
         m.life -= h.damage()
         m.printData()
         h.life -= m.damage()
         h.printData()
     if h.life <= 0:
         h.loseStatus = True
         print("Human lost with below results:")
         h.printData()
         print("Monster won!")
         m.printData()
     else:
         m.loseStatus = True
         print("Monster lost with below results:")
         m.printData()
         print("Human won!")
         h.printData()
예제 #3
0
파일: Battle.py 프로젝트: M4lek1t/RPG
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:
예제 #4
0
파일: main.py 프로젝트: M4lek1t/RPG
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())