Phase 3: trade/end-game client, bot simulator, first balance pass
Built: - Client: trade screen, world/end-game screen (landing sites, shipping, node build, final ranking), report sharing + alliance reports tab, alert describers for all notification types, error-code strings (en+nb) for every server CODE. - tools/bot.js (+ tools/bot/): 50 headless bots against the real server in-process with a fake clock; resource/unit conservation ledger, exit 1 on broken invariants. docs/BALANCE.md has method and every run behind a number. - Balance changes (evidence in docs/BALANCE.md): secondQueueCoreLevel 10 -> 3, TRANSPORT.capacityPerLink 500 -> 1000 (end game was shipping-limited in bot runs). - Server fixes: POST /reports/:id/share 500 without a pending reportCleanup; bounced link shipments were silent about cargo overflow. Tested: npm test 207/207 (new: bot determinism + invariants, client alerts/world/i18n over CODES, two regression tests that failed before their fix); openapi check up to date. Real-browser scratch runs (not in repo): WebSocket push shows an incoming-attack banner ~214 ms after launch, polling fallback ~52 s, 15 scripted flows, 71 screenshots. NOT tested: Playwright suite (e2e/ still empty), real devices/Safari, nginx proxy websockets, throttled networks, HTTP-level bot load. NOT claimed: balance. Bots are not humans; open balance items (loot waste, escrow refund clipping, no garrisons at landing sites, end game not scaling with world speed) are listed in docs/BALANCE.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
d84b0c9d12
commit
931f59e11e
49 changed files with 4750 additions and 59 deletions
69
docs/NEXT.md
69
docs/NEXT.md
|
|
@ -20,7 +20,7 @@ Not done:
|
|||
- Marketplace / Internet exchange: DONE on the server, see "Trade, end game, gaps" below.
|
||||
- Shared report folder and "see each other's incoming": DONE on the server (below). The pact effect "no attacks inside a NAP/confederation"
|
||||
is enforced by the military stage (`pactBlocks`).
|
||||
- No web client; WebSocket push (stage 6) now exists server-side, see "Stage 6" below.
|
||||
- Web client: see the client sections below; WebSocket push (stage 6) exists server-side and in the client.
|
||||
- Message retention/cleanup of old rows, alliance rename/description, mass-mail abuse reporting, sitter accounts.
|
||||
- Rankings are not cached; battle rankings stay empty until the military stage writes `operator_stats`.
|
||||
- Not run: Playwright, load, or any bot balance run; the social numbers in `SOCIAL` (limits, TTLs, role table) are first guesses.
|
||||
|
|
@ -41,7 +41,7 @@ its protections, offline units and decommission, restart catch-up from a reopene
|
|||
recall, research, reports/cursor/retention, API smoke over HTTP). Fake clock, in-memory DB, port 0; no Playwright.
|
||||
Not done / not claimed:
|
||||
- **Nothing is balanced.** All unit stats, costs, research curves, incumbent defence and the 50-unit-scale combat numbers are first guesses;
|
||||
there was no bot run (`tools/bot.js` does not exist yet). Do not cite any of them as tuned.
|
||||
there was no bot run when this was written (`tools/bot.js` exists now: see "Stage 7" below and BALANCE.md; most of these numbers are still untuned). Do not cite any of them as tuned.
|
||||
- Training cannot be cancelled; no sitter, no night protection. (Report sharing and allied incoming: done, see below.)
|
||||
- Units in transit draw no power from anyone; an operator cannot choose a new capital POP (no command); a captured POP keeps its footprint.
|
||||
- Backbone landing sites and the Backbone node: see "Trade, end game, gaps" below.
|
||||
|
|
@ -133,6 +133,47 @@ Not done / not claimed:
|
|||
- Close 4401 stops the socket but does not itself send the player to login: that happens on the next REST 401 (`api` `unauthorized`).
|
||||
- `ready.serverTime` is not used for the clock offset (no round-trip estimate on the socket); REST responses keep doing that.
|
||||
|
||||
## Client: trade, end game, alerts (public/)
|
||||
Built (More group; strings in `strings/{trade,world,alerts}.js`, en + nb):
|
||||
- **Exchange** (`screens/trade.js`): tabs Offers / New / Mine / Send. Offers: filters give / want / POP, reach pills, "Take" sheet with a POP chooser
|
||||
from `acceptableFrom` (distance, transport time, stock, free links, why a POP is greyed out). New: live check with `rules.tradeTermsCheck` (1:2 band,
|
||||
1000 per link, distance), stock and free-link checks, the exchange level a taker needs, escrow/expiry rules in words. Mine: status chips, poster/acceptor
|
||||
role, expiry countdown, cancel. Send: direct transport through the send dialog (`App.openSend({ type: 'transport' })`; `milcore.moveOptions` got a
|
||||
`transportOnly` flag so a rival's POP can be the target) plus links in use per exchange POP. No exchange: empty state with the requirement (Core router 4).
|
||||
- **Backbone race / ended world** (`screens/world.js`, `endcore.js`, `cargo-ui.js`): phase banner (countdown to the landing sites, leading alliance, winner,
|
||||
ended), the 7 sites with holder / level / build progress / stockpile, Manage sheet for your alliance's sites (build next level, ship resources, ledger),
|
||||
scan/attack through the send dialog (`milcore.moveOptions` landing branch), final ranking tabs after the end. Whole-client ended mode: `App.worldEnded()`,
|
||||
pill in the top bar, card on the POP screen, action buttons (primary/danger/`[data-act]`, not `[data-keep]`) disabled by a MutationObserver; a stale page
|
||||
learns it from a `world_ended` error (via `App.errMsg`), the `world_ended` push or `/me`.
|
||||
- **Map**: landing sites drawn as a diamond with a level ring (gold = incumbent, cyan = yours, magenta = rival alliance), legend row, tile sheet (holder, level,
|
||||
Backbone race button, send). **Reports**: `landing` type, scans of landing sites, share to alliance, Alliance tab (folder), remove from folder; shared reports
|
||||
are told from nobody's side. **Movements**: shipments to a site are labelled; `alliedIncoming` was already there and never counts in the red badge.
|
||||
- **Alerts** (`alertkinds.js`, pure): every notification type the server writes (found by a test that greps `server/`) has a describer; includes trade_*,
|
||||
backbone_*, world_ended, alliance_*, diplomacy_*, message kinds.
|
||||
- Tests: `test/client-world.test.js` (endcore, moveOptions, string coverage, no HTML sinks, every public script parses), `test/client-alerts.test.js`,
|
||||
`test/client-i18n.test.js` now iterates `CODES` of `server/errors.js`. 203 tests green.
|
||||
- Looked at in headless Chromium against the real server (real clock, in-memory DB; scratch scripts, not in the repo): screenshot sweep of every new screen on phone
|
||||
portrait, phone landscape and desktop (en, plus nb for trade/world) in three world states (day 62, day 100+ with held sites, ended); scripted flows with DB
|
||||
assertions (take an offer, post with live validation, cancel, transport to a rival by coordinates, ship, build, scan/attack dialog, tap a site on the map, share
|
||||
and unshare a report, alerts feed, a stale page hitting `world_ended`).
|
||||
- **Push, end to end in real browsers**: Alice raids Bob; Bob's page (real login, WebSocket open) showed the incoming banner, red Moves badge and toast 214 ms
|
||||
after the launch with no reload; the banner went away and the Reports badge rose when the raid arrived. With `WebSocket` undefined, and with a socket that is
|
||||
closed at once (reconnect loop, 7 attempts in the run), the same raid showed up after about 52 s through the REST poll (15 s tick, 45 s gap): worst case about a
|
||||
minute. Confederate Carol gets no push for `alliedIncoming` (known server gap): it shows when the Moves screen is opened or the poll runs, and never in her badge.
|
||||
Found and fixed in the client: `report` pushes now also refetch movements (the incoming banner used to linger up to a few seconds after the arrival).
|
||||
Not done / not claimed:
|
||||
- Not run: real devices, Safari, a socket behind nginx Proxy Manager, throttled networks, the Playwright suite (`e2e/` is still empty), long lists (offers > 25 per
|
||||
filter paged only up to what the sweep seeded).
|
||||
- Ended-world locking is a DOM sweep, not per-button wiring: a new primary/danger button that is NOT a game command must carry `data-keep`. Messages, ranking and
|
||||
settings screens are exempt by selector. Open send/trade sheets that were opened before the end stay usable until the next DOM change or a refused command.
|
||||
- Trade: no order book or price history, no notification for new offers in reach, offers are listed per page of 25 with a cursor only. The landing-site manage sheet
|
||||
does not poll while open (it reloads after your own actions and when the site screen refreshes). Ledger shows the top 15 contributors.
|
||||
- Site numbers are `index + 1` ("Landing site 1..7"), not a name from the server. `backbone_open` is only pushed on first touch (server E2): the countdown flips
|
||||
by the client clock at `opensAt`, the sites appear after the next status fetch.
|
||||
- A transport to a rival's POP is a gift that warns its owner (`incoming`, type hidden); the UI says so, but nothing stops a griefing stream of them.
|
||||
- Server bug found and fixed (tiny): `POST /reports/:id/share` threw a 500 when no `reportCleanup` event was pending (`ensureCleanup` needs `ctx.enqueue`);
|
||||
`reportShare` now wraps its ctx with `ctxOf`, regression test `test/report-share-cleanup.test.js` (failed before).
|
||||
|
||||
## Stage 6 (server half): WebSocket push
|
||||
Built: `/ws` on the game's HTTP server (`server/push.js` transport, `server/pushHooks.js` routing), contract in `docs/PROTOCOL.md`.
|
||||
Auth as first message (`ready` / close 4401), Origin check (`net.originAllowed`), per-IP cap `MAX_CONN_PER_IP` (HTTP 429), 1 KB frames,
|
||||
|
|
@ -173,7 +214,7 @@ Built and tested (`test/trade-*.test.js`, `test/endgame-*.test.js`; fake clock,
|
|||
Not done / not claimed:
|
||||
- **Nothing here is balanced.** Defence multiplier 12 (+3% per level), node cost 4000 x 1.045^(L-1) (about 7.2 M of each resource in total),
|
||||
node time 2 h x 1.025^(L-1) (about 36 world days), 48 h offer ttl, 10 tiles of reach per exchange level, 500-per-side offers: first guesses,
|
||||
no bot run (`tools/bot.js` still does not exist). Whether an alliance can actually ship 7 M of everything in time is unknown.
|
||||
no bot run when written (now there is one: BALANCE.md section 5 says an 18-member alliance needs 55 to 78 days after the sites open with 1000 per link, and does not finish in 175 days with 500).
|
||||
- **No garrison at landing sites** (E1): defence is static, holders cannot station units. If the first world shows the race is decided by who
|
||||
hits first, the next step is a small `site_units` table with reinforce-to-site and defenders in `landing.js`.
|
||||
- No `backbone_open` push at the moment the sites appear unless something touches a site first (E2); clients see the phase by polling status.
|
||||
|
|
@ -182,9 +223,25 @@ Not done / not claimed:
|
|||
- Ended worlds: movements still `out` and queued builds are left as they were (events cancelled, E3); there is no admin "end world now" or
|
||||
"reset" yet (stage 7 world lifecycle: the `worldEnd` event can be enqueued by hand); several winners are impossible by design.
|
||||
- The ranking snapshot is the same numbers as `/rankings`, computed once; `/rankings/*` after the end still compute live from the frozen state.
|
||||
- Client: nothing in `public/` was touched. New notification types (`trade_*`, `backbone_*`, `world_ended`), the `landing` report type, the
|
||||
`backbone` map special / tile, `world_ended` and the new error codes (`trade_ratio`, `offer_closed`, `own_offer`, `trade_out_of_range`,
|
||||
`world_ended`, `backbone_closed`) need strings and screens.
|
||||
- Client for all of this: see "Client: trade, end game, alerts" above.
|
||||
|
||||
## Stage 7 (first part): bot harness and first balance pass
|
||||
Built: `tools/bot.js` (+ `tools/bot/*`): N headless bots (builder, raider, conqueror, turtle, expander, trader, alliancer; a coordinated alliance
|
||||
plays the end game) against the real server in-process (`createServer` with an in-memory DB and a FakeClock, bots drive `srv.commands.run`, no
|
||||
HTTP), 50 players x 14 days in ~3 s, x 170 days in ~140 s. Per-day economy, progression, combat, trade, alliance, end game, performance and
|
||||
error tables; `--json`, `--set PATH=VALUE` data overrides, `--sessions-per-day`, `--always-on`, `--speed`, `--strategy-mix`. Exit code 1 when an
|
||||
invariant breaks: exact resource conservation (production measured at every settle, sinks from command results and notifications), exact unit
|
||||
conservation, no negative stock, no failed events, no unexpected error codes. `docs/BALANCE.md` has the method, every run behind a number, what
|
||||
was tuned and what was not.
|
||||
Tuned (each with before/after runs in BALANCE.md): second build slot at Core router 3 (was 10), transport capacity 1000 per link (was 500).
|
||||
Server fix found by the harness: bounced shipments reported no overflow (`events/return.js`).
|
||||
Tests: `test/bot-run.test.js` (12 players x 6 days twice, identical stats, invariants, the checks catch tampering, a fast world reaches the end game),
|
||||
`test/bot-server-fixes.test.js`.
|
||||
Not done / not claimed: **the game is not balanced**; the bots are not humans (no reinforcement, recall, messages, sitters; fixed sittings). Open
|
||||
items from the pass: a 3x world's end game is as long as a 1x world's (shipping is per sitting; `capacityPerLink x speed` needs the client to stop
|
||||
reading the constant); trade escrow refunds are clipped at the Rack hall cap silently; raid loot is split evenly over resources and destroyed on overflow;
|
||||
the capital runs out of things to build ~50 days before the backbone opens at 4 sittings a day; a built-up landing site is out of reach of any
|
||||
single-POP army (no garrisons, E1), so there is no fight for a site after the first days.
|
||||
|
||||
## Not done
|
||||
- Everything else. See CLAUDE.md "Working in stages".
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue