src/quagen/worker.py
def process_game(game_id):
    """
    Process unprocessed game events for a single game. At the end of a
    successful process, all outstanding events for the game will be marked
    as processed.

    Args:
        game_id (str): Game to process
    """
    game = queries.get_game(game_id)
    events = queries.get_unprocessed_game_events(game_id)

    logging.info(f"Processing {len(events)} events for game {game_id}")
    logging.debug(f"{events}")

    if game.is_in_progress():

        handle_ai_movement(game)
        handle_player_movement(game, events)

        # Try to complete a turn -- we may still be missing player turns
        turn_complete = game.process_turn()
        queries.update_game(game)

        # If we did manage to complete a turn, fire off a turn_complete event
        # which will kick off this loop again and allow any AI to get ahead
        # start on processing it's next move.
        if turn_complete:
            queries.insert_game_event(game.game_id, {"type": "turn_complete"})

    # Mark all outstanding events we just went through as processed
    event_ids = [event["id"] for event in events]
    queries.update_processed_events(event_ids)

    Process unprocessed game events for a single game. At the end of a
    successful process, all outstanding events for the game will be marked
    as processed.

    Args:
        game_id (str): Game to process
    
Process unprocessed game events for a single game. At the end of a
successful process, all outstanding events for the game will be marked
as processed.
Process unprocessed game events for a single game . At the end of a successful process all outstanding events for the game will be marked as processed .
def process_game(game_id):
    game = queries.get_game(game_id)
    events = queries.get_unprocessed_game_events(game_id)
    logging.info(f"Processing {len(events)} events for game {game_id}")
    logging.debug(f"{events}")
    if game.is_in_progress():
        handle_ai_movement(game)
        handle_player_movement(game, events)
        turn_complete = game.process_turn()
        queries.update_game(game)
        if turn_complete:
            queries.insert_game_event(game.game_id, {"type": "turn_complete"})
    event_ids = [event["id"] for event in events]
    queries.update_processed_events(event_ids)
def process_game ( game_id ) : game = queries . get_game ( game_id ) events = queries . get_unprocessed_game_events ( game_id ) logging . info ( f"Processing {len(events)} events for game {game_id}" ) logging . debug ( f"{events}" ) if game . is_in_progress ( ) : handle_ai_movement ( game ) handle_player_movement ( game , events ) turn_complete = game . process_turn ( ) queries . update_game ( game ) if turn_complete : queries . insert_game_event ( game . game_id , { "type" : "turn_complete" } ) event_ids = [ event [ "id" ] for event in events ] queries . update_processed_events ( event_ids )
Process unprocessed game events for a single game.
Process unprocessed game events for a single game .
"""
    Process unprocessed game events for a single game. At the end of a
    successful process, all outstanding events for the game will be marked
    as processed.

    Args:
        game_id (str): Game to process
    """ # Try to complete a turn -- we may still be missing player turns # If we did manage to complete a turn, fire off a turn_complete event # which will kick off this loop again and allow any AI to get ahead # start on processing it's next move. # Mark all outstanding events we just went through as processed
game_id
Game to process
Game to process