aboutsummaryrefslogtreecommitdiff
path: root/internal/game/act_effects.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-18 16:13:49 -0400
committerhistoria <[not public]>2026-09-18 16:13:49 -0400
commit194164a77eb4f2479b94c19e6f0e1278ab608781 (patch)
tree53413add8ed6f32a34d1733397e380cc98ef70ef /internal/game/act_effects.go
parent67e01aab85607b9e601185c7d62dff576af3bb43 (diff)
downloadthehouseoficarus-194164a77eb4f2479b94c19e6f0e1278ab608781.tar.gz
fix: more casino, economy, gameplay, security, and world data hardening gaps
Diffstat (limited to 'internal/game/act_effects.go')
-rw-r--r--internal/game/act_effects.go10
1 files changed, 8 insertions, 2 deletions
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)