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:
- table
TableState The shared board substrate the game plays on.
- first_player
PlayerId The seat that took the first turn, fixed at game start.
- active
PlayerId The seat whose turn it currently is.
- turn
int The turn counter, starting at 1 and incremented on each new player-turn.
- phase
Phase The current phase of the active player’s turn.
- gold
dictmappingPlayerIdtoint 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_holder
PlayerIdorNone The seat holding the Imperial Favor, or None if no one holds it. Default None.
- loser
PlayerIdorNone 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_per
setofstr Usage flags for once-per-turn and once-per-game abilities (the Inheritance Rule, Proclaim, …), keyed by a caller-chosen string. Default empty.
- seed
int The master RNG seed recorded for deterministic replay. Default 0.
- pending
DecisionRequestorNone The decision the engine is paused on, awaiting an answer from one seat, or None when the engine is free to advance. Default None.
- stack
listofWorkItem 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.
- modifiers
listofModifier 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.
- table
Methods
GameState.__init__(table, first_player, ...)GameState.add_gold(seat, amount)Add
amountproduced gold toseat's pool.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
keyhas already been claimed.GameState.spend_gold(seat, amount)Spend
amountfromseat's pool.GameState.start(table, first_player, *[, seed])Begin a game on
table: turn 1,first_playeractive, the Action phase, and an empty gold pool for every seat.GameState.use_once(key)Claim the one-time use named
key.Attributes
tablefirst_playeractiveturnphasegoldfavor_holderloseronce_perseedpendingstackmodifiersawaiting_decisionWhether the engine is paused on a pending decision.
game_overWhether the game has ended — a seat has lost.