本文整理汇总了Python中hero.Hero.upgrade_bonus方法的典型用法代码示例。如果您正苦于以下问题:Python Hero.upgrade_bonus方法的具体用法?Python Hero.upgrade_bonus怎么用?Python Hero.upgrade_bonus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hero.Hero
的用法示例。
在下文中一共展示了Hero.upgrade_bonus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestHero
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import upgrade_bonus [as 别名]
class TestHero(unittest.TestCase):
def setUp(self):
self.hero = Hero('San')
def test_hero_constructor(self):
self.assertEqual(self.hero.name, 'San')
self.assertEqual(self.hero.level, 1)
def test_level_up(self):
self.hero.experience = 245
self.hero.check_for_level_up()
self.assertEqual(self.hero.level, 2)
self.assertEqual(self.hero.experience, 45)
self.assertEqual(self.hero.experience_to_level_up, 300)
def test_town_conditions(self):
self.assertTrue(self.hero.is_in_town)
self.hero.leave_town()
self.assertFalse(self.hero.is_in_town)
self.hero.arrive_at_town()
def test_increase_decrease_army(self):
self.hero.increase_army(1, 20)
self.assertEqual(self.hero.army, [0, 20, 0, 0])
self.hero.decrease_army(1, 10)
self.assertEqual(self.hero.army, [0, 10, 0, 0])
self.assertRaises(NoUnits, self.hero.decrease_army, 1, 40)
self.hero.increase_army(3, 100)
self.assertEqual(self.hero.army, [0, 10, 0, 100])
def test_upgrade_bonus(self):
self.hero.upgrade_bonus('health')
self.assertEqual(self.hero.bonuses['health'], 1)
self.assertEqual(self.hero.bonuses['damage'], 0)
self.hero.talent_points = 0
self.assertRaises(NoTalentPoints, self.hero.upgrade_bonus, 'damage')
def test_gain_experience(self):
self.hero.gain_experience(300)
self.assertEqual(self.hero.level, 2)
self.assertEqual(self.hero.experience, 100)
self.assertEqual(self.hero.experience_to_level_up, 300)