diff options
| author | historia <[not public]> | 2026-09-24 20:06:41 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-24 20:07:31 -0400 |
| commit | 13db3e50cb6e29eedbf25416e5284bf08b0adefb (patch) | |
| tree | d5e9b99030b25cc7fc102288b694c133f8832f84 /internal/casino/betting.go | |
| parent | d114c747a7672c7e4daab3a5b5f1b2f066ebc912 (diff) | |
| download | thehouseoficarus-13db3e50cb6e29eedbf25416e5284bf08b0adefb.tar.gz | |
feat: casino table ux: aliases, rebet hints, deadline notifications, spectator mode
Diffstat (limited to 'internal/casino/betting.go')
| -rw-r--r-- | internal/casino/betting.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/casino/betting.go b/internal/casino/betting.go index fa2d2dc..54d8c60 100644 --- a/internal/casino/betting.go +++ b/internal/casino/betting.go @@ -10,7 +10,11 @@ type countdown struct { 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 } +func (c *countdown) remaining() int { return max(0, c.deadline-c.clock) } + +// One warning per window, at one quarter of its duration (at least one tick). +func (c *countdown) warn() bool { return c.deadline > 1 && c.remaining() == max(1, c.deadline/4) } +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 @@ -42,7 +46,7 @@ func (w *bettingWindow) advance(seats []*Participant) (sitOuts []string, resolve func allBet(seats []*Participant) bool { connected := false for _, p := range seats { - if !p.Connected { + if !p.Connected || p.SittingOut { continue } connected = true @@ -68,7 +72,7 @@ func anyBet(seats []*Participant) bool { func sitOutNames(seats []*Participant) []string { var names []string for _, p := range seats { - if !p.HasBet { + if !p.HasBet && !p.SittingOut { names = append(names, p.Name) } } |
