yasuki_core.engine.rules.state.GameState#

class GameState(table, first_player, active, turn, phase, gold, favor_holder=None, loser=None, once_per=<factory>, seed=0, pending=None, stack=<factory>, modifiers=<factory>)[source]#

The mutable state of one rules-driven game.

Composes the shared TableState (zones, decks, cards, positions) with the turn-level bookkeeping the rules engine owns: whose turn it is, the current phase, the per-seat gold pool, and once-per usage flags. The table stays a pure substrate so the manual sandbox keeps using it unchanged; the rules engine layers its own state on top.

Attributes:
tableTableState

The shared board substrate the game plays on.

first_playerPlayerId

The seat that took the first turn, fixed at game start.

activePlayerId

The seat whose turn it currently is.

turnint

The turn counter, starting at 1 and incremented on each new player-turn.

phasePhase

The current phase of the active player’s turn.

golddict mapping PlayerId to int

Each seat’s transient gold pool. Gold produced during a cost payment pools here for further costs in the same phase and is cleared at the end of every phase.

favor_holderPlayerId or None

The seat holding the Imperial Favor, or None if no one holds it. Default None.

loserPlayerId or None

The seat that has lost the game, or None while the game is ongoing. Set when a loss condition fires (currently a failed Legacy search). Default None.

once_perset of str

Usage flags for once-per-turn and once-per-game abilities (the Inheritance Rule, Proclaim, …), keyed by a caller-chosen string. Default empty.

seedint

The master RNG seed recorded for deterministic replay. Default 0.

pendingDecisionRequest or None

The decision the engine is paused on, awaiting an answer from one seat, or None when the engine is free to advance. Default None.

stacklist of WorkItem

Deferred engine work — the later steps of an action sequence, run once the current decision clears. Ephemeral: replay rebuilds it by re-running the engine, so it is never serialized. Default empty.

modifierslist of Modifier

The active recorded stat modifiers — created continuous effects (an ability’s grant), kept in creation order. Ephemeral: rebuilt by replay and never serialized, like stack, but unlike it may be non-empty at rest within a turn, so its order is load-bearing. Default empty.

Methods

GameState.__init__(table, first_player, ...)

GameState.add_gold(seat, amount)

Add amount produced gold to seat's pool.

GameState.clear_gold()

Empty every seat's gold pool, as happens at the end of each phase.

GameState.has_used(key)

Return whether the one-time use named key has already been claimed.

GameState.spend_gold(seat, amount)

Spend amount from seat's pool.

GameState.start(table, first_player, *[, seed])

Begin a game on table: turn 1, first_player active, the Action phase, and an empty gold pool for every seat.

GameState.use_once(key)

Claim the one-time use named key.

Attributes

table

first_player

active

turn

phase

gold

favor_holder

loser

once_per

seed

pending

stack

modifiers

awaiting_decision

Whether the engine is paused on a pending decision.

game_over

Whether the game has ended — a seat has lost.