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

@ -699,9 +699,10 @@ test('Load Balancer: cooldowns really elapse faster, so a boosted tower fires mo
a.s.tick(0.1); b.s.tick(0.1);
assert.ok(Math.abs(a.t.cd - 0.9) < 1e-9);
assert.ok(Math.abs(b.t.cd - (1 - 0.1 * (1 + TOWERS.balancer.levels[0].boost))) < 1e-9, 'cooldown ran 15% faster');
const shots = (x) => { tick(x.s, 40); return x.s.drainEvents().filter((e) => e.e === 'shot' && e.k === 'ids').length; };
const secs = 100;
const shots = (x) => { tick(x.s, secs); return x.s.drainEvents().filter((e) => e.e === 'shot' && e.k === 'ids').length; };
const na = shots(a), nb = shots(b);
assert.ok(na >= 25, 'baseline fires ~28 shots in 40 s: ' + na);
assert.ok(Math.abs(na - secs * TOWERS.ids.levels[0].rate) <= 3, 'an unboosted sniper fires about rate x seconds shots: ' + na);
assert.ok(nb > na * 1.1 && nb < na * 1.2, 'boosted ' + nb + ' vs ' + na);
});
@ -797,7 +798,7 @@ test('the new waves run end to end and the snapshot (incl. daemon, proxy, botnet
assert.equal(JSON.stringify(s.fullState()).includes('null'), false);
});
test('Orbital Uplink pricing: very expensive, and every one you own makes the next dearer', () => { // (25% per owned one, for buying and for upgrading)
test('Orbital Uplink pricing: very expensive, and every one you own makes the next dearer', () => { // (priceGrowth per owned one, for buying and for upgrading)
const base = TOWERS.uplink.levels[0].cost;
assert.ok(base >= 8 * TD.START_GOLD, 'the first Uplink costs many times the opening credits');
assert.ok(base >= 20 * TOWERS.ids.levels[0].cost, 'and a lot more than an IDS Sniper');
@ -806,7 +807,7 @@ test('Orbital Uplink pricing: very expensive, and every one you own makes the ne
assert.equal(TD.priceFor('uplink', [{ type: 'uplink' }, { type: 'filter' }, { type: 'uplink' }]), TD.priceFor('uplink', 2));
assert.equal(TD.priceFor('filter', 50), TOWERS.filter.levels[0].cost, 'a Packet Filter never gets dearer');
assert.equal(TD.priceFor('wall', [{ type: 'wall' }, { type: 'wall' }]), TOWERS.wall.levels[0].cost);
for (let n = 1; n < 6; n++) assert.ok(TD.priceFor('uplink', n) >= 1.2 * TD.priceFor('uplink', n - 1), 'each Uplink is about 25% dearer than the one before');
for (let n = 1; n < 6; n++) assert.ok(TD.priceFor('uplink', n) >= 1.2 * TD.priceFor('uplink', n - 1), 'each Uplink is about priceGrowth dearer than the one before');
const s = new Sim({ map: 'open', gold: 1e6 });
const ids = [];