diff --git a/HANDOFF.md b/HANDOFF.md index 3bdd515..62a107c 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -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:** 10.16 — Leaderboard made public (removed `requireAuth`); hero profile was already public -- **Next step:** Phase 10.17 — Build `public/leaderboard.html` + `public/js/leaderboard.js`: tabs Level/Gold/Kills, rank, hero name (link to profile.html?name=...), class, value; `textContent` only. Add nav links (Game, Shop, Leaderboard, Logout) to header of every logged-in page. Remove temporary link-checker exception from 10.5. +- **Last completed step:** 10.17 — Leaderboard UI built (`leaderboard.html` + `leaderboard.js`), nav links (Game, Shop, Leaderboard, Logout) added to all logged-in pages (game.html, shop.html, create-hero.html, leaderboard.html) +- **Next step:** Phase 10.18 — (next) - **Updated:** 2026-10-23 - **Was the last session cut off mid-task?** No @@ -14,18 +14,20 @@ |---|---| | `npm install` | succeeds | | `npm run migrate` | applies 001–007 / "nothing to do" | -| `npm test` | **273 passing, 0 failing** (97 unit + 176 integration incl. 9 public leaderboard/profile tests) | +| `npm test` | **284 passing, 0 failing** (97 unit + 187 integration incl. 11 step-10.17 tests) | | `npm run seed:dev` | creates demo user "demo"/"demo123", hero "Aldric" (warrior), starter gear | | `npm start` + `curl localhost:3000/` | 200 HTML landing page | +| `curl localhost:3000/leaderboard.html` | 200 HTML (leaderboard page) | | `curl localhost:3000/api/leaderboard?type=level` | 200 JSON (no auth required) | ## 3. What exists now (files that matter) -- `src/app.js` — leaderboard route no longer has `requireAuth` (public) -- `tests/integration/step-10.16.test.js` — NEW: 9 tests for public leaderboard + hero profile -- `tests/integration/leaderboard.test.js` — updated "rejects request without authentication" → "is accessible without authentication" +- `public/leaderboard.html` — real leaderboard page with Level/Gold/Kills tabs, table, pagination +- `public/js/leaderboard.js` — fetches API, renders entries with profile links, uses createElement/textContent only +- `public/css/main.css` — nav-links styles added to header +- `public/game.html`, `shop.html`, `create-hero.html`, `leaderboard.html` — all have nav links (Game, Shop, Leaderboard, Logout) +- `tests/integration/step-10.17.test.js` — 11 tests (nav links, page structure, code quality, API integration) ## 4. Half-finished / fragile things -- No leaderboard UI yet (stub page exists; real UI in 10.17). - No restart-persistence test for sessions. - `npm run seed` script in package.json points to nonexistent `scripts/seed.js`. - `GET /api/zones` documented in API.md but not implemented. @@ -88,8 +90,11 @@ - **10.14:** `deleteRowExact` needed for CHECK constraint `quantity >= 1` — when selling exhausts a row, delete by matching quantity instead of decrementing to 0. - **10.15:** When extracting shared `grantItem`, the calling service's stmtCache MUST include `stackRow`, `addToStack`, `insertInv` with the exact same SQL as huntService — otherwise `grantItem` gets `undefined` statements. - **10.16:** Leaderboard returns `{ ok: true, data: { entries: [...], pagination: {...} } }`. +- **10.17:** Test for `innerHTML` must also check comments — the word `innerHTML` in a comment will fail the test. +- **10.17:** Hero names in the leaderboard are rendered dynamically by JS, so tests should check the JS code pattern (not static HTML) for profile link generation. ## 7. Next-step briefing -- **Next step: 10.17** — Build `public/leaderboard.html` + `public/js/leaderboard.js`: tabs Level/Gold/Kills, rank, hero name (linking to `profile.html?name=...`), class, value; `textContent` only. Add nav links (Game, Shop, Leaderboard, Logout) to the header of every logged-in page. Remove any temporary link-checker exception from 10.5. -- The leaderboard API (`GET /api/leaderboard?type=level|gold|kills&page=1`) is already public and returns `{ entries: [{rank, name, class, level, xp, kills, gold}], pagination: {page, limit, total, totalPages} }`. -- The link-checker test currently has no exceptions (10.5 stub page was already created), so adding the real leaderboard page should make it pass naturally. +- **Next step: 10.18** — (pending) +- The leaderboard page is fully functional with tabs, pagination, and profile links. +- All logged-in pages now have consistent navigation (Game, Shop, Leaderboard, Logout). +- The link-checker test passes with no exceptions. diff --git a/STATUS.md b/STATUS.md index bf501e8..f8bb0e7 100644 --- a/STATUS.md +++ b/STATUS.md @@ -8,9 +8,9 @@ ## Current Focus - **Phase:** 10 -- **Step:** 10.17 — (next) +- **Step:** 10.18 — (next) - **Blocked?** No -- **Last verified working command:** `npm test` — 273/273 passing (97 unit + 176 integration incl. 9 public leaderboard/profile tests), 2026-10-23 step 10.16 +- **Last verified working command:** `npm test` — 284/284 passing (97 unit + 187 integration incl. 11 step-10.17 tests), 2026-10-23 step 10.17 ## Project Health | Item | State | @@ -180,6 +180,9 @@ - [x] **10.13** Starter kit (GAME_DESIGN §Items): `createCharacter` grants, in the same transaction, one class-appropriate common weapon (warrior Rusty Sword, mage Apprentice Staff, ranger Hunter's Shortbow) already equipped in the weapon slot, plus 2 Minor Healing Potions. *Acceptance:* tests per class: inventory has exactly the weapon (equipped) and 2 potions (one stack row, quantity 2); derived attack includes the weapon. *Verified:* 4 new integration tests (warrior/mage/ranger starter kit + duplicate-name rejection); `STARTER_WEAPONS` map in `characterService.js`; `grantKit` transaction inserts equipped weapon + 2 potions; `grantItem` helpers in inventory/shop tests updated to stack with existing rows; 10+ existing tests updated to account for starter kit baseline; 253/253 tests pass. +- [x] **10.17** Build `public/leaderboard.html` + `public/js/leaderboard.js`: tabs Level/Gold/Kills, rank, hero name (link to profile.html?name=...), class, value; `textContent` only. Add nav links (Game, Shop, Leaderboard, Logout) to header of every logged-in page. Remove temporary link-checker exception from 10.5. + *Acceptance:* leaderboard page loads, tabs switch, entries render with profile links; nav links on game.html, shop.html, create-hero.html, leaderboard.html; link-checker passes. + *Verified:* 11 integration tests (4 nav-link checks, 3 page-structure, 1 code-quality, 3 API integration); `leaderboard.html` with tabs/table/pagination; `leaderboard.js` uses createElement + textContent only, no innerHTML; nav-links CSS added to main.css; nav links added to game.html, shop.html, create-hero.html, leaderboard.html; 284/284 tests pass. ### E. Economy - [x] **10.14** Fix material sell prices. The code uses `defaultRate * heroLevel / itemMinLevel`; BALANCE.md says price depends on the ITEM's level: common `2 × min_level`, uncommon `4 × min_level`, rare `8 × min_level` (epic `16×`, legendary `32×`; log this extension in DECISIONS.md), minimum 1. Note BALANCE.md's table says Drake Scale sells for 90g but its formula gives 112g: follow the formula and correct the table. Use ONE function (`materialSellPrice` in `src/game/rewards.js`) for the shop list AND for selling. *Acceptance:* tests: Rat Tail sells for 2g at hero level 1, 10 and 50; Drake Scale (rare, level 14) sells for 112g at any hero level; shop-listed price equals the amount actually paid. diff --git a/public/create-hero.html b/public/create-hero.html index 521fafd..c929560 100644 --- a/public/create-hero.html +++ b/public/create-hero.html @@ -10,6 +10,12 @@