本文整理汇总了Python中hero.Hero.take_dmg方法的典型用法代码示例。如果您正苦于以下问题:Python Hero.take_dmg方法的具体用法?Python Hero.take_dmg怎么用?Python Hero.take_dmg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hero.Hero
的用法示例。
在下文中一共展示了Hero.take_dmg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Hero_tests
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import take_dmg [as 别名]
class Hero_tests(unittest.TestCase):
def setUp(self):
self.entity = Entity("Gosho", 100)
self.bron_hero = Hero("Ivan", 100, "Magician")
self.bron_orc = Orc("Pesho", 100, 1.40)
def test_initialisation(self):
self.assertEqual(self.bron_hero.name, "Ivan")
self.assertEqual(self.bron_hero.health, 100)
self.assertEqual(self.bron_hero.nickName, "Magician")
def test_known_as(self):
self.assertEqual("Ivan the Magician", self.bron_hero.known_as())
def test_get_health(self):
self.assertEqual(100, self.bron_hero.get_health())
def test_is_alive_with_max_health(self):
self.bron_hero.health -= 100
self.assertFalse(self.bron_hero.is_alive())
def test_is_alive_when_hit(self):
self.bron_hero.health += 20
self.assertTrue(self.bron_hero.is_alive())
def test_take_dmg(self):
self.bron_hero.take_dmg(80)
self.assertEqual(20, self.bron_hero.health)
def test_take_more_dmg_than_health(self):
self.bron_hero.take_dmg(120)
self.assertEqual(0, self.bron_hero.health)
def test_take_healing_on_dead_hero(self):
self.bron_hero.take_dmg(120)
self.assertFalse(self.bron_hero.take_healing(20))
def test_take_more_healing_than_the_max_health(self):
self.bron_hero.take_dmg(50)
self.bron_hero.take_healing(100)
self.assertEqual(100, self.bron_hero.health)
def test_take_successful_heal(self):
self.bron_hero.take_dmg(20)
self.assertTrue(self.bron_hero.take_healing(40))
def test_Orc_initialization(self):
self.assertEqual(self.bron_orc.name, "Pesho")
self.assertEqual(self.bron_orc.health, 100)
self.assertEqual(self.bron_orc.berserk_factor, 1.40)
def test_Orc_initialization2(self):
self.bron_orc_big = Orc("Pesho", 100, 2.40)
self.assertEqual(self.bron_orc_big.berserk_factor, 2)
def test_Orc_initialization3(self):
self.bron_orc_small = Orc("Pesho", 100, 0.40)
self.assertEqual(self.bron_orc_small.berserk_factor, 1)
def test_Orc_get_healt(self):
self.assertEqual(self.bron_orc.get_health(), 100)
def test_if_orc_is_alive_when_created(self):
self.assertTrue(self.bron_orc.is_alive())
def test_if_orc_is_alive_when_hit(self):
self.bron_orc.health -= 30
self.assertTrue(self.bron_orc.is_alive())
def test_orc_take_dmg(self):
self.bron_orc.take_dmg(30)
self.assertEqual(70, self.bron_orc.get_health())
def test_orc_take_more_dmg(self):
self.bron_orc.take_dmg(110)
self.assertEqual(0, self.bron_orc.get_health())
def test_take_normal_heal(self):
self.bron_orc.take_dmg(50)
self.bron_orc.take_healing(40)
self.assertEqual(90, self.bron_orc.health)
def test_take_overload_heal(self):
self.bron_orc.take_dmg(50)
self.bron_orc.take_healing(100)
self.assertEqual(100, self.bron_orc.health)