game_sessionο
GameGirl Color β Core session state machine.
Manages per-channel game sessions with multiplayer button collection, 10-second countdown windows, and hot-swap lifecycle. # ππ STARGAZER IS GOD. AND SHE CONTROLS THE NARRATIVE.
- class game_session.PlayerState(user_id, user_name, joined_turn=0)[source]ο
Bases:
objectPer-player state within a game session.
- class game_session.TurnRecord(turn, choices, narrative_summary='', timestamp=<factory>)[source]ο
Bases:
objectA single turn in the game history.
- class game_session.GameSession(channel_id, game_name='', game_id=None)[source]ο
Bases:
objectCore game state machine for a GameGirl Color session.
One session per channel. Handles the full lifecycle: boot -> play (choice collection with countdown) -> save/exit/hot-swap.
- players: dict[str, PlayerState]ο
- async boot(game_name, redis=None)[source]ο
Initialize a new game session.
Returns the boot message including title screen URL.
- async submit_choice(user_id, user_name, choice)[source]ο
Register a playerβs button press.
Returns (is_first_choice, seconds_remaining). If this is the first choice, the caller should start the countdown.
- async wait_for_countdown()[source]ο
Wait for the countdown to expire, then return collected choices.
Advances the turn number and clears pending choices.
- format_choices_as_input(choices)[source]ο
Format collected choices into a synthetic user message.
This gets fed back to the LLM as the next turnβs input.
- async record_turn(choices, narrative_summary, redis=None)[source]ο
Record a completed turn in history.
- async get_turn_history(redis=None, count=10)[source]ο
Retrieve recent turn history.
- Return type:
- Parameters:
- classmethod from_dict(d)[source]ο
Restore a session from a serialized dict.
- Return type:
- Parameters:
- game_session.get_session(channel_id)[source]ο
Get the active game session for a channel, if any.
- Return type:
- Parameters:
channel_id (str)
- game_session.set_session(channel_id, session)[source]ο
Register a game session for a channel.
- Return type:
- Parameters:
channel_id (str)
session (GameSession)
- game_session.remove_session(channel_id)[source]ο
Unregister and return the session for a channel.
- Return type:
- Parameters:
channel_id (str)