step 9.4: done

This commit is contained in:
bepis
2026-10-21 10:35:29 +11:00
parent cf725b40a2
commit 0b89b8f685
5 changed files with 141 additions and 47 deletions
+26 -33
View File
@@ -4,8 +4,8 @@
> If this file disagrees with the code, trust the code and fix this file.
## 1. Where we are
- **Last completed step:** 9.3 (error pages, shared toast system, loading states) — TICKED in STATUS.md
- **Next step:** Phase 9 — 9.4 (Mobile-responsive pass per UI_GUIDE)
- **Last completed step:** 9.4 (Mobile-responsive pass) — TICKED in STATUS.md
- **Next step:** Phase 9 — 9.5 (Final full run of "Definition of playable" from NOTES.md §7)
- **Updated:** 2026-10-21
- **Was the last session cut off mid-task?** No
@@ -18,26 +18,23 @@
| `npm run seed:dev` | creates demo user "demo"/"demo123", hero "Aldric" (warrior), starter gear |
## 3. What exists now (files that matter)
- `public/404.html` — Custom 404 error page (branding: "Page Not Found", Emberfall theme).
- `public/500.html` — Custom 500 error page (branding: "Something went wrong", retry button).
- `public/js/toast.js` — Shared toast notification system (window.showToast, 3 types: error/info/success).
- `public/game.html` — Dashboard with stats panel, tabbed action panel (Hunt/Inventory/Expedition).
- `public/js/game.js` — hunt UI + inventory UI + expedition UI (uses shared toast.js).
- `public/shop.html` — Dedicated shop page.
- `public/js/shop.js` — buy/sell handlers (uses shared toast.js).
- `public/login.html`, `public/register.html`, `public/create-hero.html` — Auth & hero creation (all include toast.js).
- `public/profile.html` — Public hero profile page.
- `public/js/profile.js` — Fetches GET /api/heroes/:name, renders profile.
- `public/game.html` — Dashboard with 3-col grid (stats | action | combat), mobile bottom nav (⚔️ Hunt / 🏕️ Trip / 🎒 Items), tabbed action area.
- `public/js/game.js` — hunt UI + inventory UI + expedition UI + mobile nav init (DOMContentLoaded); uses shared toast.js.
- `public/css/main.css` — All styles including 3-col desktop grid, mobile bottom nav (< 700px), stacked panels on mobile, spinner, toast, button loading states.
- `public/404.html` — Custom 404 error page.
- `public/500.html` — Custom 500 error page.
- `public/js/toast.js` — Shared toast notification system.
- `public/shop.html` / `public/js/shop.js` — Shop page (buy/sell).
- `public/login.html`, `public/register.html`, `public/create-hero.html` — Auth & hero creation.
- `public/profile.html` / `public/js/profile.js` — Public hero profile page.
- `public/js/auth.js` — Shared API wrapper + showError.
- `public/css/main.css` — All styles including spinner, toast, button loading states, error page shared CSS.
- `scripts/seed-dev.js` — Creates demo account + hero + starter gear (idempotent, skips in production).
- `scripts/seed-dev.js` — Creates demo account + hero + starter gear.
- `src/app.js` — Express app with helmet, rate limiters, catch-all 404, 500 HTML serving.
- `src/services/*` — All game services (auth, character, hunt, inventory, shop, expedition, leaderboard, profile).
- `src/services/*` — All game services.
- `src/routes/*` — All route handlers.
- `src/game/*` — Pure game logic (combat, stats, energy, leveling, rewards).
- `tests/integration/error-pages.test.js` — 3 tests for 404/500 page serving.
- `tests/integration/*.test.js` — 90 integration tests across auth, combat, hunt, inventory, shop, expeditions, profile, leaderboard, error-pages.
- `tests/unit/*.test.js` — 85 unit tests for game logic.
- `src/game/*` — Pure game logic.
- `tests/integration/*.test.js` — 90 integration tests.
- `tests/unit/*.test.js` — 85 unit tests.
## 4. Half-finished / fragile things
- No leaderboard UI yet (Phase 8 API done but no UI).
@@ -45,21 +42,19 @@
- No restart-persistence test for sessions.
- `npm run seed` script in package.json points to nonexistent `scripts/seed.js`.
- Equipment bonuses not yet passed into combat (Issue #5 in STATUS.md).
- Starter gear (GAME_DESIGN.md §Items) documented but not auto-created on character creation.
- Starter gear documented but not auto-created on character creation.
- `GET /api/zones` documented in API.md but not implemented (Issue #2).
- Mobile nav uses emoji icons (⚔️ 🏕️ 🎒) — verify they render acceptably on all platforms.
## 5. Decisions & deviations from the docs
- D-004..D-007 in `docs/DECISIONS.md` (combat rounds, equipment counted once, session store, clock).
- **D-014:** Mobile bottom nav uses emoji icons (⚔️ Hunt / 🏕️ Trip / 🎒 Items) instead of full text labels to save horizontal space on narrow screens.
- **D-015:** Desktop tabs hidden via CSS (`display: none`) below 700px; mobile nav shown via CSS; JS `syncMobileNav()` keeps active state in sync.
- Zod query param parsing uses `zod.coerce.number()` because Express query params are strings.
- Inventory response uses `itemId` (item.id) and `inventoryId` (inventory row id) to avoid confusion.
- Consumable effect parsing: regex `^(heal|energy):(\d+)$` on items.effect field.
- Qty decrement avoids CHECK constraint violation: delete directly when qty==1, decrement when qty>1.
- **D-008:** Shop materials with buy_price=0 sell at `floor(default_rate * character_level / item_min_level)`.
- **D-009:** `sellItem` checks equipped_slot before material type.
- **D-010:** `startExpedition` checks active-expedition before energy.
- **D-011:** `computeEnergy` uses `now()` from utils/time.
- **D-012:** General `/api` rate limiter at 120 req/min per IP (SECURITY.md spec), 1000 in test mode.
- **D-013:** All `innerHTML` with dynamic data removed from game.js and profile.js — use createElement/textContent.
- D-008..D-013 from previous steps.
## 6. Gotchas learned
- `npm test` must be `node --test` with NO path/glob; files must be named `*.test.js`.
@@ -81,10 +76,8 @@
- Express `sendFile` rejects `../` path segments — use `path.resolve()` + `path.join()` for absolute paths.
- `express.static` sends its own 404 responses; catch-all must be placed BEFORE static middleware.
## 7. Next-step briefing (9.4)
- **Goal:** Mobile-responsive pass per UI_GUIDE (< 700px: single column, tabs become bottom nav).
- **Docs:** UI_GUIDE §game.html layout (Mobile section).
- Current CSS has some `@media (max-width: 600px)` rules but needs comprehensive mobile review.
- Should: verify all pages render correctly on mobile viewports.
- Should: tabs → bottom nav on mobile (per UI_GUIDE).
- Should NOT introduce new dependencies — use vanilla HTML/CSS/JS.
## 7. Next-step briefing (9.5)
- **Goal:** Final full run of "Definition of playable" from NOTES.md §7.
- Walk the complete flow: register → log in → create hero → see stats/energy → hunt → gain XP/gold/loot → level up → equip items → buy/sell in shop → start and claim expedition → see leaderboard → log out → log back in (verify persistence).
- Document any gaps or broken steps.
- No code changes expected unless a critical blocker is found.