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