From 68646f7f7b65932007d3324f45dbecd3ca6a4404 Mon Sep 17 00:00:00 2001 From: Matthew Mone Date: Sat, 27 Dec 2025 16:54:12 -0800 Subject: [PATCH] Add integration strategy for Inventory System in game engine Define connections between the Inventory System and other components, including Game Loop interactions for looting, character sheet management, combat system consumables, and persistence requirements for saving game state. Outline triggers, logic, display, and actions for each integration point to enhance overall gameplay experience. --- specs/Inventory.spec.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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`.