src/quagen/api.py
def game_view(game_id):
    """
    Grabs the current state of a Quagen game.

    Args:
        game_id (str): Game to grab

    Get:
        updatedAfter (int): Optional timestamp to only return full game state
            if game state has changed after passed timestamp. Useful for
            saving bandwidth with our current short poll approach.

    Returns:
        (Response) JSON game state
    """
    response = make_response(json.jsonify({"error": "Not found"}), 404)
    updated_after = int(request.values.get("updatedAfter", 0))

    game = queries.get_game(game_id)
    if game:

        # Grab the game state
        state = game.get_game_state()

        # If nothing has changed, let's send a minimal response
        if state["time_updated"] <= updated_after:
            state = {"game_id": state["game_id"], "time_updated": state["time_updated"]}

        # Otherwise, send the full response
        # We tack on the projected board state here to make it quickly
        # accessible to the player's client -- maybe there is a better way?
        else:
            projected_board = game.board.project()
            state["projected"] = projected_board.spots

        response = json.jsonify(game=state)

    return response

    Grabs the current state of a Quagen game.

    Args:
        game_id (str): Game to grab

    Get:
        updatedAfter (int): Optional timestamp to only return full game state
            if game state has changed after passed timestamp. Useful for
            saving bandwidth with our current short poll approach.

    Returns:
        (Response) JSON game state
    
Grabs the current state of a Quagen game.
Grabs the current state of a Quagen game .
def game_view(game_id):
    response = make_response(json.jsonify({"error": "Not found"}), 404)
    updated_after = int(request.values.get("updatedAfter", 0))
    game = queries.get_game(game_id)
    if game:
        state = game.get_game_state()
        if state["time_updated"] <= updated_after:
            state = {"game_id": state["game_id"], "time_updated": state["time_updated"]}
        else:
            projected_board = game.board.project()
            state["projected"] = projected_board.spots
        response = json.jsonify(game=state)
    return response
def game_view ( game_id ) : response = make_response ( json . jsonify ( { "error" : "Not found" } ) , 404 ) updated_after = int ( request . values . get ( "updatedAfter" , 0 ) ) game = queries . get_game ( game_id ) if game : state = game . get_game_state ( ) if state [ "time_updated" ] <= updated_after : state = { "game_id" : state [ "game_id" ] , "time_updated" : state [ "time_updated" ] } else : projected_board = game . board . project ( ) state [ "projected" ] = projected_board . spots response = json . jsonify ( game = state ) return response
Grabs the current state of a Quagen game.
Grabs the current state of a Quagen game .
"""
    Grabs the current state of a Quagen game.

    Args:
        game_id (str): Game to grab

    Get:
        updatedAfter (int): Optional timestamp to only return full game state
            if game state has changed after passed timestamp. Useful for
            saving bandwidth with our current short poll approach.

    Returns:
        (Response) JSON game state
    """ # Grab the game state # If nothing has changed, let's send a minimal response # Otherwise, send the full response # We tack on the projected board state here to make it quickly # accessible to the player's client -- maybe there is a better way?
(Response) JSON game state
( Response ) JSON game state
game_id
Game to grab
Game to grab