diff options
| author | historia <[not public]> | 2026-10-03 01:38:58 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-03 01:38:58 -0400 |
| commit | 0ec8f3692960a064616e630c914058298b22897b (patch) | |
| tree | 2b51327eb66be7df8fdcd7c12cc306ca6fa84891 /internal/casino/craps.go | |
| parent | 82e571d227feeafd0af4011e701ce26b99c5e3d9 (diff) | |
| download | thehouseoficarus-0ec8f3692960a064616e630c914058298b22897b.tar.gz | |
feat: replaced roulette wheel graphic with line-by-line 'spin'
Diffstat (limited to 'internal/casino/craps.go')
| -rw-r--r-- | internal/casino/craps.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/internal/casino/craps.go b/internal/casino/craps.go index 90c95c9..6fa6c79 100644 --- a/internal/casino/craps.go +++ b/internal/casino/craps.go @@ -249,6 +249,9 @@ func (t *crapsTable) bet(name, spot string, amount int, w Wallet) []Event { } requested := amount amount = roundUpTo(amount, payoutDen) + if amount > t.Config.MaxBet { + return reject(fmt.Sprintf("That wager rounds up to %d, above the table maximum.", amount)) + } // Compare without multiplying a potentially very large stake by Nx. if (amount-1)/limit >= b.stake.Total { return reject("Odds already placed or above the free-odds limit.") @@ -557,7 +560,6 @@ func (t *crapsTable) unbetAllLocked(p *crapsPlayer) []Event { if b.odds.Total > 0 { total += b.odds.Total ids = append(ids, b.odds.ID) - b.odds = Wager{} } live = append(live, b) default: @@ -571,12 +573,17 @@ func (t *crapsTable) unbetAllLocked(p *crapsPlayer) []Event { if total == 0 { return []Event{t.private(p.Name, "Nothing removable on the table.")} } + // Keep the live wagers intact until the atomic refund succeeds. On a + // failed save they still belong to the next roll, or a later unbet retry. + if err := p.Wallet.PayCredits(total, ids...); err != nil { + return []Event{t.private(p.Name, "The house could not take down your bets. All wagers remain live; try unbet again.")} + } + for _, b := range live { + b.odds = Wager{} + } p.bets = live p.HasBet = len(live) > 0 e := t.private(p.Name, fmt.Sprintf("You take down {casino_chips}%d{/} credits of optional bets; contracts stay up.", total)) - if err := p.Wallet.PayCredits(total, ids...); err != nil { - e.Message = payoutFailedMessage() - } events := []Event{e, t.betSummary(p)} events = append(events, t.syncRoundClock()...) if t.players.has(p.Name) { |
