feat(inventory): implement v2 data structure and JSDoc types (Epic 7.1)

Create structured inventory system with categorized storage:
- Add JSDoc type definitions (InventoryV2, InventoryV1, MigrationResult)
- Implement migration utility for v1 → v2 conversion
- Update state.js with v2 inventory structure and feature flag
- Update config.js to match new inventory defaults

Changes:
- NEW: src/types/inventory.js (30 lines) - Type definitions
- NEW: src/utils/migration.js (84 lines) - Migration logic
- MODIFIED: src/core/state.js - v2 inventory + FEATURE_FLAGS
- MODIFIED: src/core/config.js - v2 inventory defaults

Inventory v2 structure:
{
  version: 2,
  onPerson: "Sword, 3x Potions",     // Plaintext string
  stored: {
    "Home": "Clothes, Tools",         // Location → items
    "Bank": "Gold, Documents"
  },
  assets: "Motorcycle, House"         // Plaintext string
}

Migration handles all edge cases:
- v1 string → v2.onPerson
- null/undefined → v2 defaults
- "None" → v2 defaults
- Already v2 → no changes

Context overhead: +40 chars (~5% increase) for organized multi-location storage

Part of Epic 7: New Inventory System
Implements: docs/IMPLEMENTATION_PLAN.md Epic 7.1
This commit is contained in:
Lucas 'Paperboy' Rose-Winters
2025-10-17 14:58:07 +11:00
parent 658b911d12
commit 110bdb3b64
4 changed files with 141 additions and 2 deletions
+30
View File
@@ -0,0 +1,30 @@
/**
* Inventory Type Definitions
* JSDoc types for RPG Companion inventory system v2
*/
/**
* Version 2 inventory structure with categorized storage
* @typedef {Object} InventoryV2
* @property {number} version - Schema version (always 2)
* @property {string} onPerson - Items currently carried/worn by the character (plaintext list)
* @property {Object.<string, string>} stored - Items stored at named locations (location name → plaintext list)
* @property {string} assets - Character's vehicles, property, and major possessions (plaintext list)
*/
/**
* Version 1 inventory structure (legacy string format)
* Simple plaintext string like "Sword, Shield, 3x Potions"
* @typedef {string} InventoryV1
*/
/**
* Result of inventory migration operation
* @typedef {Object} MigrationResult
* @property {InventoryV2} inventory - The migrated inventory data in v2 format
* @property {boolean} migrated - Whether migration was performed (true if v1→v2, false if already v2)
* @property {string} source - Source version ('v1', 'v2', 'null', 'default')
*/
// Export types for JSDoc consumption (this file has no runtime exports)
export {};