mundane.engine.game

The Game wrapper: a GameState, the card pool it runs on, and the action log.

A game is event-sourced. The state is a fold of apply_action over the log, so the log alone (plus the card snapshot) can rebuild the state — exactly the “download game log” / replay payload. submit appends to the log only when the action is accepted; a rejected move (IllegalAction) never happened and is never logged.

The resolved card pool lives here (not on GameState): it carries bound effect closures, which are code and must never reach serialisable state. The snapshot is the pool’s plain-data, JSON-ready mirror (set by the API at creation time) so an exported game replays self-contained.

Classes

Game

A live game: its state, the card pool it runs on, the action log, and the export snapshot.

Functions

new_game(→ Game)

Create the opening position: Steve (the party) vs Alex (the complaint), 5 Time each, in Plan.

Module Contents

class mundane.engine.game.Game[source]

A live game: its state, the card pool it runs on, the action log, and the export snapshot.

state: mundane.engine.state.GameState[source]
cards: dict[str, mundane.engine.state.Card][source]
log: list[mundane.engine.actions.Action] = [][source]
card_snapshot: dict[str, object][source]
submit(action: mundane.engine.actions.Action) mundane.engine.state.GameState[source]

Apply action (raising IllegalAction if illegal) and, only on success, log it.

export() dict[str, object][source]

Return the serialised log, final state, and card snapshot — the download/replay payload.

mundane.engine.game.new_game(cards: dict[str, mundane.engine.state.Card]) Game[source]

Create the opening position: Steve (the party) vs Alex (the complaint), 5 Time each, in Plan.

cards is the resolved pool the game runs on. The opening hands name cards from the core set (the demo deal); turning the pool into real per-player decks is a separate concern.