step 10.15: done
This commit is contained in:
@@ -53,4 +53,10 @@ Format:
|
||||
## D-007: `src/utils/time.js` is the only clock
|
||||
- Decision: Services call `time.now()`; tests use `time.setNow()`. Game functions take `nowMs`/`rng` as parameters.
|
||||
|
||||
## D-023: Shared grantItem for inventory item granting
|
||||
- Date: 2026-10-23
|
||||
- Context: `huntService` and `shopService` both need to grant items to inventory. `huntService` had a local `grantItem` that correctly creates one row per unit for non-stackable items, but `shopService` duplicated the logic incorrectly (inserted full quantity for non-stackables).
|
||||
- Decision: Extract `grantItem(s, characterId, item, quantity, now)` to `src/game/inventory.js`. Both services import it. The service's stmtCache must include `stackRow`, `addToStack`, `insertInv` with the exact same SQL used by huntService.
|
||||
- Consequences: Single source of truth for item-granting logic. Any future service that grants items (expeditions, quests, etc.) can reuse it.
|
||||
|
||||
<!-- Add D-008 onward below -->
|
||||
|
||||
Reference in New Issue
Block a user