aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/craps.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/craps.go')
-rw-r--r--internal/casino/craps.go35
1 files changed, 26 insertions, 9 deletions
diff --git a/internal/casino/craps.go b/internal/casino/craps.go
index 9e48667..410a372 100644
--- a/internal/casino/craps.go
+++ b/internal/casino/craps.go
@@ -207,17 +207,22 @@ func (t *crapsTable) bet(name, spot string, amount int, w Wallet) []Event {
continue
}
against := strings.HasPrefix(b.kind, "dont")
- x, y := crapsTrueOdds(b.number)
+ // The odds payout is a whole-ratio return on the stake, so the wager
+ // must divide evenly by the ratio's denominator. Don't odds invert
+ // the pass ratio, so against the same number the other side of the
+ // true odds is the denominator. (crapsReturn applies the full
+ // ratio at payout time.)
+ num, den := crapsTrueOdds(b.number)
+ payoutDen := den
if against {
- x, y = y, x
+ payoutDen = num
}
- _ = x
limit := t.Config.Craps.oddsLimit(b.number, against)
if b.odds.Total > 0 {
continue
}
// Compare without multiplying a potentially very large stake by Nx.
- if (amount-1)/limit >= b.stake.Total || amount%y != 0 {
+ if (amount-1)/limit >= b.stake.Total || amount%payoutDen != 0 {
return reject("Odds already placed, above the free-odds limit, or not in exact payout units.")
}
stake, err := w.Wager(amount)
@@ -575,14 +580,26 @@ func (t *crapsTable) markDisconnected(name string) []Event {
var events []Event
// Refunding after observing intermediate dice would turn contract bets into
// free options. Disconnect consumes live bets; shutdown alone refunds them.
+ // Every live bet resolves as a loss covered by ONE wallet save: PayCredits
+ // with a zero return consumes every listed stake in that one save the same
+ // way a losing round does, instead of one save per bet.
+ var ids []string
+ var lines []settlementLine
for _, b := range p.bets {
- line, failed := t.pay(p, b, -1, 1, -1, false)
- var lines []settlementLine
- if !failed {
- lines = append(lines, line)
+ ids = append(ids, b.stake.ID)
+ if b.odds.Total > 0 {
+ ids = append(ids, b.odds.ID)
}
- events = append(events, t.settlementEvent(p, lines, failed))
+ lines = append(lines, settlementLine{
+ Label: crapsBetLabel(b), Stake: b.stake.Total + b.odds.Total,
+ Returned: 0, Result: "loss",
+ })
+ }
+ failed := false
+ if p.Wallet != nil {
+ failed = p.Wallet.PayCredits(0, ids...) != nil
}
+ events = append(events, t.settlementEvent(p, lines, failed))
t.remove(name)
events = append(events, t.syncRoundClock()...)
return append(events, t.event(name+" leaves craps; live wagers are forfeited.", true))