fix: canEquipInSlot uses instance ID as type ID — two-handed weapon check broken #30
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: Major
File:
src/lib/game/crafting-utils.ts(line 151)Problem: In
canEquipInSlot, the offhand two-handed check does:But
currentlyEquipped.mainHandis an instance ID (e.g.,'equip_1234567890_abc'), not a type ID.EQUIPMENT_TYPESis keyed by type ID, so this lookup always returnsundefined, meaning the two-handed weapon restriction in the offhand slot is silently broken.Impact: Players can equip any item in the offhand slot even when holding a two-handed weapon in main hand. The two-handed weapon validation is non-functional.
Fix: Look up the instance first, then get its type:
This requires passing
instancesas an additional parameter tocanEquipInSlot.Fixed: canEquipInSlot now accepts an optional
instancesparameter and looks up the main hand instance before getting its type. Updated call site in equipment-actions.ts to pass state.equipmentInstances.