diff options
| author | historia <[not public]> | 2026-08-03 14:08:09 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-08-03 14:08:09 -0400 |
| commit | 612e429de438821ae8e099d6b54f87c11ff6c1b5 (patch) | |
| tree | ad6f9edf74339b9b50f9c7c2cd314ee7b6e04b2c /internal/casino/betting.go | |
| parent | f51424c90dbce7191a31b6e675818c985f0f4539 (diff) | |
| download | thehouseoficarus-612e429de438821ae8e099d6b54f87c11ff6c1b5.tar.gz | |
refactor: casino game slop refactor
Diffstat (limited to 'internal/casino/betting.go')
| -rw-r--r-- | internal/casino/betting.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/internal/casino/betting.go b/internal/casino/betting.go new file mode 100644 index 0000000..3ffee88 --- /dev/null +++ b/internal/casino/betting.go @@ -0,0 +1,60 @@ +package casino + +// countdown tracks tick-based deadlines for table phases (betting windows, +// insurance offers, and player action timeouts). +type countdown struct { + clock int + deadline int +} + +func (c *countdown) start(ticks int) { c.clock, c.deadline = 0, ticks } +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 } + +// allBet reports whether at least one connected participant exists and every +// connected participant has placed a bet. Disconnected participants never +// hold a round open. +func allBet(seats []*Participant) bool { + connected := false + for _, p := range seats { + if !p.Connected { + continue + } + connected = true + if !p.HasBet { + return false + } + } + return connected +} + +// anyBet reports whether any participant, connected or not, has a wager +// committed to the current round. +func anyBet(seats []*Participant) bool { + for _, p := range seats { + if p.HasBet { + return true + } + } + return false +} + +// sitOutNames lists participants without a bet, in seat order. +func sitOutNames(seats []*Participant) []string { + var names []string + for _, p := range seats { + if !p.HasBet { + names = append(names, p.Name) + } + } + return names +} + +// clearBets resets per-round betting state on every participant. +func clearBets(seats []*Participant) { + for _, p := range seats { + p.HasBet = false + p.Wager = Wager{} + } +} |
