Exemple #1
0
 def get(self, gid, pid):
     user = authenticate(request.authorization)
     if not user:
         return auth_response()
     player = Player(gid, pid)
     if not player.exists():
         return '', 404
     cards = player.get_cards()
     response_data = player.get_data()
     if user.username == player.get_username():
         response_data['color'] = player.get_color()
     return jsonify(response_data)
Exemple #2
0
 def get(self, gid):
     user = authenticate(request.authorization)
     if not user:
         return auth_response()
     game = Game(gid)
     game_state = game.get_state()
     pids = game.get_pids()
     players = []
     for pid in pids:
         player = Player(gid, pid)
         cards = player.get_cards()
         username = player.get_username()
         player_data = player.get_data()
         if (user and username == user.username) or game_state == 'ended':
             player_data['color'] = player.get_color()
         players.append(player_data)
     return jsonify({'players': players})