diff options
| author | historia <[not public]> | 2026-09-15 15:35:52 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-15 15:35:52 -0400 |
| commit | 0b0b25222b3131ada79ff78c28eb8bf07d977deb (patch) | |
| tree | 2ceaef5203595044f66a8f00064cd8e017f8f48d /internal/casino/table.go | |
| parent | 396c3facb8287b9a34076cae8f3d7b300d366d99 (diff) | |
| download | thehouseoficarus-0b0b25222b3131ada79ff78c28eb8bf07d977deb.tar.gz | |
feat: single-owner game state, transactional lifecycle, durable money on server stop
Diffstat (limited to 'internal/casino/table.go')
| -rw-r--r-- | internal/casino/table.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/casino/table.go b/internal/casino/table.go index 80ae451..09c19de 100644 --- a/internal/casino/table.go +++ b/internal/casino/table.go @@ -16,6 +16,9 @@ type tableGame interface { rebet(name string) (spot string, amount int) markDisconnected(name string) []Event hasParticipant(name string) bool + refundAll() []Event + setRoom(roomID int) + idle() bool } // tableBase carries the identity every table game needs to build events. @@ -78,3 +81,29 @@ func (t *Table) rebet(name string) (string, int) { return t.game.rebet(name) func (t *Table) markDisconnected(name string) []Event { return t.game.markDisconnected(name) } func (t *Table) hasParticipant(name string) bool { return t.game.hasParticipant(name) } + +// refundAll resolves every committed wager at this table (graceful +// shutdown): stakes return to their players through the wallet. +func (t *Table) refundAll() []Event { return t.game.refundAll() } + +// setRoom updates the table game's room for event routing after a room-ID +// rekey. Games keep their state; only their location moves. +func (b *tableBase) setRoom(roomID int) { b.RoomID = roomID } + +// idle reports whether no player is seated (or mid-round): only an idle +// table may have its live rules replaced by new room configuration. +func (t *blackjackTable) idle() bool { + t.mu.Lock() + defer t.mu.Unlock() + return t.players.count() == 0 +} + +// idle reports whether no player is seated (or mid-round). +func (t *baccaratTable) idle() bool { + t.mu.Lock() + defer t.mu.Unlock() + return t.players.count() == 0 +} + +// idle on the Table wrapper delegates to the game. +func (t *Table) idle() bool { return t.game.idle() } |
