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
seqso clients can detect dropped messages and request a fresh snapshot.- Attributes:
- seats
dictmappingPlayerIdtoSeatInfo The two seats and their public status (name, honor, ready, connected).
- zones
dictmappingZoneKeytoZone Owned, role-keyed zones (hands, discards, banishes, provinces).
- decks
dictmappingDeckKeytoDeck Each seat’s fate and dynasty decks.
- battlefield
BattlefieldZone Shared, public play area; member cards have a position in
positions.- positions
dictmappingstrtoBoardPos Table coordinates for battlefield cards, keyed by card id.
- attachments
dictmappingstrto(strorZoneKey) 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
ZoneKeya 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_id
dictmappingstrtoL5RCard Identity map over every card on the table, for fast intent lookup.
- creatable_tokens
dictmappingstrtoL5RCard Token templates the loaded decks can create, keyed by token card id, resolved at deck load.
- seq
int Monotonic view version, bumped on every state change: by
apply_intentfor game intents and bybump_version()for non-intent seat metadata, so no two distinct broadcasts share aseq. The action log records only intents, so loggedseqvalues may skip the bumps.
- seats
Methods
TableState.__init__(seats, zones, decks, ...)Advance
seqfor a state change made outsideapply_intent(seat metadata), so every broadcast that changed the view carries a strictly newerseqthan the last.TableState.empty_two_seat([p1_name, p2_name])Build an empty, ready-to-fill two-seat table.
Yield every card located on the table, across all zones, decks, and the battlefield.
Check the table's structural invariants, raising
ValueErroron the first violation.Attributes
seatszonesdecksbattlefieldpositionsattachmentscards_by_idcreatable_tokensseq