diff options
Diffstat (limited to 'internal/casino/pai_gow.go')
| -rw-r--r-- | internal/casino/pai_gow.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/internal/casino/pai_gow.go b/internal/casino/pai_gow.go index 55dc601..8a7ddf3 100644 --- a/internal/casino/pai_gow.go +++ b/internal/casino/pai_gow.go @@ -88,6 +88,7 @@ type paiGowTable struct { dealer []card dealerSplit pgSplit tie [2]card + settleTried bool // guards against re-saving/re-messaging every tick while settling } func newPaiGowTable(room int, c TableConfig, rng *rand.Rand) tableGame { @@ -601,6 +602,7 @@ func (t *paiGowTable) action(name, action string) []Event { } func (t *paiGowTable) prepareSettlementLocked() []Event { t.phase = phaseSettling + t.settleTried = false for _, p := range t.players { if p.main.Total == 0 { continue @@ -742,6 +744,13 @@ func (t *paiGowTable) tick() []Event { defer t.mu.Unlock() switch t.phase { case phaseSettling: + // Try to settle once automatically. If storage is persistently failing, + // do not re-attempt the full save (and failure message) every tick; the + // explicit `settle` command retries instead. + if t.settleTried { + return nil + } + t.settleTried = true return t.payLocked() case phaseBetting: if t.allBetLocked() { @@ -868,7 +877,7 @@ func (t *paiGowTable) refundSideBetsLocked(p *pgPlayer) []Event { } e := t.private(p.name, fmt.Sprintf("Your %d in side bets is returned; no main wager was placed.", total)) if p.wallet != nil { - if err := p.wallet.PayCredits(total, ids...); err != nil { + if err := p.wallet.RefundStakes(ids...); err != nil { e.Message = payoutFailedMessage() } } @@ -938,7 +947,7 @@ func (t *paiGowTable) unbetLocked(p *pgPlayer) []Event { return []Event{t.private(p.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(p.name, payoutFailedMessage())} } } |
