本文整理匯總了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}],
})