本文整理汇总了Python中game.models.Game.status方法的典型用法代码示例。如果您正苦于以下问题:Python Game.status方法的具体用法?Python Game.status怎么用?Python Game.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game.models.Game
的用法示例。
在下文中一共展示了Game.status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: match
# 需要导入模块: from game.models import Game [as 别名]
# 或者: from game.models.Game import status [as 别名]
def match(first, second):
first_push_id = first.push_id[1:-1]
first_push_id = re.sub(r'\s', '', first_push_id)
second_push_id = second.push_id[1:-1]
second_push_id = re.sub(r'\s', '', second_push_id)
first.status = PLAYER_STATUS_ONLINE
second.status = PLAYER_STATUS_ONLINE
first.save()
second.save()
game = Game()
game.status = settings.GAME_STATUS_NEW
game.save()
game.players.add(first)
game.players.add(second)
r = Round()
r.game = game
r.owner = random.choice((first, second))
r.turn = r.owner
r.current = 1
r.save()
if len(first_push_id) == 64:
print ('--- sending notifications for ', first.login)
connection.send(first_push_id, {
'changed': [{'entity': 'user', 'entity_id': first.id}],
'new': [{'entity': 'game', 'entity_id': game.id}],
})
if len(second_push_id) == 64:
print ('--- sending notifications for ', second.login)
connection.send(second_push_id, {
'changed': [{'entity': 'user', 'entity_id': second.id}],
'new': [{'entity': 'game', 'entity_id': game.id}],
})