aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/betting.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-08-07 05:02:39 -0400
committerhistoria <[not public]>2026-08-07 05:02:39 -0400
commit9a716a7d2ce514f452b425caedc1a9a15cde09f0 (patch)
treede980f16c4af93512a1616e6521275fd62aca542 /internal/casino/betting.go
parent0f008790f192a491ac3901d54b506b756f57fef8 (diff)
downloadthehouseoficarus-9a716a7d2ce514f452b425caedc1a9a15cde09f0.tar.gz
feat: disconnect forfeits bet and frees up seat
Diffstat (limited to 'internal/casino/betting.go')
-rw-r--r--internal/casino/betting.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/casino/betting.go b/internal/casino/betting.go
index 3ffee88..fa2d2dc 100644
--- a/internal/casino/betting.go
+++ b/internal/casino/betting.go
@@ -12,6 +12,30 @@ func (c *countdown) stop() { c.clock, c.deadline = 0, 0 }
func (c *countdown) tick() { c.clock++ }
func (c *countdown) expired() bool { return c.deadline > 0 && c.clock >= c.deadline }
+// bettingWindow is the timed betting phase shared by multiplayer table games.
+// The owning table opens it when the first wager lands with multiple seated
+// players and decides the outcome (deal/resolve vs reset) from advance.
+type bettingWindow struct {
+ timer countdown
+}
+
+func (w *bettingWindow) open(ticks int) { w.timer.start(ticks) }
+func (w *bettingWindow) close() { w.timer.stop() }
+
+// advance moves the window one tick. pending means the window is still open;
+// otherwise resolve reports whether wagers are down and the round should play
+// out, and sitOuts names the seated players who never bet.
+func (w *bettingWindow) advance(seats []*Participant) (sitOuts []string, resolve, pending bool) {
+ w.timer.tick()
+ if allBet(seats) {
+ return nil, true, false
+ }
+ if !w.timer.expired() {
+ return nil, false, true
+ }
+ return sitOutNames(seats), anyBet(seats), false
+}
+
// allBet reports whether at least one connected participant exists and every
// connected participant has placed a bet. Disconnected participants never
// hold a round open.