本文整理汇总了Python中fight.Fight.who_is_first方法的典型用法代码示例。如果您正苦于以下问题:Python Fight.who_is_first方法的具体用法?Python Fight.who_is_first怎么用?Python Fight.who_is_first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fight.Fight
的用法示例。
在下文中一共展示了Fight.who_is_first方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FightTest
# 需要导入模块: from fight import Fight [as 别名]
# 或者: from fight.Fight import who_is_first [as 别名]
class FightTest(unittest.TestCase):
def setUp(self):
self.bron_hero = Hero("Bron", 100, "DragonSlayer")
self.torug_orc = Orc("Torug", 100, 1.2)
self.new_fight = Fight(self.bron_hero, self.torug_orc)
self.axe = Weapon("Axe", 20, 0.2)
self.sword = Weapon("Sword", 12, 0.7)
self.bron_hero.equip_weapon(self.sword)
self.torug_orc.equip_weapon(self.axe)
def test_init(self):
self.assertEqual(self.new_fight.orc, self.torug_orc)
self.assertEqual(self.new_fight.hero, self.bron_hero)
def test_who_is_first(self):
first_entity = self.new_fight.who_is_first()
self.assertIn(first_entity, [self.bron_hero, self.torug_orc])
def test_fight(self):
self.new_fight.simulate_battle()
self.assertFalse(self.torug_orc.is_alive() and self.bron_hero.is_alive())
def test_fight_with_no_weapons(self):
self.torug_orc.weapon = None
self.new_fight.simulate_battle()
self.assertFalse(self.torug_orc.is_alive())
示例2: TestFight
# 需要导入模块: from fight import Fight [as 别名]
# 或者: from fight.Fight import who_is_first [as 别名]
class TestFight(unittest.TestCase):
def setUp(self):
self.bron_hero = Hero("Bron", 100, "DragonSlayer")
self.axe = Weapon("Mighty Axe", 25, 0.2)
self.sword = Weapon("Mighty Sword", 12, 0.7)
self.bron_orc = Orc("Bron", 100, 1.3)
self.my_fight = Fight(self.bron_hero, self.bron_orc)
self.bron_hero.weapon = self.sword
self.bron_orc.weapon = self.axe
def test_fight_init(self):
self.assertEqual(self.my_fight.hero, self.bron_hero)
self.assertEqual(self.my_fight.orc, self.bron_orc)
def test_who_is_first(self):
flag_hero = False
flag_orc = False
for i in range(0, 10):
self.my_fight.who_is_first()
if self.my_fight.who_is_first() == self.bron_hero:
flag_hero = True
else:
flag_orc = True
self.assertTrue(flag_hero and flag_orc)
def test_simulate_fight(self):
self.my_fight.simulate_fight()
self.assertFalse(self.bron_orc.is_alive() and self.bron_hero.is_alive())
def test_simulate_fight_hero_wtih_wep_vs_hero_without_wep(self):
self.hero_without_wep = Hero("Toni", 100, "Monster")
self.fight = Fight(self.bron_hero, self.hero_without_wep)
self.fight.simulate_fight()
self.assertFalse(self.hero_without_wep.is_alive())
def test_simulate_fight_hero_vs_equal_orc(self):
self.equal_orc = Orc("Toni", 100, 1.5)
self.equal_orc.weapon = self.sword
self.fight = Fight(self.bron_hero, self.equal_orc)
self.fight.simulate_fight()
self.assertFalse(self.bron_hero.is_alive())