Difficulty picker (Easy/Normal/Hard) and a balance pass

Difficulty:
- TD.DIFFICULTIES (starting credits, lives, enemy hp/shield, kill reward), validated
  create-room / newgame option, state carries it; solo menu picker and co-op lobby
  picker (44px segmented control, reachable on every layout), HUD/room/end-screen
  labels, best-wave record per map AND difficulty (Normal keeps the legacy key),
  Play again keeps the running game's difficulty for host and guest

Balance (12 bot runs, deterministic, 48/48 games replay identically in QA):
- Normal ~71% bot wins at wave 30 (was 94%), Easy 100%, Hard 25% on open
- credits tamed: reward growth 3% -> 2% per wave, clear bonus 10+2n -> 10+n, hp scaling
  eased, Rootkit pays 60 (was 100) but is tougher, flyers slower; unspent credits at
  wave 30: 1309 -> 335
- IDS Sniper is now a slow heavy hitter (essential, no longer sufficient: IDS-only
  dies by wave 7); Mortar, Arc and Filter buffed
- Orbital Uplink price step per owned unit 30% (buy and upgrade)
- remaining imbalances documented in docs/BALANCE.md

Tests: difficulty (19) and balance (8) unit suites, 14-difficulty e2e, layout matrix
reachability of the picker. 156 unit tests, 17 e2e scenarios.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
Claude 2026-10-10 23:41:21 +00:00
parent 28502984ec
commit b4ae6cb57d
19 changed files with 1348 additions and 156 deletions

View file

@ -32,7 +32,9 @@ module.exports = async function ({ browser, url: URL }) {
assert(g1 === 20000 - base, `the first Uplink was charged ${base}`);
t = await tile();
const second = await page.evaluate(() => TD.priceFor('uplink', NW.app.ctrl.view.towers));
assert(second > base * 1.2 && second < base * 1.3 && t.cost === String(second), `the tile now shows the second one at ${second} (about 25% dearer)`);
const growth = await page.evaluate(() => TD.TOWERS.uplink.priceGrowth);
assert(growth > 1.25 && growth <= 1.4, `each Uplink owned makes the next dearer by ${Math.round((growth - 1) * 100)}% (more than the old 25%, still slight)`);
assert(Math.abs(second - base * growth) <= 5 && t.cost === String(second), `the tile now shows the second one at ${second} (${Math.round((growth - 1) * 100)}% dearer)`);
assert((await page.locator('#info').innerText()).includes(String(second) + ' credits'), 'and so does the armed panel');
p = await pt(9, 5); await page.mouse.click(p.x, p.y); await sleep(250);
assert((await page.evaluate(() => NW.app.ctrl.view.gold)) === g1 - second, `the second one was charged ${second}`);
@ -46,7 +48,7 @@ module.exports = async function ({ browser, url: URL }) {
await page.keyboard.press('Escape');
p = await pt(9, 5); await page.mouse.click(p.x, p.y); await sleep(250);
const secondUp = await page.evaluate(() => { const t = NW.app.ctrl.view.towers.filter((x) => x.type === 'uplink')[1]; return TD.upgradePrice('uplink', t.level, t.pm); });
assert(secondUp > firstUp * 1.2 && (await upBtn()) === String(secondUp), `the second Uplink upgrades for ${secondUp} (the same 25% more)`);
assert(Math.abs(secondUp - firstUp * growth) <= 5 && (await upBtn()) === String(secondUp), `the second Uplink upgrades for ${secondUp} (the same ${Math.round((growth - 1) * 100)}% more)`);
await page.keyboard.press('Escape');
p = await pt(9, 5); await page.mouse.click(p.x, p.y); await sleep(200);