yasuki_core.engine.table.TableState#

class TableState(seats, zones, decks, battlefield, positions=<factory>, attachments=<factory>, cards_by_id=<factory>, creatable_tokens=<factory>, seq=0)[source]#

Authoritative, per-room game state.

Holds the full truth for one table: both seats, every zone and deck, the shared battlefield, and an identity map from card id to card. Mutations bump seq so clients can detect dropped messages and request a fresh snapshot.

Attributes:
seatsdict mapping PlayerId to SeatInfo

The two seats and their public status (name, honor, ready, connected).

zonesdict mapping ZoneKey to Zone

Owned, role-keyed zones (hands, discards, banishes, provinces).

decksdict mapping DeckKey to Deck

Each seat’s fate and dynasty decks.

battlefieldBattlefieldZone

Shared, public play area; member cards have a position in positions.

positionsdict mapping str to BoardPos

Table coordinates for battlefield cards, keyed by card id.

attachmentsdict mapping str to (str or ZoneKey)

The attachment graph, keyed by the attached (child) card id. A value is either a parent card id — the child sits behind that battlefield card — or a province ZoneKey a fortification or region is attached to. Only battlefield cards appear as children; a card leaving the battlefield drops its entry and detaches whatever is hung off it.

cards_by_iddict mapping str to L5RCard

Identity map over every card on the table, for fast intent lookup.

creatable_tokensdict mapping str to L5RCard

Token templates the loaded decks can create, keyed by token card id, resolved at deck load.

seqint

Monotonic view version, bumped on every state change: by apply_intent for game intents and by bump_version() for non-intent seat metadata, so no two distinct broadcasts share a seq. The action log records only intents, so logged seq values may skip the bumps.

Methods

TableState.__init__(seats, zones, decks, ...)

TableState.bump_version()

Advance seq for a state change made outside apply_intent (seat metadata), so every broadcast that changed the view carries a strictly newer seq than the last.

TableState.empty_two_seat([p1_name, p2_name])

Build an empty, ready-to-fill two-seat table.

TableState.iter_all_cards()

Yield every card located on the table, across all zones, decks, and the battlefield.

TableState.validate()

Check the table's structural invariants, raising ValueError on the first violation.

Attributes

seats

zones

decks

battlefield

positions

attachments

cards_by_id

creatable_tokens

seq