From 0f812ccc307ea0550511ccced40b65dfb0cdaa91 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 18 Sep 2026 20:11:29 -0400 Subject: fix: world and casino integrity fixes --- internal/casino/credits.go | 6 +++++- internal/casino/manager.go | 6 +++--- internal/casino/money_regression_test.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'internal/casino') diff --git a/internal/casino/credits.go b/internal/casino/credits.go index 631a4bc..19364da 100644 --- a/internal/casino/credits.go +++ b/internal/casino/credits.go @@ -76,6 +76,10 @@ func walletErrorMessage(err error, context ...string) string { // payoutFailedMessage explains a settlement the wallet could not persist: // the journal record for the payout stays open, so startup recovery will // re-apply the owed amount. Games must NOT announce such a payout as paid. +// payoutFailedMessage explains a settlement the wallet could not apply right +// now. This covers both a persistence failure and a credit-cap block (the +// journal record stays open either way), so it must not assert a persistence +// failure as the cause. Recovery re-applies the owed amount. func payoutFailedMessage() string { - return "The house could not process your payout (persistence failure). Your settlement is recorded and will be restored when you return." + return "The house could not process your payout right now. Your settlement is recorded and will be restored when you return." } diff --git a/internal/casino/manager.go b/internal/casino/manager.go index b71e5df..d9b2c3e 100644 --- a/internal/casino/manager.go +++ b/internal/casino/manager.go @@ -75,9 +75,9 @@ func (m *Manager) EnsureMachine(roomID int, cfg MachineConfig) *Machine { m.mu.Lock() defer m.mu.Unlock() if machine := m.machines[key]; machine != nil { - // DeepEqual (not ==) so the *bool rule fields compare by value; - // == would treat every freshly parsed config as different and - // discard an idle machine on every room load. + // DeepEqual (not ==) compares the config by value and stays correct + // as rule structs gain pointer/slice fields; == would panic or, for + // a struct with incomparable fields, fail to compile. if reflect.DeepEqual(machine.Config, cfg) { return machine } diff --git a/internal/casino/money_regression_test.go b/internal/casino/money_regression_test.go index 31cd0e6..bb8263e 100644 --- a/internal/casino/money_regression_test.go +++ b/internal/casino/money_regression_test.go @@ -129,7 +129,7 @@ func TestBlackjackFailedPayoutNotAnnouncedAsPaid(t *testing.T) { if strings.Contains(e.PrivateMessage, "You win! +") { t.Fatalf("announced a successful payout after the wallet rejected it: %q", e.PrivateMessage) } - if strings.Contains(e.PrivateMessage, "persistence failure") { + if strings.Contains(e.PrivateMessage, "could not process your payout") { return // the failure was explained to the player } } -- cgit v1.2.3