diff --git a/specs/Inventory.spec.md b/specs/Inventory.spec.md index a83e4f6..7e94cb5 100644 --- a/specs/Inventory.spec.md +++ b/specs/Inventory.spec.md @@ -154,3 +154,37 @@ function finalizeRun(runInventory, hubInventory) { - Saving the game must serialize the `InventoryStorage` array correctly. - Loading the game must restore specific item instances (not just generic definitions). + +--- + +## **6. Integration Strategy (Wiring)** + +This section defines where the Inventory System connects to the rest of the engine. + +### **A. Game Loop (Looting)** + +- **Trigger:** Player unit moves onto a tile with a Loot Chest / Item Drop. +- **Logic:** `GameLoop` detects collision -> calls `InventoryManager.runStash.addItem(foundItem)`. +- **Visual:** `VoxelManager` removes the chest model. UI shows "Item Acquired" toast. + +### **B. Character Sheet (Management)** + +- **Trigger:** Player opens Character Sheet -> Inventory Tab. +- **Logic:** The UI Component imports `InventoryManager`. +- **Display:** It renders `InventoryManager.runStash.items` (if in dungeon) or `hubStash.items` (if in hub). +- **Action:** Dragging an item to a slot calls `InventoryManager.equipItem(activeUnit, itemUid, slot)`. + +### **C. Combat System (Consumables)** + +- **Trigger:** Player selects a "Potion" from the Combat HUD Action Bar. +- **Logic:** + 1. Check `unit.equipment.belt` for the item. + 2. Execute Effect (Heal). + 3. Call `InventoryManager.consumeItem(unit, slotIndex)`. + 4. Update Unit Inventory state. + +### **D. Persistence (Saving)** + +- **Trigger:** `GameStateManager.saveRun()` or `saveRoster()`. +- **Logic:** The `Explorer` class's `equipment` object and the `InventoryManager`'s `runStash` must be serialized to JSON. +- **Requirement:** Ensure `ItemInstance` objects are saved with their specific `uid` and `quantity`, not just `defId`.