step 10.13: done

This commit is contained in:
bepis
2026-10-23 05:16:35 +11:00
parent 4277b9c273
commit 32fb0eee9a
8 changed files with 290 additions and 78 deletions
+5 -3
View File
@@ -8,9 +8,9 @@
## Current Focus
- **Phase:** 10
- **Step:** 10.13 — Starter kit: createCharacter grants class-appropriate weapon + 2 Minor Healing Potions in same transaction
- **Step:** 10.14 — Material sell prices use item-level formula (BALANCE.md) instead of hero-level formula
- **Blocked?** No
- **Last verified working command:** `npm test` — 249/249 passing (97 unit + 152 integration incl. 4 equipment bonus tests), 2026-10-23 step 10.12
- **Last verified working command:** `npm test` — 253/253 passing (97 unit + 156 integration incl. 4 equipment bonus tests + 4 starter kit tests), 2026-10-23 step 10.13
## Project Health
| Item | State |
@@ -177,8 +177,9 @@
- [x] **10.12** Equipment must matter in combat. Create ONE `getEquipmentBonuses(characterId)` function (sum of `bonus_str/agi/int/vit/attack/defense` over equipped items) and use it in `huntService` (pass the totals to `resolveCombat` as `bonus_*`), in `getCharacterProfile` (derived stats), in potion max-HP capping, and in the shop/inventory stat previews. Delete the copy-pasted aggregation code in `shopService.js` and `inventoryService.js`.
*Acceptance:* deterministic tests with a constant rng: the first hero hit is exactly higher with an equipped weapon than without; `GET /api/character` `derived.attack` includes the weapon bonus; equipment `bonus_vit` raises max HP exactly once; grep shows only one aggregation implementation.
*Verified:* ONE `getEquipmentBonuses()` in `src/game/equipment.js` used by huntService (combat), characterService (profile + rest), inventoryService (potion capping), shopService (listInventory); duplicate aggregation removed from shopService.js; 4 integration tests (derived stats include bonuses, vit raises maxHp by 10, potion caps at equipment-inclusive maxHp, unequip removes bonuses); 249/249 tests pass.
- [ ] **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.
- [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.
### E. Economy
- [ ] **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.
@@ -285,3 +286,4 @@ _Format:_ `YYYY-MM-DD | step | what changed | result`
- 2026-10-21 | 9.2 | Created `scripts/seed-dev.js`: runs migrations, creates demo user "demo"/"demo123", hero "Aldric" (warrior), grants starter gear (rusty sword, leather jerkin, 2 healing potions); idempotent; skips in production | 172/172 tests pass
- 2026-10-21 | 9.3 | Added shared toast system (`public/js/toast.js`), 404/500 error pages (`public/404.html`, `public/500.html`), CSS loading spinner + button loading states, server-side catch-all 404 + 500 HTML serving; removed duplicate showToast from game.js/shop.js; 3 integration tests for error pages | 175/175 tests pass
- 2026-10-23 | 10.12 | Created ONE `getEquipmentBonuses()` in `src/game/equipment.js`; integrated into huntService (combat), characterService (profile + rest), inventoryService (potion capping), shopService (listInventory); removed duplicate aggregation from shopService.js; 4 integration tests | 249/249 tests pass
- 2026-10-23 | 10.13 | Starter kit: createCharacter grants class-appropriate weapon (equipped) + 2 Minor Healing Potions in same transaction; 10+ existing tests updated to account for starter kit baseline; grantItem helpers fixed to stack with existing rows | 253/253 tests pass