本文整理汇总了Python中models.Score.won方法的典型用法代码示例。如果您正苦于以下问题:Python Score.won方法的具体用法?Python Score.won怎么用?Python Score.won使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Score
的用法示例。
在下文中一共展示了Score.won方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_move
# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import won [as 别名]
def make_move(self, request):
"""Makes a move. Returns a game state with message"""
cards = [random.randint(1,11) for i in range(2)]
game = get_by_urlsafe(request.urlsafe_game_key, Game)
if game.game_over:
return game.to_form('Game already over!')
if sum(cards) > 21:
move = False
game.end_game(True)
return game.to_form('You Lose!')
if sum(cards) == 21:
move = False
game.end_game(True)
return game.to_form('You win!')
Score.won(True)
if sum(cards) < 21:
game.end_game(False)
call = input("Hit or stay?")
if call.lower() == "hit":
move = True
new_card = random.randint(1,11)
cards.append(new_card)
return sum(cards)
if call.lower() == "stay":
move = False
return sum(cards)
game.end_game(True)
return game.to_form('You lose!')
else:
game.put()
return game.to_form('Make a move!')
while game.end_game(False):
self.make_move(self, request)