aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/machine.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-30 17:29:42 -0400
committerhistoria <[not public]>2026-09-30 17:29:42 -0400
commita18bc0a38e3a90bcd91260d7abfef340f093a9bd (patch)
tree9fa580879988485ef077d0fdf63dcb91eb0e57a4 /internal/casino/machine.go
parenta4c09c2d38d1f3bc1d3ad4bdb0234bdea7c37e73 (diff)
downloadthehouseoficarus-a18bc0a38e3a90bcd91260d7abfef340f093a9bd.tar.gz
fix: preserve banked free-spin winnings when a settlement save fails
Diffstat (limited to 'internal/casino/machine.go')
-rw-r--r--internal/casino/machine.go14
1 files changed, 13 insertions, 1 deletions
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 {