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

@ -3,18 +3,18 @@
Netwall is playable and pushed: solo (desktop + phone), two-player co-op through the Node server, music, PWA, deploy docs.
Development was paused on purpose before the fix stage. This file is the entry point for the next session.
## State of the repo
## State of the repo (2026-10-11)
| Area | State |
|---|---|
| `public/js/sim.js` | Shared rules. 20 unit tests. **Balance not tuned yet** (see `docs/BALANCE.md`). |
| `server/` | Done and reviewed by an independent adversarial pass (5 real issues found and fixed: pid leak/slot hijack, room-flood lockout, spoofable X-Forwarded-For, startup crash in restricted sandboxes, clock-step in rate limiter). 59 tests. |
| `public/` client | Works, but a second review pass found many issues. **None fixed yet.** See `docs/review-2026-10-09/findings.md`. |
| `e2e/` | `npm run e2e`: smoke, touch, end flow, co-op (two browsers incl. reconnect), 14-size layout matrix. All passed at the last run. |
| `tools/bot.js` | Headless balance bot (dev tool). Complete; its results are summarised in `docs/BALANCE.md`. |
| Deploy | `docs/DEPLOY.md`, `deploy/netwall.service`, README setup guide. Never run against a real nginx Proxy Manager or on a phone yet (an NPM-style review found doc inaccuracies, listed in the findings). |
| `public/js/sim.js` | Shared rules: 7 maps, 9 towers (Sandbox, Load Balancer, 4-level Orbital Uplink with escalating prices), 9 enemy kinds, Easy/Normal/Hard. **Balance tuned once** (Normal ~71% bot wins, see `docs/BALANCE.md`); remaining imbalances are listed there. |
| `server/` | Adversarially reviewed (pid leak, room flood, XFF, ...) and proxy-tested against real nginx with Proxy Manager's config. Co-op robustness fixed (stalls, half-open sockets, idempotent commands). |
| `public/` client | Phone-first layout (action bars, scrollable palette, pinned overlay footers), touch precision (nothing commits on pointerdown, nudge arrows), a11y/audio fixes, difficulty picker. Tested across 33 viewports incl. tablets and foldables (emulated). |
| `e2e/` | `npm run e2e`: 17 scenarios (smoke, touch, touch precision, select/sell, info-panel stability, UI states, a11y, audio, content gallery, co-op chaos, session UI, Uplink price, difficulty, 33-layout matrix ~8 min). Timing checks can flake on a loaded machine: rerun a scenario alone before concluding anything. |
| `tools/bot.js` | Headless defender bot (dev tool; deterministic). Does not build Sandbox / Load Balancer / Uplink. |
| Deploy | `docs/DEPLOY.md`, `deploy/netwall.service`, README setup guide; proxy behaviour verified against nginx 1.26 with Proxy Manager v2.16's rendered config (not the NPM app itself, not a real LXC). |
`npm test` = 91 passing. `npm run e2e` = 9 scenarios (22-layout matrix, touch precision, selection/sell, info-panel stability, UI states, co-op). Verified from a fresh `git clone` earlier (2026-10-09).
`npm test` = 156 passing.
## Fixed since this was written
@ -31,8 +31,8 @@ and a check that the layout holds on **tablets and foldables**.
|---|---|---|
| 1 | Phone panels/layout + touch precision, proxy/server doc fixes, QA | **done 2026-10-10** |
| 2 | Co-op robustness (stalled-render tower loss, half-open sockets, idempotent upgrade/wave, restart message), audio + keyboard + a11y | **done 2026-10-10** (QA passed) |
| 3 | New enemies (Daemon healer, Proxy shielded, Botnet swarm) and towers (Sandbox stun, Load Balancer buff), glyphs/shapes, gallery e2e; Orbital Uplink (4 levels, priced 1500 + 25% per owned, upgrades scale equally); 4 new maps | **done 2026-10-10** (QA passed) |
| 4 | Difficulty picker (Easy/Normal/Hard) + ONE time-boxed balance pass (IDS dominance, weak Mortar/Arc, credit snowball and boss rewards, new content) | drafted (`wave4d`) |
| 3 | New enemies (Daemon healer, Proxy shielded, Botnet swarm) and towers (Sandbox stun, Load Balancer buff), glyphs/shapes, gallery e2e; Orbital Uplink (4 levels, priced 1500 + 25% per owned, upgrades scale equally; ); 4 new maps | **done 2026-10-10** (QA passed) |
| 4 | Difficulty picker (Easy/Normal/Hard) + ONE time-boxed balance pass (IDS no longer sufficient, credit snowball tamed, Mortar/Arc/Filter buffed, flyers slower); Uplink price step set to 30% per owned | **done 2026-10-11** (QA passed) |
| 5 | Attack-vs-defend versus mode, bots for both sides | design in `docs/VERSUS.md`, workflow drafted |
| 6 | Server leaderboard (needs `StateDirectory=netwall` + `DATA_DIR`; solo scores are client-reported) and an opt-in public room list | after 5 |
| any | Fold/tablet real-device check; open items below | |