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

@ -133,6 +133,16 @@ module.exports = async function ({ browser, url: URL, out: OUT }) {
// main menu: primary buttons always reachable (with 8 maps in the picker)
await must(page, '#btnSolo', 'menu Play solo'); await must(page, '#btnCoop', 'menu Co-op');
// the difficulty picker: every segment on screen, uncovered and (on phones) a 44px target; a real tap picks one, a second tap puts it back
const diffIds = await page.evaluate(() => TD.DIFFICULTY_ORDER.slice());
check(diffIds.length >= 3, `the picker offers only ${diffIds.length} difficulties`);
for (const id of diffIds) await must(page, `#diffPick [data-diff="${id}"]`, `menu difficulty ${id}`);
const diffState = () => page.evaluate(() => [...document.querySelectorAll('#diffPick button')].filter((b) => b.getAttribute('aria-checked') === 'true').map((b) => b.dataset.diff).join());
check(await diffState() === 'normal', 'the difficulty picker does not start on normal');
await tapBtn(page, `#diffPick [data-diff="${diffIds[diffIds.length - 1]}"]`, 'menu difficulty (last)');
check(await diffState() === diffIds[diffIds.length - 1], `tapping the last difficulty did not pick it (${await diffState()})`);
await tapBtn(page, '#diffPick [data-diff="normal"]', 'menu difficulty normal');
check(await diffState() === 'normal', 'tapping normal did not pick it again');
await noOverflow(page, 'menu'); await allButtonsBigEnough(page, 'menu');
await page.screenshot({ path: `${OUT}matrix-${w}x${h}-${kind}-${nTowers}-menu.png` });
const p0 = await probe(page, '#btnSolo');
@ -273,6 +283,11 @@ module.exports = async function ({ browser, url: URL, out: OUT }) {
await page.goto(URL); await sleep(250);
await tapBtn(page, '#btnCoop', 'menu Co-op');
await must(page, '#btnCreate', 'lobby Create room'); await must(page, '#btnJoin', 'lobby Join'); await must(page, '#btnLobbyBack', 'lobby Back');
// the host picks the difficulty here: reachable at every size, and the room is created on it
const lobbyIds = await page.evaluate(() => TD.DIFFICULTY_ORDER.slice());
for (const id of lobbyIds) await must(page, `#lobbyDiff [data-diff="${id}"]`, `lobby difficulty ${id}`);
await tapBtn(page, `#lobbyDiff [data-diff="hard"]`, 'lobby difficulty hard');
check(await page.evaluate(() => [...document.querySelectorAll('#lobbyDiff button')].filter((b) => b.getAttribute('aria-checked') === 'true').map((b) => b.dataset.diff).join()) === 'hard', 'tapping Hard in the lobby did not pick it');
await noOverflow(page, 'lobby'); await allButtonsBigEnough(page, 'lobby');
await page.screenshot({ path: `${OUT}matrix-${w}x${h}-${kind}-${nTowers}-lobby.png` });
await tapBtn(page, '#btnCreate', 'lobby Create room');
@ -281,6 +296,7 @@ module.exports = async function ({ browser, url: URL, out: OUT }) {
if (!joined) fails.push('could not create a co-op room');
else {
await sleep(300);
check(await page.evaluate(() => NW.app.ctrl.view.difficulty) === 'hard', 'the room was not created on the difficulty picked in the lobby');
// a first-time co-op player gets the first-run help too (code-26): same rule as solo, it needs a visible "Got it"
check(await page.evaluate(() => !document.getElementById('help').hidden), 'co-op first run: help overlay did not open');
await must(page, '#btnHelpClose', 'co-op help Got it');