本文整理汇总了Python中dice.Dice.valuelist方法的典型用法代码示例。如果您正苦于以下问题:Python Dice.valuelist方法的具体用法?Python Dice.valuelist怎么用?Python Dice.valuelist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dice.Dice
的用法示例。
在下文中一共展示了Dice.valuelist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CommandlinePlayer
# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import valuelist [as 别名]
class CommandlinePlayer(Player):
def __init__(self, game, uid=1, max_turns=3, point_config='STD_CONFIG'):
super(CommandlinePlayer, self).__init__(game, uid=uid, point_config=point_config, max_turns=max_turns)
self.commands = {
'd': self.roll_dice,
's': self.save_dice,
'save': self.save_dice,
'help': print_help,
'p': self.show_points,
'p_all': self.show_all_points
}
self.point_commands = [
'one', 'two', 'three', 'four', 'five', 'six', 'threesome', 'foursome', 'onepair', 'twopair',
'smallstreet', 'bigstreet', 'kniffel', 'fullhouse', 'chance'
]
def play(self):
self.dice = Dice()
while True:
try:
self.command_prompt()
except WrongCommandException:
print_message('wrongcommand')
except TurnEndException:
break
self.turn = 0
def roll_dice(self):
super(CommandlinePlayer, self).roll_dice()
print_dice(self.dice)
def show_points(self):
print_points(self)
def print_points(self):
print_points(self.points)
def command_prompt(self):
value = prompt('playerprompt', self.id)
try:
if value.split(' ')[0] is 's':
for pos in value.split(' ')[1].split(','):
try:
self.save_dice([int(pos)])
except ValueError:
print_message('unknown_param', pos)
print_dice(self.dice)
elif value in self.commands:
try:
self.commands[value]()
except NoTurnsLeftException:
print_message('noturnsleft')
elif value.split(' ')[0] in self.point_commands:
try:
try:
column = value.split(' ')[1]
self.entry_points(value, column, self.dice.valuelist())
raise TurnEndException()
except IndexError:
print_message('specify_column')
except FieldAlreadyAssignedException:
print_message('fieldblocked')
else:
raise WrongCommandException()
except IndexError:
print_dice(self.dice)
def show_all_points(self):
print_points(self.game.players)