From a18bc0a38e3a90bcd91260d7abfef340f093a9bd Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 30 Sep 2026 17:29:42 -0400 Subject: fix: preserve banked free-spin winnings when a settlement save fails --- internal/casino/machine.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'internal/casino/machine.go') diff --git a/internal/casino/machine.go b/internal/casino/machine.go index 36576d0..aad6352 100644 --- a/internal/casino/machine.go +++ b/internal/casino/machine.go @@ -272,7 +272,6 @@ func (m *Machine) finishSpin() []Event { payNow = 0 case featureEnds: payNow = credits + int(m.featureBank) - m.featureBank = 0 } payFailed := false @@ -290,8 +289,21 @@ func (m *Machine) finishSpin() []Event { failedEvents := m.private(payoutFailedMessage()) failedEvents[0].Color = "casino_payout" events = append(events, failedEvents...) + if featureEnds && int(m.featureBank) > 0 { + bankEvents := m.private("The house could not credit your banked free-spin winnings either; they stay banked and are paid with your next completed free-spin feature, or when the casino closes.") + bankEvents[0].Color = "casino_action" + events = append(events, bankEvents...) + } } } + if featureEnds && !payFailed { + // The bank is now part of the settled (or absent-wallet) payout. It is + // cleared only once the save succeeded, so a failed settlement leaves + // the banked winnings on the machine instead of destroying them: the + // next free-spin feature pays them again, and shutdown/refund paths + // (refundAll, markDisconnected) still settle or report them. + m.featureBank = 0 + } if payNow > 0 && !payFailed { message := fmt.Sprintf("\nYou win %d credits.", payNow) switch { -- cgit v1.2.3