Skip to content

Fix duplicate inventory removal when equipping items #3

Description

@keepithandy

Goal

Make equipment changes safe when the inventory contains multiple copies of the same item id.

Current behavior

equipItem(itemId) removes equipped items with a full inventory filter, which can remove every copy of that item id instead of only the selected copy.

Proposed work

  • Change equip behavior so equipping one item removes only one matching inventory entry.
  • Preserve the existing behavior where the previously equipped item returns to inventory.
  • Keep item ids stable and keep the inventory format as an array of item ids.
  • Add or update smoke coverage for duplicate inventory entries.

Acceptance checks

  • If inventory contains two copies of the same item, equipping one leaves the other copy in inventory.
  • Replacing equipped gear still returns the previous item to inventory.
  • Selling behavior remains unchanged.
  • node smoke_depth_engine_core.mjs passes.
  • node smoke_rat_cellar_content.mjs passes.

Guardrails

This is a focused inventory correctness fix. Do not rewrite the inventory model or introduce item instances in this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingengine

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions