Ejemplo n.º 1
0
	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()],
		}
Ejemplo n.º 2
0
	def game_constants(self, params):
		self.respond()
		self.wfile.write(json.dumps(Constants.to_dict()))