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.go26
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()...)