step 7.3: done

This commit is contained in:
bepis
2026-10-21 07:16:18 +11:00
parent 3991295395
commit 944a2e69d4
7 changed files with 201 additions and 28 deletions
+17 -20
View File
@@ -4,9 +4,8 @@
> If this file disagrees with the code, trust the code and fix this file.
## 1. Where we are
- **Last completed step:** 7.2 (Expedition API: start, active, claim endpoints) — TICKED in STATUS.md
- **Next step:** 7.3 — UI: start panel, progress bar, claim button.
*Acceptance:* start → close browser → return after duration → claim → rewards granted exactly once.
- **Last completed step:** 7.3 (Expedition UI: start panel, progress bar, claim button) — TICKED in STATUS.md
- **Next step:** 8.1 — Leaderboard: `GET /api/leaderboard?type=level|gold|kills` top 50, with pagination param.
- **Updated:** 2026-10-21
- **Was the last session cut off mid-task?** No
@@ -15,13 +14,13 @@
|---|---|
| `npm install` | succeeds |
| `npm run migrate` | applies 001–006 / "nothing to do" |
| `npm test` | **151 passing, 0 failing** (85 unit + 66 integration) |
| `npm test` | **153 passing, 0 failing** (85 unit + 68 integration) |
## 3. What exists now (files that matter)
- `src/db/migrations/005_expeditions.sql` — `expedition_defs` + `expeditions` tables, unique active-expedition index, 3 seed definitions.
- `src/services/expeditionService.js` — NEW: `startExpedition`, `getActive`, `claimExpedition`. Uses WeakMap stmt cache.
- `src/routes/expeditions.js` — NEW: `POST /api/expeditions/start`, `GET /api/expeditions/active`, `POST /api/expeditions/claim`.
- `src/game/energy.js` — Modified: `computeEnergy` now uses `now()` from utils/time (for test time override compatibility).
- `src/services/expeditionService.js` — `startExpedition`, `getActive`, `claimExpedition`, `listDefinitions`. Uses WeakMap stmt cache.
- `src/routes/expeditions.js` — `POST /api/expeditions/start`, `GET /api/expeditions/active`, `POST /api/expeditions/claim`, `GET /api/expeditions/defs`.
- `src/game/energy.js` — `computeEnergy` now uses `now()` from utils/time.
- `src/services/characterService.js` — `createCharacter`, `getCharacterProfile`, `getCharacterIdForUser`.
- `src/services/huntService.js` — `hunt(characterId, zoneId, {rng, now})`; ONE transaction; test-injectable.
- `src/services/inventoryService.js` — `listInventory`, `equipItem`, `unequipItem`, `useConsumable`. Uses WeakMap stmt cache.
@@ -31,18 +30,16 @@
- `src/utils/time.js` — `now()/setNow()/resetNow()`; never call `Date.now()` in services.
- `src/routes/zones.js` — `GET /api/zones`.
- `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/004_inventory.sql` — inventory table, FK constraints, partial unique index for equipped slots.
- `tests/integration/expeditions.test.js` — NEW: 11 integration tests.
- `public/game.html` — dashboard with stats panel, tabbed action panel (Hunt/Inventory/Expedition).
- `public/js/game.js` — full hunt UI + inventory UI + expedition UI (start panel, progress bar, claim button, auto-refresh).
- `public/css/main.css` — expedition UI styles (cards, progress bar, buttons).
- `public/shop.html` — dedicated shop page with buy/sell tabs.
- `tests/integration/expeditions.test.js` — 13 integration tests.
- `tests/integration/shop.test.js` — 16 integration tests.
- `tests/integration/shop-page.test.js` — 5 integration tests.
- `tests/integration/inventory.test.js` — 20 integration tests.
- `public/shop.html` — dedicated shop page with buy/sell tabs.
- `public/game.html` — dashboard with stats panel, tabbed action panel (Hunt/Inventory).
- `public/js/game.js` — full hunt UI + inventory UI.
## 4. Half-finished / fragile things
- No expedition UI yet (step 7.3).
- No leaderboard UI yet (Phase 8).
- HP never regenerates naturally; only level-up restores it.
- No restart-persistence test for sessions.
@@ -72,12 +69,12 @@
- Error responses from route-level `AppError`s do NOT include `data` field.
- `setNow` affects ALL `now()` calls including those in service logic — for tests that need to verify time-based behavior, manipulate the DB directly instead.
## 7. Next-step briefing (7.3)
- **Goal:** Expedition UI — start panel, progress bar, claim button.
- **Docs:** GAME_DESIGN.md §Expeditions, UI_GUIDE.md.
- **Files to modify:** `public/game.html` (add expedition tab/panel), `public/js/game.js` (expedition UI logic).
- **APIs to use:** `GET /api/expeditions/active` (check for active expedition), `POST /api/expeditions/start { defId }` (start expedition), `POST /api/expeditions/claim { expeditionId }` (claim finished expedition).
- **UI elements:** expedition definitions list with level gating, energy cost display, progress bar with countdown, claim button when finished.
## 7. Next-step briefing (8.1)
- **Goal:** Leaderboard endpoint — `GET /api/leaderboard?type=level|gold|kills` top 50, with `?page=N` pagination.
- **Docs:** GAME_DESIGN.md §Leaderboards, DATABASE.
- **Files to create:** `src/services/leaderboardService.js`, `src/routes/leaderboard.js`.
- **Files to modify:** `src/app.js` (register route).
- **API:** `GET /api/leaderboard?type=level|gold|kills&page=1` — returns ranked list of heroes (name, level/gold/kills) with pagination metadata.
## 8. Open Known Issues
STATUS.md issues 1–6 (balance, dangling `seed` script, restart test, equipment-in-combat, HP regen, zone min_level balance).