本文整理汇总了Python中dice.Dice.split方法的典型用法代码示例。如果您正苦于以下问题:Python Dice.split方法的具体用法?Python Dice.split怎么用?Python Dice.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dice.Dice
的用法示例。
在下文中一共展示了Dice.split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: random
# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import split [as 别名]
self.critical_multiplier = critical_multiplier or {'light': 1.5, 'medium': 2.0, 'heavy': 3.0}[size]
self.critical_chance = critical_chance or {'light': 15, 'medium': 10, 'heavy': 5}[size]
self.price = price
@classmethod
def random(cls):
global _weapon_id
name = u'weapon%d' % _weapon_id
_weapon_id += 1
size = random.choice(cls.sizes)
type = random.choice(cls.types)
class_ = random.choice(cls.classes)
damage = Dice(random.randrange(1, 4), random.randrange(4, 11, 2))
damage_type = set([random.choice(cls.damage_types)])
magic_enchantment = random.randrange(11)
return cls(name, size, type, class_, damage, damage_type, magic_enchantment, price = 10)
def __repr__(self):
return 'Weapon(%r, %r, %r, %r, %r, %r, %r)' % (self.name, self.size, self.type, self.class_, self.damage, self.damage_type, self.magic_enchantment)
def __str__(self):
return '%s (%s %s %s %s+%d %s)' % (self.name or 'Weapon', self.size, self.type, self.class_, self.damage, self.magic_enchantment, '/'.join(self.damage_type))
weapons = {}
for name, type, size, dmg_type, dmg_roll, crit_mult, crit_chance, min_range, max_range, price in weapon_data:
dmg_roll = Dice(*map(int, dmg_roll.split('d')))
weapons[name] = Weapon(name, size, type, None, dmg_roll, set(dmg_type), 0, crit_mult, crit_chance, price)
default = Weapon('fist', 'light', 'melee', None, Dice(0, 0), set(['bludgeoning']), 0, 1, 0, 0)