本文整理汇总了Python中dice.Dice.from_str方法的典型用法代码示例。如果您正苦于以下问题:Python Dice.from_str方法的具体用法?Python Dice.from_str怎么用?Python Dice.from_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dice.Dice
的用法示例。
在下文中一共展示了Dice.from_str方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: end_turn
# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import from_str [as 别名]
def end_turn(self):
for c in self.conditions.values():
if c['cond_type'] == 's':
r = None
if self.pc:
print '{}: save against {}.'.format(self, c['name'])
r = easyinput.input_int('saving throw')
else:
save_die = Dice.from_str('1d20')
r = save_die.roll()['total']
if r >= 10:
self.remove_condition(c['index'])
print '{} successfully saved against {}.'.format(self, c['name'])
else:
print '{} failed a save against {}.'.format(self, c['name'])
elif c['cond_type'] == 't' and c['end_type'] == 'e':
if c['duration'] <= 0:
self.remove_condition(c['index'])
else:
print '{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])
for r in self.recharges.values():
if r['used']:
if r['just_used']:
r['just_used'] = False
continue
# Roll to recharge
d = Dice.from_str('1d6')
n = d.roll()['total']
if n >= r['value']:
r['used'] = False
print '{} can use {} again!'.format(self, r['name'])
示例2: parse_input
# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import from_str [as 别名]
def parse_input(args):
dice_list = []
for arg in args:
dice_list.append(Dice.from_str(arg))
return dice_list
示例3: roll_init
# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import from_str [as 别名]
def roll_init(self):
d = Dice.from_str('1d20+{}'.format(self.init_mod))
self.set_init(d.roll()['total'])