From d1e127da67c1a47fd441999b4a0493035a5b6b07 Mon Sep 17 00:00:00 2001 From: jvanvik Date: Sat, 7 Nov 2026 10:26:06 +0100 Subject: [PATCH] Server-run play, part 1: game prerequisites and shared contracts Groundwork for running multiplayer games on the session server; nothing of it is switched on yet, and the plain build is unchanged. - A new network in two halves (beginState/beginShow), the coach split into tutAdvance/coachDom, toastPop split out of toast, bootNotes() for the once-per-load toasts, the five text actions take their text as an argument, and srvOn() with its two checks in the loop. - Live state is what a reload makes of it (migrate() is a no-op on it): new POPs, ports, PNIs, customers, attacks, dark fiber and the intern's notes are written in their saved shape; a 365-day test proves it. - pniAll and bstdApply check the quote the sheet showed (bstdApply by its plan, within 1% for the daily hardware drift; utilityKit too). - assemble({mp}) leaves src/game/98-server-play/ and its CSS out of every page but a multiplayer build's, which also gets a SIM_ID build id. - Contracts for the server, protocol and browser parts: the action tables and envelope check (scripts/lib/mp-sim-acts.js), event fixtures, a shape checker, a fake engine, and load({mp:true}) in the test harness. - route-fuzz judges both pages with one migrate(), so reload repairs of the base no longer count as divergences. --- docs/ARCHITECTURE.md | 5 +- scripts/build.js | 18 +- scripts/i18n-check.js | 7 +- scripts/lib/fuzz-page.js | 44 +- scripts/lib/mp-sim-acts.js | 579 ++++++++++++++++++ scripts/lib/page.js | 37 +- scripts/lib/route-fuzz.js | 11 +- src/agent/10-domains.js | 2 + src/agent/20-commands.js | 12 +- src/game/00-core/20-analytics.js | 2 + src/game/60-features/20-scenarios.js | 20 +- src/game/60-features/38-sales-desk.js | 4 +- src/game/60-features/40-tutorial.js | 10 +- src/game/60-features/80-new-game.js | 8 +- src/game/60-features/89-multiplayer.js | 7 +- src/game/60-features/90-automation.js | 3 +- src/game/70-rules/35-pni-orders.js | 3 +- src/game/70-rules/95-utilities.js | 3 + src/game/80-simulation/50-sanitize.js | 5 +- .../85-incidents/10-incidents-and-ddos.js | 11 +- src/game/88-days/10-day-tick.js | 10 +- src/game/90-actions/20-pops-transit-ix.js | 5 +- .../90-actions/30-route-script-and-tools.js | 5 +- .../90-actions/40-sites-peering-caches.js | 4 +- src/game/90-actions/50-customers.js | 2 +- src/game/90-actions/60-links.js | 9 +- src/game/90-actions/80-security-and-china.js | 2 +- src/game/90-actions/86-specialist.js | 2 +- src/game/90-actions/87-fiber-and-hardware.js | 4 +- src/game/90-actions/87-teleports.js | 2 +- src/game/90-actions/88-build-standard.js | 12 +- src/game/90-actions/88-utilities.js | 4 +- src/game/90-actions/91-slots.js | 3 +- src/game/90-actions/97-pie.js | 3 +- src/game/91-save.js | 4 + src/game/93-ui/59-build-standard.js | 8 +- src/game/95-modals/10-toasts.js | 5 +- src/game/95-modals/35-pni-all.js | 7 +- src/game/98-server-play/00-about.js | 6 + src/game/99-loop.js | 8 +- src/styles/43-server-play.css | 3 + tests/canonical-state.test.js | 131 ++++ tests/ddos-model.test.js | 5 +- tests/durations.json | 3 + tests/fixtures/mp-sim/clock.json | 1 + tests/fixtures/mp-sim/roster.json | 1 + tests/fixtures/mp-sim/snap.json | 1 + tests/fixtures/mp-sim/sub.json | 1 + tests/fixtures/mp-sim/upd-act.json | 1 + tests/fixtures/mp-sim/upd-day.json | 1 + tests/gameplay-rules.test.js | 2 +- tests/harness.js | 73 ++- tests/lib/mp-sim-fake-engine.js | 187 ++++++ tests/lib/mp-sim-fixtures.js | 91 +++ tests/lib/mp-sim-shape.js | 183 ++++++ tests/mp-sim-contract.test.js | 308 ++++++++++ tests/pages.test.js | 23 + tests/pni-global.test.js | 2 +- tests/server-sim-prereqs.test.js | 389 ++++++++++++ tests/utilities.test.js | 3 +- 60 files changed, 2200 insertions(+), 105 deletions(-) create mode 100644 scripts/lib/mp-sim-acts.js create mode 100644 src/game/98-server-play/00-about.js create mode 100644 src/styles/43-server-play.css create mode 100644 tests/canonical-state.test.js create mode 100644 tests/fixtures/mp-sim/clock.json create mode 100644 tests/fixtures/mp-sim/roster.json create mode 100644 tests/fixtures/mp-sim/snap.json create mode 100644 tests/fixtures/mp-sim/sub.json create mode 100644 tests/fixtures/mp-sim/upd-act.json create mode 100644 tests/fixtures/mp-sim/upd-day.json create mode 100644 tests/lib/mp-sim-fake-engine.js create mode 100644 tests/lib/mp-sim-fixtures.js create mode 100644 tests/lib/mp-sim-shape.js create mode 100644 tests/mp-sim-contract.test.js create mode 100644 tests/server-sim-prereqs.test.js diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index af0768b..fc819a8 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -12,9 +12,12 @@ src/ the game page, in pieces styles/NN-*.css → pasted into the page's