mundane.engine.state

Game-state dataclasses: the single source of truth for a Mundane game.

Nothing in this module mutates state; mundane.engine.rules.apply_action() is the only thing that does. Cards are referenced by id throughout the state; card objects — built from JSON sets by mundane.engine.cards.build_card() — and the effect closures they carry live only in the per-game pool, never in serialisable state. That separation is what lets a whole GameState round-trip through JSON.

Attributes

Effect

An effect mutates the state when its card resolves, given the resolving StackItem.

PERMANENTS

PHASES

Classes

CardType

The five kinds of card. The first three are permanents (they stay on the board).

Card

A card definition, built from a JSON set by mundane.engine.cards.build_card().

Player

One household. Card collections hold library ids (str), never Card objects.

StackItem

A card waiting to resolve. id is unique within a game (see GameState.next_stack_id).

GameState

The entire game. Fully JSON-serialisable: every field is data, never code.

Functions

_no_effect(→ None)

Do nothing. Permanents resolve onto the board, so they carry this placeholder effect.

Module Contents

class mundane.engine.state.CardType[source]

Bases: enum.StrEnum

The five kinds of card. The first three are permanents (they stay on the board).

PERSON = 'person'[source]
APPLIANCE = 'appliance'[source]
HABIT = 'habit'[source]
TASK = 'task'[source]
INSTANT = 'instant'[source]
type mundane.engine.state.Effect = Callable[[GameState, StackItem], None][source]

An effect mutates the state when its card resolves, given the resolving StackItem.

mundane.engine.state._no_effect(_state: GameState, _item: StackItem) None[source]

Do nothing. Permanents resolve onto the board, so they carry this placeholder effect.

class mundane.engine.state.Card[source]

A card definition, built from a JSON set by mundane.engine.cards.build_card().

State refers to a card only by its composed id (set_id:id); the bound effect closure lives in the per-game pool, never in serialisable state.

id: str[source]
name: str[source]
cost: int[source]
type: CardType[source]
effect: Effect[source]
text: str = ''[source]
flavor: str = ''[source]
mundane.engine.state.PERMANENTS[source]
class mundane.engine.state.Player[source]

One household. Card collections hold library ids (str), never Card objects.

name: str[source]
composure: int = 20[source]
time: int = 0[source]
hand: list[str] = [][source]
board: list[str] = [][source]
deck: list[str] = [][source]
discard: list[str] = [][source]
class mundane.engine.state.StackItem[source]

A card waiting to resolve. id is unique within a game (see GameState.next_stack_id).

card_id: str[source]
controller: int[source]
target_id: int | None = None[source]
id: int = 0[source]
mundane.engine.state.PHASES = ['RESET', 'WAKE_UP', 'PLAN', 'DO_STUFF', 'WIND_DOWN'][source]
class mundane.engine.state.GameState[source]

The entire game. Fully JSON-serialisable: every field is data, never code.

players: list[Player][source]
active_player: int = 0[source]
priority_player: int = 0[source]
phase: str = 'PLAN'[source]
stack: list[StackItem] = [][source]
passes_in_a_row: int = 0[source]
turn: int = 1[source]
winner: int | None = None[source]
next_stack_id: int = 1[source]
next_player(i: int) int[source]

Return the index of the player after i (wraps around the table).

opponent(i: int) int[source]

Return the opponent of player i (2-player convenience).