本文整理汇总了Python中orc.Orc.set_berserk_factor方法的典型用法代码示例。如果您正苦于以下问题:Python Orc.set_berserk_factor方法的具体用法?Python Orc.set_berserk_factor怎么用?Python Orc.set_berserk_factor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orc.Orc
的用法示例。
在下文中一共展示了Orc.set_berserk_factor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OrcTests
# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import set_berserk_factor [as 别名]
class OrcTests(unittest.TestCase):
def setUp(self):
self.the_orc = Orc("Oplik", 122, 1.42)
def test_orc_init(self):
self.assertEqual(1.42, self.the_orc.berserk_factor)
def test_set_berserk_factor(self):
self.the_orc.set_berserk_factor(2.55)
self.assertEqual(2, self.the_orc.berserk_factor)
self.the_orc.set_berserk_factor(0.55)
self.assertEqual(1, self.the_orc.berserk_factor)
def test_orc_attack_no_weapon(self):
self.assertEqual(0, self.the_orc.attack())
# that's a stupid test, fix it later!
def test_orc_attack(self):
weapon = Weapon("spoon", 2, 0.7)
self.the_orc.equip_weapon(weapon)
critical = False
normal = False
critical_num = 4 * self.the_orc.berserk_factor
normal_num = 2 * self.the_orc.berserk_factor
for i in range(0, 1000):
critical = critical or (critical_num == self.the_orc.attack())
normal = normal or (normal_num == self.the_orc.attack())
self.assertTrue(critical)
self.assertTrue(normal)
示例2: OrcTest
# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import set_berserk_factor [as 别名]
class OrcTest(unittest.TestCase):
def setUp(self):
self.orc = Orc("Thrall", 200, 1.7)
self.orc.weapon = Weapon("Frostmourne", 35, 0.7)
def test_init(self):
self.assertEqual(self.orc.name, "Thrall")
self.assertEqual(self.orc.health, 200)
self.assertEqual(self.orc.berserk_factor, 1.7)
def test_berserk_set_with_higher_value(self):
result = self.orc.set_berserk_factor(3.5)
self.assertEqual(result, 2.0)
def test_berserk_set_with_lower_value(self):
result = self.orc.set_berserk_factor(0.4)
self.assertEqual(result, 1.0)
def test_berserk_set_with_negative(self):
result = self.orc.set_berserk_factor(-5)
self.assertEqual(result, 1.0)
def test_has_weapon_when_present(self):
self.assertEqual(self.orc.has_weapon(), True)
def test_has_weapon_when_not_present(self):
self.orc.weapon = None
self.assertEqual(self.orc.has_weapon(), False)
def test_equip_stronger_weapon(self):
test_weapon = Weapon("Stick", 500, 0.1)
self.orc.equip_weapon(test_weapon)
self.assertEqual(self.orc.weapon, test_weapon)
def test_equip_weaker_weapon(self):
test_weapon = Weapon("Stick", 5, 0.1)
self.orc.equip_weapon(test_weapon)
self.assertNotEqual(self.orc.weapon, test_weapon)
def test_attack_when_no_weapon_is_equipped(self):
self.orc.weapon = None
self.assertEqual(self.orc.attack(), 0)
def test_attack_when_weapon_is_equipped(self):
self.assertIn(self.orc.attack(), [35 * 1.7, 70 * 1.7])