当前位置: 首页>>代码示例>>Python>>正文


Python Fight.coin_toss方法代码示例

本文整理汇总了Python中fight.Fight.coin_toss方法的典型用法代码示例。如果您正苦于以下问题:Python Fight.coin_toss方法的具体用法?Python Fight.coin_toss怎么用?Python Fight.coin_toss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fight.Fight的用法示例。


在下文中一共展示了Fight.coin_toss方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FightTest

# 需要导入模块: from fight import Fight [as 别名]
# 或者: from fight.Fight import coin_toss [as 别名]
class FightTest(unittest.TestCase):

    def setUp(self):
        self.hero = Hero("Arthas", 660, "Lich King")
        self.orc = Orc("Thrall", 700, 1.7)
        self.heroWeapon = Weapon("Frostmourne", 35, 0.7)
        self.orcWeapon = Weapon("Doomhammer", 40, 0.6)
        self.hero.weapon = self.heroWeapon
        self.orc.weapon = self.orcWeapon
        self.fight = Fight(self.hero, self.orc)

    def test_init(self):
        self.assertEqual(self.fight.hero, self.hero)
        self.assertEqual(self.fight.orc, self.orc)

    def test_coin_toss_for_first_attacker(self):
        self.assertIn(self.fight.coin_toss(),
                      [(self.orc, self.hero), (self.hero, self.orc)])

    def test_simulate_fight_with_no_weapons(self):
        self.fight.hero.weapon = None
        self.fight.orc.weapon = None
        result = self.fight.simulate_fight()
        self.assertEqual(result, "No winner")

    def test_simulate_fight_with_only_one_weapon(self):
        self.fight.hero.weapon = None
        result = self.fight.simulate_fight()
        self.assertEqual(result, self.fight.orc)

    def test_simulate_fight_with_both_armed_chars(self):
        result = self.fight.simulate_fight()
        self.assertIn(result, [self.fight.orc, self.hero])
开发者ID:sslavov93,项目名称:TreasureDungeon,代码行数:35,代码来源:test_all.py


注:本文中的fight.Fight.coin_toss方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。