Merge branch 'main' into own-carrier-egress
This commit is contained in:
commit
296de1d946
232 changed files with 18447 additions and 2047 deletions
|
|
@ -27,10 +27,10 @@ hoisted across files, and top-level statements run in path order. Find code by n
|
|||
| `10-catalog/` | Prices and gear: POP and port costs, routers (`RG`), supply chain, port slots, dark fiber systems and optics (`OPT`), reach and subsea upgrades |
|
||||
| `20-world/` | Map projection, landmasses, coastline, city coordinates (`CITY_LL`), `CITIES`, `CABLES` |
|
||||
| `30-networks/` | Other ASes (`NETS`), rival exchanges (`XIX`), the long tail, traffic shares (`NSH`) |
|
||||
| `40-progress/` | Customer types (`BIZ_T`), `LEVELS` and their requirements, `GOALS` |
|
||||
| `40-progress/` | Customer types (`BIZ_T`), `LEVELS` and their requirements, `GOALS`; the per-save ruleset (`S.rules`, `rule()`, `PRESETS`, `chaosMul()`, `leadDays()`) |
|
||||
| `50-state.js` | The globals `S`, `R`, `UI`; `emptyR()` |
|
||||
| `60-features/` | Banks and loans, scenarios and the weekly challenge, conferences, the tutorial, traceroute, the share card, `newGame()` |
|
||||
| `70-rules/` | Formatting helpers and market rules: exchanges, PNIs, the peering inbox, peering policy and snubs, DE-KICKS, sold-out routes, hot ports and the Tier 1/2/3 rank |
|
||||
| `60-features/` | Banks and loans, scenarios and the weekly challenge, puzzles and the published weekly puzzle, conferences, the tutorial, traceroute, the share card, `newGame()`, the offer trial (`autoOffer()`), standing orders (`S.ops`, `opsDay()`, run from `dayTick()`) |
|
||||
| `70-rules/` | Formatting helpers and market rules: exchanges, PNIs, the peering desk (requests answered by policy), peering policy and snubs, DE-KICKS, sold-out routes, hot ports and the Tier 1/2/3 rank |
|
||||
| `80-simulation/` | Dijkstra, RouteScript, `compute()`, monthly prices, `sanitize()`/`migrate()`, customer requirements, events, geography pricing and latency, second sites and service |
|
||||
| `85-incidents/` | `addInc()`, DDoS and scrubbing, `fireFailure()`, `clearInc()`, `fireEvent()` |
|
||||
| `88-days/` | `dayTick()`, new offers, badges, `checkGoals()` |
|
||||
|
|
@ -72,13 +72,16 @@ Development runs on `npm run dev` (assembles on every request, reloads on save);
|
|||
| `.github/workflows/ci.yml` | Tests and build on every push and PR |
|
||||
| `.github/workflows/auto-release.yml` | On a `package.json` version bump on `main`: test, tag, GitHub release from the CHANGELOG, start the deploy |
|
||||
| `.github/workflows/release.yml` | Builds and deploys to GitHub Pages, the only workflow that can |
|
||||
| `.github/workflows/weekly-puzzle.yml` | Sunday 03:37 UTC: makes the week's puzzle, commits it to `main` (data only, no release) and starts `release.yml` for the live release tag with `weekly=true` |
|
||||
| `scripts/weekly-puzzle.js`, `site/puzzles/weekly/` | The weekly puzzle generator and its output, one `<key>.json` per week plus `index.json` (see below) |
|
||||
| `scripts/weekly-scenario.js`, `scripts/lib/scenario-bot.js`, `site/scenarios/weekly/` | The weekly scenario generator, its reference player and its output (see below) |
|
||||
| `docs/adr/` | Decisions: GitHub Pages only (0001), one page assembled at build (0002), translations by label (0003) |
|
||||
|
||||
## Globals
|
||||
|
||||
- **`S`**: the whole saved game (one JSON object). Cash, day, POPs, links, transit,
|
||||
IX ports, PNIs, caches, customers (`biz`), offers, incidents (`inc`), live events
|
||||
(`ev`), stats, settings. Saved to `localStorage` key `sot-save-v1`.
|
||||
(`ev`), stats, settings. Saved to `localStorage` key `sot-save-v1:<slot>` (one per network, see below).
|
||||
- **`R`**: results of the last `compute()`: per-link load, per-exit use, served and
|
||||
demanded traffic, reach, costs and revenue. Never saved; always rebuilt.
|
||||
- **`UI`**: view state (selection, open tabs, speed, confirmations). Not game state.
|
||||
|
|
@ -99,6 +102,9 @@ never freezes the game.
|
|||
3. Records history for 95th-percentile billing, stats and streaks.
|
||||
4. Rolls failures (`fireFailure()`) and events (`fireEvent()`) when their timers run out,
|
||||
and expires incidents.
|
||||
Then the NOC intern's standing orders (`opsDay()`), if one is hired: each order clicks the same `ACT`
|
||||
actions a player would, muted, within its monthly budget, and the shift recomputes once at the end, only if
|
||||
a job changed the network. An order that throws is paused; the day goes on. The NOC gets one notice a week.
|
||||
5. Updates customer mood, churn and new offers; IX members join; loans tick.
|
||||
6. Every 30 days: bills the month (revenue minus costs) and checks for bankruptcy.
|
||||
7. Checks goals, level, badges and scenario end conditions.
|
||||
|
|
@ -149,11 +155,59 @@ Served share per city (`sfOf`) drives eyeball revenue and customer mood.
|
|||
- The map is a canvas drawn every frame by `draw()`. Zoomed out (`lodFar()`) it uses
|
||||
a simplified style; parallel waves are grouped by `linkGroups()`.
|
||||
|
||||
## The weekly puzzle
|
||||
|
||||
A puzzle week runs from Sunday 06:00 Berlin time to the next Sunday 06:00, and is named after the ISO week of
|
||||
its Monday (the week starting Sunday 1 November 2026 is `2026-W45`); `pzWeekKey()` and `pzWeekStart()` in
|
||||
`src/game/60-features/93-puzzles-weekly.js` handle summer time and the year boundary.
|
||||
|
||||
Every Sunday `weekly-puzzle.yml` runs `scripts/weekly-puzzle.js`, which loads the real game headless, picks a
|
||||
theme the last three weeks did not have (region tour, ring, detour around a hub, ocean crossing, island hopping,
|
||||
latency sprint) and cities the last four weeks did not use, gives them traffic (content in the first city, eyeballs
|
||||
in the others, a circuit with a latency cap for a sprint), searches for the cheapest topology that connects them and
|
||||
the cheapest one that survives any single cut (a whole cable, or a trench), then sizes both with the game's own
|
||||
routing (`scripts/lib/puzzle-solver.js`: links and routers big enough for every flow, after any cut too, then as
|
||||
small as they go). The budget sits just above that N-1 build. Both references are judged by the game's own star
|
||||
code and must earn one and three stars, or the puzzle is thrown away. The file holds only ids, numbers and
|
||||
translation labels with their fill-ins
|
||||
(`{"v":2,"key","theme","cities","src","dem","via","avoid","budget","twist","name":{"l","p"},"joke":{"l","p"},"ref","rev"?}`).
|
||||
`--check` re-validates every file the way the game does.
|
||||
|
||||
The game fetches `puzzles/weekly/<key>.json` (relative, same origin) only when the Puzzles list opens, and checks
|
||||
it field by field (`pzWkValid()`): known fields, playable cities, labels from the theme's own list, sane numbers.
|
||||
When it is missing, offline or wrong, the seeded weekly (`pzWeekly()`) stands in, so the weekly puzzle always
|
||||
works. The service worker fetches these files network-first and keeps a copy for offline play.
|
||||
|
||||
The weekly ships without a release: the workflow commits only `site/puzzles/weekly/` to `main` (no version bump,
|
||||
so `auto-release.yml` stays quiet) and starts `release.yml` from the live release's tag with `weekly=true`, which
|
||||
rebuilds that exact release with every weekly file from `main` and deploys it. Every release build takes the
|
||||
weekly files from `main` too, so no deploy ever drops a published week.
|
||||
|
||||
The weekly scenario is its twin, in the same weeks and the same workflow run: `scripts/weekly-scenario.js` writes
|
||||
`site/scenarios/weekly/<key>.json`. A template (plain data in the script) picks a theme, a home city, rules from the
|
||||
scenario vocabulary (`scnRule` keys, `WEEK_MODS`) and a goal type with parameters; each goal type (`WS_GOALS` in
|
||||
`src/game/60-features/94-scenarios-weekly.js`) is implemented once in the game, with its progress card. A reference
|
||||
player (`scripts/lib/scenario-bot.js`) plays it through `ACT`, seeded with the scenario's seed; the goal's number is
|
||||
calibrated from that run, the scenario must not be won on day 0, the reference must win with a tenth of the days to
|
||||
spare, and its finishing day is the par. The file keeps the reference plan (`ref`), which `--check` replays. The game
|
||||
fetches the file when the Scenarios list opens, checks it with `wsValid()` (again in `sanitize()` on load), and falls
|
||||
back to the in-browser `weekly()`.
|
||||
|
||||
## Saves, imports and migration
|
||||
|
||||
- `save()` writes `S` to localStorage every few seconds and after actions.
|
||||
- `save()` writes `S` to localStorage every few seconds and after actions, into this window's slot
|
||||
(`UI.slot`, `src/game/91-slots.js`): `sot-save-v1:<id>`, plain JSON or `gz:`-compressed above a million
|
||||
characters, with a stamp `sv:{seq,at}` appended. Then the index `sot-slots` (name, ASN, preset, day, tier,
|
||||
cash, last played, size, seq) is updated; the title screen lists networks from the index alone.
|
||||
- Each tab keeps its slot in `sessionStorage['sot-slot']`. One window per slot: a Web Lock
|
||||
(`sot-slot:<id>`) where supported, plus a heartbeat `sot-open:<id>`; BroadcastChannel `sot-slots` asks
|
||||
another window to hand over, and the `storage` event stops a window whose slot was saved newer elsewhere
|
||||
(higher seq) or deleted. A window never writes a slot whose index seq is newer than its own.
|
||||
- The single save of older versions (`sot-save-v1`) is copied to slot `main` and read back before the
|
||||
index lists it; the old key is removed only by that slot's next successful save.
|
||||
- `boot()` loads the save through `migrate()` → `sanitize()`. If loading throws, the
|
||||
damaged save is kept under `sot-save-broken` and the player starts fresh.
|
||||
slot is kept and marked damaged in the index (it can still be exported or deleted).
|
||||
- Puzzles never write a slot; while one runs, `save()` writes the network set aside (`UI.pzKeep`).
|
||||
- `sanitize(s)` is the gate for all untrusted state (saves and imported files): it
|
||||
drops unknown ids, clamps numbers, repairs references and fills defaults. Every new
|
||||
field in `S` needs a line there.
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ fell back to English. Long sentences as keys made dictionary diffs hard to read
|
|||
- **`npm run i18n:check`** verifies that every label used in `src/` is defined in English, every
|
||||
English label is used, every translation keeps its English's placeholders, HTML tags and plural forms,
|
||||
and every dictionary is sorted.
|
||||
- **Saves:** a few things in a save hold text to show later (the peering inbox log, sold-out reasons,
|
||||
- **Saves:** a few things in a save hold text to show later (sold-out reasons,
|
||||
attack names). New saves hold labels. Saves from before labels (1.34 and older) hold the English text; `tr()` maps it
|
||||
back to its label the first time it sees one, so old saves still show the player's language.
|
||||
- **Translators** read `src/i18n/en.js` next to their file; both are sorted by the same labels, so the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue