本文整理汇总了Python中weapon.Weapon类的典型用法代码示例。如果您正苦于以下问题:Python Weapon类的具体用法?Python Weapon怎么用?Python Weapon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Weapon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_critical_hit_true_and_false
def test_critical_hit_true_and_false(self):
new_weapon = Weapon("Mighty Axe", 25, 0.2)
results = []
for i in range(10):
results.append(new_weapon.critical_hit())
self.assertIn(True, results)
self.assertIn(False, results)
示例2: rubber_bullet
def rubber_bullet(self):
'''
Патрон с резиновой пулей.
:return: int
'''
return int(
(Weapon.special_carbine(self) * 250) + (Weapon.guns(self) * 48))
示例3: __init__
def __init__(self, pos = (0,0), **images) :
Projectile.__init__ (self, pos, **images)
Weapon.__init__ (self, pos, **images)
self._has_been_launched = False
self.set_knockback_factor (5)
self._damage = 5
self._name = "Bomb"
示例4: automat_catridges
def automat_catridges(self):
'''
5,45 и 7,62 мм автоматные патроны.
:return: int
'''
return int(
(Weapon.automat(self) * 246) + (Weapon.hand_gun(self) * 750))
示例5: TestWeapon
class TestWeapon(unittest.TestCase):
def setUp(self):
self.sword = Weapon('Sword', 15, 0.4)
def test_init_weapon(self):
self.assertEqual(self.sword.type, 'Sword')
self.assertEqual(self.sword.damage, 15)
self.assertEqual(self.sword.critical_strike_percent, 0.4)
def test_critical_hit(self):
critical_hit_used = False
critical_hit_not_used = False
while True:
if self.sword.critical_hit():
critical_hit_used = True
return
while True:
if not self.sword.critical_hit():
critical_hit_not_used = True
return
self.assertTrue(critical_hit_used)
self.assertFalse(critical_hit_not_used)
def test_critical_raises_error(self):
with self.assertRaises(ValueError):
axe = Weapon('Axe', 25, 2)
示例6: pistol_catridges
def pistol_catridges(self):
'''
Пистолетные патроны.
:return: int
'''
return int((Weapon.guns(self) * 24) + (
Weapon.pistol_gun(self) * 100))
示例7: WeaponTest
class WeaponTest(unittest.TestCase):
def setUp(self):
self.weapon = Weapon("Spike", 200)
def test_is_instance(self):
self.assertTrue(isinstance(self.weapon, Weapon))
def test_valid_members(self):
self.assertEqual(self.weapon.name, "Spike")
self.assertEqual(self.weapon.damage, 200)
def test_str(self):
expected = "{} with damage = {}"
expected = expected.format(self.weapon.name, self.weapon.damage)
self.assertEqual(str(self.weapon), expected)
def test_get_functions(self):
self.assertEqual(self.weapon.get_name(), "Spike")
self.assertEqual(self.weapon.get_damage(), 200)
def test_prepare_json(self):
data = {
"name": "Spike",
"damage": 200
}
self.assertEqual(self.weapon.prepare_json(), data)
示例8: test_critical_hit
def test_critical_hit(self):
weapon = Weapon("axe", 10, 0.5)
results = []
for x in range(1000):
results.append(weapon.critical_hit())
self.assertTrue(True in results)
self.assertTrue(False in results)
示例9: test_weapon_no_crit
def test_weapon_no_crit(self):
new_weapon = Weapon("alwayscrit", 10, 0)
for i in range(0, 1000):
iscrit = new_weapon.critical_hit()
if iscrit:
break
self.assertFalse(iscrit)
示例10: test_weapon_critical_hit
def test_weapon_critical_hit(self):
new_weapon = Weapon("alwayscrit", 10, 1)
for i in range(0, 10):
iscrit = new_weapon.critical_hit()
if not iscrit:
break
self.assertTrue(iscrit)
示例11: update
def update (self) :
assert (self._cooldown_frames_left >= 0)
if self._cooldown_frames_left > 0 :
self._cooldown_frames_left -= 1
Weapon.update (self)
示例12: __init__
def __init__(self):
Weapon.__init__(self)
self.enhancement = 2
self.damageDie = 'd8'
self.numDie = 0
self.extraCrit = '2d6'
self.weaponType = 'implement'
self.keywords = ['implement',]
示例13: WeaponTest
class WeaponTest(unittest.TestCase):
def setUp(self):
self.weapon = Weapon("gun", 40)
def test_damage(self):
self.assertEqual(self.weapon.get_damage(), 40)
def test_name(self):
self.assertEqual(self.weapon.get_name(), 'gun')
示例14: __init__
def __init__(self, pos = (0,0), **images) :
Weapon.__init__ (self, pos,**images)
self._firing_velocity = 20
self._magazine = []
self._cooldown = 30
self._name = "Firearm"
#used for timing
self._cooldown_frames_left = 0
示例15: __init__
def __init__(self):
Weapon.__init__(self)
self.enhancement = 3
self.damageDie = "d8"
self.numDie = 1
self.critDamage = "3d6"
self.damageType = "str"
self.weaponType = "dagger"
self.keywords = ["dagger", "lightBlade", "radiant"]
self.extraCrit = "3d6"