aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_remove.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-06 12:57:23 -0400
committerhistoria <[not public]>2026-10-06 12:57:23 -0400
commit9666676766bf21364f4fc4d0d1d336e72f2a91b4 (patch)
tree0cade34091d7602790dc38cd44053f0b74bbadf2 /internal/game/cmd_remove.go
parent4bc1daaf259e0c19c5fe4a12ec8bc7f6e5a735c1 (diff)
downloadthehouseoficarus-9666676766bf21364f4fc4d0d1d336e72f2a91b4.tar.gz
refactor: split casino.go, dedup helpers, remove audit docs
Diffstat (limited to 'internal/game/cmd_remove.go')
-rw-r--r--internal/game/cmd_remove.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/internal/game/cmd_remove.go b/internal/game/cmd_remove.go
index d03daec..8ea21a9 100644
--- a/internal/game/cmd_remove.go
+++ b/internal/game/cmd_remove.go
@@ -150,7 +150,21 @@ func (g *Game) doRemoveAll(sess *net.Session) {
return
}
- needed := len(p.Equipment)
+ // Ammo routes through removeAllAmmo, which merges into an existing
+ // matching-quality stack and therefore needs no fresh slot. Count only the
+ // entries that will actually consume a slot so a mergeable ammo stack does
+ // not make the pre-gate report a false "no room".
+ needed := 0
+ for _, slot := range EquipSlots {
+ itemID, ok := p.Equipment[slot]
+ if !ok {
+ continue
+ }
+ if slot == item.SlotAmmo && p.AmmoQty > 0 && g.ammoHasMergeableStack(p, itemID) {
+ continue
+ }
+ needed++
+ }
if needed > p.FreeSlots() {
sess.WriteLine("You don't have room to remove everything!")
return
@@ -232,3 +246,17 @@ func (g *Game) removeAllAmmo(sess *net.Session, p *player.Player, itemID string)
}
sess.WriteLine(fmt.Sprintf("You remove %s.", g.itemColorize(sess, def, name)))
}
+
+// ammoHasMergeableStack reports whether removeAllAmmo will merge the equipped
+// ammo stack into an existing inventory stack with the same freshly-picked
+// properties (see pickedStackProps), which consumes no free slot.
+func (g *Game) ammoHasMergeableStack(p *player.Player, itemID string) bool {
+ quality, maxQuality := g.pickedStackProps(itemID)
+ for i := 0; i < player.MaxInventorySlots; i++ {
+ s := p.InvSlot(i)
+ if s != nil && s.ItemID == itemID && s.Quality == quality && s.MaxQuality == maxQuality {
+ return true
+ }
+ }
+ return false
+}