예제 #1
0
 def ipc_retrieve_registry(game, **req_data):
     """Retrieve local registry."""
     registry = req_data["registry_id"]
     if registry == "player":
         return ipc_ok_response(PLAYER_REGISTRY.serialized)
     if registry == "tournament":
         return ipc_ok_response(TOURNAMENT_REGISTRY.serialized)
     if registry == "game":
         return ipc_ok_response(GAME_REGISTRY.serialized)
     return ipc_error_response("invalid registry")
예제 #2
0
    def ipc_game_status(game, **req_data):
        """Get game status."""
        if game.ongoing:
            if game.paused:
                status_string = "paused"
            else:
                status_string = "started"
        elif game.finished:
            status_string = "finished"
        else:
            status_string = "stopped"

        if game.tournament_mode:
            tournament = TOURNAMENT_REGISTRY[game.tournament_id]
            tournament_str = "{} {} ".format(tournament.season,
                                             tournament.description)
            if game.active_game_id is not None:
                game_entry = GAME_REGISTRY[game.active_game_id]
                game_seq = game_entry.sequence
            else:
                game_seq = None
        else:
            tournament_str = ""
            game_seq = None
        status = {
            "game": status_string,
            "serving": game.active_player,
            "serving_user_id": game.active_player_id,
            "internal_game_id": game.g_persist.current_game_series,
            "internal_user_id": game.g_persist.get_current_user_id(),
            "scores": ChainballMainIPC._get_scores(game),
            "tournament": game.tournament_mode,
            "tournament_id": game.tournament_id,
            "tournament_str": tournament_str,
            "game_id": game.active_game_id,
            "game_seq": game_seq,
            "players": ChainballMainIPC.make_player_status(game),
            "remaining_time": game.get_remaining_time(),
        }
        return ipc_ok_response(status)
예제 #3
0
 def ipc_tournament_active(game, **req_data):
     """Get tournament status."""
     return ipc_ok_response(game.tournament_id)
예제 #4
0
 def ipc_player_status(game, **req_data):
     """Get player status."""
     players = ChainballMainIPC.make_player_status(game)
     return ipc_ok_response(players)
예제 #5
0
 def ipc_score_status(game, **req_data):
     """Get score status."""
     return ipc_ok_response(ChainballMainIPC._get_scores(game))
예제 #6
0
 def ipc_game_can_start(game, **req_data):
     """Get whether game can start."""
     return ipc_ok_response(game.game_can_start())