From 194164a77eb4f2479b94c19e6f0e1278ab608781 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 18 Sep 2026 16:13:49 -0400 Subject: fix: more casino, economy, gameplay, security, and world data hardening gaps --- internal/game/act_effects.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'internal/game/act_effects.go') diff --git a/internal/game/act_effects.go b/internal/game/act_effects.go index a107320..e51deab 100644 --- a/internal/game/act_effects.go +++ b/internal/game/act_effects.go @@ -173,10 +173,16 @@ func (g *Game) applyStep(sess *net.Session, p *player.Player, step *behavior.Ste } // 10. credits (signed). A negative cost was preflighted for affordability, - // so the debit is unconditional here. + // so the debit is unconditional here. Clamp defensively anyway: a + // multi-step batch that shares one tick must never drive the balance + // negative, an invariant every wallet/economy path relies on. if step.Credits != 0 { if step.Credits < 0 { - p.Credits += step.Credits + debit := step.Credits + if p.Credits+debit < 0 { + debit = -p.Credits + } + p.Credits += debit g.saveCharacter(p) } else { g.grantCredits(p, step.Credits) -- cgit v1.2.3