step 6.1: done
This commit is contained in:
+7
-7
@@ -4,8 +4,8 @@
|
|||||||
> If this file disagrees with the code, trust the code and fix this file.
|
> If this file disagrees with the code, trust the code and fix this file.
|
||||||
|
|
||||||
## 1. Where we are
|
## 1. Where we are
|
||||||
- **Last completed step:** 6.1 (Shop API: GET /api/shop, POST /api/shop/buy, POST /api/shop/sell)
|
- **Last completed step:** 6.1 (Shop API: GET /api/shop, POST /api/shop/buy, POST /api/shop/sell) — TICKED in STATUS.md
|
||||||
- **Next step:** 6.2 — Level-gated shop stock (filter by character level) + UI page
|
- **Next step:** 6.2 — Level-gated shop stock (ensure stock query properly filters by level) + UI shop page
|
||||||
- **Updated:** 2026-10-21
|
- **Updated:** 2026-10-21
|
||||||
- **Was the last session cut off mid-task?** No
|
- **Was the last session cut off mid-task?** No
|
||||||
|
|
||||||
@@ -24,15 +24,15 @@
|
|||||||
- `src/services/combatLogService.js` — `getCombatLog(characterId, limit)` → recent fights.
|
- `src/services/combatLogService.js` — `getCombatLog(characterId, limit)` → recent fights.
|
||||||
- `src/services/characterService.js` — `createCharacter`, `getCharacterProfile`, `getCharacterIdForUser`.
|
- `src/services/characterService.js` — `createCharacter`, `getCharacterProfile`, `getCharacterIdForUser`.
|
||||||
- `src/services/inventoryService.js` — `listInventory`, `equipItem`, `unequipItem`, `useConsumable`. Uses WeakMap stmt cache.
|
- `src/services/inventoryService.js` — `listInventory`, `equipItem`, `unequipItem`, `useConsumable`. Uses WeakMap stmt cache.
|
||||||
- `src/services/shopService.js` — **NEW**: `getStock`, `buyItem`, `sellItem`. Uses WeakMap stmt cache. Sell value = 40% of buy_price (materials use rarity default).
|
- `src/services/shopService.js` — `getStock`, `buyItem`, `sellItem`. Uses WeakMap stmt cache. Sell value = 40% of buy_price (materials use rarity default).
|
||||||
- `src/routes/shop.js` — **NEW**: `GET /api/shop`, `POST /api/shop/buy`, `POST /api/shop/sell`.
|
- `src/routes/shop.js` — `GET /api/shop`, `POST /api/shop/buy`, `POST /api/shop/sell`.
|
||||||
- `src/routes/inventory.js` — `GET /api/inventory`, `POST /api/inventory/equip`, `POST /api/inventory/unequip`, `POST /api/inventory/use`.
|
- `src/routes/inventory.js` — `GET /api/inventory`, `POST /api/inventory/equip`, `POST /api/inventory/unequip`, `POST /api/inventory/use`.
|
||||||
- `src/utils/time.js` — `now()/setNow()/resetNow()`; never call `Date.now()` in services.
|
- `src/utils/time.js` — `now()/setNow()/resetNow()`; never call `Date.now()` in services.
|
||||||
- `src/routes/zones.js` — `GET /api/zones`.
|
- `src/routes/zones.js` — `GET /api/zones`.
|
||||||
- `src/routes/combatLog.js` — `GET /api/combat-log`.
|
- `src/routes/combatLog.js` — `GET /api/combat-log`.
|
||||||
- `src/db/migrations/003_content.sql` — also SEEDS zones/monsters/items/loot (INSERT OR IGNORE).
|
- `src/db/migrations/003_content.sql` — also SEEDS zones/monsters/items/loot (INSERT OR IGNORE).
|
||||||
- `src/db/migrations/004_inventory.sql` — inventory table, FK constraints, partial unique index for equipped slots.
|
- `src/db/migrations/004_inventory.sql` — inventory table, FK constraints, partial unique index for equipped slots.
|
||||||
- `tests/integration/shop.test.js` — **NEW**: 14 integration tests (stock listing, level gating, buy, sell, error paths, round-trip spread).
|
- `tests/integration/shop.test.js` — 14 integration tests (stock listing, level gating, buy, sell, error paths, round-trip spread).
|
||||||
- `tests/integration/inventory.test.js` — 20 integration tests (13 equip/unequip + 7 consumable).
|
- `tests/integration/inventory.test.js` — 20 integration tests (13 equip/unequip + 7 consumable).
|
||||||
- `public/game.html` — dashboard with stats panel, tabbed action panel (Hunt/Inventory), equipment panel, inventory grid.
|
- `public/game.html` — dashboard with stats panel, tabbed action panel (Hunt/Inventory), equipment panel, inventory grid.
|
||||||
- `public/js/game.js` — full hunt UI + inventory UI.
|
- `public/js/game.js` — full hunt UI + inventory UI.
|
||||||
@@ -70,9 +70,9 @@
|
|||||||
- Error responses from route-level `AppError`s do NOT include `data` field — only `{ ok: false, error: { code, message } }`.
|
- Error responses from route-level `AppError`s do NOT include `data` field — only `{ ok: false, error: { code, message } }`.
|
||||||
|
|
||||||
## 7. Next-step briefing (6.2)
|
## 7. Next-step briefing (6.2)
|
||||||
- **Goal:** Level-gated shop stock (already partially done — `levelOk` flag exists; ensure stock query properly filters by level) + UI shop page.
|
- **Goal:** Level-gated shop stock (already partially done — `levelOk` flag exists and stock query filters by level; verify completeness) + UI shop page.
|
||||||
- **Docs:** GAME_DESIGN.md §Economy, API.md, UI_GUIDE.
|
- **Docs:** GAME_DESIGN.md §Economy, API.md, UI_GUIDE.
|
||||||
- **Files to create/modify:** `public/shop.html`, `public/js/shop.js`, verify shopService stock filtering.
|
- **Files to create/modify:** `public/shop.html`, `public/js/shop.js`, verify shopService stock filtering is complete.
|
||||||
- **Key rules:** Shop stock should only show items where character level >= item min_level. Materials always visible for selling.
|
- **Key rules:** Shop stock should only show items where character level >= item min_level. Materials always visible for selling.
|
||||||
|
|
||||||
## 8. Open Known Issues
|
## 8. Open Known Issues
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
- **Phase:** 6
|
- **Phase:** 6
|
||||||
- **Step:** 6.2
|
- **Step:** 6.2
|
||||||
- **Blocked?** No
|
- **Blocked?** No
|
||||||
- **Last verified working command:** `npm test` — 132/132 passing (99 unit + 33 integration), 2026-10-21 step 6.1
|
- **Last verified working command:** `npm test` — 132/132 passing (85 unit + 47 integration), 2026-10-21 step 6.1
|
||||||
|
|
||||||
## Project Health
|
## Project Health
|
||||||
| Item | State |
|
| Item | State |
|
||||||
@@ -83,7 +83,8 @@
|
|||||||
*Verified:* tab switching (Hunt/Inventory), equipment panel shows 3 slots with item names, rarity colors, stat bonuses, unequip button; inventory grid shows unequipped items with emoji icons, rarity badges, compact stats, quantity display, and hover tooltips showing full item details (name, type, stats/effect, level requirement).
|
*Verified:* tab switching (Hunt/Inventory), equipment panel shows 3 slots with item names, rarity colors, stat bonuses, unequip button; inventory grid shows unequipped items with emoji icons, rarity badges, compact stats, quantity display, and hover tooltips showing full item details (name, type, stats/effect, level requirement).
|
||||||
|
|
||||||
## Phase 6 — Shop & Economy (docs: GAME_DESIGN §Economy)
|
## Phase 6 — Shop & Economy (docs: GAME_DESIGN §Economy)
|
||||||
- [ ] **6.1** `GET /api/shop`, `POST /api/shop/buy`, `POST /api/shop/sell`. Sell value = 40% of base price. Gold can never go negative.
|
- [x] **6.1** `GET /api/shop`, `POST /api/shop/buy`, `POST /api/shop/sell`. Sell value = 40% of base price. Gold can never go negative.
|
||||||
|
*Acceptance:* shop endpoints return stock, buy deducts gold, sell adds gold at 40%, gold never goes negative. *Verified:* 14 integration tests covering stock listing, level gating, buy/sell, gold math, error paths, round-trip spread.
|
||||||
- [ ] **6.2** Level-gated shop stock. UI page.
|
- [ ] **6.2** Level-gated shop stock. UI page.
|
||||||
- [ ] **6.3** Tests: buy with insufficient gold, sell equipped item (must be rejected), concurrent double-buy safety (transaction).
|
- [ ] **6.3** Tests: buy with insufficient gold, sell equipped item (must be rejected), concurrent double-buy safety (transaction).
|
||||||
|
|
||||||
@@ -150,6 +151,7 @@ Severity: `blocker` / `major` / `minor` / `cosmetic`. Status: `open` / `fixing`
|
|||||||
|
|
||||||
## Session Log
|
## Session Log
|
||||||
_Format:_ `YYYY-MM-DD | step | what changed | result`
|
_Format:_ `YYYY-MM-DD | step | what changed | result`
|
||||||
|
- 2026-10-21 | 6.1 | Ticked step 6.1 — acceptance criteria verified: GET /api/shop, POST /api/shop/buy, POST /api/shop/sell all implemented with 40% sell value and gold-negative protection; 14 integration tests all passing | 132/132 tests pass
|
||||||
- 2026-10-21 | 6.1 | Created `src/services/shopService.js` (getStock, buyItem, sellItem) + `src/routes/shop.js` (GET /api/shop, POST /api/shop/buy, POST /api/shop/sell); registered routes in app.js; 14 integration tests covering stock listing, level gating, buy/sell, gold math, error paths, round-trip spread | 132/132 tests pass
|
- 2026-10-21 | 6.1 | Created `src/services/shopService.js` (getStock, buyItem, sellItem) + `src/routes/shop.js` (GET /api/shop, POST /api/shop/buy, POST /api/shop/sell); registered routes in app.js; 14 integration tests covering stock listing, level gating, buy/sell, gold math, error paths, round-trip spread | 132/132 tests pass
|
||||||
- 2026-10-20 | 5.4 | Added inventory UI: tab switching (Hunt/Inventory), equipment panel (3 slots with item names, rarity colors, stat bonuses, unequip button), inventory grid (unequipped items with emoji icons, rarity badges, compact stats, quantity, hover tooltips with full details), click-to-equip/use handlers | 118/118 tests pass
|
- 2026-10-20 | 5.4 | Added inventory UI: tab switching (Hunt/Inventory), equipment panel (3 slots with item names, rarity colors, stat bonuses, unequip button), inventory grid (unequipped items with emoji icons, rarity badges, compact stats, quantity, hover tooltips with full details), click-to-equip/use handlers | 118/118 tests pass
|
||||||
- 2026-10-20 | 5.3 | Added `useConsumable()` to inventoryService (heal/energy effects, qty decrement, row removal at 0) + `POST /api/inventory/use` route; 7 integration tests covering heal, energy, cap, non-consumable rejection, missing item, qty-0 removal | 118/118 tests pass
|
- 2026-10-20 | 5.3 | Added `useConsumable()` to inventoryService (heal/energy effects, qty decrement, row removal at 0) + `POST /api/inventory/use` route; 7 integration tests covering heal, energy, cap, non-consumable rejection, missing item, qty-0 removal | 118/118 tests pass
|
||||||
|
|||||||
Reference in New Issue
Block a user