本文整理汇总了Python中Constants.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.to_dict方法的具体用法?Python Constants.to_dict怎么用?Python Constants.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constants
的用法示例。
在下文中一共展示了Constants.to_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: game_avail_info
# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import to_dict [as 别名]
def game_avail_info(self, auth):
"""
Return game state including objects of player with given auth code.
@type auth: string
@param auth: authCode of the player making the requests.
"""
alive_players = []
for player in self.players.itervalues():
if player.alive:
alive_players.append(player.name)
player = self.get_player_by_auth(auth)
if player == None:
return {'success':False, 'message':'bad auth'}
return {
'game_active': self.active,
'turn':self.turn,
'constants':Constants.to_dict(),
'you': id(player),
'resources': player.resources,
'score':player.score,
'alive_players': alive_players,
'objects': [object.to_dict() for object in\
player.objects.itervalues()],
}
示例2: game_constants
# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import to_dict [as 别名]
def game_constants(self, params):
self.respond()
self.wfile.write(json.dumps(Constants.to_dict()))