aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_wear.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/cmd_wear.go')
-rw-r--r--internal/game/cmd_wear.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/game/cmd_wear.go b/internal/game/cmd_wear.go
index cea4d67..a02fd3b 100644
--- a/internal/game/cmd_wear.go
+++ b/internal/game/cmd_wear.go
@@ -94,13 +94,14 @@ func (g *Game) doWear(sess *net.Session, input string) {
if slotOccupied {
freeSlot := p.FirstFreeSlot()
- if freeSlot == -1 && existingItemID != slot.ItemID {
+ // The equipped item must always be returned to the inventory before
+ // the new one is removed; with no free slot, refuse rather than
+ // silently destroy an identical equipped copy.
+ if freeSlot == -1 {
sess.WriteLine("Your inventory is full.")
return
}
- if freeSlot >= 0 {
- p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: existingItemID, Quantity: 1})
- }
+ p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: existingItemID, Quantity: 1})
}
if slot.Quantity > 1 {