Example #1
0
 def test_hero_magic(self):
     hero1 = Hero(name="qingfeng", hp=100, attk=1)
     magic1 = Magic(name="huoqiu", attk=2)
     enemy1 = Enemy(name="enemy1", hp=200, deff=1)
     self.assertEqual(hero1.hp, 100)
     hero1.use(magic1, enemy1)
     self.assertEqual(enemy1.hp, 198)
Example #2
0
 def test_hero_magic(self):
     hero1 = Hero(name="qingfeng", hp=100, attk=1)
     magic1 = Magic(name="huoqiu", attk=2)
     enemy1 = Enemy(name="enemy1", hp=200, deff=1)
     self.assertEqual(hero1.hp, 100)
     hero1.use(magic1, enemy1)
     self.assertEqual(enemy1.hp, 198)
Example #3
0
 def test_hero_equip(self):
     hero1 = Hero(name="qingfeng", hp=100, mp=100,
                     mxhp=100, mxmp=100, attk=1)
     self.assertEqual(hero1.attk, 1)
     gun = Equip(name="gun")
     hero1.equip(gun)
     self.assertEqual(hero1.attk, 2)
Example #4
0
 def test_people_item(self):     
     hero1 = Hero(name="hero1", hp=100, mxhp=200, mp=100, mxmp=200)
     item1 = Item(name='xue', hp=120)
     hero1.eat(item1)
     self.assertEqual(hero1.hp, 200)
     item2 = Item(name='mxue', mp=220)
     hero1.eat(item2)
     self.assertEqual(hero1.mp, 200)
Example #5
0
 def test_hero_attk(self):
     hero1 = Hero(name="qingfeng", hp=100, mp=100,
                  mxhp=100, mxmp=100, attk=1)
     enemy1 = Enemy(name="enemy1", hp=200, mp=200,
                    mxhp=200, mxmp=200, deff=2)
     self.assertEqual(hero1.hp, 100)
     hero1.attack(enemy1)
     self.assertEqual(enemy1.hp, 200)
Example #6
0
 def test_people_level(self):     
     hero1 = Hero(name="hero1", exp=0)
     self.assertEqual(hero1.level, 1)
     hero2 = Hero(name="hero2", exp=100)
     self.assertEqual(hero2.level, 11)
     enemy1 = Enemy(name="enemy1")
     for i in range(10):
         hero2.attack(enemy1)
     self.assertEqual(hero2.level, 12)
Example #7
0
 def test_is_dead(self):
     hero1 = Hero(name="qingfeng", hp=1000, attk=2)
     enemy1 = Enemy(name="enemy1", hp=800, deff=1)
     magic1 = Magic(name="Stone", attk=1)
     for i in range(399):
         hero1.use(magic1, enemy1)
     self.assertFalse(enemy1.isdead())
     hero1.use(magic1, enemy1)
     self.assertTrue(enemy1.isdead())
Example #8
0
 def test_people_level(self):
     hero1 = Hero(name="hero1", exp=0)
     self.assertEqual(hero1.level, 1)
     hero2 = Hero(name="hero2", exp=100)
     self.assertEqual(hero2.level, 11)
     enemy1 = Enemy(name="enemy1")
     for i in range(10):
         hero2.attack(enemy1)
     self.assertEqual(hero2.level, 12)
Example #9
0
 def test_hero_equip(self):
     hero1 = Hero(name="qingfeng",
                  hp=100,
                  mp=100,
                  mxhp=100,
                  mxmp=100,
                  attk=1)
     self.assertEqual(hero1.attk, 1)
     gun = Equip(name="gun")
     hero1.equip(gun)
     self.assertEqual(hero1.attk, 2)
Example #10
0
 def test_hero_shuxing(self):
     hero1 = Hero(name="testhero", hp=100, mp=100, mxhp=100, mxmp=100)
     self.assertEqual(hero1.name, 'testhero')
     self.assertEqual(hero1.hp, 100)
     self.assertEqual(hero1.mp, 100)
     self.assertEqual(hero1.mxhp, 100)
     self.assertEqual(hero1.mxmp, 100)
Example #11
0
 def test_hero_attk(self):
     hero1 = Hero(name="qingfeng",
                  hp=100,
                  mp=100,
                  mxhp=100,
                  mxmp=100,
                  attk=1)
     enemy1 = Enemy(name="enemy1",
                    hp=200,
                    mp=200,
                    mxhp=200,
                    mxmp=200,
                    deff=2)
     self.assertEqual(hero1.hp, 100)
     hero1.attack(enemy1)
     self.assertEqual(enemy1.hp, 200)
Example #12
0
 def test_people_bag(self):
     hero1 = Hero(name="hero1")
     bag1 = Bag(limit=3)
     for i in range(3):
         item = Item(name='mxue', mp=220)
         bag1.add(item)
     item2 = Item(name='mxue', mp=220)
     r = bag1.add(item2)
     self.assertFalse(r)
Example #13
0
 def test_people_item(self):
     hero1 = Hero(name="hero1", hp=100, mxhp=200, mp=100, mxmp=200)
     item1 = Item(name='xue', hp=120)
     hero1.eat(item1)
     self.assertEqual(hero1.hp, 200)
     item2 = Item(name='mxue', mp=220)
     hero1.eat(item2)
     self.assertEqual(hero1.mp, 200)
Example #14
0
 def test_is_dead(self):
     hero1 = Hero(name="qingfeng", hp=1000, attk=2)
     enemy1 = Enemy(name="enemy1", hp=800, deff=1)
     magic1 = Magic(name="Stone", attk=1)
     for i in range(399):
         hero1.use(magic1, enemy1)
     self.assertFalse(enemy1.isdead())
     hero1.use(magic1, enemy1)
     self.assertTrue(enemy1.isdead())
Example #15
0
 def test_hero_run(self):
     hero1 = Hero(name="testhero", hp=100, mp=100, mxhp=100, mxmp=100)
     self.assertEqual(hero1.hp, 100)
     hero1.run()
     self.assertEqual(hero1.hp, 99)
Example #16
0
 def test_hero_run(self):
     hero1 = Hero(name="testhero", hp=100, mp=100, mxhp=100, mxmp=100)
     self.assertEqual(hero1.hp, 100)
     hero1.run()
     self.assertEqual(hero1.hp, 99)