diff options
Diffstat (limited to 'internal/casino/craps.go')
| -rw-r--r-- | internal/casino/craps.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/internal/casino/craps.go b/internal/casino/craps.go index 8322192..3bbb08f 100644 --- a/internal/casino/craps.go +++ b/internal/casino/craps.go @@ -37,7 +37,8 @@ type crapsTable struct { roundElapsed time.Duration multiplayer bool lastCall bool - countdown int // simplified craps: automatic-roll countdown lines emitted + pendingRoll time.Duration // manual roll: time left before the dice resolve + countdown int // simplified craps: automatic-roll countdown lines emitted } type CrapsBetView struct { Name, Target string @@ -111,6 +112,9 @@ func (t *crapsTable) board(_ string) Snapshot { } func (t *crapsTable) menu(name string) Event { e := t.betMenuEvent(name, t.commands(name)) + if e.Menu != nil { + e.Menu.Heading = t.shooterHeading() + } e.Snapshot = t.view() return e } @@ -130,6 +134,10 @@ func (t *crapsTable) join(name string) []Event { } func (t *crapsTable) remove(name string) { t.countdown = 0 + if len(t.queue) > 0 && t.queue[0] == name { + // The queued roll belongs to the shooter; a departing shooter cancels it. + t.pendingRoll = 0 + } t.removeSeatLocked(name) for i, n := range t.queue { if n == name { @@ -457,6 +465,12 @@ func (t *crapsTable) action(name, action string) []Event { if p == nil { return []Event{t.private(name, "You aren't playing craps.")} } + if action == "leave_after" { + p.LeaveAfter = true + events := []Event{t.private(name, "You’ll leave after this round. Your live bets still need to settle.")} + events = append(events, t.finishCrapsControls()...) + return append(events, t.syncRoundClock()...) + } if events, ok := t.controlLocked(name, action); ok { events = append(events, t.finishCrapsControls()...) return append(events, t.syncRoundClock()...) @@ -485,7 +499,12 @@ func (t *crapsTable) action(name, action string) []Event { if t.multiplayer && t.roundElapsed < crapsBetDelay { return append(events, t.private(name, fmt.Sprintf("Others have time to bet: you can shoot in {casino_emphasis}%d seconds{/}. Bets remain open until you roll.", crapsSeconds(crapsBetDelay-t.roundElapsed)))) } - return append(events, t.roll()...) + if t.pendingRoll > 0 { + return append(events, t.private(name, "The dice are already in the air.")) + } + t.pendingRoll = crapsManualRollDelay + shake := t.playerAction(name, fmt.Sprintf("{casino_emphasis}%s shakes the dice...{/}", name), "{casino_emphasis}You shake the dice...{/}") + return append(events, shake) } if action == "unbet" { return append(t.unbetAllLocked(p), t.finishCrapsControls()...) @@ -593,6 +612,7 @@ func (t *crapsTable) refundAll() []Event { t.point = 0 t.rolled = false t.countdown = 0 + t.pendingRoll = 0 t.made = map[int]bool{} t.seen = map[int]bool{} t.phase = phaseWaiting |
