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/cmd_shop.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'internal/game/cmd_shop.go') diff --git a/internal/game/cmd_shop.go b/internal/game/cmd_shop.go index f3211e0..e2209fc 100644 --- a/internal/game/cmd_shop.go +++ b/internal/game/cmd_shop.go @@ -345,10 +345,25 @@ func (g *Game) doShopSell(sess *net.Session, mob *world.MobInstance, input strin } stock := g.MobStore.ShopStockOf(mob.InstanceID, match.ID) + // Only sell as many as the balance headroom can pay for: grantCredits + // clamps at the economy cap, so selling past it would consume the items + // and destroy the excess credits (the pickup paths take only the headroom). + headroom := creditHeadroom(p) total := 0 + sellQty := 0 for k := 0; k < actualQty; k++ { - total += mob.Shop.SellPrice(value, stock+k) + price := mob.Shop.SellPrice(value, stock+k) + if total+price > headroom { + break + } + total += price + sellQty++ + } + if sellQty <= 0 { + sess.WriteLine("You can't carry any more credits.") + return } + actualQty = sellQty p.RemoveItem(match.ID, actualQty) g.grantCredits(p, total) -- cgit v1.2.3