aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/table.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/table.go')
-rw-r--r--internal/casino/table.go29
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() }