diff options
| author | historia <[not public]> | 2026-09-18 21:50:17 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 21:50:17 -0400 |
| commit | 2c38386484cdb507c4687caceb37e0b963e33594 (patch) | |
| tree | b25ecf9f509a48d8126f5a4b3a0482de42676239 /internal/casino/machine.go | |
| parent | e7848ea79a9a57fdf391d30c48ce649f3d2f6180 (diff) | |
| download | thehouseoficarus-2c38386484cdb507c4687caceb37e0b963e33594.tar.gz | |
fix: make slot payout and stake resolution one durable save
Diffstat (limited to 'internal/casino/machine.go')
| -rw-r--r-- | internal/casino/machine.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/internal/casino/machine.go b/internal/casino/machine.go index 5c73b6f..97b846d 100644 --- a/internal/casino/machine.go +++ b/internal/casino/machine.go @@ -277,7 +277,9 @@ func (m *Machine) finishSpin() []Event { payFailed := false if payNow > 0 && m.player.Wallet != nil { - if err := m.player.Wallet.PayCredits(payNow); err != nil { + // Credit the payout and consume the triggering stake in ONE save: a + // crash can then never pay the win AND refund the same stake. + if err := m.player.Wallet.PayCredits(payNow, m.stakeID); err != nil { // The payout could not be made durable. Do not announce the win as // paid, stop any autobet chain, and keep the stake PENDING // (stakeFailed): the settlement was never durable, so the stake is @@ -334,10 +336,9 @@ func (m *Machine) finishSpin() []Event { } else { m.inFreeSpins = false if !payFailed && m.player.Wallet != nil { - // The paid round fully resolved (the feature either never - // started or just completed; free spins wager nothing): consume - // ONLY this round's stake, leaving an older failed-payout stake - // pending. + // A win already consumed this round's stake inside PayCredits; a + // loss (payNow == 0) has not, so consume it here. Either way the + // round is over and the stake must not be refunded. m.player.Wallet.ResolveStake(m.stakeID) m.stakeID = "" m.stakeFailed = false |
