本文整理汇总了Python中fight.Fight.get_player_sequence方法的典型用法代码示例。如果您正苦于以下问题:Python Fight.get_player_sequence方法的具体用法?Python Fight.get_player_sequence怎么用?Python Fight.get_player_sequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fight.Fight
的用法示例。
在下文中一共展示了Fight.get_player_sequence方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FightTests
# 需要导入模块: from fight import Fight [as 别名]
# 或者: from fight.Fight import get_player_sequence [as 别名]
class FightTests(unittest.TestCase):
def setUp(self):
self.hero = Hero("Don Quixote", 9.99, "The Common Sense")
self.orc = Orc("Oplik", 10, 0.3)
self.fight = Fight(self.hero, self.orc)
self.spoon = Weapon("Rounded Spoon", 2, 0.7)
self.knife = Weapon("Rusty Knife", 6, 0.3)
self.orc.weapon = self.knife
self.hero.weapon = self.spoon
def test_fight_init(self):
self.assertEqual(self.hero, self.fight.hero)
self.assertEqual(self.orc, self.fight.orc)
def test_set_hero_value_error(self):
with self.assertRaises(ValueError):
Fight("pancake", self.orc)
def test_set_orc_value_erroe(self):
with self.assertRaises(ValueError):
Fight(self.hero, "pancake")
def test_get_player_sequence(self):
h = False
o = False
for i in range(0, 1000):
h = h or (self.fight.get_player_sequence()
== (self.hero, self.orc))
o = o or (self.fight.get_player_sequence()
== (self.orc, self.hero))
self.assertTrue(h)
self.assertTrue(o)
def test_simulate_fight(self):
self.fight.simulate_fight()
self.assertFalse(self.fight.orc.is_alive()
and self.fight.hero.is_alive())
def test_simulate_fight_no_weapon_orc(self):
self.fight.orc.weapon = None
self.fight.simulate_fight()
self.assertFalse(self.fight.orc.is_alive())
def test_simulate_fight_no_weapon_hero(self):
self.fight.hero.weapon = None
self.fight.simulate_fight()
self.assertFalse(self.fight.hero.is_alive())