From 9666676766bf21364f4fc4d0d1d336e72f2a91b4 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 6 Oct 2026 12:57:23 -0400 Subject: refactor: split casino.go, dedup helpers, remove audit docs --- internal/casino/baccarat.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'internal/casino/baccarat.go') diff --git a/internal/casino/baccarat.go b/internal/casino/baccarat.go index d385834..94d960a 100644 --- a/internal/casino/baccarat.go +++ b/internal/casino/baccarat.go @@ -264,6 +264,11 @@ func (t *baccaratTable) rebetAll(name string, wallet Wallet) []Event { if !p.hasLastBet() { return []Event{t.private(name, "Bet on what? Try bet N on "+t.Rules.betChoices()+".")} } + // Require the main wager before committing remembered side bets: a + // side-only memory would otherwise charge the sides and never deal. + if p.mainSpot == "" || p.lastBets[p.mainSpot] <= 0 { + return []Event{t.private(name, "Your last bet had no main wager. Use bet N on " + t.Rules.betChoices() + ".")} + } var events []Event for _, spot := range t.Rules.spots() { if baccaratIsMainSpot(spot) { @@ -374,7 +379,7 @@ func (t *baccaratTable) unbetAllLocked(name string) []Event { return []Event{t.private(name, "Nothing to take back.")} } if p.Wallet != nil { - if err := p.Wallet.PayCredits(total, ids...); err != nil { + if err := p.Wallet.RefundStakes(ids...); err != nil { return []Event{t.private(name, payoutFailedMessage())} } } @@ -399,7 +404,7 @@ func (t *baccaratTable) refundSidesLocked(p *baccaratPlayer) []Event { return nil } if p.Wallet != nil { - if err := p.Wallet.PayCredits(total, ids...); err != nil { + if err := p.Wallet.RefundStakes(ids...); err != nil { return []Event{t.private(p.Name, "Your side bets could not be returned just now; the stake stays pending and will be refunded after the next server restart.")} } } @@ -476,7 +481,7 @@ func (t *baccaratTable) deal() []Event { settlement := t.playerAction(p.Name, publicResult, privateResult) // Returning players get their balance in the next bet menu; only // departures/sit-outs need it attached to the settlement. - settlement.ShowBalance = !payoutFailed && (p.LeaveAfter || p.SitOutAfter || !p.Connected) + settlement.ShowBalance = p.SettlementBalanceNeeded(payoutFailed) if !payoutFailed { settlement.Settlement = lines switch { -- cgit v1.2.3