diff options
| author | historia <[not public]> | 2026-10-01 22:47:41 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-01 22:47:41 -0400 |
| commit | 8eea0e4e06a4aaa6a18edabd9897d3bea1ea2ca0 (patch) | |
| tree | 63698c0618f382a553d4558a33e3d2087039c378 /internal/casino/craps.go | |
| parent | 6d9908b29c8187196d23b126b1165c7e0bd0fc76 (diff) | |
| download | thehouseoficarus-8eea0e4e06a4aaa6a18edabd9897d3bea1ea2ca0.tar.gz | |
feat: consistent wager outcome table across casino games
Diffstat (limited to 'internal/casino/craps.go')
| -rw-r--r-- | internal/casino/craps.go | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/internal/casino/craps.go b/internal/casino/craps.go index 95d3c21..69a38ed 100644 --- a/internal/casino/craps.go +++ b/internal/casino/craps.go @@ -293,19 +293,13 @@ func (t *crapsTable) bet(name, spot string, amount int, w Wallet) []Event { events = append(events, t.syncRoundClock()...) return append(events, t.betSummary(p), t.reminder(name)) } -func (t *crapsTable) pay(p *crapsPlayer, b *crapsBet, profit, den int, oddsProfit int, refundOdds bool) (settlementLine, bool) { +func (t *crapsTable) pay(p *crapsPlayer, b *crapsBet, profit, den int, oddsProfit int, refundOdds bool) bool { payout := crapsReturn(b, profit, den, oddsProfit, refundOdds) ids := []string{b.stake.ID} if b.odds.Total > 0 { ids = append(ids, b.odds.ID) } - line := settlementLine{Label: crapsBetLabel(b), Stake: b.stake.Total + b.odds.Total, Returned: payout, Result: "push"} - if payout > line.Stake { - line.Result = "win" - } else if payout < line.Stake { - line.Result = "loss" - } - return line, p.Wallet.PayCredits(payout, ids...) != nil + return p.Wallet.PayCredits(payout, ids...) != nil } func (t *crapsTable) roll() []Event { a, b := 0, 0 @@ -355,11 +349,10 @@ func (t *crapsTable) resolveRoll(a, b int) []Event { done, x, y := t.outcomeFor(bet, a, b) if done { refundOdds := oldPoint == 0 && bet.kind == "come" - line, err := t.pay(p, bet, x, y, x, refundOdds) - if err { + if t.pay(p, bet, x, y, x, refundOdds) { failed = true } else { - lines = append(lines, line) + lines = append(lines, t.crapsSettlementLines(bet, x, y, refundOdds, false)...) } continue } @@ -370,6 +363,9 @@ func (t *crapsTable) resolveRoll(a, b int) []Event { } p.bets = live p.HasBet = len(live) > 0 + for _, bet := range live { + lines = append(lines, t.crapsSettlementLines(bet, 0, 1, false, true)...) + } if len(lines) > 0 || failed { results = append(results, t.settlementEvent(p, lines, failed)) } @@ -563,15 +559,15 @@ func (t *crapsTable) markDisconnected(name string) []Event { if b.odds.Total > 0 { ids = append(ids, b.odds.ID) } - lines = append(lines, settlementLine{ - Label: crapsBetLabel(b), Stake: b.stake.Total + b.odds.Total, - Returned: 0, Result: "loss", - }) + lines = append(lines, t.crapsSettlementLines(b, -1, 1, false, false)...) } failed := false if p.Wallet != nil { failed = p.Wallet.PayCredits(0, ids...) != nil } + if failed { + lines = nil + } events = append(events, t.settlementEvent(p, lines, failed)) t.remove(name) events = append(events, t.syncRoundClock()...) |
