本文整理汇总了Python中dice.Dice.save方法的典型用法代码示例。如果您正苦于以下问题:Python Dice.save方法的具体用法?Python Dice.save怎么用?Python Dice.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dice.Dice
的用法示例。
在下文中一共展示了Dice.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Player
# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import save [as 别名]
class Player(object):
def __init__(self, game, point_config='STD_CONFIG', uid=1, max_turns=3):
self.game = game
self.id = uid
self.turn = 0
self.points = Points(config=point_config)
self.dice = Dice()
self.max_turns = max_turns
def save_dice(self, values):
self.dice.save(values)
def entry_points(self, field, column, values, preview=False):
score = self.points.entry(field, column, values, self.game, preview=preview)
if not preview:
self.game.next_player()
self.turn = 0
if all([all([i[1] for i in column.points.values()]) for column in self.points.columns]):
raise PlayerFinishedException()
return score
def roll_dice(self):
if self.turn >= self.max_turns:
raise NoTurnsLeftException()
self.dice.roll()
self.turn += 1
def delete(self):
if self.game.active_player == self:
self.game.next_player()
del self.game.players[self.game.players.index(self)]
@classmethod
def generate_players(cls, game, count, point_config):
return [cls(game, point_config=point_config, uid=i) for i in range(1, count+1)]