本文整理汇总了Python中fight.Fight.attacks_first方法的典型用法代码示例。如果您正苦于以下问题:Python Fight.attacks_first方法的具体用法?Python Fight.attacks_first怎么用?Python Fight.attacks_first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fight.Fight
的用法示例。
在下文中一共展示了Fight.attacks_first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestFight
# 需要导入模块: from fight import Fight [as 别名]
# 或者: from fight.Fight import attacks_first [as 别名]
class TestFight(unittest.TestCase):
def setUp(self):
self.my_hero = Hero("Hero", 100, "Hero")
self.my_orc = Orc("Orc", 100, 1.5)
self.the_fight = Fight(self.my_hero, self.my_orc)
def test_init(self):
self.assertEqual(self.my_hero.name, "Hero")
self.assertEqual(self.my_hero.health, 100)
self.assertEqual(self.my_hero.nickname, "Hero")
self.assertEqual(self.my_orc.name, "Orc")
self.assertEqual(self.my_orc.health, 100)
self.assertEqual(self.my_orc.berserk_factor, 1.5)
def test_attacks_first(self):
my_arr = []
for i in range(0, 100):
if self.the_fight.attacks_first() == True:
my_arr.append(1)
my_arr.append(0)
self.assertIn(1, my_arr)
self.assertIn(0, my_arr)
def test_simulate_fight(self):
proba1 = Weapon("axe", 1, 0.1)
proba2 = Weapon("sword", 40, 0.9)
self.my_hero.equip_weapon(proba1)
self.my_orc.equip_weapon(proba2)
the_fight = Fight(self.my_hero, self.my_orc)
self.assertFalse(the_fight.simulate_fight())