コード例 #1
0
    def test_xp_gain(self):
        cleric = heroes.Cleric()
        troll = monsters.Troll()
        troll.hp = 1
        participants = [cleric, troll]

        battle = Battle(participants)

        before_level = cleric.level

        battle.start()
        with self.assertRaises(Victory):
            battle.execute_command('smite', troll)
        after_level = cleric.level
        self.assertNotEqual(before_level, after_level)
コード例 #2
0
 def test_create_levelled_troll(self):
     troll = monsters.Troll(level=5)
     expected_stats = {'str': 21,
                       'con': 18,
                       'int': 12,
                       'spd': 12,
                       'maxhp': 56}
     actual_stats = {'str': troll.strength,
                     'con': troll.constitution,
                     'int': troll.intelligence,
                     'spd': troll.speed,
                     'maxhp': troll.maxhp}
     self.assertEqual(troll.level, 5)
     self.assertEqual(actual_stats, expected_stats)
     self.assertEqual(troll.hp, troll.maxhp)
コード例 #3
0
 def test_troll_regenerate(self):
     troll = monsters.Troll()
     troll.take_damage(12)
     self.assertNotEqual(troll.hp, troll.maxhp)
     troll.regenerate()
コード例 #4
0
 def test_troll_slash(self):
     troll = monsters.Troll()
     troll.slash(self.dummy)
     self.assertEqual(self.dummy.hp, self.dummy.maxhp - 26)