Merge branch 'main' into own-carrier-egress
This commit is contained in:
commit
296de1d946
232 changed files with 18447 additions and 2047 deletions
68
.claude/skills/gameplay-rules/SKILL.md
Normal file
68
.claude/skills/gameplay-rules/SKILL.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
---
|
||||
name: gameplay-rules
|
||||
description: The design rules of Series of Tubes, each with an id and the test that enforces it. Use whenever you add or change cities, countries, networks (NETS, upstreams, traffic shares, presence), cables, exchanges, data centers, customers, scenarios, puzzles, presets or rules, balance numbers or progression, and before committing any such change.
|
||||
---
|
||||
|
||||
# Gameplay rules
|
||||
|
||||
These are what the game promises, held up by `tests/gameplay-rules.test.js` (one `test()` per id, on the live
|
||||
`CITIES`, `NETS`, `CABLES`, `SCN`, `PZ`, `PRESETS`…). Each rule is true of the intended design.
|
||||
|
||||
## Procedure
|
||||
|
||||
1. Changing anything above? Run `npm test -- tests/gameplay-rules.test.js` (under a minute) before committing.
|
||||
2. A failure names what breaks the rule and how to fix it. Fix the data or the code.
|
||||
3. Only when real life really is different, add an entry to `EXCEPTIONS` in the test (keyed by rule id, sorted, with
|
||||
its reason in plain words). Never delete or loosen a check to make it pass. A stale exception fails too.
|
||||
4. A new rule gets an id in the right section here, one line, a why, and its own `test('ID: …')`.
|
||||
|
||||
## World
|
||||
|
||||
| Id | Rule | Why |
|
||||
| --- | --- | --- |
|
||||
| W1 | Every city has a country code (`cc`, ISO 3166-1 alpha-2; territories have their own: PR, GU, RE, MQ, CW…), a region, a landmass and coordinates. | Borders, prices and the eyeball rule all hang off the country. |
|
||||
| W2 | Every country on the map has at least two consumer networks of its own: an eyeball network, or a Tier 2 incumbent that sells to homes, whose home markets (`cc` on the network) include that country and which has a PoP there. | Real countries have competing local ISPs, and peering locally is half the game. Add real operators in `src/game/30-networks/32-homegrown-eyeballs.js`. |
|
||||
| W3 | Every city can buy transit from someone, or is a documented exception (Pitcairn: land your own cable; Stuttgart: peering only). | A start or an expansion must never be a dead end by accident. |
|
||||
| W4 | Cable pairs join two distinct real cities, have a length, and cable ids are unique. | Broken landings break routing and the own-cable planner. |
|
||||
| W5 | A city alone on its landmass has a cable or a beach to land one. | Islands are reachable. |
|
||||
|
||||
## Networks
|
||||
|
||||
| Id | Rule | Why |
|
||||
| --- | --- | --- |
|
||||
| N1 | Network ids and ASNs are unique; ASNs are public (the real one for real-world networks). | Saves key on ids; players look ASNs up. |
|
||||
| N2 | Names are puns: no network, cable, exchange, data center, router or optic is called by a real name (blocklist `REAL_NAMES` in the test), and no lazy "-ish" names. | CLAUDE.md. Add the real name to the blocklist whenever you add its pun. |
|
||||
| N3 | Every non-Tier-1, non-content network is in a founding Tier 1's customer cone (`up`), or is a documented island (transit-free incumbents, China, Korea, Australia…). Upstreams exist and are never content. | Tier 1 by customer cone (#85): a new network outside the cones makes Tier 1 harder for every save, old ones included. |
|
||||
| N4 | No upstream cycles. | Cones must be trees, not loops. |
|
||||
| N5 | Traffic shares are positive and below 20%; `NSH` and the regional tables sum to 1; content carries at least 30%. | Shares drive every flow; eyeballs mostly ask for traffic. |
|
||||
| N6 | Every network has a type, a peering policy (selective ones state `minIx`/`minPni`), a colour and a translated blurb; carriers have a price. | Panels and the peering rules read them. |
|
||||
| N7 | PoPs are real, distinct cities; exchange ports only where the city has an exchange and the network has a PoP. | Presence follows PeeringDB-style reality. |
|
||||
|
||||
## Modes and rules
|
||||
|
||||
| Id | Rule | Why |
|
||||
| --- | --- | --- |
|
||||
| M1 | On-call is the classic game: it equals `RULE_DEF`, and a save without rules loads as On-call. The seeded suites (`tests/game.test.js`, `tests/rules.test.js`) are its behaviour. | Old saves never change under them. |
|
||||
| M2 | Presets are ordered: Change Freeze never harsher than On-call, BGP at 3 a.m. never gentler (chaos, lead times, market; and a seeded year of incidents). | The names promise it. |
|
||||
| M3 | Every subsystem that can annoy the player reads a rule: outages and events (`chaos`), DDoS, sold-out routes, de-peering and hardware prices (`market`), lead times (`lead`), the clock. A quiet ruleset gives a quiet year. | Rules are presets of flags, not separate code. |
|
||||
| M4 | Scenarios and the weekly challenge always run On-call plus their own `S.scn.rules`. | Fair scores. |
|
||||
| M5 | Sandbox has no locked feature: open gates, every level, own cables, endless money. | It is a sandbox. |
|
||||
|
||||
## Content
|
||||
|
||||
| Id | Rule | Why |
|
||||
| --- | --- | --- |
|
||||
| C1 | Every scenario has a name, a goal, an `ok()` its progress card (`SCN_PROG`) shows, and cannot be won on day 0; so does every committed weekly scenario (`site/scenarios/weekly/`, its goal type's card in `WS_GOALS`). | A goal must need play. |
|
||||
| C2 | Every puzzle has a 1-star and a 3-star reference solution in `REF` of `tests/puzzles.test.js`, which builds and scores them. | Every puzzle is solvable and every star reachable. |
|
||||
| C3 | Every player-facing string is translated in every language (`node scripts/i18n-check.js`: 0 missing, 0 unused, 0 broken). | CLAUDE.md; see `add-strings`. |
|
||||
| C4 | Every Architect run, handmade (`REF` in `tests/architect.test.js`) or weekly (`ref` in its file, `scripts/weekly-architect.js --check`), has a reference build that passes every brief's chaos monkey review and earns three stars; every weekly brief takes at least one change (a tube, a bigger tube, a move), and later briefs' cities stay hidden until they come. | A run you cannot finish, or a brief that asks for nothing, is not a puzzle; knowing the next brief makes it a chore. |
|
||||
|
||||
## Fun and fairness
|
||||
|
||||
| Id | Rule | Why |
|
||||
| --- | --- | --- |
|
||||
| F1 | A new network gets a gentle start: no outage before day 45, no event before day 40 and only good news before day 50, nothing sold out for 90 days, hardware prices hold for 180, and a new customer loses no mood for 15 days. | New players learn before they get punished. |
|
||||
| F2 | On On-call, a simple build in a start city (broadband, the cheapest 100G transit, an exchange port with the route server) makes money within 3 months, in Frankfurt, New York, Singapore and Johannesburg. | Seeded today it turns a profit in month 1 or 2; a balance change that breaks this makes the start too hard. |
|
||||
| F3 | A specialist path (#187) only brings a customer type in below its level when the network can already serve it, or nearly: the spotted cities have POPs, the latency is met, the fiber carries at least three quarters of the smallest order. | Capability, not luck: an offer you cannot fulfil with a reasonable build is a trap. |
|
||||
| F4 | The chaos monkey visits only On-call and BGP at 3 a.m. (never Change Freeze, Sandbox, puzzles or scenarios), not before day 180, for 120 to 240 days; while it is here its snips replace the ordinary failures, each snip heals within a week, and it goes after tubes with no other way round first. | A test of resilience you can prepare for, not a pile-on: the reward goes to networks built with a second path. |
|
||||
| F5 | Capacity you rent to other carriers never outgrows the route's market: a broker listing sells over time as carriers between the two cities want it, and neither it nor a random offer sells past what both cities' eyeballs support (a landing town counts the big city it serves). | Rent that scales with your own glass and not with demand is a money machine (#203). |
|
||||
|
|
@ -40,6 +40,17 @@ publishes the GitHub release and starts `release.yml`: test, `REQUIRE_NOTES=1 np
|
|||
`pages: write`. Pushes to `main` and pull requests build but never deploy. The `release` skill has the
|
||||
steps.
|
||||
|
||||
**The one exception: the weekly puzzle.** Every Sunday at 03:37 UTC `weekly-puzzle.yml` commits the new
|
||||
`site/puzzles/weekly/<key>.json` to `main` (data only, no version bump) and starts `release.yml` for the **live
|
||||
release tag** with `weekly=true`. That run rebuilds exactly the live release, with every weekly file from `main`
|
||||
added, checks them with `scripts/weekly-puzzle.js --check`, and deploys it in the same `pages` concurrency group.
|
||||
Players get no update banner (the version does not change). Every release build also copies all weekly files from
|
||||
`main`, so a release never drops a published week, and regenerates (in the build, deterministically) any week
|
||||
not over yet that the release's prices no longer fit. Weekly files are plain JSON the game fetches only when the
|
||||
Puzzles list opens and never trusts; the service worker serves them network-first. The weekly scenario rides along in
|
||||
the same run: `scripts/weekly-scenario.js` writes `site/scenarios/weekly/<key>.json` (fetched when the Scenarios list
|
||||
opens), committed and deployed with the puzzle, never by a second workflow. See `docs/ARCHITECTURE.md`.
|
||||
|
||||
## Before you hand back a change that touches the build, deploy or loading
|
||||
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -12,6 +12,26 @@ that version's CHANGELOG section as notes, and dispatches `release.yml`, which b
|
|||
to GitHub Pages (https://seriesoftub.es). GitHub Pages is the only host, ever: see the
|
||||
`github-pages` skill.
|
||||
|
||||
## Weekly puzzles are not releases
|
||||
|
||||
`weekly-puzzle.yml` publishes a new puzzle every Sunday morning without a release: it commits the JSON under
|
||||
`site/puzzles/weekly/` to `main` and redeploys the live tag through `release.yml` (`weekly=true`). Never bump the
|
||||
version for a weekly puzzle. To publish or fix one by hand: `node scripts/weekly-puzzle.js --key 2026-W45 --force`,
|
||||
`node scripts/weekly-puzzle.js --check`, commit to `main`, then run the "Weekly puzzle" workflow (or
|
||||
`gh workflow run release.yml --ref <live tag> -f tag=<live tag> -f weekly=true`). A release includes every weekly
|
||||
file on `main` when it builds.
|
||||
|
||||
The weekly scenario (`site/scenarios/weekly/`, `scripts/weekly-scenario.js`) ships in the same run and the same way:
|
||||
`--key`, `--force` and `--check` work alike. Its `--check` replays each week not over yet with the reference plan in
|
||||
the file; a new par is just written, a week the reference no longer wins is regenerated with `rev` + 1.
|
||||
|
||||
**Prices change, weeks follow.** `--check` re-solves every week not over yet with the game it runs; a week whose
|
||||
budget no longer verifies is regenerated deterministically (the same puzzle with a new budget if that works, else a
|
||||
fresh one for the same key) with `rev` + 1, which resets players' stars for that week only. Past weeks are left alone
|
||||
unless the game rejects them. `release.yml` runs it before the tests on every deploy and fails only if a week cannot be
|
||||
regenerated. A change to prices, cables or cities fails `npm test` until you run `node scripts/weekly-puzzle.js --check`
|
||||
and commit the regenerated files with it (and `node scripts/weekly-scenario.js --check` for the scenarios).
|
||||
|
||||
## Only release when Frederic says so
|
||||
|
||||
Never bump the version on your own. Finished work is committed and pushed with its
|
||||
|
|
|
|||
36
.github/workflows/release.yml
vendored
36
.github/workflows/release.yml
vendored
|
|
@ -4,7 +4,8 @@ name: Release to GitHub Pages
|
|||
# Pushes to main run CI but never deploy. To ship: bump "version" in
|
||||
# package.json and date its CHANGELOG section; auto-release.yml then tags,
|
||||
# publishes the release and starts this workflow from the tag. Publishing a
|
||||
# release by hand works too.
|
||||
# release by hand works too. Every Sunday weekly-puzzle.yml redeploys the live
|
||||
# release from its tag with the new weekly puzzle added (input weekly).
|
||||
on:
|
||||
release:
|
||||
# "released" also fires when a pre-release is promoted to a full release.
|
||||
|
|
@ -18,6 +19,10 @@ on:
|
|||
description: Allow deploying a version older than what is live (rollback)
|
||||
type: boolean
|
||||
default: false
|
||||
weekly:
|
||||
description: Only the weekly puzzles changed (weekly-puzzle.yml); the release itself was tested when it shipped
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
# Least privilege: only the deploy job can write to Pages.
|
||||
permissions:
|
||||
|
|
@ -63,8 +68,36 @@ jobs:
|
|||
if [ "$ALLOW_OLDER" != "true" ] && [ "$(printf '%s\n%s\n' "$live" "$new" | sort -V | tail -n1)" != "$new" ]; then
|
||||
echo "::error::$new is older than the live $live. Re-run with allow_older to roll back on purpose."; exit 1
|
||||
fi
|
||||
# Weekly puzzles are published on main between releases (weekly-puzzle.yml). Every deploy ships all of them,
|
||||
# so neither a release nor a weekly redeploy ever drops a week that is already out.
|
||||
- name: Weekly puzzles and scenarios from main
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch --no-tags --depth=1 origin main
|
||||
for d in site/puzzles/weekly site/scenarios/weekly site/architect/weekly; do
|
||||
if git cat-file -e "FETCH_HEAD:$d" 2>/dev/null; then
|
||||
rm -rf "$d"
|
||||
git checkout FETCH_HEAD -- "$d"
|
||||
echo "$d: $(ls "$d" | grep -c '^[0-9].*\.json$')"
|
||||
fi
|
||||
done
|
||||
- run: npm ci
|
||||
# This release's prices may no longer fit a week already published: --check regenerates every week not over
|
||||
# yet whose budget no longer verifies (deterministically, so main's next weekly run commits the same files),
|
||||
# and fails the deploy only if that fails. Before the tests, which check the weeks too.
|
||||
- name: Fit the weekly puzzles to this release
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# A release from before the weekly puzzles ships the files without reading them: nothing to check.
|
||||
if [ ! -f scripts/weekly-puzzle.js ]; then echo "This release does not read weekly puzzles yet."; exit 0; fi
|
||||
node scripts/weekly-puzzle.js --check
|
||||
if [ -f scripts/weekly-scenario.js ]; then node scripts/weekly-scenario.js --check; fi
|
||||
if [ -f scripts/weekly-architect.js ]; then node scripts/weekly-architect.js --check; fi
|
||||
- run: npm test
|
||||
if: ${{ !inputs.weekly }}
|
||||
- name: Test the weekly puzzles against this release
|
||||
if: ${{ inputs.weekly && hashFiles('scripts/weekly-puzzle.js') != '' }}
|
||||
run: npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js $(ls tests/weekly-scenario.test.js tests/weekly-architect.test.js 2>/dev/null)
|
||||
- name: Build site
|
||||
run: VERSION="${TAG#v}" REQUIRE_NOTES=1 npm run build
|
||||
- uses: actions/upload-pages-artifact@v5
|
||||
|
|
@ -88,6 +121,7 @@ jobs:
|
|||
# the site is live.
|
||||
indexnow:
|
||||
needs: deploy
|
||||
if: ${{ !inputs.weekly }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# IndexNow keys are public by design (also served at /<key>.txt).
|
||||
|
|
|
|||
88
.github/workflows/weekly-puzzle.yml
vendored
Normal file
88
.github/workflows/weekly-puzzle.yml
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
name: Weekly puzzle
|
||||
|
||||
# Every Sunday morning: make this week's puzzle (scripts/weekly-puzzle.js), scenario (scripts/weekly-scenario.js) and
|
||||
# Architect run (scripts/weekly-architect.js),
|
||||
# commit them to main as a data-only change, and redeploy the live release with them, once. Weeks start Sunday
|
||||
# 06:00 Berlin time; 03:37 UTC is 04:37 in winter and 05:37 in summer, so the files are live before the week starts.
|
||||
#
|
||||
# No version bump, so no release: auto-release.yml only runs when package.json changes (and pushes made with
|
||||
# the workflow token start no workflows at all). The deploy itself is release.yml, still the only workflow
|
||||
# that can write to Pages, started from the live release's tag with weekly=true: it rebuilds exactly that
|
||||
# release with every weekly puzzle from main added, in the same "pages" concurrency group as any release.
|
||||
on:
|
||||
schedule:
|
||||
- cron: '37 3 * * 0'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
key:
|
||||
description: Week to make, e.g. 2026-W45 (default the week starting this Sunday)
|
||||
required: false
|
||||
deploy:
|
||||
description: Redeploy the live release with it
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
permissions:
|
||||
contents: write # commit the puzzle to main
|
||||
actions: write # start release.yml
|
||||
|
||||
concurrency:
|
||||
group: weekly-puzzle
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
puzzle:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
KEY: ${{ inputs.key }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
ref: main
|
||||
- uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
# Weeks already out that main's prices no longer fit are regenerated first, so the new week's history is current.
|
||||
- name: Fit the published weeks to main
|
||||
run: node scripts/weekly-puzzle.js --check && node scripts/weekly-scenario.js --check && node scripts/weekly-architect.js --check
|
||||
- name: Make the puzzle and the scenario
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -n "$KEY" ]; then
|
||||
[[ "$KEY" =~ ^[0-9]{4}-W[0-9]{2}$ ]] || { echo "::error::$KEY is not a week key"; exit 1; }
|
||||
node scripts/weekly-puzzle.js --key "$KEY"
|
||||
node scripts/weekly-scenario.js --key "$KEY"
|
||||
node scripts/weekly-architect.js --key "$KEY"
|
||||
else
|
||||
node scripts/weekly-puzzle.js
|
||||
node scripts/weekly-scenario.js
|
||||
node scripts/weekly-architect.js
|
||||
fi
|
||||
- name: Check every weekly puzzle
|
||||
run: node scripts/weekly-puzzle.js --check && node scripts/weekly-scenario.js --check && node scripts/weekly-architect.js --check && npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js tests/weekly-scenario.test.js tests/weekly-architect.test.js
|
||||
- name: Commit it to main
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git add site/puzzles/weekly site/scenarios/weekly site/architect/weekly
|
||||
# Data only: anything else changed means something is wrong.
|
||||
if git status --porcelain | grep -v -e ' site/puzzles/weekly/' -e ' site/scenarios/weekly/' -e ' site/architect/weekly/' | grep -q .; then git status --porcelain; echo "::error::unexpected changes"; exit 1; fi
|
||||
if git diff --cached --quiet; then echo "Nothing new to commit."; exit 0; fi
|
||||
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
|
||||
commit -m "Weekly puzzle and scenario $(git diff --cached --name-only | grep -o '[0-9]\{4\}-W[0-9]\{2\}' | sort -u | paste -sd ' ')"
|
||||
git push origin HEAD:main
|
||||
- name: Redeploy the live release with it
|
||||
if: github.event_name == 'schedule' || inputs.deploy
|
||||
run: |
|
||||
set -euo pipefail
|
||||
tag=$(gh release list --repo "$GITHUB_REPOSITORY" --exclude-pre-releases --exclude-drafts --limit 1 --json tagName -q '.[0].tagName')
|
||||
[ -n "$tag" ] || { echo "::error::no release to redeploy"; exit 1; }
|
||||
# Releases from before the weekly puzzles cannot take them (and their game would not read them).
|
||||
if ! git fetch --no-tags --depth=1 origin "refs/tags/$tag" || ! git show FETCH_HEAD:.github/workflows/release.yml | grep -q '^ weekly:'; then
|
||||
echo "::notice::$tag predates weekly puzzles; the puzzle is on main and ships with the next release."; exit 0
|
||||
fi
|
||||
gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "$tag" -f tag="$tag" -f weekly=true
|
||||
echo "Redeploying $tag with the weekly puzzles."
|
||||
124
CHANGELOG.md
124
CHANGELOG.md
|
|
@ -6,7 +6,129 @@ All notable changes to this project are documented here. The project follows
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- Traffic for a carrier now leaves through that carrier's own transit port at the same POP, instead of being shared with every other transit port there. Networks that buy transit from the carrier get the same treatment, and a new switch on each transit port, Carry here, pulls that traffic across your network from POPs that have no port of that carrier. Prefer, Backup only and RouteScript still win.
|
||||
- Cities on the map now show how big they are: zoomed out, bigger cities are bigger dots and megacities glow; zoomed in, a city's skyline grows from a hut to a megacity's towers. When cities crowd together, the smaller ones step back to a dot until you zoom in, so the map stays readable, and exchanges you haven't joined are quieter tags.
|
||||
## [2.1.0] — 2026-10-31
|
||||
|
||||
- Your backbone now runs a technology you choose: plain IGP, LDP/MPLS, RSVP-TE, SR-MPLS or SRv6. Each step up costs plenty and uses less router CPU: label switching makes traffic that only passes through a POP cheaper for its router, and Auto-TE and RouteScript now need RSVP-TE or higher. Routers only run what they support, so a POP with an older router stays outside the backbone, and mixing vendors at the very top of what their routers can do brings interop failures. Networks that already have Auto-TE keep it exactly as it is.
|
||||
- An upgraded backbone brings new customers: L3VPNs for enterprises from LDP/MPLS, flex-algo low-latency links from SR-MPLS and network slices from SRv6.
|
||||
- A seat on a consortium cable can be lit with the optics you have: add regen sites in the landing stations along the cable. Before, a seat bought at level 2 or 3 stayed dark until long-haul transponders arrived at level 4.
|
||||
- List spare capacity with a capacity broker as a standing listing: pick how many alien waves (or your spare pair) to sell, and the broker sells them off over time as carriers on that route want capacity. Each route's market is sized by the eyeballs at both ends, and a busy route sells in days while a road to nowhere sells maybe once, so renting out long empty fibers is no longer a money machine (#203).
|
||||
- Two new routers for RSVP-TE backbones: the refurbished Brocadabra MLX-16 with 400G ports, and the Extremely Networks SLX 9740 with 1.6T ports.
|
||||
- From RSVP-TE up, fast reroute has backup paths ready, so customers lose only half as much happiness while a link is cut.
|
||||
- An interop lab in the NOC tests your vendors against each other first and cuts interop incidents by 60%.
|
||||
- Four new badges for your backbone: Label switcher, Bleeding edge, Single-vendor shop and Vendor zoo.
|
||||
- The chaos monkey's notice in the NOC no longer has an Open button that did nothing; the monkey's own card is right above it (#226).
|
||||
- The puzzle list counts each section's own stars: architect runs show theirs next to their title, and the pack total now sits right above the packs, the stars that unlock the next one (#231).
|
||||
- The intern's notes now name the exchanges it peered at: a city's first exchange showed as the city, so "Apfelwein-IX, London" really meant Apfelwein-IX and LYNX (#228).
|
||||
- Cancelling an IRU, giving up your own fiber or decommissioning a POP now puts the optics on its fibers back on the spares shelf, instead of throwing them away (#229).
|
||||
- Big networks freeze for less on every game day and every click: working out where traffic goes skips exits whose route is already full, so a game day takes about 40% less time (#210). Traffic goes exactly where it went before.
|
||||
- Premium submarine terminals and Optical engineering can no longer be bought on a cable where they would change nothing (#198). The button now says so, and an upgrade that only helps together with the other one stays available.
|
||||
- A wave size that is sold out on a route can no longer be reached by upgrading a smaller wave on it (#201). The upgrade button says how long it is sold out, just like when buying.
|
||||
- Choosing Both for a PNI with one member now really splits it: the second member arrives in the other building when the augment lands, instead of joining the first (#219).
|
||||
- The Open button next to your intern's weekly shift report in the NOC now opens the Standing orders sheet, where the whole week is laid out (#226). Before, it did nothing.
|
||||
|
||||
## [2.0.0] — 2026-10-30
|
||||
|
||||
**Series of Tubes 2.0: one game, four doors.** Some of you wanted a calmer game, some a harder one, some a quick puzzle over coffee and some a playground where nothing can go wrong. So now every network starts behind a door, and the rules you pick stay with that network for good. Your saved games carry on exactly as they were.
|
||||
|
||||
**Normal** comes in three flavours. Change Freeze is the calm one: a third of the outages, no DDoS floods, and deliveries in days instead of months. On-call is the game you know. BGP at 3 a.m. is for people whose pager is a personality: more outages, longer ones, more attacks, and fiery badges to prove you survived. In your first month you also pick a charter: a global backbone, or a low-latency boutique racing the speed of light.
|
||||
|
||||
**Sandbox** is a real sandbox now: everything unlocked from day one, money that never runs out, and a chaos dial from nothing ever breaks to spicy.
|
||||
|
||||
**Puzzles** are small networks that carry real traffic, routed exactly like the big game. Deliver every flow for the first star, stay on budget for the second, and survive any single cut for the third. When your build earns a star, the chaos monkey runs round the map snipping every trench and cable to prove it. A new puzzle arrives every Sunday morning, the same for everyone.
|
||||
|
||||
**Architect runs** grow one network brief by brief. New sites sign up, some become mission-critical, a city closes, traffic outgrows its tubes, and the chaos monkey reviews every brief before the next customer signs. Three handmade runs to start, and a fresh one every Sunday with its HQ somewhere new.
|
||||
|
||||
**Scenarios** are themed crises against the clock: a cut cable, a peering spat, a flood week, a race for low latency. A new one comes out every Sunday too.
|
||||
|
||||
And in On-call and BGP at 3 a.m., a **chaos monkey** sometimes moves into your network for a few months and snips tubes on purpose, the ones without a backup path first. Outlast it without a customer noticing and it pays; throw it a banana if you have had enough.
|
||||
|
||||
**Also new:** Tier 1 works like the real thing, so peering with the big club brings their customers along. A NOC intern carries out your standing orders. Customers call when your network can serve them, not only when your level says so. You can buy a seat on a consortium subsea cable, see at a glance whether a PNI is worth it, keep several networks and play two side by side, and every router model has its own face.
|
||||
|
||||
### One game, four doors
|
||||
|
||||
- A new start screen with four doors: Puzzles, Sandbox, Normal, and Scenarios & weekly. Every network now picks its rules when it starts, and they stay locked for that network; your saved games carry on exactly as before.
|
||||
- Normal comes in three flavours. Change Freeze has a third of the outages and no DDoS floods, delivers PNIs, cross-connects and builds in days instead of months (#151), and skips hardware shortages, sold-out routes and de-peering at exchanges. On-call is the classic game. BGP at 3 a.m. brings almost twice the outages, lasting half as long again, and twice the DDoS. The HUD and the share card show which one you picked.
|
||||
- Sandbox is a real sandbox now (#188): everything is unlocked from day one, your own subsea cable included, money never runs out, deliveries are quick, and you pick how much chaos you want, from none to spicy.
|
||||
- Pick a charter in your first month of a Normal game: Global backbone (the game as you know it, and the default) or Low-latency boutique (#187). The boutique gets more trading firms, pays them 40% more and has its own win, Speed of Light: beat the fastest leased latency on three finance routes with your own glass while two latency customers pay you. It comes with a badge and shows on your share card.
|
||||
- Badges now come in variants: games under the Change Freeze rules earn frosted Freeze-dried badges, and games under BGP at 3 a.m. earn fiery ones worth bragging about. Earning a badge under harder rules than before upgrades it in your collection on this device, and the badge list counts how many of each kind you have. On-call games earn the standard badges; Sandbox and puzzles earn none.
|
||||
- Keep several networks on one device, and play two of them side by side in two browser windows. The title screen lists your networks, newest first, with their day, tier, cash and when you last played; tap one to continue it, or use ⋯ to export or delete it. Starting a scenario, the weekly challenge or a new network, or importing a save, now adds a network instead of replacing the one you have, and you can rename a network from the menu. Each window remembers its own network when you reload it. If a network is already open in another window, you can switch to it or take it over, and the other window steps aside instead of both saving over each other. Your existing save carries on as your first network.
|
||||
- A tidier start screen: language first, then your network's name, the doors, three compact difficulty buttons with the chosen one explained below, and one drop-down for your home city with the five suggested homes at the top.
|
||||
- Pick your own AS number next to your network's name when you start (#135). Leave it empty and the game picks one, and the round green arrow in the name box suggests another name.
|
||||
|
||||
### Puzzles
|
||||
|
||||
- Puzzles: small networks that carry real traffic, routed exactly like the main game (#190). Each puzzle has flows to deliver (eyeballs pulling from a content origin, circuits between two cities with a latency cap, best-effort traffic that may drop), and the map shows every link's load as it fills. Earn up to three stars: everything delivered, under budget, and still delivered when any single trench or cable is cut. Build with the real tools: link sizes from 10G to 800G, parallel links in the same trench or on a diverse route (also from the link panel), routers with real ports and limits, routing metrics, standby, lowest-latency paths for circuits, and the redundancy check. The whole world is open: any city can get a POP if it helps. Parallel links show their count and sizes, and selecting a city lights up every path it has. Eighteen puzzles in five packs, each teaching one idea: Fat Pipes, Router Rodeo, Traffic Cops, N-1 Club and Grand Tour. No clock, no bills, nothing breaks, and your main game is never touched.
|
||||
- A new weekly puzzle every Sunday morning, the same for everyone: a themed puzzle with its own traffic, such as an ocean crossing, a ring, a latency sprint, island hopping or a detour around a busy hub, with its own name and a budget tuned so three stars take a smart design. The Puzzles door says "New this Sunday!" until you have played it, the list counts down to the next one, and your streak and share line use the week's name. A new puzzle week starts on Sunday at 06:00 Berlin time; offline, the game still has a weekly puzzle of its own.
|
||||
- Every puzzle now has the chaos monkey: when your build earns a new star, it runs round the map snipping each trench and cable in turn, and the cities that lose traffic say how much. Let it loose again whenever you like, or skip straight to the stars.
|
||||
- In puzzles, the map now shows whether the tubes between two cities share one trench or take separate paths, at any zoom: one trench is drawn as a bundle with a "2× one trench" tag, separate paths bow apart with a "2 paths" tag.
|
||||
- When a new release changes prices so that this week's or a coming week's puzzle no longer adds up, that puzzle gets a fair new budget, and only its stars start again. Weeks that are over keep theirs.
|
||||
|
||||
### Architect runs
|
||||
|
||||
- Architect runs, under Puzzles: grow one network brief by brief, from a single tube to a ring that shrugs off any cut. Your build carries over between briefs, mission-critical sites must survive any single trench or cable cut with room on the detour, and a chaos monkey runs round the map snipping tubes before the next customer signs. Three runs to start: Euro Run, Coast to Coast and Pacific Rim.
|
||||
- A new Architect run every week: every Sunday a fresh HQ somewhere in the world and six or seven briefs, each built around the network you already have, with its own stars. Sites can outgrow their tubes, so some briefs are about making room. Later briefs stay a surprise in every Architect run: their cities only appear when they come.
|
||||
|
||||
### Scenarios
|
||||
|
||||
- A new weekly scenario every Sunday morning too, the same for everyone: a themed crisis such as a cut cable, a peering spat, a big event, a flood week, island hopping, a race for low latency, a push across a continent or a shoestring budget, in about a year of game days. It sits at the top of Scenarios & weekly with a countdown and a "New this Sunday!" badge, has its own goal and progress card, a par to beat, a weekly streak and a result line to share. Offline, the classic weekly challenge stands in.
|
||||
- Scenario tuning: every handmade scenario now asks for what its story is about, with shorter clocks where it was won in a tenth of the time. Mind the Gap, Cape to Cairo and Order and Progress count cities and IX.brrr ports only when your network joins them up; Fibre to the Basement also wants 500 Gbps served; in Anchors Away nobody sells transit in Tallinn and ships really do drag their anchors over the Baltic links, while the Great Firewall's losses no longer break your 99.5% streak; in the Cogentle Spat, Goggle wants a lot more of your traffic before it peers; Flood Season's terabit floods count when your scrubbing or Flowspec took them; Stepping Stones and Mid-Atlantic Accent start with 5M, enough to light the whole 1.6T chain. Gangnam Style Peering is now really about sender pays: Seoul transit carries a fee on every Gbps, the three incumbents only peer over a paid PNI, and Korean users notice every millisecond, so you win by hauling cheap Tokyo transit while keeping Seoul fast and in profit.
|
||||
|
||||
### The chaos monkey
|
||||
|
||||
- A chaos monkey now and then moves into your network in On-call and BGP at 3 a.m., and snips a tube every couple of weeks for 120 to 240 days, tubes with no backup path first. Its snips replace the usual random outages while it is here; get through the visit without a customer noticing for a resilience bonus and a new badge, or throw it a banana to send it home early. The "Met the Backhoe" badge is now "Met the Chaos Monkey", earned on its first visit; badges you already have stay yours.
|
||||
|
||||
### Build your network your way
|
||||
|
||||
- Customers now call when your network can already serve them, not only when your level says so (#187). A fast path between two finance cities brings trading firms, lit dark fiber brings AI interconnects, two diverse paths in one country bring sovereign clouds and broadband in a big city brings cloud gaming, each at its smallest size and with a note on what they spotted; your level still makes them bigger and more frequent.
|
||||
- Routers, line systems and optics one level above yours can be had early as a vendor demo unit (#187). Ask the vendor, wait about two weeks, then pay 60% over list until your level catches up; and you can dig your own dark fiber from level 2 as a pioneer, at 60% more than the level 3 price.
|
||||
- Take a seat on a new consortium subsea cable (#173). Capacity conferences offer them, and now and then a consortium calls from level 2: pay your share of the build, wait for the ship, then own one, two or four fiber pairs and light them with your own optics, your way onto your own subsea glass before Tier 1. A cut on that cable cuts your pairs too.
|
||||
- Hire a NOC intern and give them standing orders: from customer level 2, Kevin from the night shift, Anycast Annie or Tracy Route runs your rules once a game day and pays exactly what your own clicks would. Keep transit above a multiple of its peak, add or swap routers above a load, take free caches, peer at every IX and PNI with the big networks every week, sign ready customers and decline tiny ones, rush repairs, light more fiber and retire small parallel waves. Each order has a pause switch, its own settings, a monthly budget and per-POP exceptions, never breaks a customer's or a bank's transit requirement, and shows what it adds to your monthly bill. The Ops sheet opens with the intern's mood and a weekly shift report, which is also the one notice a week the intern leaves in the NOC (#98, #100, #102, #181, #185, #192, #177).
|
||||
- The intern only signs a customer after a trial run shows the network can carry them without hurting anyone else, and rushes every repair that has a price, while the budget lasts (#185). The bulk peering and PNI batches live in the Ops sheet, next to the orders that repeat them (#181, #192).
|
||||
- Open a new city from a template in one tap: POP, broadband, transit, an IX port and the redundancy kit, priced up front, with your standing orders taking it from there (#98, #192).
|
||||
- Utilities join route servers and request eligible peers across every joined IX, install missing PoP redundancy hardware and balance caches between sites, and request a cache from each eligible provider at each site. A POP's Infra tab shows the redundancy kit as one line with its price, above the rows it fills in.
|
||||
- Order PNIs with one network or every network at all shared POPs from the Ops sheet: choose a port size, review the total cost, and add missing connections or upgrade smaller ones in one go. Each network keeps its own smallest PNI size and delivery time.
|
||||
- Set the number of each optic model directly on land and subsea fiber links. Apply a whole change at once, with its total price shown before buying; removed optics return to the spares shelf.
|
||||
- Every router model has its own picture: open one of your POPs and its router sits next to the city's name.
|
||||
|
||||
### Peering and Tier 1
|
||||
|
||||
- Tier 1 now works like the real thing: peer with the Tier 1 club and their customers come along for free (#85). A PNI or an exchange session reaches the networks you peer with and everyone who buys transit from them, so you no longer chase every tiny ISP for the win; only networks that buy transit from nobody, like the content giants and the big incumbents, still need peering of their own. Small networks and more real eyeball ISPs now buy transit from real-world upstreams, a peer's customers are tried after your direct peers and before transit (so peering widely still pays), the traceroute shows the hand-off, and the Road to Tier 1 card counts who already comes along. Games already won stay won.
|
||||
- The peering inbox is gone: your peering policy now answers every peering request for you. Open accepts everyone, Selective accepts small networks on the exchange and newcomers with an up-to-date PeeringDB and quietly declines the rest, and Closed declines them all; once a week the NOC log sums it up, like "Peering desk: 7 new sessions at DE-KICKS and HAMS-IX, 3 declined (Selective)". Max-prefix alerts, the button that raised every limit at once, max-prefix outages at exchanges, your peering reputation and the Large Peering Model are gone too. The policy picker sits in the Networks tab, saved games keep their policy, and a game that hired the AI simply stops paying for it.
|
||||
- Every network in a POP's PNI list now shows how you reach it today and whether a PNI there is worth the cross-connect (#175, #172). A chip says PNI here (with size and load), PNI elsewhere, which exchanges you peer at, whose customer cone carries it, transit only or not reached; a value line shows how much of its traffic leaves from that POP over transit, exchanges or other PNIs, and what a PNI there would save or cost a month. The best candidates get a ⭐ Worth it tag, the list sorts them first, filters to All, Via transit, Worth it or Already PNI, and groups networks by type, with idle groups folded. The same chip shows in the Networks tab and in the bulk PNI preview.
|
||||
- Only Spätzle-IX now asks for 50% reach instead of 45%, since peering with the Tier 1 club brings their customers along. Two Tier 1 PNIs and the exchange are no longer quite enough (#114).
|
||||
- Every country on the map now has at least two homegrown eyeball networks. Sixty-three real consumer ISPs and mobile operators join, from Angola and Bangladesh to Iceland, Japan and Zimbabwe, each with its real AS number and a pun name. They buy transit from the big carriers, so peering with the Tier 1 club reaches them too, and saved games get the usual courtesy route to them for their first 60 days.
|
||||
- Palau's and the Marshall Islands' main networks now show their real AS numbers instead of ones borrowed from networks elsewhere.
|
||||
|
||||
### Prices, routing and money
|
||||
|
||||
- Prices now follow how connected each city really is, based on public peering and routing data. Every city on the map now has it, from Düsseldorf and Riga to Malé, the Caribbean and the Russian Arctic. Transit costs up to 1.8× more in cities where few networks are present, a POP costs 1.25× to 1.5× where there is little or no carrier-neutral data center, and countries with thousands of networks, like Brazil and the US, bring more ISP customers. Big hubs such as Frankfurt, Amsterdam, New York and São Paulo keep their prices.
|
||||
- Every city now knows its country. Long-distance waves cost double only where they cross a border inside Africa, as they always meant to; a few northern routes, such as Kristiansand to Esbjerg and Anchorage to Halifax, lose a surcharge they picked up by mistake.
|
||||
- Transit bills no longer change when you click something later in the day. After each day, the 95th percentile counted that day twice and dropped the oldest day, so building or changing anything could nudge your transit bill (and the bank's view of it) until the next day came round.
|
||||
- Links can now use a custom routing metric, set either as a multiplier or as an exact cost. Pick Custom under Routing metric to fine-tune where your traffic goes; it explains how a link's cost is worked out and what each preset comes to on that link.
|
||||
- Check a selected link’s redundancy against current demand: see disconnected endpoints, additional service loss and full fallback links without changing the live network.
|
||||
|
||||
### Attacks
|
||||
|
||||
- Attacks are more varied: sizes and lengths change from one attack to the next, and several can hit at once, each with its own controls in the NOC. Hosting game servers or cloud gaming makes attacks more frequent, as it does in real life (#153).
|
||||
- Hosting game servers or cloud gaming brings RackNet and TeamSpooked attacks. Both bypass Flowspec and require dedicated mitigation (#153).
|
||||
- Attacks can now use Memcached amplification or an ACK flood. Flowspec catches the former; the latter need mitigation (#153).
|
||||
- Game server and cloud gaming customers now carry a “Gaming attracts attacks” note on their offers and customer lists, so you can see the DDoS risk before signing them (#153).
|
||||
- Each live attack in the NOC now shows incoming bandwidth, upstream scrubbing, edge filtering, scrubbing-center use and any traffic still leaking through (#153).
|
||||
- DDoS bandwidth now adds up: upstream scrubbing, edge filters and scrubbing centers work in sequence. The NOC uses the same figures as traffic routing, including floods that cannot reach a remote center (#153).
|
||||
- Live attacks now show how much traffic Flowspec actually drops. Routers without TCAM no longer claim to filter attacks, and Flowspec drops are counted separately from other edge filters (#153).
|
||||
- Live attacks now show one scrubbing detour from the attacked city to its nearest active scrubbing center, using the links' one-way latency (#153).
|
||||
- The link traffic breakdown now shows the correct source city for scrubbing traffic. Cities using the same center no longer overwrite each other's labels (#153).
|
||||
- Flood Season keeps sending ever larger attacks when you keep playing after winning or running out of time. Finishing the challenge no longer switches the floods off (#153).
|
||||
- Flood Season escalates again: ordinary floods mixed with terabit monsters, all growing through the year, and floods go for the POPs that serve customers, so empty POPs no longer hold them for free.
|
||||
|
||||
### Smoother and safer
|
||||
|
||||
- Big networks load faster: on a phone, the map of a late-game network now appears about a second and a half sooner.
|
||||
- The Networks list shows 100 networks at a time, with a button for the rest, so it opens quickly now that every country has its own networks.
|
||||
- When your browser's storage is full, the warning now lists your other networks by size so you can export or delete one to make room. Closing the tab in the middle of a puzzle no longer loses recent progress on the network you set aside.
|
||||
- The China licence follows quick lead times: about 5 days instead of 45 under Change Freeze and in Sandbox.
|
||||
- Imported saves can no longer change a network's rules or slip HTML into a Flood Season attacker's name.
|
||||
|
||||
## [1.37.0] — 2026-10-28
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ Read these before larger changes:
|
|||
- `docs/adr/`: decisions that are settled (GitHub Pages only; one page assembled at build).
|
||||
- `.claude/skills/`: step-by-step procedures (`edit-the-game`, `github-pages`, release,
|
||||
translations, tests, performance).
|
||||
- `.claude/skills/gameplay-rules/`: the game's design rules (W1, N3, F2…), each enforced by
|
||||
`tests/gameplay-rules.test.js`; run it before changing cities, networks, cables, modes or balance.
|
||||
|
||||
## Commands
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.37.0",
|
||||
"version": "2.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.37.0",
|
||||
"version": "2.1.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"jsdom": "24.1.3",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.37.0",
|
||||
"version": "2.1.0",
|
||||
"description": "A cartoon browser game about building the internet.",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -41,8 +41,11 @@ if (process.env.REQUIRE_NOTES === '1' && notes === '[]') die(`CHANGELOG.md has n
|
|||
const page = path.join(OUT, 'index.html'), PH = '/*__RELEASE_NOTES__*/[]', html = fs.readFileSync(page, 'utf8');
|
||||
if (!html.includes(PH)) die('release-notes placeholder missing from the page');
|
||||
// Function replacer: no $& / $$ expansion. Escape "<" so a note can never close the <script>.
|
||||
fs.writeFileSync(page, html.replace(PH, () => notes.replace(/</g, '\\u003c')));
|
||||
fs.writeFileSync(path.join(OUT, 'version.json'), JSON.stringify({ version: VERSION, date: BUILD_DATE, notes: JSON.parse(notes) }, null, 2) + '\n');
|
||||
// A release can also open with a story (prose before its first bullet), shown in full in "What's new".
|
||||
const story = execFileSync(process.execPath, [path.join(__dirname, 'release-notes.js'), VERSION, '--story'], { encoding: 'utf8' }), PS = '/*__RELEASE_STORY__*/[]';
|
||||
if (!html.includes(PS)) die('release-story placeholder missing from the page');
|
||||
fs.writeFileSync(page, html.replace(PH, () => notes.replace(/</g, '\\u003c')).replace(PS, () => story.replace(/</g, '\\u003c')));
|
||||
fs.writeFileSync(path.join(OUT, 'version.json'), JSON.stringify({ version: VERSION, date: BUILD_DATE, notes: JSON.parse(notes), story: JSON.parse(story) }, null, 2) + '\n');
|
||||
|
||||
// Nothing may ship half-stamped.
|
||||
const left = [];
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
// static markup, in the inlined English and in every translation file, and the page ends up about the
|
||||
// size it was when the English text itself was the key.
|
||||
//
|
||||
// Labels passed to N_() are kept whole: those are the ones the game stores (in saves, in the inbox log)
|
||||
// Labels passed to N_() are kept whole: those are the ones the game stores (in saves)
|
||||
// and shows later, and an id would mean something else in the next release.
|
||||
const { CALL } = require('../legacy/labels');
|
||||
const D = require('./dict');
|
||||
|
|
|
|||
89
scripts/lib/puzzle-solver.js
Normal file
89
scripts/lib/puzzle-solver.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
// Puzzle tools (the weekly generator, the puzzle tests): build a puzzle network straight into a headless game, judge
|
||||
// it with the game's own star code, and search for the cheapest build that earns three stars.
|
||||
//
|
||||
// A build is a list of links [a, b, via, tier, same]: via is 'land' or a cable id, tier an index into LT, and `same`
|
||||
// (k > 0) puts an overland link in the k-th trench already on that pair (otherwise a further one takes a diverse
|
||||
// route, +40%). Routers
|
||||
// are not part of the search: each POP gets the cheapest models that carry its busiest moment (across every single
|
||||
// cut), its ports and its biggest wave, which is what any sensible player would buy for that build.
|
||||
|
||||
// Runs inside the page.
|
||||
function page() {
|
||||
window.pzsReset = () => { S.pops = {}; S.links = []; S.pairMet = {}; for (const b of S.biz) b.route = 'normal'; UI.pzEv = null; };
|
||||
window.pzsLink = (a, b, via, tier, same) => {
|
||||
const r = pzRoutes(a, b).find((x) => x.via === via); if (!r) throw new Error(`no route ${via} for ${a}-${b}`);
|
||||
for (const c of [a, b]) if (!S.pops[c]) S.pops[c] = pzNewPop(c);
|
||||
// `same` k > 0: in the k-th overland trench on this pair; 0: a trench of its own (diverse, unless it is the first).
|
||||
const tr = !r.sub ? [...new Set(S.links.filter((l) => edgeKey(l) === edgeKey({ a, b }) && !l.cable).map((l) => l.trench))] : [], sm = same && tr[same - 1], div = !!(tr.length && sm !== tr[0]), id = uid();
|
||||
S.links.push({ id, a, b, kind: 'wave', border: false, premium: false, tier, km: r.km, sub: r.sub, cable: r.cab, mo: pzMo(r, tier, div), mult: r.f * (div ? DIVERSE : 1), trench: r.cab ? 'cab:' + r.cab : sm || id, cut: 0, day: 0 });
|
||||
};
|
||||
// The cheapest routers for POP c: enough ports, a model that lights its biggest wave, and capacity for its peak.
|
||||
window.pzsRouters = (c, peak) => {
|
||||
const used = portsUsed(c), lt = Math.max(0, ...S.links.filter((l) => l.a === c || l.b === c).map((l) => l.tier)); let best = null;
|
||||
for (const g of PZ_RG) for (let rt = 1; rt <= 6; rt++) { const M = RG[g]; if (M.maxLT < lt || M.ports * rt < used - 1e-9 || M.cap * rt < peak - 1e-6) continue;
|
||||
const cost = pzRtCost(g, rt); if (!best || cost < best.cost) best = { g, rt, cost }; }
|
||||
return best;
|
||||
};
|
||||
// Judge the build on routers big enough for anything, then price the routers it really needs. With those, routing
|
||||
// is the same (no router is ever full), so the stars are too.
|
||||
window.pzsJudge = () => {
|
||||
const BIG = RG.findIndex((r) => r.n === 'Arrrhipster 7800R'), keep = {};
|
||||
for (const c in S.pops) { keep[c] = [S.pops[c].rgen, S.pops[c].routers]; S.pops[c].rgen = BIG; S.pops[c].routers = 1; }
|
||||
UI.pzEv = null; const b0 = S.pz.budget; S.pz.budget = 0; const e = pzEval(); S.pz.budget = b0; UI.pzEv = null;
|
||||
const rt = {}; let spend = 0, bad = false;
|
||||
for (const c in S.pops) { const r = pzsRouters(c, e.peak[c] || 0); if (!r) { bad = true; continue; } rt[c] = [r.g, r.rt]; spend += r.cost + pzPopCost(c); S.pops[c].rgen = keep[c][0]; S.pops[c].routers = keep[c][1]; }
|
||||
for (const l of S.links) spend += l.mo * PZ_YEAR;
|
||||
return { one: e.goal && !bad, three: e.goal && e.n1 && !bad, spend, rt };
|
||||
};
|
||||
window.pzsApplyRt = (rt) => { for (const c in rt) { S.pops[c].rgen = rt[c][0]; S.pops[c].routers = rt[c][1]; } UI.pzEv = null; };
|
||||
}
|
||||
const install = (ev) => { if (ev("typeof pzsJudge!=='function'")) ev(`(${page.toString()})()`); };
|
||||
|
||||
const key = (L) => JSON.stringify(L);
|
||||
// Steps that are not links set what a player sets in the panels: ['@route', flow, 'fast'] a circuit's path,
|
||||
// ['@met', a, b, 'avoid'] a pair's metric. The search keeps them as they are.
|
||||
const step = ([a, b, v, t, s]) => a === '@route' ? `S.biz.find(x=>x.id===pzFlowId(${b})).route='${v}';` : a === '@met' ? `(S.pairMet=S.pairMet||{})[edgeKey({a:'${b}',b:'${v}'})]='${t}';`
|
||||
: `pzsLink('${a}','${b}','${v}',${t},${s || 0});`;
|
||||
function judge(ev, L) {
|
||||
return JSON.parse(ev(`pzsReset();${L.map(step).join('')}JSON.stringify(pzsJudge())`));
|
||||
}
|
||||
// Every link option between the given cities: each route, at tiers up to maxTier.
|
||||
function options(ev, cities, maxTier, noSub) {
|
||||
const out = [];
|
||||
for (let i = 0; i < cities.length; i++) for (let j = i + 1; j < cities.length; j++) {
|
||||
const [a, b] = [cities[i], cities[j]];
|
||||
const rs = JSON.parse(ev(`JSON.stringify(pzRoutes('${a}','${b}').map(r=>({via:r.via,sub:r.sub,ok:[0,1,2,3].map(t=>!subWaveWhy(t,r.km,r.sub))})))`));
|
||||
for (const r of rs) { if (noSub && r.sub) continue; for (let t = 0; t <= maxTier; t++) if (r.ok[t]) { out.push([a, b, r.via, t, 0]); if (!r.sub) { out.push([a, b, r.via, t, 1]); out.push([a, b, r.via, t, 2]); } } }
|
||||
}
|
||||
return out;
|
||||
}
|
||||
// Local search from a 3-star build: drop a link, shrink one, move one to another route, put it in the first trench
|
||||
// or out of it, or swap one link for another option, while it is cheaper and still three stars.
|
||||
function improve(ev, start, opts = {}) {
|
||||
const memo = new Map(), J = (L) => { const k = key(L); if (!memo.has(k)) memo.set(k, judge(ev, L)); return memo.get(k); };
|
||||
let cur = start.map((x) => x.slice()), cj = J(cur);
|
||||
if (!cj.three) throw new Error('the starting build does not earn three stars');
|
||||
const routes = {}, via = (a, b) => { const k = a < b ? a + '|' + b : b + '|' + a; if (!routes[k]) routes[k] = JSON.parse(ev(`JSON.stringify(pzRoutes('${a}','${b}').map(r=>r.via))`)); return routes[k]; };
|
||||
const opt = opts.options || [];
|
||||
for (let round = 0; round < 60; round++) {
|
||||
const nb = [];
|
||||
for (let i = 0; i < cur.length; i++) {
|
||||
const w = (x) => { const L = cur.slice(); L[i] = x; return L; }, [a, b, v, t, s] = cur[i];
|
||||
if (a[0] === '@') continue;
|
||||
nb.push(cur.filter((_, k) => k !== i));
|
||||
if (t > 0) nb.push(w([a, b, v, t - 1, s]));
|
||||
for (const v2 of via(a, b)) if (v2 !== v) nb.push(w([a, b, v2, t, 0]));
|
||||
if (v === 'land') for (const s2 of [0, 1, 2]) if (s2 !== (s || 0)) nb.push(w([a, b, v, t, s2]));
|
||||
}
|
||||
if (opts.swap) for (const o of opt) for (let i = 0; i < cur.length; i++) { if (cur[i][0][0] === '@') continue; const L = cur.slice(); L[i] = o; nb.push(L); }
|
||||
let best = null;
|
||||
for (const L of nb) { const j = J(L); if (j.three && j.spend < cj.spend - 1 && (!best || j.spend < best.j.spend)) best = { L, j }; }
|
||||
if (!best && opts.add) for (const o of opt) for (let i = 0; i < cur.length; i++) for (let k = i + 1; k < cur.length; k++) {
|
||||
if (cur[i][0][0] === '@' || cur[k][0][0] === '@') continue;
|
||||
const L = [...cur.filter((_, x) => x !== i && x !== k), o], j = J(L); if (j.three && j.spend < cj.spend - 1 && (!best || j.spend < best.j.spend)) best = { L, j }; }
|
||||
if (!best) break;
|
||||
cur = best.L; cj = best.j;
|
||||
}
|
||||
return { links: cur, ...cj };
|
||||
}
|
||||
module.exports = { install, judge, options, improve };
|
||||
53
scripts/lib/scenario-bot.js
Normal file
53
scripts/lib/scenario-bot.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// The reference player for weekly scenarios (scripts/weekly-scenario.js). It plays inside the real game, headless,
|
||||
// through the game's own actions (ACT.*, openLinkModal + buildLink), as a careful human would: broadband, transit and
|
||||
// an exchange port at home on day 0, a NOC intern on standing orders for transit and routers, then the generator's
|
||||
// plan one step at a time whenever the bank allows it, upgrading any wave that runs hot. It never reads the goal, so the
|
||||
// same seed and plan always play the same game, and the generator can calibrate a goal from what it reached.
|
||||
const BOT = String.raw`(()=>{
|
||||
const B=window.__wsBot={};
|
||||
const cheapNet=(c,avoid)=>NETS.filter(n=>n.price&&sellsAt(n,c)&&!avoid.includes(n.id)&&!S.transit.some(t=>t.city===c&&t.net===n.id)).sort((a,b)=>a.price*netMult(a,c)-b.price*netMult(b,c))[0];
|
||||
const reserve=()=>Math.max(60000,1.5*(R.costMo||0));
|
||||
const can=x=>S.cash>=x+reserve();
|
||||
const quiet=f=>{const t=window.toast;window.toast=()=>{};try{f();}finally{window.toast=t;}};
|
||||
function link(a,b,tier,via){UI.via=via||null;UI.route=null;openLinkModal(a,b);ACT.buildLink({tier});closeModal();return S.links.some(l=>(l.a===a&&l.b===b)||(l.a===b&&l.b===a));}
|
||||
function ix(c){if(!S.pops[c])return;for(const x of (B.plan&&B.plan.allIx?ixIdsIn(c):[c])){if(!ixName(x)||S.ixp[x]!==undefined)continue;ACT.buyIx({city:x,tier:1,signed:true});if(S.ixp[x]!==undefined&&!S.rs[x])ACT.rs({city:x});}}
|
||||
// Before a big event: transit enough for the event on top of the usual peak, and routers that can take it.
|
||||
function prep(E){const c=E.city,need=(S.stats.peak||R.served||0)*1.2+E.g*1.15;let cap=()=>S.transit.filter(t=>t.city===c).reduce((a,t)=>a+PORT[t.tier].g*(t.n||1),0);
|
||||
for(let k=0;k<12&&cap()<need;k++){const t=S.transit.filter(t=>t.city===c).sort((a,b)=>PORT[a.tier].g*(a.n||1)-PORT[b.tier].g*(b.n||1))[0];if(!t)break;const c0=cap();
|
||||
if(t.tier<PORT.length-1&&PORT[t.tier+1].g>=need/4&&portOk(c,t.tier+1))ACT.buyTransit({city:c,net:t.net,tier:t.tier+1});else ACT.lagT({id:t.id,d:1});if(cap()===c0)break;}
|
||||
for(let k=0;k<4;k++){const p=S.pops[c];if(!p||(p.routers||1)>=RMAX)break;const r0=p.routers||1;ACT.addRouter({city:c});if((p.routers||1)===r0)break;}}
|
||||
B.start=(plan)=>{B.plan=plan;B.i=0;const c=S.scn.home||plan.home;quiet(()=>{
|
||||
ACT.launchBB({city:c});
|
||||
if(!scnRule('noTransit')){const n=cheapNet(c,plan.avoid||[]);if(n)ACT.buyTransit({city:c,net:n.id,tier:1});if(plan.tr2){const m=cheapNet(c,plan.avoid||[]);if(m)ACT.buyTransit({city:c,net:m.id,tier:1});}}
|
||||
ix(c);if(plan.scrub)ACT.buildScrub({city:c,tier:plan.scrub});});};
|
||||
B.day=()=>{const P=B.plan,d=S.day;if(!P)return;quiet(()=>{
|
||||
// A month in, with the first bills paid: the intern keeps transit and routers ahead of the traffic.
|
||||
if(d===30&&opsCanHire()&&!opsHired()&&rule('clock')){ACT.opsHire({id:'kevin'});closeModal();if(opsHired())for(const k of ['transit','routers','repair'])if(!S.ops.on[k])ACT.opsToggle({k});closeModal();}
|
||||
if(d%7===0)for(const l of S.links){if(l.kind!=='wave'||l.tier>=LT.length-1||(R.load[l.id]||0)<LT[l.tier].g*0.7)continue;const nm=Math.round(waveMo(l.km,l.sub,l.tier+1)*(l.mult||1));if(can(nm))ACT.upLink({id:l.id,tier:l.tier+1});}
|
||||
if(P.event&&d>=P.event.day-21&&d<P.event.day&&d%7===0)prep(P.event);
|
||||
const s=P.steps[B.i];if(!s)return;
|
||||
if(s.k==='hop'){const [a,b,t,via]=s.v;if(!S.pops[a])return;const est=(S.pops[b]?0:popCost(b))+waveMo(kmBetween(a,b),isSub(a,b),t)*2+(P.bb?bbCost(b):0);if(!can(est))return;
|
||||
// Big waves need big routers at both ends: the POP first, then the routers, then the wave.
|
||||
if(!waveOk(a,b,t)){if(!S.pops[b])ACT.buildPop({city:b});for(const c of [a,b])for(let k=0;k<4&&S.pops[c]&&!waveOk(a,b,t);k++){const g0=S.pops[c].rgen||0;ACT.upRouter({city:c});if((S.pops[c].rgen||0)===g0)break;}}
|
||||
if(!link(a,b,t,via)){B.i++;return;}if(P.bb&&!S.pops[b].bb)ACT.launchBB({city:b});if(P.ix)ix(b);B.i++;}
|
||||
else if(s.k==='ix'){if(can(30000)){ix(s.v);B.i++;}}
|
||||
else if(s.k==='tr'){if(can(40000)&&!scnRule('noTransit')){const n=cheapNet(s.v,P.avoid||[]);if(n)ACT.buyTransit({city:s.v,net:n.id,tier:1});B.i++;}}
|
||||
else B.i++;});};
|
||||
})()`;
|
||||
|
||||
const install = (ev) => { if (!ev('!!window.__wsBot')) ev(BOT); };
|
||||
|
||||
// Plays a weekly scenario file from day 0: the plan steps once a day, until the goal is met (when stop) or the days
|
||||
// run out. Returns the day the goal was first met (or null), what the goal measure read each day, and the end state.
|
||||
function play(ev, file, plan, { days, stop = true, measure = 'wsMeasure()' } = {}) {
|
||||
install(ev);
|
||||
ev(`localStorage.removeItem('sot-wkscn');wsBegin(${JSON.stringify(file)},'Ref');if(UI.pendGame)ACT.pitchSkip();UI.speed=0;closeModal()`);
|
||||
if (ev('!!(S.scn&&S.scn.wk)') !== true) throw new Error('the game would not start this scenario');
|
||||
ev(`__wsBot.start(${JSON.stringify(plan)})`);
|
||||
const won0 = ev('wsOk()'), n = days || ev('S.scn.days');
|
||||
// Each day: the bot moves, the day ticks (scnTick records a win), and we note the measure.
|
||||
const out = JSON.parse(ev(`(()=>{const m=[];let won=null;for(let i=0;i<${n};i++){__wsBot.day();dayTick();closeModal();m.push(+(${measure}).toFixed(3));if(won===null&&S.scn.done)won=S.scn.done;if(won!==null&&${stop})break;if(S.lost)break;}return JSON.stringify({won,m,lost:!!S.lost,day:S.day,cash:Math.round(S.cash)});})()`));
|
||||
return { won0, ...out };
|
||||
}
|
||||
|
||||
module.exports = { BOT, install, play };
|
||||
75
scripts/lib/scenario-ref.js
Normal file
75
scripts/lib/scenario-ref.js
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// The reference player for the handmade scenarios (tests/scenarios-playtest.test.js), the sibling of scenario-bot.js
|
||||
// (which plays the weekly ones). It plays inside the real game, headless, through the game's own actions, one plan
|
||||
// step at a time whenever the bank allows it, plus the upkeep a careful human does every week: hot waves a size up, hot
|
||||
// transit and exchange ports a LAG member, new peers at every exchange, routers before they fill.
|
||||
//
|
||||
// A plan is a list of steps, each [op, ...args]:
|
||||
// ['bb', c] POP and broadband ['tr', c, tier] the cheapest transit there ['ix', c, tier] every exchange
|
||||
// ['pop', c] a POP only ['link', a, b, tier, cable] a wave (routers upgraded first, a swap a day)
|
||||
// ['hire', orders, params] the NOC intern on standing orders, as soon as the level allows
|
||||
// ['wait', day] until that day ['served', g] until g Gbps are served ['prep', c, g] capacity for an event
|
||||
// ['scrub', c, tier] a scrubbing center ['pnis'] a PNI with every unreached network that takes one
|
||||
// ['pni', c, net, tier] one PNI with that network there ['last', c] transit there only as a last resort
|
||||
// ['loans'] take every loan the banks offer, from now on (the cheese plans)
|
||||
const REF = String.raw`(()=>{
|
||||
const Q=window.__ref={log:[]};
|
||||
const quiet=f=>{const t=window.toast;window.toast=()=>{};try{return f();}finally{window.toast=t;}};
|
||||
Q.reserve=()=>Math.max(40000,1.3*(R.costMo||0));
|
||||
Q.can=x=>S.cash>=x+Q.reserve();
|
||||
Q.cheap=c=>NETS.filter(n=>n.price&&sellsAt(n,c)&&!(Q.avoid||[]).includes(n.id)&&!S.transit.some(t=>t.city===c&&t.net===n.id)).sort((a,b)=>a.price*netMult(a,c)-b.price*netMult(b,c))[0];
|
||||
Q.pop=c=>{if(!S.pops[c])ACT.buildPop({city:c});return !!S.pops[c];};
|
||||
Q.bb=c=>{Q.pop(c);if(S.pops[c]&&!S.pops[c].bb)ACT.launchBB({city:c});return !!(S.pops[c]&&S.pops[c].bb);};
|
||||
Q.tr=(c,tier=1)=>{Q.pop(c);const n=Q.cheap(c);if(!n)return true;ACT.buyTransit({city:c,net:n.id,tier});return true;};
|
||||
Q.last=c=>{for(const t of S.transit)if(t.city===c)ACT.setPref({kind:'t',id:t.id,v:'low'});return true;};
|
||||
Q.ix=(c,tier=1)=>{if(!S.pops[c])return false;for(const x of ixIdsIn(c)){if(!ixName(x))continue;if(S.ixp[x]===undefined)ACT.buyIx({city:x,tier,signed:true});if(S.ixp[x]===undefined)continue;if(!S.rs[x])ACT.rs({city:x});ACT.peerAll({city:x});}return true;};
|
||||
// A wave: big waves need big routers at both ends, and a router swap takes a day, so the step waits (null) until they fit.
|
||||
Q.link=(a,b,tier=1,via)=>{for(const c of [a,b])Q.pop(c);if(!S.pops[a]||!S.pops[b])return false;
|
||||
for(const c of [a,b])for(let k=0;k<4&&!waveOk(a,b,tier);k++){const g0=S.pops[c].rgen||0;ACT.upRouter({city:c});if((S.pops[c].rgen||0)===g0)break;}
|
||||
if(!waveOk(a,b,tier))return null;const n0=S.links.length;UI.via=via||null;UI.route=null;openLinkModal(a,b);ACT.buildLink({tier});closeModal();return S.links.length>n0;};
|
||||
Q.hire=(orders,par)=>{Q.wantHire=[orders||['transit','routers','repair'],par||{}];return true;};
|
||||
Q.hire0=(orders,par)=>{if(!opsCanHire()||!Q.can(20000))return false;if(!opsHired()){ACT.opsHire({id:'kevin'});closeModal();}if(!opsHired())return false;
|
||||
for(const k of orders)if(!S.ops.on[k])ACT.opsToggle({k});for(const k in par)for(const [p,v] of Object.entries(par[k]))for(let i=0;i<8&&opsP(k,p)!==v;i++)ACT.opsParam({k,p});closeModal();return true;};
|
||||
Q.pnis=(tier=0)=>{for(const n of NETS.filter(n=>!R.reachable[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id])){const b=pniBatch(n.id,tier);if(!b||!b.orders.length||!Q.can(b.cost))continue;ACT.pniAll({net:n.id,tier});}return true;};
|
||||
Q.pni=(c,net,tier=0)=>{if(!S.pni.some(p=>p.city===c&&p.net===net))ACT.pni({city:c,net,tier});closeModal();return S.pni.some(p=>p.city===c&&p.net===net);};
|
||||
Q.scrub=(c,tier=0)=>{ACT.buildScrub({city:c,tier});return true;};
|
||||
Q.loans=()=>{Q.loan=true;return true;};
|
||||
Q.served=g=>R.served>=g||null;
|
||||
Q.wait=d=>S.day>=d||null;
|
||||
// Before an event: transit for the event on top of the usual peak, and routers that can take it.
|
||||
Q.prep=(c,g)=>{const need=(S.stats.peak||R.served||0)*1.2+g*1.15,cap=()=>S.transit.filter(t=>t.city===c).reduce((a,t)=>a+PORT[t.tier].g*(t.n||1),0);
|
||||
for(let k=0;k<12&&cap()<need;k++){const t=S.transit.filter(t=>t.city===c).sort((a,b)=>PORT[a.tier].g*(a.n||1)-PORT[b.tier].g*(b.n||1))[0];if(!t)break;const c0=cap();
|
||||
if(t.tier<PORT.length-1&&PORT[t.tier+1].g>=need/4&&portOk(c,t.tier+1))ACT.buyTransit({city:c,net:t.net,tier:t.tier+1});else ACT.lagT({id:t.id,d:1});
|
||||
if(cap()===c0){if(t.tier<PORT.length-1&&!portOk(c,t.tier+1))ACT.upRouter({city:c});else break;}}
|
||||
for(let k=0;k<4;k++){const p=S.pops[c];if(!p||(p.routers||1)>=RMAX)break;const r0=p.routers||1;ACT.addRouter({city:c});if((p.routers||1)===r0)break;}return true;};
|
||||
Q.est={pop:c=>S.pops[c]?0:popCost(c),bb:c=>(S.pops[c]?0:popCost(c))+bbCost(c),tr:()=>20000,pni:()=>20000,ix:()=>25000,hire:()=>0,scrub:(c,t)=>SCRUB_TIERS[t||0].cost,
|
||||
link:(a,b,t)=>(S.pops[a]?0:popCost(a))+(S.pops[b]?0:popCost(b))+waveMo(kmBetween(a,b),isSub(a,b),t)*2+20000};
|
||||
Q.upkeep=()=>{
|
||||
for(const l of S.links){if(l.kind!=='wave'||l.tier>=LT.length-1||linkDown(l)||(R.load[l.id]||0)<LT[l.tier].g*0.75)continue;
|
||||
if(!waveOk(l.a,l.b,l.tier+1))for(const c of [l.a,l.b])if(!waveOk(l.a,l.b,l.tier+1)&&Q.can(80000))ACT.upRouter({city:c});
|
||||
if(Q.can(Math.round(waveMo(l.km,l.sub,l.tier+1)*(l.mult||1))*2))ACT.upLink({id:l.id,tier:l.tier+1});}
|
||||
for(const x in S.ixp)if(!(S.myIx&&S.myIx[x]))ACT.peerAll({city:x});
|
||||
if(!(opsHired()&&S.ops.on.transit))for(const t of S.transit.slice()){const u=(R.useT&&R.useT[t.id])||0,cap=lagCap(PORT[t.tier].g,t.n);if(u<cap*0.75)continue;
|
||||
if((t.n||1)<2||t.tier>=PORT.length-1||!portOk(t.city,t.tier+1)){if(Q.can(PORT[t.tier].setup+20000))ACT.lagT({id:t.id,d:1});if(lagCap(PORT[t.tier].g,t.n)===cap&&Q.can(80000))ACT.upRouter({city:t.city});}
|
||||
else if(Q.can(PORT[t.tier+1].setup+30000))ACT.buyTransit({city:t.city,net:t.net,tier:t.tier+1});}
|
||||
for(const x in S.ixp){if(S.myIx&&S.myIx[x])continue;const u=(R.useIx&&R.useIx[x])||0;if(u>=lagCap(PORT[S.ixp[x]].g,(S.ixn||{})[x])*0.75&&Q.can(30000))ACT.lagIx({city:x,d:1});}
|
||||
if(!(opsHired()&&S.ops.on.routers))for(const c in S.pops){if((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1)>0.8&&Q.can(80000)){if((S.pops[c].routers||1)<2)ACT.addRouter({city:c});else ACT.upRouter({city:c});}}};
|
||||
Q.step=()=>{for(let k=0;k<6;k++){const s=Q.steps[Q.i];if(!s)return;const [op,...a]=s;
|
||||
if(Q.est[op]&&!Q.can(Q.est[op](...a)))return;const ok=Q[op](...a);if(ok===null)return;Q.log.push(S.day+' '+op+' '+a.join(',')+(ok?'':' (failed)'));Q.i++;}};
|
||||
Q.day=()=>quiet(()=>{if(Q.wantHire&&Q.hire0(...Q.wantHire)){Q.log.push(S.day+' hired');Q.wantHire=null;}
|
||||
if(Q.loan)for(const o of (S.loanOffers||[]).slice())ACT.takeLoan({id:o.id});closeModal();
|
||||
Q.step();if(S.day%7===0)Q.upkeep();});
|
||||
Q.start=(steps,o={})=>quiet(()=>{Q.steps=steps;Q.i=0;Q.avoid=o.avoid||[];Q.step();});
|
||||
})()`;
|
||||
|
||||
// Starts scenario `id` (with `seed`, or its own), plays `plan` for up to `days` days (default: the scenario's), and
|
||||
// returns the day it was won (or null), whether the network went broke, and the end state.
|
||||
function play(ev, id, plan, { seed, days, avoid } = {}) {
|
||||
ev(`localStorage.removeItem('sot-scn');beginGame('Ref',SCN.find(x=>x.id==='${id}').city,{scn:SCN.find(x=>x.id==='${id}')${seed ? ',seed:' + seed : ''}});if(UI.pendGame)ACT.pitchSkip();UI.speed=0;closeModal()`);
|
||||
if (ev('typeof __ref') === 'undefined') ev(REF);
|
||||
ev(`__ref.start(${JSON.stringify(plan)},${JSON.stringify({ avoid })})`);
|
||||
const n = days || ev('S.scn.days');
|
||||
return JSON.parse(ev(`(()=>{let won=null;for(let i=0;i<${n};i++){__ref.day();dayTick();closeModal();if(S.scn.done){won=S.scn.done;break;}if(S.lost||S.scn.failed)break;}
|
||||
return JSON.stringify({won,lost:!!S.lost,day:S.day,limit:S.scn.days,cash:Math.round(S.cash),served:Math.round(R.served)});})()`));
|
||||
}
|
||||
|
||||
module.exports = { REF, play };
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
#!/usr/bin/env node
|
||||
// Prints the CHANGELOG.md bullets for one version as a JSON array of strings.
|
||||
// Usage: node scripts/release-notes.js 1.2.0
|
||||
// node scripts/release-notes.js 2.0.0 --story the release's story instead: the paragraphs of prose between
|
||||
// its heading and its first bullet or ### heading (often none)
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const version = process.argv[2];
|
||||
const version = process.argv[2], story = process.argv.includes('--story');
|
||||
const text = fs.readFileSync(path.join(__dirname, '..', 'CHANGELOG.md'), 'utf8');
|
||||
const lines = text.split('\n');
|
||||
const start = lines.findIndex((l) => l.startsWith(`## [${version}]`));
|
||||
|
|
@ -16,4 +18,15 @@ if (start >= 0) {
|
|||
else if (/^\s{2,}\S/.test(l) && notes.length) notes[notes.length - 1] += ' ' + l.trim();
|
||||
}
|
||||
}
|
||||
process.stdout.write(JSON.stringify(notes));
|
||||
if (story) {
|
||||
const paras = [];
|
||||
if (start >= 0) {
|
||||
let cur = [];
|
||||
for (let i = start + 1; i < lines.length && !lines[i].startsWith('## [') && !/^\s*-\s+/.test(lines[i]) && !lines[i].startsWith('###'); i++) {
|
||||
const l = lines[i].trim();
|
||||
if (l) cur.push(l); else if (cur.length) { paras.push(cur.join(' ')); cur = []; }
|
||||
}
|
||||
if (cur.length) paras.push(cur.join(' '));
|
||||
}
|
||||
process.stdout.write(JSON.stringify(paras));
|
||||
} else process.stdout.write(JSON.stringify(notes));
|
||||
|
|
|
|||
241
scripts/weekly-architect.js
Normal file
241
scripts/weekly-architect.js
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
#!/usr/bin/env node
|
||||
// The weekly Architect run generator, the twin of scripts/weekly-puzzle.js. Every Sunday .github/workflows/weekly-puzzle.yml
|
||||
// runs it to publish site/architect/weekly/<key>.json, which the game fetches when Puzzles opens
|
||||
// (src/game/60-features/98-architect-weekly.js). It plays the real game headless, so the briefs are judged by the game's
|
||||
// own checklist and chaos monkey review.
|
||||
//
|
||||
// node scripts/weekly-architect.js the week starting on the coming (or current) Sunday 06:00 Berlin, if missing
|
||||
// node scripts/weekly-architect.js --key 2026-W45 that week (--force replaces an existing file)
|
||||
// node scripts/weekly-architect.js --next 3 this week and the next two
|
||||
// node scripts/weekly-architect.js --check re-play every week not over yet; one whose reference no longer
|
||||
// earns three stars is regenerated with rev + 1; then validate every file
|
||||
// --page FILE / --dir DIR another build of the game / where the files live
|
||||
//
|
||||
// How a run is made: an HQ in a region the last weeks did not have, and its nearest cities as the sites to come. Then a
|
||||
// reference architect plays it brief by brief, and each brief is designed against the network it has built so far, so
|
||||
// every brief asks for something new: a site to connect, a site that one cut would strand made mission-critical, a ring
|
||||
// it does not have yet, a latency cap its paths miss, a site that closes. The reference builds the cheapest fix it finds
|
||||
// (connect to the nearest POP; for a site a cut strands, the cheapest tube from the stranded side to the rest on another
|
||||
// trench or cable) until the game's review passes. Its tube count is the brief's plan, its spend plus a little the
|
||||
// budget, and the whole run is then replayed from the file and must earn three stars.
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { game, world } = require('./weekly-puzzle');
|
||||
|
||||
const ROOT = path.join(__dirname, '..');
|
||||
const SCHEMA = 1, HISTORY = 4, ATTEMPTS = 40, DEM_MAX = 380;
|
||||
const NAMES = ['architect_weekly.name_all_roads_lead_to_hq', 'architect_weekly.name_the_hq_job', 'architect_weekly.name_hq_and_friends'];
|
||||
const JOKES = ['architect_weekly.joke_hq_signed_the_lease', 'architect_weekly.joke_one_network_a_handful'];
|
||||
|
||||
const hash = (s) => { let h = 2166136261; for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619); } return h >>> 0; };
|
||||
function rng(seed) { let a = seed >>> 0 || 1; return () => { a = (a + 0x6D2B79F5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; }
|
||||
const pick = (r, a) => a[Math.floor(r() * a.length)];
|
||||
const shuffle = (r, a) => { a = a.slice(); for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(r() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; };
|
||||
const ceil10k = (x) => Math.ceil(x / 10000) * 10000;
|
||||
const list = (dir) => (fs.existsSync(dir) ? fs.readdirSync(dir).filter((f) => /^\d{4}-W\d{2}\.json$/.test(f)).map((f) => f.slice(0, -5)).sort() : []);
|
||||
const J = (ev, code) => JSON.parse(ev(`JSON.stringify(${code})`));
|
||||
|
||||
// ---------- playing the game ----------
|
||||
// Load a run definition into the page as this week's, with the briefs known so far.
|
||||
function stage(ev, key, hq, briefs) {
|
||||
ev(`UI.arWk={key:'${key}',def:{id:arWkId('${key}'),key:'${key}',wk:true,n:'',j:'',hq:'${hq}',via:[],budget:2e7,briefs:${JSON.stringify(briefs)},rev:1},at:Date.now()}`);
|
||||
}
|
||||
// Lay one tube the way a player does: a diverse trench when the pair already has one overland. The size is what all
|
||||
// the traffic needs (100G, or 400G once there is more than 100G), smaller where a long cable cannot take it.
|
||||
const tierFor = (ev) => (ev('S.pz.cities.reduce((a,c)=>a+(c===S.ar.hq?0:arDem(c)),0)') > 100 ? 2 : 1);
|
||||
function lay(ev, a, b, via, tier) {
|
||||
if (!ev(`!!S.pops['${a}']`)) [a, b] = [b, a];
|
||||
const n = ev('S.links.length');
|
||||
for (let t = tier == null ? tierFor(ev) : tier; t >= 0; t--) {
|
||||
ev(`ACT.pzLinkTo({a:'${a}',b:'${b}'});ACT.pzVia({v:'${via}'});ACT.pzDiv({v:1});ACT.pzLink({tier:${t}});closeModal()`);
|
||||
if (ev('S.links.length') === n + 1) return [a, b, via, t];
|
||||
if (tier != null) break;
|
||||
}
|
||||
throw new Error(`could not lay ${a}-${b} ${via}`);
|
||||
}
|
||||
// One step of a reference, as the file keeps it: a tube [a, b, route, size], ['@rm', city] closing a POP, or
|
||||
// ['@tier', n, size] resizing the n-th tube.
|
||||
function step(ev, s) {
|
||||
if (s[0] === '@rm') { ev(`ACT.pzRmPop({city:'${s[1]}'})`); return; }
|
||||
if (s[0] === '@tier') { const n = ev(`(()=>{const l=S.links[${s[1]}];ACT.pzTier({id:l.id,tier:${s[2]}});return S.links[${s[1]}].tier;})()`); if (n !== s[2]) throw new Error(`could not resize tube ${s[1]}`); return; }
|
||||
lay(ev, s[0], s[1], s[2], s[3]);
|
||||
}
|
||||
// Room for the traffic: upsize the busiest tube that is not cut (or, when it cannot grow, lay a second one beside it).
|
||||
function makeRoom(ev, W, steps, cut) {
|
||||
const ls = J(ev, `(()=>{${cut ? `for(const l of S.links)if(pzUnit(l)===${JSON.stringify(cut)})l.cut=1;` : ''}compute();const o=S.links.map((l,i)=>({i,a:l.a,b:l.b,cut:!!l.cut,tier:l.tier,u:(R.load[l.id]||0)/capOf(l)})).filter(x=>!x.cut).sort((x,y)=>y.u-x.u);for(const l of S.links)l.cut=0;compute();return o;})()`);
|
||||
for (const l of ls.slice(0, 3)) {
|
||||
if (l.tier < 2) { const t = ev(`(()=>{const l=S.links[${l.i}];ACT.pzTier({id:l.id,tier:${l.tier + 1}});return S.links[${l.i}].tier;})()`); if (t === l.tier + 1) { steps.push(['@tier', l.i, t]); return; } }
|
||||
const o = W.opts(l.a, l.b).filter((x) => !x.second).sort((x, y) => x.cost - y.cost)[0];
|
||||
if (o) { try { steps.push(lay(ev, o.a, o.b, o.via)); return; } catch (e) { /* try the next tube */ } }
|
||||
}
|
||||
throw new Error('no room to be made');
|
||||
}
|
||||
// What the review would say: the first cut that strands a mission-critical site or leaves a site short.
|
||||
const reviewFail = (ev) => J(ev, `(()=>{let f=null;for(const u of [...new Set(S.links.map(pzUnit))]){const x=arCut(u);for(const l of x.ls)l.cut=0;if(x.gold.length||x.short.length){f={u,gold:x.gold,short:x.short,dark:x.dark};break;}}compute();return f;})()`);
|
||||
const passes = (ev) => ev('arShowStart();arShowSkip();S.ar.passed===pzSig()');
|
||||
|
||||
// The reference architect: fix what the checklist and the review find, cheapest first, until the brief passes.
|
||||
function solveBrief(ev, W, steps) {
|
||||
for (let guard = 0; guard < 24; guard++) {
|
||||
for (const c of J(ev, 'S.pz.avoid.filter(c=>S.pops[c])')) { ev(`ACT.pzRmPop({city:'${c}'})`); steps.push(['@rm', c]); }
|
||||
const e = J(ev, '(()=>{const e=arEval(),r=[...arReach(S.ar.hq,arAdj())];return {conn:e.conn,lat:e.lat,rings:e.rings,ready:e.ready,why:e.why,r,miss:e.sites.filter(s=>!s.ok).map(s=>s.c)};})()');
|
||||
const best = (from, to, skip) => { let o = null; for (const a of from) for (const b of to) if (a !== b) for (const x of W.opts(a, b)) if (!x.second && x.unit !== skip && (!o || x.cost < o.cost)) o = x; return o; };
|
||||
if (!e.conn) { const c = e.miss[0], o = best([c], e.r); if (!o) throw new Error(`no way to ${c}`); steps.push(lay(ev, o.a, o.b, o.via)); continue; }
|
||||
if (e.lat && !e.lat.ok) { const os = W.opts(e.lat.a, e.lat.b).filter((x) => !x.second && x.ms <= e.lat.cap).sort((x, y) => x.cost - y.cost); if (!os.length) throw new Error('latency cap out of reach'); steps.push(lay(ev, os[0].a, os[0].b, os[0].via)); continue; }
|
||||
const rg = e.rings.find((x) => !x.ok);
|
||||
if (rg) { const cs = rg.cs, has = J(ev, 'S.links.map(l=>edgeKey(l))'); let done = false;
|
||||
for (let i = 0; i < cs.length && !done; i++) { const a = cs[i], b = cs[(i + 1) % cs.length]; if (has.includes(ev(`edgeKey({a:'${a}',b:'${b}'})`))) continue; const o = best([a], [b]); if (o) { steps.push(lay(ev, o.a, o.b, o.via)); done = true; } }
|
||||
if (!done) throw new Error('ring out of reach'); continue; }
|
||||
if (!e.ready) { if (/thin/i.test(e.why) || J(ev, 'arEval().sites.some(s=>!s.full)')) { makeRoom(ev, W, steps, null); continue; } throw new Error(`not ready: ${e.why}`); }
|
||||
const f = reviewFail(ev); if (!f) return;
|
||||
if (f.short.length && !f.gold.length) { makeRoom(ev, W, steps, f.u); continue; }
|
||||
// A cut strands a mission-critical site: join the stranded side to the rest another way.
|
||||
const rest = J(ev, `Object.keys(S.pops).filter(c=>!${JSON.stringify(f.dark)}.includes(c))`), o = best(f.dark, rest, f.u);
|
||||
if (!o) throw new Error('no second way'); steps.push(lay(ev, o.a, o.b, o.via));
|
||||
}
|
||||
throw new Error('the brief would not pass');
|
||||
}
|
||||
|
||||
// ---------- designing a run ----------
|
||||
// The brief kinds after the first two. Each is designed against the reference network as it stands, or refused (null).
|
||||
function design(kind, ev, W, r, s) {
|
||||
const pops = J(ev, 'S.pz.cities'), gold = J(ev, 'S.ar.gold'), hq = s.hq, next = () => s.todo.shift(), dem = (c) => { const g = Math.min(s.room, pick(r, [10, 20, 20, 30])); s.room -= g; return { [c]: g }; };
|
||||
const weak = J(ev, `S.pz.cities.filter(c=>c!==S.ar.hq&&!S.ar.gold.includes(c)&&[...new Set(S.links.map(pzUnit))].some(u=>arDark(u).includes(c)))`);
|
||||
if (kind === 'gold') { if (!weak.length) return null; const c = weak.sort((a, b) => W.km(hq, b) - W.km(hq, a))[0]; return { gold: [c] }; }
|
||||
if (kind === 'addgold') { if (!s.todo.length || s.room < 10) return null; const c = next(); return { add: [c], dem: dem(c), gold: [c] }; }
|
||||
if (kind === 'move') { const c = pops.filter((x) => x !== hq && !gold.includes(x) && !(s.lat || []).includes(x)).sort((a, b) => W.km(hq, b) - W.km(hq, a))[0];
|
||||
if (!c || !s.todo.length || s.room < 10) return null; const n = next(); return { drop: [c], add: [n], dem: dem(n), gold: [n] }; }
|
||||
if (kind === 'lat') { let bestP = null;
|
||||
for (const a of pops) for (const b of pops) { if (a >= b) continue; const cur = J(ev, `arLat('${a}','${b}')`), os = W.opts(a, b).filter((x) => !x.second); if (cur == null || !os.length) continue;
|
||||
const ms = Math.min(...os.map((x) => x.ms)), cap = Math.ceil(ms * 1.12 * 10) / 10; if (cap < 2 || cap >= cur * 0.85) continue;
|
||||
if (!bestP || cur / cap > bestP.k) bestP = { a, b, cap, k: cur / cap }; }
|
||||
if (!bestP) return null; s.lat = [bestP.a, bestP.b]; return { lat: [bestP.a, bestP.b, bestP.cap] }; }
|
||||
if (kind === 'grow') { const cs = pops.filter((c) => c !== hq).map((c) => [c, ev(`arDem('${c}')`)]).sort((x, y) => y[1] - x[1]); if (!cs.length || s.room < 60) return null;
|
||||
const [c, d] = cs[0], g = d + Math.min(s.room, pick(r, [60, 90, 120])); s.room -= g - d; return { dem: { [c]: g } }; }
|
||||
if (kind === 'ring') { const cs = pops.filter((c) => c !== hq).sort((a, b) => W.km(hq, a) - W.km(hq, b)).slice(0, 2); if (cs.length < 2) return null;
|
||||
const ring = [hq, ...cs]; if (ev(`arRingOk(${JSON.stringify(ring)})`)) return null; return { ring }; }
|
||||
return null;
|
||||
}
|
||||
|
||||
// Play a run from scratch: stage, start, then brief by brief design (when designing) or follow the file, solve, review, next.
|
||||
function play(g, W, key, hq, plan, r, sites) {
|
||||
const { ev } = g, briefs = [], steps = [], s = { hq, todo: sites.slice(), room: DEM_MAX, lat: null };
|
||||
const first = () => { const c = s.todo.shift(), g0 = Math.min(s.room, pick(r, [20, 30, 40])); s.room -= g0; return { add: [c], dem: { [c]: g0 } }; };
|
||||
for (let i = 0; i < plan.length; i++) {
|
||||
let b = null;
|
||||
if (plan[i] === 'add1') b = first();
|
||||
else if (plan[i] === 'add2') { if (s.todo.length < 2) throw new Error('not enough sites'); const a = s.todo.shift(), c = s.todo.shift(), ga = Math.min(s.room, 20); s.room -= ga; const gc = Math.min(s.room, pick(r, [10, 20])); s.room -= gc; b = { add: [a, c], dem: { [a]: ga, [c]: gc } }; }
|
||||
// A kind that cannot be made here gives way to one the run has not had yet, then to a new mission-critical site.
|
||||
else for (const k of [plan[i], ...['lat', 'ring', 'move', 'grow', 'gold'].filter((x) => !plan.slice(0, i).includes(x) && x !== plan[i]), 'addgold']) { b = design(k, ev, W, r, s); if (b) { plan[i] = k; break; } }
|
||||
if (!b) throw new Error(`brief ${i + 1}: nothing left to ask`);
|
||||
b.tubes = 9; briefs.push(b); stage(ev, key, hq, briefs.map((x) => Object.assign({ t: '' }, x)));
|
||||
if (i === 0) ev(`ACT.pzArStart({id:arWkId('${key}')})`); else ev('ACT.pzArNext()');
|
||||
if (ev('S.ar.bi') !== i) throw new Error(`brief ${i + 1} did not start`);
|
||||
const st = []; solveBrief(ev, W, st); steps.push(st);
|
||||
b.tubes = ev('S.links.filter(l=>(l.br|0)===S.ar.bi).length');
|
||||
if (!st.length) throw new Error(`brief ${i + 1} asks for nothing new`);
|
||||
ev(`UI.arWk.def.briefs[${i}].tubes=${b.tubes}`);
|
||||
if (!passes(ev)) throw new Error(`brief ${i + 1}: the review does not pass`);
|
||||
}
|
||||
return { briefs, steps, spend: ev('arSpend()') };
|
||||
}
|
||||
|
||||
// Replay a file the way a player would, from its own reference: it must pass every brief and earn three stars.
|
||||
function verify(g, j, key) {
|
||||
const { ev } = g, def = J(ev, `arWkValid(${JSON.stringify(j)},'${key}')`);
|
||||
if (!def) return { ok: false, why: 'the game rejects it' };
|
||||
if (!j.ref || !Array.isArray(j.ref.steps) || j.ref.steps.length !== def.briefs.length) return { ok: false, why: 'no reference' };
|
||||
try {
|
||||
ev(`UI.arWk={key:'${key}',def:arWkValid(${JSON.stringify(j)},'${key}'),at:Date.now()}`);
|
||||
ev(`ACT.pzArStart({id:arWkId('${key}')})`);
|
||||
for (let i = 0; i < def.briefs.length; i++) {
|
||||
for (const st of j.ref.steps[i]) step(ev, st);
|
||||
if (!passes(ev)) return { ok: false, why: `brief ${i + 1} does not pass` };
|
||||
if (i < def.briefs.length - 1) ev('ACT.pzArNext()');
|
||||
}
|
||||
const sp = ev('arSpend()'), stars = ev(`arStars(${sp})`);
|
||||
ev('arStop(true)');
|
||||
return stars === 3 ? { ok: true, spend: sp } : { ok: false, why: `the reference earns ${stars} stars (spend ${sp}, budget ${j.budget})` };
|
||||
} catch (e) { return { ok: false, why: e.message }; }
|
||||
}
|
||||
|
||||
function generate(g, key, dir) {
|
||||
const { ev } = g, W = world(ev);
|
||||
// The regions of the last weeks, so the HQ moves around the world.
|
||||
const past = list(dir).filter((k) => k < key).map((k) => { try { return JSON.parse(fs.readFileSync(path.join(dir, k + '.json'), 'utf8')).hq; } catch (e) { return null; } });
|
||||
const recent = past.slice(-HISTORY).map((c) => W.C[c] && W.C[c].reg), used = past.slice(-12);
|
||||
for (let attempt = 0; attempt < ATTEMPTS; attempt++) {
|
||||
const r = rng(hash(`architect|${key}|${attempt}`));
|
||||
const hqs = W.cities.filter((c) => !used.includes(c.id) && (!recent.includes(c.reg) || attempt >= ATTEMPTS / 2));
|
||||
const hq = pick(r, hqs).id;
|
||||
const near = W.cities.filter((c) => c.id !== hq && c.reg === W.C[hq].reg && W.km(hq, c.id) < 2500).sort((a, b) => W.km(hq, a.id) - W.km(hq, b.id)).slice(0, 8).map((c) => c.id);
|
||||
if (near.length < 6) continue;
|
||||
const mid = shuffle(r, ['lat', 'ring', 'move', 'addgold', 'grow']).slice(0, r() < 0.5 ? 2 : 3);
|
||||
const plan = ['add1', 'add2', 'gold', ...mid, 'gold'];
|
||||
const sites = [...near.slice(0, 3), ...shuffle(r, near.slice(3))];
|
||||
try {
|
||||
const run = play(g, W, key, hq, plan, r, sites);
|
||||
const jk = pick(r, JOKES), j = { v: SCHEMA, key, hq, budget: ceil10k(run.spend * 1.06), name: { l: pick(r, NAMES), p: { hq } }, joke: { l: jk, p: jk === JOKES[0] ? { hq } : {} }, briefs: run.briefs, ref: { spend: run.spend, steps: run.steps } };
|
||||
const v = verify(g, j, key);
|
||||
if (!v.ok) { if (process.env.DEBUG) console.warn(`${key} #${attempt}: ${v.why}`); continue; }
|
||||
return j;
|
||||
} catch (e) { if (process.env.DEBUG) console.warn(`${key} #${attempt} (${hq}): ${e.message}`); }
|
||||
}
|
||||
throw new Error(`${key}: no run survived verification`);
|
||||
}
|
||||
|
||||
// --check: every file is what the game accepts, under its own name, and the weeks still to come earn three stars.
|
||||
function check(g, dir, now = Date.now()) {
|
||||
const { ev } = g, bad = [], keys = list(dir);
|
||||
for (const k of keys) {
|
||||
let j; try { j = JSON.parse(fs.readFileSync(path.join(dir, k + '.json'), 'utf8')); } catch (e) { bad.push(`${k}: not JSON`); continue; }
|
||||
if (!ev(`!!arWkValid(${JSON.stringify(j)},'${k}')`)) { bad.push(`${k}: the game rejects it`); continue; }
|
||||
if (ev(`pzWeekStart('${k}')`) + 7 * 864e5 > now) { const v = verify(g, j, k); if (!v.ok) bad.push(`${k}: ${v.why}`); }
|
||||
}
|
||||
if (keys.length) {
|
||||
let idx = null; try { idx = JSON.parse(fs.readFileSync(path.join(dir, 'index.json'), 'utf8')); } catch (e) { /* reported below */ }
|
||||
if (!idx || idx.v !== SCHEMA || JSON.stringify(idx.weeks) !== JSON.stringify(keys)) bad.push('index.json does not list exactly the weekly files');
|
||||
}
|
||||
return bad;
|
||||
}
|
||||
// A release can change prices under weeks already out: a week not over yet whose reference no longer earns three stars
|
||||
// is regenerated with its rev up, so players' stars for that week (only that week) start again. Past weeks stay.
|
||||
function refresh(g, dir, now = Date.now()) {
|
||||
const { ev } = g, fixed = [], bad = [];
|
||||
for (const k of list(dir)) {
|
||||
let j = null; try { j = JSON.parse(fs.readFileSync(path.join(dir, k + '.json'), 'utf8')); } catch (e) { /* regenerated below */ }
|
||||
const valid = !!j && ev(`!!arWkValid(${JSON.stringify(j)},'${k}')`), live = ev(`pzWeekStart('${k}')`) + 7 * 864e5 > now;
|
||||
if (valid && (!live || verify(g, j, k).ok)) continue;
|
||||
const rev = (j && Number.isInteger(j.rev) && j.rev >= 2 ? j.rev : 1) + 1;
|
||||
try { writeWeek(dir, Object.assign(generate(g, k, dir), { rev })); fixed.push(`${k}: regenerated as rev ${rev}`); } catch (e) { bad.push(`${k}: could not regenerate (${e.message})`); }
|
||||
}
|
||||
let idx = null; try { idx = JSON.parse(fs.readFileSync(path.join(dir, 'index.json'), 'utf8')); } catch (e) { /* rewritten */ }
|
||||
if (list(dir).length && (!idx || idx.v !== SCHEMA || JSON.stringify(idx.weeks) !== JSON.stringify(list(dir)))) { writeIndex(dir); fixed.push('index.json rewritten'); }
|
||||
return { fixed, bad };
|
||||
}
|
||||
const writeIndex = (dir) => fs.writeFileSync(path.join(dir, 'index.json'), JSON.stringify({ v: SCHEMA, weeks: list(dir) }) + '\n');
|
||||
const writeWeek = (dir, j) => { fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(path.join(dir, j.key + '.json'), JSON.stringify(j) + '\n'); writeIndex(dir); };
|
||||
const say = (j) => `${j.key}: HQ ${j.hq}, ${j.briefs.length} briefs (${j.briefs.map((b) => Object.keys(b).filter((k) => k !== 'tubes' && (k !== 'dem' || !b.add)).map((k) => (k === 'dem' ? 'grow' : k)).join('+')).join(', ')}), budget ${j.budget}, reference ${j.ref.spend}`;
|
||||
|
||||
module.exports = { generate, verify, check, refresh, writeWeek, writeIndex, list, say, step };
|
||||
|
||||
if (require.main === module) {
|
||||
const args = process.argv.slice(2), opt = (n, d) => { const i = args.indexOf(n); return i >= 0 ? args[i + 1] : d; };
|
||||
const dir = path.resolve(ROOT, opt('--dir', 'site/architect/weekly')), g = game(opt('--page') && path.resolve(opt('--page')));
|
||||
if (!g.ev("typeof arWkValid==='function'")) { console.log('This game has no weekly Architect runs yet.'); process.exit(0); }
|
||||
if (args.includes('--check')) {
|
||||
const r = refresh(g, dir);
|
||||
for (const x of r.fixed) console.log(`fixed: ${x}`);
|
||||
const bad = [...r.bad, ...check(g, dir)];
|
||||
for (const b of bad) console.error(`error: ${b}`);
|
||||
console.log(bad.length ? `${bad.length} problem(s)` : `${list(dir).length} weekly Architect run(s) OK`);
|
||||
process.exit(bad.length ? 1 : 0);
|
||||
}
|
||||
const first = opt('--key') || g.ev(`pzWeekKey(Date.now()+12*3600e3)`), n = +opt('--next', 1);
|
||||
for (let i = 0; i < n; i++) {
|
||||
const key = g.ev(`pzKeyAdd('${first}',${i})`);
|
||||
if (!key) { console.error(`error: ${first} is not a week`); process.exit(1); }
|
||||
if (fs.existsSync(path.join(dir, key + '.json')) && !args.includes('--force')) { console.log(`${key}: already there`); continue; }
|
||||
const j = generate(g, key, dir); writeWeek(dir, j); console.log(say(j));
|
||||
}
|
||||
}
|
||||
412
scripts/weekly-puzzle.js
Normal file
412
scripts/weekly-puzzle.js
Normal file
|
|
@ -0,0 +1,412 @@
|
|||
#!/usr/bin/env node
|
||||
// The weekly puzzle generator. Every Sunday .github/workflows/weekly-puzzle.yml runs it to publish that week's
|
||||
// puzzle as a static file, site/puzzles/weekly/<key>.json, which the game fetches when Puzzles opens
|
||||
// (src/game/60-features/93-puzzles-weekly.js). It loads the real game headless (tests/harness.js), so it uses the
|
||||
// game's own cities, cables, prices, week keys, file validator and star code.
|
||||
//
|
||||
// node scripts/weekly-puzzle.js the week starting on the coming (or current) Sunday 06:00 Berlin, if missing
|
||||
// node scripts/weekly-puzzle.js --key 2026-W45 that week (--force replaces an existing file)
|
||||
// node scripts/weekly-puzzle.js --next 3 this week and the next two
|
||||
// node scripts/weekly-puzzle.js --check regenerate weeks not over yet whose budget this game no longer verifies
|
||||
// (see refresh()), then validate every file; fails only if that fails
|
||||
// --page FILE play another build of the game (the live release), see the workflow
|
||||
// --dir DIR where the files live (default site/puzzles/weekly)
|
||||
//
|
||||
// How a puzzle is made: pick a theme the last weeks did not have, choose 4-6 cities for it (avoiding last weeks'
|
||||
// cities) and the traffic they carry (content in the first city, eyeballs in the others; a latency sprint adds a
|
||||
// circuit with a latency cap). Search for the cheapest topology that connects them and the cheapest one that survives
|
||||
// any single cut (a whole cable or a trench), then size each with the game's own routing (scripts/lib/puzzle-solver.js):
|
||||
// links and routers big enough for every flow, after any single cut too, then as small as they can be. The budget is
|
||||
// that N-1 build plus a little. Both reference builds are judged by the game's own star code and must earn their
|
||||
// stars, or the candidate is thrown away and another one tried.
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const ROOT = path.join(__dirname, '..');
|
||||
const SV = require('./lib/puzzle-solver');
|
||||
const SCHEMA = 2, HISTORY = 4, THEME_GAP = 3, REG_GAP = 2, ATTEMPTS = 40, KEEP = 6;
|
||||
const THEMES = ['tour', 'ring', 'detour', 'ocean', 'islands', 'sprint'];
|
||||
|
||||
// ---------- the game, headless ----------
|
||||
function game(file) {
|
||||
const { load } = require('../tests/harness');
|
||||
let g = load(file ? { file } : {});
|
||||
if (file && !g.ev("typeof pzWkValid==='function'")) {
|
||||
console.warn(`warning: ${file} has no published weekly puzzles yet; using src/ instead`);
|
||||
g = load();
|
||||
}
|
||||
SV.install(g.ev);
|
||||
// N-1 counts a whole cable as one failure (every segment of a cable shares its risk), as the solver does.
|
||||
if (g.ev("pzUnit({cable:'x',a:'a',b:'b'})") !== 'cab:x') throw new Error('this game counts cable segments separately; the solver would not match its N-1 check');
|
||||
return g;
|
||||
}
|
||||
|
||||
// ---------- small helpers ----------
|
||||
const hash = (s) => { let h = 2166136261; for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619); } return h >>> 0; };
|
||||
function rng(seed) { let a = seed >>> 0 || 1; return () => { a = (a + 0x6D2B79F5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; }
|
||||
const pick = (r, a) => a[Math.floor(r() * a.length)];
|
||||
const shuffle = (r, a) => { a = a.slice(); for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(r() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; };
|
||||
const ceil10k = (x) => Math.ceil(x / 10000) * 10000;
|
||||
function perms(a) { if (a.length <= 1) return [a]; const out = []; a.forEach((x, i) => { for (const p of perms([...a.slice(0, i), ...a.slice(i + 1)])) out.push([x, ...p]); }); return out; }
|
||||
function subsets(a) { const out = []; for (let m = 0; m < 1 << a.length; m++) out.push(a.filter((_, i) => m >> i & 1)); return out; }
|
||||
|
||||
// ---------- the world, as the game prices it ----------
|
||||
function world(ev) {
|
||||
const cities = JSON.parse(ev("JSON.stringify(Object.values(CITY).filter(c=>!c.off&&!c.cn).map(c=>({id:c.id,name:c.name,lands:lands(c),reg:c.reg,P:c.P,lon:c.lon,lat:c.lat,pop:pzPopCost(c.id)})))"));
|
||||
const C = Object.fromEntries(cities.map((c) => [c.id, c]));
|
||||
const cablePairs = JSON.parse(ev('JSON.stringify(CABLE_PAIRS.map(p=>[p.cid,p.a,p.b]))')).filter(([, a, b]) => C[a] && C[b]);
|
||||
const cabs = {}; for (const [cid, a, b] of cablePairs) { (cabs[a] = cabs[a] || new Set()).add(cid); (cabs[b] = cabs[b] || new Set()).add(cid); }
|
||||
const memo = new Map();
|
||||
// Every way to join a and b: overland (first wave, and a second one on a diverse route) and each cable.
|
||||
const opts = (a, b) => {
|
||||
const k = a < b ? a + '|' + b : b + '|' + a; if (memo.has(k)) return memo.get(k);
|
||||
const rs = JSON.parse(ev(`JSON.stringify(pzRoutes('${a}','${b}').filter(r=>!subWaveWhy(0,r.km,r.sub)).map(r=>({via:r.via,cab:r.cab,sub:r.sub,ms:r.ms,c:pzLinkCost(r,0,false),c2:r.sub?0:pzLinkCost(r,0,true)})))`));
|
||||
const out = [];
|
||||
for (const r of rs) {
|
||||
if (r.cab) out.push({ a, b, via: r.via, sub: true, ms: r.ms, cost: r.c, unit: 'cab:' + r.cab });
|
||||
else { out.push({ a, b, via: 'land', sub: false, ms: r.ms, cost: r.c, unit: `land:${k}:1` }); out.push({ a, b, via: 'land', sub: false, ms: r.ms, cost: r.c2, unit: `land:${k}:2`, second: true }); }
|
||||
}
|
||||
out.sort((x, y) => x.cost - y.cost || (x.unit < y.unit ? -1 : 1));
|
||||
memo.set(k, out); return out;
|
||||
};
|
||||
const km = (a, b) => { const A = C[a], B = C[b], r = Math.PI / 180, h = Math.sin((B.lat - A.lat) * r / 2) ** 2 + Math.cos(A.lat * r) * Math.cos(B.lat * r) * Math.sin((B.lon - A.lon) * r / 2) ** 2; return 12742 * Math.asin(Math.sqrt(h)); };
|
||||
return { cities, C, cablePairs, cabs, opts, km };
|
||||
}
|
||||
|
||||
// ---------- judging a build (the game has the last word; this steers the search) ----------
|
||||
function judge(W, P, links) {
|
||||
const nodes = new Set(); for (const l of links) { nodes.add(l.a); nodes.add(l.b); }
|
||||
// A second overland wave on a pair needs the first one.
|
||||
for (const l of links) if (l.second && !links.some((x) => x !== l && !x.second && x.via === 'land' && x.unit === l.unit.replace(/2$/, '1'))) return null;
|
||||
if (new Set(links.map((l) => l.unit)).size !== links.length) return null;
|
||||
const cost = [...nodes].reduce((s, c) => s + W.C[c].pop, 0) + links.reduce((s, l) => s + l.cost, 0);
|
||||
const comp = (skip) => { const adj = {}; for (const l of links) if (l.unit !== skip) { (adj[l.a] = adj[l.a] || []).push(l.b); (adj[l.b] = adj[l.b] || []).push(l.a); }
|
||||
const seen = new Set([P.cities[0]]), q = [P.cities[0]]; while (q.length) { const u = q.pop(); for (const v of adj[u] || []) if (!seen.has(v)) { seen.add(v); q.push(v); } } return seen; };
|
||||
const all = comp(null);
|
||||
if (!P.cities.every((c) => all.has(c))) return { ok: false, cost };
|
||||
if (P.avoid.some((c) => nodes.has(c))) return { ok: false, cost };
|
||||
if (P.noSub && links.some((l) => l.sub)) return { ok: false, cost };
|
||||
if (P.ring) { const nb = {}; for (const l of links) { (nb[l.a] = nb[l.a] || new Set()).add(l.b); (nb[l.b] = nb[l.b] || new Set()).add(l.a); }
|
||||
if (links.length !== nodes.size || ![...nodes].every((c) => nb[c].size === 2)) return { ok: false, cost }; }
|
||||
if (P.lat) { const [a, b, ms] = P.lat, d = { [a]: 0 }, done = new Set();
|
||||
for (;;) { let u = null; for (const k in d) if (!done.has(k) && (u === null || d[k] < d[u])) u = k; if (u === null || u === b) break; done.add(u);
|
||||
for (const l of links) { const v = l.a === u ? l.b : l.b === u ? l.a : null; if (v && !(d[v] <= d[u] + l.ms)) d[v] = d[u] + l.ms; } }
|
||||
if (!(d[b] <= ms)) return { ok: false, cost }; }
|
||||
const weak = [...new Set(links.map((l) => l.unit))].filter((u) => { const g = comp(u); return !P.cities.every((c) => g.has(c)); });
|
||||
return { ok: true, cost, n1: weak.length === 0, weak };
|
||||
}
|
||||
|
||||
// ---------- the solver ----------
|
||||
// Cheapest tree over a node set (Kruskal on each pair's cheapest way), with some links forced in.
|
||||
function tree(W, nodes, forced = []) {
|
||||
const par = Object.fromEntries(nodes.map((n) => [n, n])), f = (x) => (par[x] === x ? x : (par[x] = f(par[x])));
|
||||
const out = [];
|
||||
for (const l of forced) { par[f(l.a)] = f(l.b); out.push(l); }
|
||||
const es = [];
|
||||
for (let i = 0; i < nodes.length; i++) for (let j = i + 1; j < nodes.length; j++) { const o = W.opts(nodes[i], nodes[j]).filter((x) => !x.second); if (o.length) es.push(o[0]); }
|
||||
es.sort((x, y) => x.cost - y.cost);
|
||||
for (const e of es) if (f(e.a) !== f(e.b)) { par[f(e.a)] = f(e.b); out.push(e); }
|
||||
return out.length - forced.length === nodes.length - 1 - forced.length ? out : null;
|
||||
}
|
||||
// Add the link that removes the most single points of failure per dollar, until none are left.
|
||||
function harden(W, P, nodes, links) {
|
||||
links = links.slice();
|
||||
for (let guard = 0; guard < 12; guard++) {
|
||||
const j = judge(W, P, links); if (!j || !j.ok) return null; if (j.n1) return links;
|
||||
let best = null;
|
||||
for (let i = 0; i < nodes.length; i++) for (let k = i + 1; k < nodes.length; k++) for (const o of W.opts(nodes[i], nodes[k])) {
|
||||
if (links.some((l) => l.unit === o.unit)) continue;
|
||||
const jj = judge(W, P, [...links, o]); if (!jj || !jj.ok) continue;
|
||||
const gain = j.weak.length - jj.weak.length; if (gain <= 0) continue;
|
||||
const score = gain / o.cost; if (!best || score > best.score) best = { score, o };
|
||||
}
|
||||
if (!best) return null; links.push(best.o);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Every simple cycle through the node set, each hop by one of its three cheapest ways, cheapest first.
|
||||
function cycles(W, P, nodes, bound) {
|
||||
let best = null; const [h, ...rest] = nodes;
|
||||
if (nodes.length < 3) return null;
|
||||
for (const p of perms(rest)) {
|
||||
if (p[0] > p[p.length - 1]) continue; // each cycle once
|
||||
const ring = [h, ...p], hops = ring.map((x, i) => W.opts(x, ring[(i + 1) % ring.length]).filter((o) => !o.second).slice(0, 3));
|
||||
if (hops.some((o) => !o.length)) continue;
|
||||
const pop = ring.reduce((s, c) => s + W.C[c].pop, 0);
|
||||
const go = (i, acc, cost) => {
|
||||
if (cost >= Math.min(bound, best ? best.cost : Infinity)) return;
|
||||
if (i === hops.length) { const j = judge(W, P, acc); if (j && j.ok && j.n1) best = { cost: j.cost, links: acc.slice() }; return; }
|
||||
for (const o of hops[i]) { if (acc.some((l) => l.unit === o.unit)) continue; acc.push(o); go(i + 1, acc, cost + o.cost); acc.pop(); }
|
||||
};
|
||||
go(0, [], pop);
|
||||
}
|
||||
return best;
|
||||
}
|
||||
function solve(W, P) {
|
||||
const vias = P.via.filter((c) => !P.avoid.includes(c));
|
||||
let one = null, three = null, naive = null;
|
||||
const keep = (cur, links) => { if (!links) return cur; const j = judge(W, P, links); if (!j || !j.ok) return cur; return !cur || j.cost < cur.cost ? { cost: j.cost, links, n1: j.n1 } : cur; };
|
||||
for (const sub of subsets(vias)) {
|
||||
const nodes = [...P.cities, ...sub];
|
||||
const forced = P.lat ? [W.opts(P.lat[0], P.lat[1]).filter((o) => !o.second).sort((x, y) => x.ms - y.ms)[0]].filter(Boolean) : [];
|
||||
const ts = [tree(W, nodes), forced.length ? tree(W, nodes, forced) : null].filter(Boolean)
|
||||
// A via city left as a leaf is money for nothing.
|
||||
.filter((t) => sub.every((v) => t.filter((l) => l.a === v || l.b === v).length >= 2));
|
||||
if (!P.ring) for (const t of ts) {
|
||||
one = keep(one, t);
|
||||
// The obvious way to survive a cut: a second, different way along every hop of the tree.
|
||||
const dbl = t.slice(); let okd = true;
|
||||
for (const l of t) { const alt = W.opts(l.a, l.b).find((o) => o.unit !== l.unit && !dbl.some((x) => x.unit === o.unit)); if (!alt) { okd = false; break; } dbl.push(alt); }
|
||||
if (okd) { const j = judge(W, P, dbl); if (j && j.ok && j.n1 && (!naive || j.cost < naive.cost)) naive = { cost: j.cost, links: dbl }; if (j && j.ok && j.n1) three = keep(three, dbl); }
|
||||
const hd = harden(W, P, nodes, t); if (hd) three = keep(three, hd);
|
||||
}
|
||||
if (nodes.length <= 7) { const c = cycles(W, P, nodes, three ? three.cost : Infinity); if (c) { three = keep(three, c.links); if (P.ring) one = keep(one, c.links); } }
|
||||
}
|
||||
return { one, three, naive };
|
||||
}
|
||||
|
||||
// ---------- themes: which cities, which twist ----------
|
||||
function pools(W) {
|
||||
const byLand = {};
|
||||
for (const c of W.cities) { const k = c.lands[0] + '/' + c.reg; (byLand[k] = byLand[k] || []).push(c.id); }
|
||||
const big = Object.values(byLand).map((g) => g.filter((c) => W.C[c].P >= 100)).filter((g) => g.length >= 6);
|
||||
const isl = W.cities.filter((c) => byLand[c.lands[0] + '/' + c.reg].length === 1 && c.lands.length === 1 && (W.cabs[c.id] || new Set()).size >= 2).map((c) => c.id);
|
||||
return { big, isl };
|
||||
}
|
||||
const near = (W, c, from, n) => from.filter((x) => x !== c).sort((a, b) => W.km(c, a) - W.km(c, b)).slice(0, n);
|
||||
function draft(W, theme, r, banned) {
|
||||
const { big, isl } = pools(W), free = (c) => !banned.has(c);
|
||||
const P = { theme, cities: [], via: [], avoid: [], noSub: false, ring: false, lat: null };
|
||||
if (theme === 'tour' || theme === 'ring' || theme === 'detour') {
|
||||
const g = pick(r, big).filter(free);
|
||||
if (g.length < 6) return null;
|
||||
if (theme === 'detour') {
|
||||
const hub = pick(r, g.slice().sort((a, b) => W.C[b].P - W.C[a].P).slice(0, 4)), around = near(W, hub, g, 8);
|
||||
if (around.length < 6) return null;
|
||||
const sh = shuffle(r, around); P.cities = sh.slice(0, 4); P.via = sh.slice(4, 6); P.avoid = [hub];
|
||||
} else {
|
||||
const seed = pick(r, g), n = theme === 'ring' ? 4 + Math.floor(r() * 2) : 4 + Math.floor(r() * 3);
|
||||
P.cities = [seed, ...shuffle(r, near(W, seed, g, n + 2)).slice(0, n - 1)];
|
||||
if (theme === 'tour') P.via = near(W, seed, g, n + 4).filter((c) => !P.cities.includes(c)).slice(0, 1);
|
||||
P.ring = theme === 'ring';
|
||||
}
|
||||
} else if (theme === 'ocean') {
|
||||
const land = (c) => W.C[c].lands[0], ok = W.cablePairs.filter(([, a, b]) => land(a) !== land(b) && free(a) && free(b) && big.some((g) => g.includes(a)) && big.some((g) => g.includes(b)));
|
||||
if (!ok.length) return null;
|
||||
const [, a, b] = pick(r, ok), ga = big.find((g) => g.includes(a)).filter(free), gb = big.find((g) => g.includes(b)).filter(free);
|
||||
const a2 = pick(r, near(W, a, ga, 3)), b2 = pick(r, near(W, b, gb, 3));
|
||||
if (!a2 || !b2) return null;
|
||||
P.cities = [a, a2, b, b2];
|
||||
// Other landing points on either shore that cross the same ocean: the stepping stones to a second crossing.
|
||||
const shores = W.cablePairs.filter(([, x, y]) => (land(x) === land(a) && land(y) === land(b)) || (land(x) === land(b) && land(y) === land(a))).flatMap(([, x, y]) => [x, y]);
|
||||
P.via = shuffle(r, [...new Set(shores)].filter((c) => free(c) && !P.cities.includes(c))).slice(0, 2);
|
||||
} else if (theme === 'islands') {
|
||||
const i0 = pick(r, isl.filter(free)); if (!i0) return null;
|
||||
const hops = W.cablePairs.filter(([, x, y]) => x === i0 || y === i0).map(([, x, y]) => (x === i0 ? y : x));
|
||||
const islN = near(W, i0, isl.filter((c) => free(c) && W.km(i0, c) < 4500), 3), main = near(W, i0, [...new Set(hops)].filter((c) => free(c) && !isl.includes(c)), 2);
|
||||
if (!islN.length || !main.length) return null;
|
||||
P.cities = [i0, ...shuffle(r, islN).slice(0, 1 + Math.floor(r() * 2)), main[0]];
|
||||
P.via = [...new Set([...islN, ...main, ...hops])].filter((c) => !P.cities.includes(c) && free(c)).sort((x, y) => W.km(i0, x) - W.km(i0, y)).slice(0, 3);
|
||||
} else if (theme === 'sprint') {
|
||||
const ok = [];
|
||||
for (const [, a, b] of W.cablePairs) { if (!free(a) || !free(b) || W.C[a].P < 100 || W.C[b].P < 100) continue;
|
||||
const o = W.opts(a, b).filter((x) => !x.second); if (o.length < 2) continue;
|
||||
const fast = o.slice().sort((x, y) => x.ms - y.ms)[0], cheap = o[0];
|
||||
if (fast.unit !== cheap.unit && fast.ms < cheap.ms * 0.94 && fast.ms >= 5) ok.push([a, b, fast.ms, cheap.ms]); }
|
||||
if (!ok.length) return null;
|
||||
const [a, b, fms, cms] = pick(r, ok.sort((x, y) => (x[0] + x[1] < y[0] + y[1] ? -1 : 1)));
|
||||
const ms = Math.ceil(fms * 1.04 + 0.5); if (ms >= cms) return null;
|
||||
const ga = big.find((g) => g.includes(a)) || [], gb = big.find((g) => g.includes(b)) || [];
|
||||
const extra = [...near(W, a, ga.filter(free), 2), ...near(W, b, gb.filter(free), 2)];
|
||||
P.cities = [a, b, ...shuffle(r, extra).slice(0, 1 + Math.floor(r() * 2))];
|
||||
P.via = W.cablePairs.filter(([, x, y]) => [x, y].includes(a) || [x, y].includes(b)).flatMap(([, x, y]) => [x, y]).filter((c, i, s) => s.indexOf(c) === i && free(c) && !P.cities.includes(c)).sort((x, y) => W.km(a, x) - W.km(a, y)).slice(0, 2);
|
||||
P.lat = [a, b, ms];
|
||||
}
|
||||
if (new Set([...P.cities, ...P.via, ...P.avoid]).size !== P.cities.length + P.via.length + P.avoid.length) return null;
|
||||
if (P.cities.length < 3 || P.cities.length > 6) return null;
|
||||
// The traffic: content in the first city, eyeballs in the others (less across an ocean, where waves are dear), and
|
||||
// for a sprint a circuit between its two cities under the latency cap.
|
||||
const far = theme === 'ocean' || theme === 'islands', sizes = far ? [5, 8, 10, 15] : [10, 20, 30, 40, 60];
|
||||
P.src = [P.cities[0]];
|
||||
P.dem = P.cities.slice(1).map((c) => ({ t: 'eye', a: c, g: pick(r, sizes) }));
|
||||
if (P.lat) P.dem.unshift({ t: 'l2', a: P.lat[0], b: P.lat[1], g: 10, ms: P.lat[2] });
|
||||
return P;
|
||||
}
|
||||
|
||||
// ---------- names and jokes: labels and their fill-ins ----------
|
||||
function words(ev, W, P, r) {
|
||||
const T = JSON.parse(ev(`JSON.stringify(PZ_WK_THEMES['${P.theme}'])`)), c = P.cities, last = c[c.length - 1];
|
||||
const fill = (l) => { const need = [...new Set([...ev(`EN['${l}']`).matchAll(/\{(\w+)\}/g)].map((m) => m[1]))], p = {};
|
||||
for (const k of need) p[k] = k === 'hub' ? P.avoid[0] : k === 'reg' ? W.C[c[0]].reg : k === 'ms' ? P.lat[2] : k === 'n' ? c.length : k === 'a' ? (P.lat ? P.lat[0] : P.theme === 'tour' ? last : c[0]) : k === 'b' ? (P.lat ? P.lat[1] : c[2] || last) : null;
|
||||
return { l, p }; };
|
||||
return { name: fill(pick(r, T.names)), joke: fill(pick(r, T.jokes)) };
|
||||
}
|
||||
|
||||
// ---------- one week ----------
|
||||
function history(dir, key) {
|
||||
const keys = list(dir).filter((k) => k < key).slice(-HISTORY);
|
||||
const files = keys.map((k) => JSON.parse(fs.readFileSync(path.join(dir, k + '.json'), 'utf8')));
|
||||
return { cities: new Set(files.flatMap((f) => [...(f.cities || []), ...(f.via || []), ...(f.avoid || [])])), themes: files.slice(-THEME_GAP).map((f) => f.theme),
|
||||
regs: files.slice(-REG_GAP).map((f) => f.cities && f.cities[0]).filter(Boolean) };
|
||||
}
|
||||
const list = (dir) => (fs.existsSync(dir) ? fs.readdirSync(dir).filter((f) => /^\d{4}-W\d{2}\.json$/.test(f)).map((f) => f.slice(0, -5)).sort() : []);
|
||||
|
||||
// A topology's links, sized for the traffic: every wave at the smallest size that carries it all (after any single cut
|
||||
// too, for the N-1 build), as the game routes it, with the cheapest routers that fit.
|
||||
const TIER_G = [10, 100, 400];
|
||||
function size(ev, def, links, n1) {
|
||||
ev(`pzBegin(${JSON.stringify(def)})`);
|
||||
const tot = def.dem.reduce((a, f) => a + f.g, 0), t0 = Math.max(0, TIER_G.findIndex((g) => g >= tot));
|
||||
for (let t = t0; t < TIER_G.length; t++) {
|
||||
const L = [...links.map((l) => [l.a, l.b, l.via, t, 0]), ...def.dem.map((f, i) => f.ms ? ['@route', i, 'fast'] : null).filter(Boolean)], j = SV.judge(ev, L);
|
||||
if (n1 ? j.three : j.one) { const r = n1 ? SV.improve(ev, L) : { links: L, ...j }; return r; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Plays a sized build (links and routers) in the game and returns the stars it earns.
|
||||
function play(ev, def, b) {
|
||||
ev(`localStorage.removeItem('sot-puzzles');pzBegin(${JSON.stringify(def)})`);
|
||||
SV.judge(ev, b.links); ev(`pzsApplyRt(${JSON.stringify(b.rt)})`);
|
||||
return JSON.parse(ev('JSON.stringify((({stars,spend,goal,n1,cheap})=>({stars,spend,goal,n1,cheap}))(pzEval()))'));
|
||||
}
|
||||
const fileOf = (key, P, budget, w, sol) => ({ v: SCHEMA, key, theme: P.theme, cities: P.cities, src: P.src, dem: P.dem, via: P.via, avoid: P.avoid, budget,
|
||||
twist: Object.assign({}, P.ring ? { ring: true } : {}, P.noSub ? { noSub: true } : {}),
|
||||
name: w.name, joke: w.joke, ref: { one: sol.one.cost, three: sol.three.cost } });
|
||||
// The topology search reads a sprint's latency cap from its circuit.
|
||||
const shape = (def) => { const l2 = def.dem.find((f) => f.t === 'l2' && f.ms); return { theme: def.theme, cities: def.cities, via: def.via, avoid: def.avoid, noSub: def.noSub, ring: def.ring, lat: l2 ? [l2.a, l2.b, l2.ms] : null }; };
|
||||
// Topology, then sizes: the 1-star and 3-star references with their prices.
|
||||
function sized(g, W, P, def) {
|
||||
const sol = solve(W, P); if (!sol.one || !sol.three) return null;
|
||||
const one = size(g.ev, def, sol.one.links, false), three = size(g.ev, def, sol.three.links, true);
|
||||
if (!one || !three) return null;
|
||||
// The three-star build delivers too: when it is the cheaper one (a ring, sized down), it is the one-star reference.
|
||||
const o = one.spend <= three.spend ? one : three;
|
||||
return { one: { cost: Math.round(o.spend), b: o }, three: { cost: Math.round(three.spend), b: three } };
|
||||
}
|
||||
// The game's own validator decides what a puzzle is; then both references must earn their stars.
|
||||
function verify(g, W, j, key, known) {
|
||||
const { ev } = g, def = JSON.parse(ev(`JSON.stringify(pzWkValid(${JSON.stringify(j)},'${key}'))`));
|
||||
if (!def) return { ok: false, why: 'the game rejects the file' };
|
||||
const P = shape(def), sol = known || sized(g, W, P, def);
|
||||
if (!sol) return { ok: false, why: 'no build delivers the traffic and survives a cut' };
|
||||
if (sol.three.cost > def.budget) return { ok: false, why: `the cheapest N-1 build found costs ${sol.three.cost}, over the budget ${def.budget}` };
|
||||
const s1 = play(ev, def, sol.one.b), s3 = play(ev, def, sol.three.b);
|
||||
if (s1.stars < 1) return { ok: false, why: `the one-star reference earns ${s1.stars} stars` };
|
||||
if (s3.stars !== 3) return { ok: false, why: `the three-star reference earns ${s3.stars} stars (${JSON.stringify(s3)})` };
|
||||
return { ok: true, sol, s1, s3 };
|
||||
}
|
||||
|
||||
// Three stars need the smart design: the budget sits just above the cheapest N-1 build found, sized for its traffic.
|
||||
const budgetOf = (sol) => Math.max(50000, ceil10k(sol.three.cost * 1.05));
|
||||
|
||||
function generate(g, key, dir) {
|
||||
const { ev } = g, W = world(ev);
|
||||
if (ev(`pzWeekStart('${key}')`) == null) throw new Error(`${key} is not a week`);
|
||||
// Themes take turns (none of the last weeks' again); the week's own theme first, the others only if it finds nothing.
|
||||
const hist = history(dir, key), free = THEMES.filter((t) => !hist.themes.includes(t)), h = hash(key);
|
||||
const order = free.map((_, i) => free[(h + i) % free.length]);
|
||||
for (const theme of order) {
|
||||
const cands = [];
|
||||
for (let at = 0; at < ATTEMPTS && cands.length < KEEP; at++) {
|
||||
const r = rng(hash(`${key}|${theme}|${at}`)), P = draft(W, theme, r, hist.cities);
|
||||
// Not the same part of the world as the last two weeks.
|
||||
if (!P || hist.regs.some((c) => W.C[c] && W.C[c].reg === W.C[P.cities[0]].reg && W.C[c].lands[0] === W.C[P.cities[0]].lands[0])) continue;
|
||||
const sol = solve(W, P);
|
||||
if (!sol.one || !sol.three) continue;
|
||||
// Prefer puzzles where surviving a cut takes real thought: the obvious "double everything" costs a lot more.
|
||||
const smart = sol.naive ? sol.naive.cost / sol.three.cost : 1.05, slack = sol.three.cost / sol.one.cost;
|
||||
const score = Math.min(smart, 1.6) + Math.min(slack, 2) * 0.2 + r() * 0.05;
|
||||
cands.push({ P, score, w: words(ev, W, P, r) });
|
||||
}
|
||||
cands.sort((a, b) => b.score - a.score);
|
||||
for (const c of cands) {
|
||||
// Sized with the traffic: the budget sits just above the cheapest N-1 build found.
|
||||
const def = JSON.parse(ev(`JSON.stringify(pzWkValid(${JSON.stringify(fileOf(key, c.P, 1e6, c.w, { one: { cost: 0 }, three: { cost: 0 } }))},'${key}'))`));
|
||||
const sol = def && sized(g, W, c.P, def);
|
||||
if (!sol) { console.warn(`${key}: rejected a ${theme} puzzle: no build carries its traffic`); continue; }
|
||||
const j = fileOf(key, c.P, budgetOf(sol), c.w, sol), v = verify(g, W, j, key, sol);
|
||||
if (v.ok) return j;
|
||||
console.warn(`${key}: rejected a ${theme} puzzle: ${v.why}`);
|
||||
}
|
||||
}
|
||||
throw new Error(`${key}: no puzzle survived verification`);
|
||||
}
|
||||
|
||||
// --check: every file is what the game accepts, under its own name, and the weeks still to come are solvable.
|
||||
function check(g, dir, now = Date.now()) {
|
||||
const { ev } = g, W = world(ev), bad = [], keys = list(dir);
|
||||
for (const k of keys) {
|
||||
let j; try { j = JSON.parse(fs.readFileSync(path.join(dir, k + '.json'), 'utf8')); } catch (e) { bad.push(`${k}: not JSON`); continue; }
|
||||
if (!ev(`!!pzWkValid(${JSON.stringify(j)},'${k}')`)) { bad.push(`${k}: the game rejects it`); continue; }
|
||||
if (!j.ref || !Number.isInteger(j.ref.one) || !Number.isInteger(j.ref.three) || j.ref.one > j.ref.three || j.ref.three > j.budget) { bad.push(`${k}: bad ref`); continue; }
|
||||
if (ev(`pzWeekStart('${k}')`) + 7 * 864e5 > now) { const v = verify(g, W, j, k); if (!v.ok) bad.push(`${k}: ${v.why}`); }
|
||||
}
|
||||
const ip = path.join(dir, 'index.json');
|
||||
if (keys.length) {
|
||||
let idx = null; try { idx = JSON.parse(fs.readFileSync(ip, 'utf8')); } catch (e) { /* reported below */ }
|
||||
if (!idx || idx.v !== SCHEMA || JSON.stringify(idx.weeks) !== JSON.stringify(keys)) bad.push('index.json does not list exactly the weekly files');
|
||||
}
|
||||
return bad;
|
||||
}
|
||||
/* --check, first part: a release can change prices, cables or cities under weeks that are already published. Every
|
||||
week not over yet is re-solved with this game; when its budget no longer verifies it is regenerated, deterministically:
|
||||
the same puzzle (theme, cities, twist, name) with a new budget when that still works, else a fresh puzzle for the
|
||||
same key. Its rev goes up, so players' stars for that week (and only that week) start again; new references alone
|
||||
keep the rev. Past weeks can no longer be played, so they keep their stars and are only replaced when the game
|
||||
rejects them outright. Returns what changed and what could not be fixed. */
|
||||
function refresh(g, dir, now = Date.now()) {
|
||||
const { ev } = g, W = world(ev), fixed = [], bad = [];
|
||||
for (const k of list(dir)) {
|
||||
const f = path.join(dir, k + '.json');
|
||||
let j = null; try { j = JSON.parse(fs.readFileSync(f, 'utf8')); } catch (e) { /* regenerated below */ }
|
||||
const valid = !!j && ev(`!!pzWkValid(${JSON.stringify(j)},'${k}')`), live = ev(`pzWeekStart('${k}')`) + 7 * 864e5 > now;
|
||||
if (valid && !live) continue;
|
||||
const v = valid ? verify(g, W, j, k) : null;
|
||||
if (v && v.ok) {
|
||||
if (j.ref && j.ref.one === v.sol.one.cost && j.ref.three === v.sol.three.cost) continue;
|
||||
j.ref = { one: v.sol.one.cost, three: v.sol.three.cost }; writeWeek(dir, j); fixed.push(`${k}: new references`); continue;
|
||||
}
|
||||
const rev = (j && Number.isInteger(j.rev) && j.rev >= 2 ? j.rev : 1) + 1;
|
||||
let n = null;
|
||||
if (valid) {
|
||||
const def = JSON.parse(ev(`JSON.stringify(pzWkValid(${JSON.stringify(j)},'${k}'))`));
|
||||
const sol = sized(g, W, shape(def), def);
|
||||
if (sol) {
|
||||
const c = Object.assign({}, j, { budget: budgetOf(sol), ref: { one: sol.one.cost, three: sol.three.cost }, rev });
|
||||
if (verify(g, W, c, k, sol).ok) n = c;
|
||||
}
|
||||
}
|
||||
if (!n) { try { n = Object.assign(generate(g, k, dir), { rev }); } catch (e) { bad.push(`${k}: could not regenerate (${e.message})`); continue; } }
|
||||
writeWeek(dir, n); fixed.push(`${k}: regenerated as rev ${rev}${n.theme === (j && j.theme) && JSON.stringify(n.cities) === JSON.stringify(j.cities) ? ', same puzzle, new budget ' + n.budget : ', a new ' + n.theme + ' puzzle'}`);
|
||||
}
|
||||
let idx = null; try { idx = JSON.parse(fs.readFileSync(path.join(dir, 'index.json'), 'utf8')); } catch (e) { /* rewritten */ }
|
||||
if (list(dir).length && (!idx || idx.v !== SCHEMA || JSON.stringify(idx.weeks) !== JSON.stringify(list(dir)))) { writeIndex(dir); fixed.push('index.json rewritten'); }
|
||||
return { fixed, bad };
|
||||
}
|
||||
const writeIndex = (dir) => fs.writeFileSync(path.join(dir, 'index.json'), JSON.stringify({ v: SCHEMA, weeks: list(dir) }) + '\n');
|
||||
const writeWeek = (dir, j) => { fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(path.join(dir, j.key + '.json'), JSON.stringify(j) + '\n'); writeIndex(dir); };
|
||||
|
||||
module.exports = { game, generate, check, refresh, solve, sized, shape, world, writeWeek, writeIndex, list };
|
||||
|
||||
if (require.main === module) {
|
||||
const args = process.argv.slice(2), opt = (n, d) => { const i = args.indexOf(n); return i >= 0 ? args[i + 1] : d; };
|
||||
const dir = path.resolve(ROOT, opt('--dir', 'site/puzzles/weekly')), g = game(opt('--page') && path.resolve(opt('--page')));
|
||||
if (args.includes('--check')) {
|
||||
// Fix what a release's new prices broke, then check everything; only what could not be fixed fails.
|
||||
const r = refresh(g, dir);
|
||||
for (const x of r.fixed) console.log(`fixed: ${x}`);
|
||||
const bad = [...r.bad, ...check(g, dir)];
|
||||
for (const b of bad) console.error(`error: ${b}`);
|
||||
console.log(bad.length ? `${bad.length} problem(s)` : `${list(dir).length} weekly puzzle(s) OK`);
|
||||
process.exit(bad.length ? 1 : 0);
|
||||
}
|
||||
// By default the week that holds "12 hours from now": run early on Sunday, that is the week starting that morning.
|
||||
const first = opt('--key') || g.ev(`pzWeekKey(Date.now()+12*3600e3)`), n = +opt('--next', 1);
|
||||
for (let i = 0; i < n; i++) {
|
||||
const key = g.ev(`pzKeyAdd('${first}',${i})`);
|
||||
if (!key) { console.error(`error: ${first} is not a week`); process.exit(1); }
|
||||
if (fs.existsSync(path.join(dir, key + '.json')) && !args.includes('--force')) { console.log(`${key}: already there`); continue; }
|
||||
const j = generate(g, key, dir); writeWeek(dir, j);
|
||||
console.log(`${key}: ${j.theme}, ${j.cities.join(' ')}${j.via.length ? ' via ' + j.via.join(' ') : ''}${j.avoid.length ? ' avoid ' + j.avoid.join(' ') : ''}, budget ${j.budget} (1★ ${j.ref.one}, 3★ ${j.ref.three})`);
|
||||
}
|
||||
}
|
||||
297
scripts/weekly-scenario.js
Normal file
297
scripts/weekly-scenario.js
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
#!/usr/bin/env node
|
||||
// The weekly scenario generator, the twin of scripts/weekly-puzzle.js. Every Sunday .github/workflows/weekly-puzzle.yml
|
||||
// runs both; this one publishes site/scenarios/weekly/<key>.json, which the game fetches when the Scenarios list opens
|
||||
// (src/game/60-features/94-scenarios-weekly.js). It loads the real game headless, so it uses the game's own cities,
|
||||
// cables, prices, week keys, file validator and goal code.
|
||||
//
|
||||
// node scripts/weekly-scenario.js the week starting on the coming (or current) Sunday 06:00 Berlin, if missing
|
||||
// node scripts/weekly-scenario.js --key 2026-W45 that week (--force replaces an existing file)
|
||||
// node scripts/weekly-scenario.js --next 3 this week and the next two
|
||||
// node scripts/weekly-scenario.js --check re-play every week not over yet with this game; a week its reference
|
||||
// no longer wins is regenerated with rev + 1 (see refresh()); then
|
||||
// validate every file. Fails only if that fails.
|
||||
// --page FILE / --dir DIR another build of the game / where the files live
|
||||
//
|
||||
// How a scenario is made: pick a theme the last weeks did not have (TEMPLATES, plain data), a home city from another part
|
||||
// of the world than the last weeks', its rules and the reference plan (which links to build, in order). Then the
|
||||
// reference player (scripts/lib/scenario-bot.js) plays it through the game's own actions with the scenario's seed. The
|
||||
// goal's number is calibrated from that run (what the reference reached about three quarters of the way in), and the
|
||||
// scenario is verified: not won on day 0, won by the reference with time to spare. Its finishing day is the par.
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const BOT = require('./lib/scenario-bot');
|
||||
|
||||
const ROOT = path.join(__dirname, '..');
|
||||
const SCHEMA = 1, HISTORY = 4, THEME_GAP = 4, REG_GAP = 3, ATTEMPTS = 12, AT = 0.8, MARGIN = 0.9;
|
||||
|
||||
// ---------- the templates: data only. `home` names a city pool, `goal` a goal type of the game, `plan` a planner ----------
|
||||
const TEMPLATES = {
|
||||
budget: { goal: 'served', home: 'big', days: [240, 300], cash: [150000, 250000], lvl: 2, mods: ['pricey'], plan: 'spread', hops: 4 },
|
||||
spat: { goal: 'reach', home: 'big', days: [240, 300], cash: [500000, 800000], lvl: 2, rules: { spat: true }, plan: 'spread', hops: 3, tr2: true, avoid: ['cog'] },
|
||||
region: { goal: 'ix', home: 'ixrich', days: [270, 365], cash: [200000, 350000], lvl: 2, plan: 'exchanges', hops: 14 },
|
||||
event: { goal: 'event', home: 'big', days: [180, 240], cash: [500000, 900000], lvl: 2, plan: 'spread', hops: 2, sizes: [1600, 800, 400, 200] },
|
||||
flood: { goal: 'floods', home: 'big', days: [240, 300], cash: [1500000, 2500000], lvl: 3, rules: { ddos: true }, plan: 'spread', hops: 2, scrub: 1 },
|
||||
island: { goal: 'pops', home: 'island', days: [240, 365], cash: [250000, 500000], lvl: 3, plan: 'islands', hops: 3 },
|
||||
cable: { goal: 'path', home: 'landing', days: [270, 365], cash: [200000, 400000], lvl: 3, plan: 'detour', g: [400, 800], n: 45 },
|
||||
latency: { goal: 'lat', home: 'fast', days: [180, 270], cash: [300000, 600000], lvl: 3, plan: 'fast', n: 60 },
|
||||
};
|
||||
|
||||
// ---------- the game, headless ----------
|
||||
function game(file) {
|
||||
const { load } = require('../tests/harness');
|
||||
let g = load(file ? { file } : {});
|
||||
if (file && !g.ev("typeof wsValid==='function'")) { console.warn(`warning: ${file} has no weekly scenarios yet; using src/ instead`); g = load(); }
|
||||
return g;
|
||||
}
|
||||
const J = (ev, s) => JSON.parse(ev(`JSON.stringify(${s})`));
|
||||
|
||||
// ---------- small helpers ----------
|
||||
const hash = (s) => { let h = 2166136261; for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619); } return h >>> 0; };
|
||||
function rng(seed) { let a = seed >>> 0 || 1; return () => { a = (a + 0x6D2B79F5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; }
|
||||
const pick = (r, a) => a[Math.floor(r() * a.length)];
|
||||
const between = (r, [lo, hi], step) => lo + Math.floor(r() * ((hi - lo) / step + 1)) * step;
|
||||
// A goal number players can read: two significant digits, rounded down.
|
||||
const nice = (x) => { if (x < 10) return Math.max(1, Math.floor(x)); const p = 10 ** (Math.floor(Math.log10(x)) - 1); return Math.floor(x / p) * p; };
|
||||
|
||||
// ---------- the world, as the game sees it ----------
|
||||
function world(ev) {
|
||||
const cities = J(ev, `Object.values(CITY).filter(c=>pzCityOk(c.id)).map(c=>({id:c.id,reg:c.reg,P:c.P,land:lands(c)[0],nl:lands(c).length,ix:ixIdsIn(c.id).length,lon:c.lon,lat:c.lat}))`);
|
||||
const C = Object.fromEntries(cities.map((c) => [c.id, c]));
|
||||
const pairs = J(ev, 'CABLE_PAIRS.map(p=>[p.cid,p.a,p.b])').filter(([, a, b]) => C[a] && C[b]);
|
||||
const byLand = {}; for (const c of cities) (byLand[c.land] = byLand[c.land] || []).push(c.id);
|
||||
const km = (a, b) => { const A = C[a], B = C[b], r = Math.PI / 180, h = Math.sin((B.lat - A.lat) * r / 2) ** 2 + Math.cos(A.lat * r) * Math.cos(B.lat * r) * Math.sin((B.lon - A.lon) * r / 2) ** 2; return 12742 * Math.asin(Math.sqrt(h)); };
|
||||
const cabs = (c) => pairs.filter(([, a, b]) => a === c || b === c);
|
||||
const pools = {
|
||||
big: cities.filter((c) => c.P >= 150 && byLand[c.land].length >= 5).map((c) => c.id),
|
||||
ixrich: cities.filter((c) => c.ix && cities.filter((x) => x.reg === c.reg && x.land === c.land && x.ix && km(c.id, x.id) < 2500).length >= 9).map((c) => c.id),
|
||||
island: cities.filter((c) => byLand[c.land].length <= 2 && c.nl === 1 && cabs(c.id).length >= 2).map((c) => c.id),
|
||||
landing: cities.filter((c) => c.P >= 100 && cabs(c.id).length >= 3).map((c) => c.id),
|
||||
fast: cities.filter((c) => c.P >= 100 && cabs(c.id).length >= 2).map((c) => c.id),
|
||||
};
|
||||
return { cities, C, pairs, byLand, km, cabs, pools };
|
||||
}
|
||||
const near = (W, c, from, n) => from.filter((x) => x !== c).sort((a, b) => W.km(c, a) - W.km(c, b)).slice(0, n);
|
||||
|
||||
// ---------- drafts: a template, a home, rules, the goal's fixed parameters and the reference plan ----------
|
||||
// Plans are lists of steps for the reference player: {k:'hop',v:[a,b,tier,via]} lights a wave a-b (a new POP at b).
|
||||
function draft(g, W, theme, r, hist) {
|
||||
const T = TEMPLATES[theme], free = (c) => !hist.cities.has(c) && !hist.regs.includes(W.C[c].reg);
|
||||
const homes = W.pools[T.home].filter(free); if (!homes.length) return null;
|
||||
const home = pick(r, homes), H = W.C[home];
|
||||
const f = { theme, city: home, cash: between(r, T.cash, 50000), days: between(r, T.days, 10), lvl: T.lvl, rules: { ...(T.rules || {}) }, mods: (T.mods || []).slice() };
|
||||
const plan = { home, bb: true, ix: true, steps: [], avoid: T.avoid || [], tr2: !!T.tr2, scrub: T.scrub || 0 };
|
||||
const hop = (a, b, t = 1, via = null) => plan.steps.push({ k: 'hop', v: [a, b, t, via] });
|
||||
const land = W.byLand[H.land].filter((c) => c !== home && W.km(home, c) < 1500);
|
||||
let goal = null, words = {};
|
||||
if (T.plan === 'spread') {
|
||||
// Overland to the nearest big cities, each from the closest POP already built.
|
||||
const to = near(W, home, land.filter((c) => W.C[c].P >= 60), T.hops); if (to.length < Math.min(2, T.hops)) return null;
|
||||
const built = [home]; for (const c of to) { hop(near(W, c, built, 1)[0], c); built.push(c); }
|
||||
if (theme === 'budget') goal = { t: 'served', p: { g: 0 } };
|
||||
if (theme === 'spat') goal = { t: 'reach', p: { r: 99, g: 0 } };
|
||||
if (theme === 'flood') goal = { t: 'floods', p: { n: 0, big: 0 } };
|
||||
if (theme === 'event') { const day = Math.round(f.days * (0.6 + r() * 0.15)); goal = { t: 'event', p: { city: home, g: 0, day, dur: 3 + Math.floor(r() * 3) } }; plan.event = { city: home, day }; words = { day }; }
|
||||
} else if (T.plan === 'exchanges') {
|
||||
const to = near(W, home, W.cities.filter((c) => c.reg === H.reg && c.land === H.land && c.ix).map((c) => c.id), T.hops); if (to.length < T.hops) return null;
|
||||
const built = [home]; for (const c of to) { hop(near(W, c, built, 1)[0], c); built.push(c); }
|
||||
plan.allIx = true; goal = { t: 'ix', p: { reg: H.reg, n: 0 } }; words = { reg: H.reg };
|
||||
} else {
|
||||
// Cable work: plan inside the game, which knows each pair's cables under this scenario's rules.
|
||||
let a = home, b = null, cs = null;
|
||||
if (theme === 'cable') {
|
||||
// Cut one cable everywhere it lands; the goal is its far end, the long way round.
|
||||
const mine = W.cabs(home).filter(([, x, y]) => W.C[x].land !== W.C[y].land && W.C[x === home ? y : x].P >= 60);
|
||||
if (!mine.length) return null;
|
||||
const [cid, x, y] = pick(r, mine); b = x === home ? y : x;
|
||||
// The whole cable, and every other cable straight from home to its far end: the corridor is closed.
|
||||
const cut = new Set([cid, ...W.pairs.filter(([, p, q]) => (p === home && q === b) || (p === b && q === home)).map(([c]) => c)]);
|
||||
f.rules.banPairs = W.pairs.filter(([c, p, q]) => c === cid || (cut.has(c) && [p, q].includes(home) && [p, q].includes(b))).map(([c, p, q]) => `${c}:${p}-${q}`);
|
||||
if (f.rules.banPairs.length > 40) return null;
|
||||
const gb = pick(r, T.g); plan.tier = J(g.ev, `LT.findIndex(x=>x.g>=${gb})`);
|
||||
goal = { t: 'path', p: { a, b, g: gb, n: T.n } }; words = { cab: cid, a, b };
|
||||
} else if (theme === 'island') {
|
||||
const hops = W.cabs(home).map(([, x, y]) => (x === home ? y : x)).filter((c, i, s) => s.indexOf(c) === i && W.km(home, c) < 6000);
|
||||
if (hops.length < 2) return null;
|
||||
// The nearest islands a cable away, and one more island further out.
|
||||
const isl = W.pools.island.filter((c) => c !== home && W.km(home, c) < 9000 && !hops.includes(c));
|
||||
cs = [...near(W, home, hops, 2), ...near(W, home, isl, 1 + Math.floor(r() * 2))];
|
||||
if (cs.length < 3) return null;
|
||||
goal = { t: 'pops', p: { cs } };
|
||||
} else if (theme === 'latency') {
|
||||
// Far enough that the fast way takes more than one cable.
|
||||
const ok = W.cities.filter((c) => c.P >= 100 && c.land !== H.land && W.km(home, c.id) > 5000 && W.km(home, c.id) < 11000 && W.cabs(c.id).length >= 2).map((c) => c.id);
|
||||
if (!ok.length) return null; b = pick(r, ok); goal = { t: 'lat', p: { a, b, ms: 0, n: T.n } }; words = { a, b };
|
||||
}
|
||||
plan.targets = cs || [b]; plan.fast = theme === 'latency';
|
||||
f.goal = goal;
|
||||
return { f, plan, words, T };
|
||||
}
|
||||
f.goal = goal;
|
||||
return { f, plan, words, T };
|
||||
}
|
||||
|
||||
// ---------- names and descriptions: labels and their fill-ins ----------
|
||||
function texts(ev, d, r) {
|
||||
const T = J(ev, `WS_THEMES['${d.f.theme}']`), p = d.f.goal.p;
|
||||
const fill = (l) => { const need = [...new Set([...ev(`EN['${l}']`).matchAll(/\{(\w+)\}/g)].map((m) => m[1]))], o = {};
|
||||
for (const k of need) o[k] = k === 'city' ? d.f.city : k === 'ms' ? p.ms : k === 'g' ? p.g : k === 'n' ? p.n : d.words[k];
|
||||
return { l, p: o }; };
|
||||
return { name: fill(pick(r, T.names)), desc: fill(pick(r, T.descs)) };
|
||||
}
|
||||
|
||||
// ---------- playing a draft ----------
|
||||
const fileOf = (key, d, seed, extra) => ({ v: SCHEMA, key, theme: d.f.theme, city: d.f.city, cash: d.f.cash, days: d.f.days, lvl: d.f.lvl, rules: d.f.rules, mods: d.f.mods, goal: d.f.goal, ...extra, seed, ref: d.plan });
|
||||
// Cable plans are made in the game, once the scenario's rules are in force: the shortest chain of POPs to each target.
|
||||
function cablePlan(ev, plan) {
|
||||
if (!plan.targets) return plan;
|
||||
const steps = J(ev, `(()=>{const home=S.scn.home,T=${JSON.stringify(plan.targets)},fast=${!!plan.fast},out=[],have=new Set([home]);
|
||||
const ok=c=>pzCityOk(c)&&cityOn(c)&&!cnCity(c);
|
||||
const edges=u=>{const o=[];for(const p of CABLE_PAIRS){const v=p.a===u?p.b:p.b===u?p.a:null;if(!v||!ok(v))continue;const cs=cablesOk(u,v);if(!cs.length)continue;
|
||||
const c=cs.slice().sort((x,y)=>x.km*(CAB[x.cid].lat||1)-y.km*(CAB[y.cid].lat||1))[0];o.push([v,c.km*(CAB[c.cid].lat||1)/200,c.cid]);}
|
||||
for(const c of CITIES)if(c.id!==u&&ok(c.id)&&!isSub(u,c.id)&&kmBetween(u,c.id)<(fast?4000:1800))o.push([c.id,kmBetween(u,c.id)*1.3/200,null]);return o;};
|
||||
for(const t of T){if(have.has(t))continue;const d={},pv={},done=new Set();for(const h of have)d[h]=0;
|
||||
for(;;){let u=null;for(const k in d)if(!done.has(k)&&(u===null||d[k]<d[u]))u=k;if(u===null||u===t)break;done.add(u);for(const [v,w,cid] of edges(u)){const nd=d[u]+(fast?w:1+w/1000);if(!(d[v]<=nd)){d[v]=nd;pv[v]=[u,cid];}}}
|
||||
if(d[t]===undefined)return null;const chain=[];for(let v=t;!have.has(v);v=pv[v][0])chain.unshift([pv[v][0],v,${plan.tier || 1},pv[v][1]]);for(const h of chain){out.push({k:'hop',v:h});have.add(h[1]);}}
|
||||
return out;})()`);
|
||||
return steps ? { ...plan, steps } : null;
|
||||
}
|
||||
// Starts the draft in the game (so its rules apply), finishes the plan, and plays it with the reference player.
|
||||
function run(g, file, plan, days) {
|
||||
const { ev } = g;
|
||||
ev(`localStorage.removeItem('sot-wkscn');wsBegin(${JSON.stringify(file)},'Ref');if(UI.pendGame)ACT.pitchSkip()`);
|
||||
const p = cablePlan(ev, plan); if (!p || (plan.targets && p.steps.length < 2)) return null;
|
||||
return { plan: p, res: BOT.play(ev, { ...file, ref: p }, p, { days, stop: false }) };
|
||||
}
|
||||
|
||||
// The goal's number, from the reference run: what it held about three quarters of the way in.
|
||||
function calibrate(g, d, key, seed) {
|
||||
const { f } = d, p = f.goal.p, t = f.goal.t, at = Math.round(f.days * AT);
|
||||
// The validator wants a complete goal: start from placeholders the game accepts.
|
||||
const probe = JSON.parse(JSON.stringify(f.goal));
|
||||
if (t === 'served') probe.p.g = 50000; if (t === 'reach') probe.p.g = 50000; if (t === 'ix') probe.p.n = 60; if (t === 'floods') probe.p.n = 60;
|
||||
if (t === 'event') probe.p.g = 10; if (t === 'lat') probe.p.ms = 400;
|
||||
// Probed with placeholder numbers; the real name and text are filled in once the numbers are known.
|
||||
const tmp = { ...d, f: { ...f, goal: probe } }, file = fileOf(key, tmp, seed, { ...texts(g.ev, tmp, rng(1)), par: 1 });
|
||||
if (t === 'event') {
|
||||
// The biggest event the reference delivers in full.
|
||||
for (const size of d.T.sizes) { probe.p.g = size; file.goal = probe; const o = run(g, { ...file }, { ...d.plan, event: { ...d.plan.event, g: size } }, p.day + p.dur + 1); if (o && g.ev('(S.stats.evFull||0)>=1')) { p.g = size; return { plan: o.plan }; } }
|
||||
return null;
|
||||
}
|
||||
if (t === 'lat') {
|
||||
const o = run(g, file, d.plan, at); if (!o) return null;
|
||||
const best = g.ev(`bestLat('${p.a}','${p.b}')`); if (!isFinite(best)) return null;
|
||||
p.ms = Math.ceil(best * 1.03 + 0.5); return { plan: o.plan };
|
||||
}
|
||||
const o = run(g, file, d.plan, at); if (!o) return null;
|
||||
const m = o.res.m, v = m[m.length - 1];
|
||||
if (t === 'served') p.g = nice(Math.min(...m.slice(-14)));
|
||||
if (t === 'reach') { if (g.ev('R.reach') < 0.99) return null; p.g = nice(Math.min(...m.slice(-14))); }
|
||||
if (t === 'ix') p.n = Math.floor(v);
|
||||
if (t === 'floods') { p.n = Math.floor(v); p.big = Math.min(5, g.ev('S.stats.ddosOkBig||0')); }
|
||||
if ((p.g !== undefined && p.g < 5) || (p.n !== undefined && p.n < 2)) return null;
|
||||
return { plan: o.plan };
|
||||
}
|
||||
|
||||
// The game's validator decides what a scenario is; then it must need play, and the reference must win with time to spare.
|
||||
function verify(g, j) {
|
||||
const { ev } = g;
|
||||
if (!ev(`!!wsValid(${JSON.stringify(j)},'${j.key}')`)) return { ok: false, why: 'the game rejects the file' };
|
||||
// Played with the longest clock the game allows, so a late win still shows its day (the days change nothing else).
|
||||
const res = BOT.play(ev, { ...j, days: 400 }, j.ref, { stop: true });
|
||||
if (res.won0) return { ok: false, why: 'won on day 0' };
|
||||
if (!res.won) return { ok: false, why: `the reference does not win in ${j.days} days` };
|
||||
if (res.won > j.days * MARGIN) return { ok: false, late: res.won, why: `the reference wins only on day ${res.won} of ${j.days}` };
|
||||
if (res.won < 40) return { ok: false, why: `the reference wins already on day ${res.won} of ${j.days}` };
|
||||
return { ok: true, par: res.won };
|
||||
}
|
||||
|
||||
// ---------- one week ----------
|
||||
const list = (dir) => (fs.existsSync(dir) ? fs.readdirSync(dir).filter((f) => /^\d{4}-W\d{2}\.json$/.test(f)).map((f) => f.slice(0, -5)).sort() : []);
|
||||
function history(W, dir, key) {
|
||||
const files = list(dir).filter((k) => k < key).slice(-HISTORY).map((k) => JSON.parse(fs.readFileSync(path.join(dir, k + '.json'), 'utf8')));
|
||||
return { themes: files.slice(-THEME_GAP).map((f) => f.theme), regs: files.slice(-REG_GAP).map((f) => W.C[f.city] && W.C[f.city].reg).filter(Boolean), cities: new Set(files.map((f) => f.city)) };
|
||||
}
|
||||
function generate(g, key, dir) {
|
||||
const { ev } = g, W = world(ev);
|
||||
if (ev(`pzWeekStart('${key}')`) == null) throw new Error(`${key} is not a week`);
|
||||
const hist = history(W, dir, key), free = Object.keys(TEMPLATES).sort().filter((t) => !hist.themes.includes(t)), h = hash('scn|' + key);
|
||||
const order = free.map((_, i) => free[(h + i) % free.length]);
|
||||
for (const theme of order) {
|
||||
for (let at = 0; at < ATTEMPTS; at++) {
|
||||
const r = rng(hash(`${key}|${theme}|${at}`)), d = draft(g, W, theme, r, hist);
|
||||
if (!d) continue;
|
||||
const seed = 1 + (hash(`${key}|seed|${at}`) % 2147483646), c = calibrate(g, d, key, seed);
|
||||
if (!c) { console.warn(`${key}: rejected a ${theme} scenario in ${d.f.city}: no goal to calibrate`); continue; }
|
||||
d.plan = c.plan;
|
||||
const w = texts(ev, d, r), j = fileOf(key, d, seed, { name: w.name, desc: w.desc, par: 1 });
|
||||
let v = verify(g, j);
|
||||
// A goal with a fixed bar (a path, a set of POPs, a latency) gets the days the reference needed, and a third more.
|
||||
const day = v.ok ? v.par : v.late;
|
||||
if (day && ['path', 'pops', 'lat'].includes(j.goal.t)) { j.days = Math.min(365, Math.max(180, Math.ceil(day / 0.7 / 10) * 10)); v = verify(g, j); }
|
||||
if (v.ok) { j.par = v.par; return order0(j); }
|
||||
console.warn(`${key}: rejected a ${theme} scenario in ${d.f.city}: ${v.why}`);
|
||||
}
|
||||
}
|
||||
throw new Error(`${key}: no scenario survived verification`);
|
||||
}
|
||||
// Fields in a fixed order, so files diff well.
|
||||
const order0 = (j) => { const o = {}; for (const k of ['v', 'key', 'rev', 'theme', 'city', 'cash', 'days', 'lvl', 'rules', 'mods', 'goal', 'name', 'desc', 'seed', 'par', 'ref']) if (j[k] !== undefined) o[k] = j[k]; return o; };
|
||||
|
||||
// --check: every file is what the game accepts, under its own name, listed in the index; weeks not over yet still verify.
|
||||
function check(g, dir, now = Date.now()) {
|
||||
const { ev } = g, bad = [], keys = list(dir);
|
||||
for (const k of keys) {
|
||||
let j; try { j = JSON.parse(fs.readFileSync(path.join(dir, k + '.json'), 'utf8')); } catch (e) { bad.push(`${k}: not JSON`); continue; }
|
||||
if (!ev(`!!wsValid(${JSON.stringify(j)},'${k}')`)) { bad.push(`${k}: the game rejects it`); continue; }
|
||||
if (!j.ref || !Array.isArray(j.ref.steps)) { bad.push(`${k}: no reference plan`); continue; }
|
||||
if (ev(`pzWeekStart('${k}')`) + 7 * 864e5 > now) { const v = verify(g, j); if (!v.ok) bad.push(`${k}: ${v.why}`); else if (v.par !== j.par) bad.push(`${k}: par is ${j.par}, the reference wins on day ${v.par}`); }
|
||||
}
|
||||
let idx = null; try { idx = JSON.parse(fs.readFileSync(path.join(dir, 'index.json'), 'utf8')); } catch (e) { /* reported below */ }
|
||||
if (keys.length && (!idx || idx.v !== SCHEMA || JSON.stringify(idx.weeks) !== JSON.stringify(keys))) bad.push('index.json does not list exactly the weekly files');
|
||||
return bad;
|
||||
}
|
||||
/* --check, first part: a release can change prices, cables or the simulation under weeks already published. Every week
|
||||
not over yet is re-played with this game. Still won with time to spare: only its par follows. Not any more: it is
|
||||
regenerated for the same key, deterministically, with rev + 1, so last week's wins for it no longer show. Past weeks
|
||||
are only replaced when the game rejects them outright. */
|
||||
function refresh(g, dir, now = Date.now()) {
|
||||
const { ev } = g, fixed = [], bad = [];
|
||||
for (const k of list(dir)) {
|
||||
let j = null; try { j = JSON.parse(fs.readFileSync(path.join(dir, k + '.json'), 'utf8')); } catch (e) { /* regenerated */ }
|
||||
const valid = !!j && ev(`!!wsValid(${JSON.stringify(j)},'${k}')`) && j.ref && Array.isArray(j.ref.steps), live = ev(`pzWeekStart('${k}')`) + 7 * 864e5 > now;
|
||||
if (valid && !live) continue;
|
||||
const v = valid ? verify(g, j) : null;
|
||||
if (v && v.ok) { if (v.par !== j.par) { j.par = v.par; writeWeek(dir, j); fixed.push(`${k}: new par ${v.par}`); } continue; }
|
||||
const rev = (j && Number.isInteger(j.rev) && j.rev >= 2 ? j.rev : 1) + 1;
|
||||
let n; try { n = order0({ ...generate(g, k, dir), rev }); } catch (e) { bad.push(`${k}: could not regenerate (${e.message})`); continue; }
|
||||
writeWeek(dir, n); fixed.push(`${k}: regenerated as rev ${rev}, a ${n.theme} scenario in ${n.city}`);
|
||||
}
|
||||
let idx = null; try { idx = JSON.parse(fs.readFileSync(path.join(dir, 'index.json'), 'utf8')); } catch (e) { /* rewritten */ }
|
||||
if (list(dir).length && (!idx || idx.v !== SCHEMA || JSON.stringify(idx.weeks) !== JSON.stringify(list(dir)))) { writeIndex(dir); fixed.push('index.json rewritten'); }
|
||||
return { fixed, bad };
|
||||
}
|
||||
const writeIndex = (dir) => fs.writeFileSync(path.join(dir, 'index.json'), JSON.stringify({ v: SCHEMA, weeks: list(dir) }) + '\n');
|
||||
const writeWeek = (dir, j) => { fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(path.join(dir, j.key + '.json'), JSON.stringify(j) + '\n'); writeIndex(dir); };
|
||||
|
||||
module.exports = { game, generate, verify, check, refresh, list, writeWeek, TEMPLATES };
|
||||
|
||||
if (require.main === module) {
|
||||
const args = process.argv.slice(2), opt = (n, d) => { const i = args.indexOf(n); return i >= 0 ? args[i + 1] : d; };
|
||||
const dir = path.resolve(ROOT, opt('--dir', 'site/scenarios/weekly')), g = game(opt('--page') && path.resolve(opt('--page')));
|
||||
if (args.includes('--check')) {
|
||||
const r = refresh(g, dir);
|
||||
for (const x of r.fixed) console.log(`fixed: ${x}`);
|
||||
const bad = [...r.bad, ...check(g, dir)];
|
||||
for (const b of bad) console.error(`error: ${b}`);
|
||||
console.log(bad.length ? `${bad.length} problem(s)` : `${list(dir).length} weekly scenario(s) OK`);
|
||||
process.exit(bad.length ? 1 : 0);
|
||||
}
|
||||
const first = opt('--key') || g.ev(`pzWeekKey(Date.now()+12*3600e3)`), n = +opt('--next', 1);
|
||||
for (let i = 0; i < n; i++) {
|
||||
const key = g.ev(`pzKeyAdd('${first}',${i})`);
|
||||
if (!key) { console.error(`error: ${first} is not a week`); process.exit(1); }
|
||||
if (fs.existsSync(path.join(dir, key + '.json')) && !args.includes('--force')) { console.log(`${key}: already there`); continue; }
|
||||
const j = generate(g, key, dir); writeWeek(dir, j);
|
||||
console.log(`${key}: ${j.theme} in ${j.city}, ${j.days} days, goal ${j.goal.t} ${JSON.stringify(j.goal.p)}, par ${j.par}`);
|
||||
}
|
||||
}
|
||||
1
site/architect/weekly/2026-W44.json
Normal file
1
site/architect/weekly/2026-W44.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":1,"key":"2026-W44","hq":"cor","budget":1580000,"name":{"l":"architect_weekly.name_all_roads_lead_to_hq","p":{"hq":"cor"}},"joke":{"l":"architect_weekly.joke_hq_signed_the_lease","p":{"hq":"cor"}},"briefs":[{"add":["bue"],"dem":{"bue":40},"tubes":1},{"add":["scl","mvd"],"dem":{"scl":20,"mvd":20},"tubes":2},{"gold":["mvd"],"tubes":2},{"drop":["scl"],"add":["ldb"],"dem":{"ldb":10},"gold":["ldb"],"tubes":2},{"lat":["ldb","mvd",10.1],"tubes":1},{"dem":{"bue":100},"tubes":0},{"add":["cgr"],"dem":{"cgr":10},"gold":["cgr"],"tubes":2}],"ref":{"spend":1489176,"steps":[[["cor","bue","land",1]],[["cor","scl","land",1],["bue","mvd","land",1]],[["bue","cor","land",1],["mvd","bue","land",1]],[["@rm","scl"],["cor","ldb","land",1],["ldb","cor","land",1]],[["ldb","mvd","land",1]],[["@tier",2,2],["@tier",0,2]],[["ldb","cgr","land",2],["cgr","ldb","land",2]]]}}
|
||||
1
site/architect/weekly/2026-W45.json
Normal file
1
site/architect/weekly/2026-W45.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":1,"key":"2026-W45","hq":"maa","budget":930000,"name":{"l":"architect_weekly.name_hq_and_friends","p":{"hq":"maa"}},"joke":{"l":"architect_weekly.joke_one_network_a_handful","p":{}},"briefs":[{"add":["blr"],"dem":{"blr":30},"tubes":1},{"add":["hyd","cbo"],"dem":{"hyd":20,"cbo":20},"tubes":2},{"gold":["cbo"],"tubes":1},{"ring":["maa","blr","hyd"],"tubes":1},{"drop":["hyd"],"add":["dac"],"dem":{"dac":20},"gold":["dac"],"tubes":2},{"gold":["blr"],"tubes":1}],"ref":{"spend":869628,"steps":[[["maa","blr","land",1]],[["blr","hyd","land",1],["maa","cbo","smw6",1]],[["cbo","maa","smw4",1]],[["hyd","maa","land",1]],[["@rm","hyd"],["maa","dac","land",1],["dac","maa","land",1]],[["blr","maa","land",1]]]}}
|
||||
1
site/architect/weekly/2026-W46.json
Normal file
1
site/architect/weekly/2026-W46.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":1,"key":"2026-W46","hq":"svg","budget":610000,"name":{"l":"architect_weekly.name_the_hq_job","p":{"hq":"svg"}},"joke":{"l":"architect_weekly.joke_one_network_a_handful","p":{}},"briefs":[{"add":["krs"],"dem":{"krs":30},"tubes":1},{"add":["osl","ebj"],"dem":{"osl":20,"ebj":20},"tubes":2},{"gold":["ebj"],"tubes":2},{"lat":["osl","svg",2.2],"tubes":1},{"drop":["krs"],"add":["cph"],"dem":{"cph":20},"gold":["cph"],"tubes":3},{"dem":{"osl":140},"tubes":0}],"ref":{"spend":567292,"steps":[[["svg","krs","land",1]],[["krs","osl","land",1],["krs","ebj","land",1]],[["krs","svg","land",1],["ebj","krs","land",1]],[["osl","svg","land",1]],[["@rm","krs"],["ebj","svg","land",1],["ebj","cph","land",1],["cph","osl","land",1]],[["@tier",0,2],["@tier",1,2],["@tier",2,2],["@tier",3,2]]]}}
|
||||
1
site/architect/weekly/index.json
Normal file
1
site/architect/weekly/index.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":1,"weeks":["2026-W44","2026-W45","2026-W46"]}
|
||||
1049
site/i18n/de.js
1049
site/i18n/de.js
File diff suppressed because it is too large
Load diff
1049
site/i18n/es.js
1049
site/i18n/es.js
File diff suppressed because it is too large
Load diff
1049
site/i18n/fr.js
1049
site/i18n/fr.js
File diff suppressed because it is too large
Load diff
1049
site/i18n/it.js
1049
site/i18n/it.js
File diff suppressed because it is too large
Load diff
1049
site/i18n/pt.js
1049
site/i18n/pt.js
File diff suppressed because it is too large
Load diff
1
site/puzzles/weekly/2026-W44.json
Normal file
1
site/puzzles/weekly/2026-W44.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":2,"key":"2026-W44","theme":"ring","cities":["ham","fra","bru","dus"],"src":["ham"],"dem":[{"t":"eye","a":"fra","g":30},{"t":"eye","a":"bru","g":60},{"t":"eye","a":"dus","g":60}],"via":[],"avoid":[],"budget":360000,"twist":{"ring":true},"name":{"l":"puzzles_weekly.name_one_ring_to_rule_reg","p":{"reg":"EU"}},"joke":{"l":"puzzles_weekly.joke_a_ring_survives_one_cut","p":{}},"ref":{"one":341708,"three":341708}}
|
||||
1
site/puzzles/weekly/2026-W45.json
Normal file
1
site/puzzles/weekly/2026-W45.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":2,"key":"2026-W45","theme":"tour","cities":["abj","fih","acc","dkr"],"src":["abj"],"dem":[{"t":"eye","a":"fih","g":20},{"t":"eye","a":"acc","g":10},{"t":"eye","a":"dkr","g":30}],"via":["lag"],"avoid":[],"budget":1750000,"twist":{},"name":{"l":"puzzles_weekly.name_tour_de_reg","p":{"reg":"AF"}},"joke":{"l":"puzzles_weekly.joke_a_road_trip_for_photons","p":{}},"ref":{"one":989200,"three":1657240}}
|
||||
1
site/puzzles/weekly/2026-W46.json
Normal file
1
site/puzzles/weekly/2026-W46.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":2,"key":"2026-W46","theme":"ocean","cities":["for","ssa","lad","lun"],"src":["for"],"dem":[{"t":"eye","a":"ssa","g":8},{"t":"eye","a":"lad","g":5},{"t":"eye","a":"lun","g":8}],"via":["sao","dla"],"avoid":[],"budget":4520000,"twist":{},"name":{"l":"puzzles_weekly.name_sea_you_in_b","p":{"b":"lad"}},"joke":{"l":"puzzles_weekly.joke_somewhere_between_a_and_b","p":{"a":"for","b":"lad"}},"ref":{"one":2368700,"three":4296628}}
|
||||
1
site/puzzles/weekly/index.json
Normal file
1
site/puzzles/weekly/index.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":2,"weeks":["2026-W44","2026-W45","2026-W46"]}
|
||||
1
site/scenarios/weekly/2026-W44.json
Normal file
1
site/scenarios/weekly/2026-W44.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":1,"key":"2026-W44","theme":"flood","city":"sto","cash":2050000,"days":250,"lvl":3,"rules":{"ddos":true},"mods":[],"goal":{"t":"floods","p":{"n":24,"big":1}},"name":{"l":"wkscn.name_packet_monsoon","p":{}},"desc":{"l":"wkscn.desc_city_hosts_the_internets_favourite","p":{"city":"sto"}},"seed":1559294845,"par":169,"ref":{"home":"sto","bb":true,"ix":true,"steps":[{"k":"hop","v":["sto","tll",1,null]},{"k":"hop","v":["tll","hel",1,null]}],"avoid":[],"tr2":false,"scrub":1}}
|
||||
1
site/scenarios/weekly/2026-W45.json
Normal file
1
site/scenarios/weekly/2026-W45.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":1,"key":"2026-W45","theme":"event","city":"bog","cash":900000,"days":230,"lvl":2,"rules":{},"mods":[],"goal":{"t":"event","p":{"city":"bog","g":400,"day":159,"dur":3}},"name":{"l":"wkscn.name_party_like_its_1999","p":{}},"desc":{"l":"wkscn.desc_the_whole_city_is_watching","p":{"day":159,"city":"bog","g":400}},"seed":169037385,"par":162,"ref":{"home":"bog","bb":true,"ix":true,"steps":[{"k":"hop","v":["bog","mde",1,null]},{"k":"hop","v":["bog","uio",1,null]}],"avoid":[],"tr2":false,"scrub":0,"event":{"city":"bog","day":159,"g":400}}}
|
||||
1
site/scenarios/weekly/2026-W46.json
Normal file
1
site/scenarios/weekly/2026-W46.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":1,"key":"2026-W46","theme":"spat","city":"fih","cash":750000,"days":250,"lvl":2,"rules":{"spat":true},"mods":[],"goal":{"t":"reach","p":{"r":99,"g":370}},"name":{"l":"wkscn.name_not_on_speaking_terms","p":{}},"desc":{"l":"wkscn.desc_two_giants_de_peered_over","p":{"city":"fih"}},"seed":61791269,"par":183,"ref":{"home":"fih","bb":true,"ix":true,"steps":[{"k":"hop","v":["fih","lad",1,null]},{"k":"hop","v":["fih","dla",1,null]}],"avoid":["cog"],"tr2":true,"scrub":0}}
|
||||
1
site/scenarios/weekly/index.json
Normal file
1
site/scenarios/weekly/index.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"v":1,"weeks":["2026-W44","2026-W45","2026-W46"]}
|
||||
|
|
@ -25,6 +25,12 @@ self.addEventListener('fetch', (e) => {
|
|||
}
|
||||
const local = url.origin === location.origin, fonts = /fonts\.(googleapis|gstatic)\.com$/.test(url.hostname);
|
||||
if (!local && !fonts) return;
|
||||
// Weekly puzzles, scenarios and Architect runs are published between releases: ask the network first, and keep a copy for offline.
|
||||
if (local && (url.pathname.startsWith('/puzzles/weekly/') || url.pathname.startsWith('/scenarios/weekly/') || url.pathname.startsWith('/architect/weekly/'))) {
|
||||
e.respondWith(fetch(req).then((r) => { if (r.ok) { const copy = r.clone(); caches.open(CACHE).then((c) => c.put(req, copy)); } return r; })
|
||||
.catch(() => caches.match(req).then((r) => r || Response.error())));
|
||||
return;
|
||||
}
|
||||
e.respondWith(caches.open(CACHE).then((c) => c.match(req).then((hit) => {
|
||||
const net = fetch(req).then((r) => { if (r && (r.ok || r.type === 'opaque')) c.put(req, r.clone()); return r; }).catch(() => hit);
|
||||
return hit || net;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
const APP_VERSION='__VERSION__';
|
||||
// Filled in by scripts/build.sh from CHANGELOG.md for this version.
|
||||
const RELEASE_NOTES=/*__RELEASE_NOTES__*/[];
|
||||
// A big release's story, shown in full in "What's new" (paragraphs; **bold** allowed). Empty for most releases.
|
||||
const RELEASE_STORY=/*__RELEASE_STORY__*/[];
|
||||
const IS_DEV=APP_VERSION.startsWith('__');
|
||||
// Only report from the real site; previews, localhost and the Claude viewer stay silent.
|
||||
const ANALYTICS={host:/(^|\.)seriesoftub\.es$/.test(location.hostname)?'https://stats.seriesoftub.es':'',site:'seriesoftub.es'};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ const RU_BOX=40000, RU_BOX_MO=2000;
|
|||
const UAE_LIC=15000,KSA_LIC=25000;
|
||||
// Korea: "sender pays" interconnection makes transit into Seoul about four times the usual price.
|
||||
const KR_TRANSIT=4;
|
||||
/* Gangnam Style Peering (scenario rule `sender`) turns sender pays all the way up: every Gbps a carrier delivers into
|
||||
Korea is billed again as a sender-pays fee, the incumbents take traffic only over a paid PNI, home gigabit is cheap,
|
||||
and users notice every millisecond of a haul to Tokyo or Hong Kong. */
|
||||
const KR_FEE=180,KR_ARPU=0.85,KR_LAT_OK=8,KR_LAT_BAD=40;
|
||||
/* Australia: a long way from everywhere. Every gigabit out of the country rides a long, thin subsea
|
||||
cable, so transit and waves cost more than almost anywhere else. IX ports are the exception: a
|
||||
nonprofit exchange sells 10G for about AUD 350 a month. Retail broadband is dear, but the national
|
||||
|
|
@ -20,7 +24,7 @@ const SITE2_N=[tr('economy.the_other_building'),tr('economy.campus_b_the_one_wit
|
|||
const siteNo=(name,n)=>name.replace('#',1+((S&&S.asn)|0)%(n||1));
|
||||
const siteName=(c,s)=>s==='b'?CITY[c].dc2?siteNo(CITY[c].dc2,CITY[c].dc2N):SITE2_N[hstr(c)%SITE2_N.length]:siteNo(CITY[c].dc,CITY[c].dcN);
|
||||
const BE_TAPE=30000;
|
||||
const popCost=c=>POP_COST+(c&&CITY[c]&&CITY[c].tape?BE_TAPE:0)+(c&&CITY[c]&&CITY[c].ru?RU_BOX:0)+(c&&CITY[c]&&CITY[c].uae?UAE_LIC:0)+(c&&CITY[c]&&CITY[c].saudi?KSA_LIC:0);
|
||||
const popCost=c=>Math.round(POP_COST*colo(c))+(c&&CITY[c]&&CITY[c].tape?BE_TAPE:0)+(c&&CITY[c]&&CITY[c].ru?RU_BOX:0)+(c&&CITY[c]&&CITY[c].uae?UAE_LIC:0)+(c&&CITY[c]&&CITY[c].saudi?KSA_LIC:0);
|
||||
const CN_LIC=150000, CN_JV_MO=6000;
|
||||
// Scrubbing centers come in tiers by clean bandwidth. Always-on diverts instantly; on-demand is cheaper
|
||||
// but takes a couple of days to engage. A clean-pipe add-on on a transit scrubs upstream, per port.
|
||||
|
|
@ -38,9 +42,13 @@ const FS_RES=[1,0.4,0.15];
|
|||
const DDOS_VEC={
|
||||
dns:{n:tr('common.dns_reflection'),fs:true},
|
||||
ntp:{n:tr('common.ntp_amplification'),fs:true},
|
||||
memcached:{n:tr('common.memcached_amplification'),fs:true},
|
||||
ack:{n:tr('common.ack_flood'),fs:false},
|
||||
cldap:{n:tr('common.cldap_flood'),fs:true},
|
||||
syn:{n:tr('common.syn_flood'),fs:true},
|
||||
http:{n:tr('common.http_flood'),fs:false},
|
||||
racknet:{n:tr('common.racknet'),fs:false,gaming:true},
|
||||
teamspooked:{n:tr('common.teamspooked'),fs:false,gaming:true},
|
||||
};
|
||||
const MYIX_COST=80000, MYIX_MO=3000, MYIX_FEE=1500, START_CASH=200000;
|
||||
// Your own exchange's switching fabric. Bigger fabrics carry more and attract more members.
|
||||
|
|
|
|||
|
|
@ -1,22 +1,29 @@
|
|||
/* Router models, by index: saves keep a POP's model as its index, so new models go at the end. bb is the highest
|
||||
core each one can run (cr, CORE_LV: 0 plain IGP, 1 LDP, 2 RSVP-TE, 3 SR-MPLS, 4 SRv6) and it runs every one below
|
||||
that too, except noMpls (SRv6 natively, no label stack). v is the vendor: mixing vendors is where interop fails. */
|
||||
const RG=[
|
||||
{n:'Rusty Router 9000',pn:'100G',cap:400,cost:0,mo:0,maxLT:1,maxP:1,ports:8,cls:0,lvl:1,boot:6,slowP:10,fs:0,chip:tr('routers.a_mystery_asic'),blurb:tr('routers.bought_used_on_ebuy_the_fans')},
|
||||
{n:'Edge Lord 400',pn:'400G',cap:3200,cost:30000,mo:1000,maxLT:2,maxP:2,ports:24,cls:1,lvl:2,boot:11,slowP:20,fs:1,chip:tr('common.merchant_silicon'),blurb:tr('routers.sharp_edgy_and_finally_speaks_400g')},
|
||||
{n:'Chonk 800',pn:'800G',cap:12800,cost:90000,mo:3000,maxLT:3,maxP:3,ports:36,cls:2,lvl:3,boot:25,slowP:45,fs:2,chip:'Junipurr PacketOinker™',blurb:tr('routers.an_absolute_unit_with_800g_ports')},
|
||||
{n:'Absolute Unit 1.6T',pn:'1.6T',cap:51200,cost:250000,mo:8000,maxLT:5,maxP:4,ports:40,cls:3,lvl:4,boot:40,slowP:60,fs:2,chip:tr('routers.packetoinker2_two_pigs_one_chassis'),blurb:tr('routers.1_6t_ports_its_own_weather')},
|
||||
{n:'Mikrowtik CCR',pn:'100G',cap:300,cost:4000,mo:150,maxLT:1,maxP:1,ports:16,cls:0,lvl:1,boot:2,slowP:5,badge:'M',fs:1,chip:tr('routers.a_few_dozen_arm_cores'),blurb:tr('routers.costs_less_than_lunch_and_has')},
|
||||
{n:'Sonic the Whitebox 32',pn:'400G',cap:3200,cost:14000,mo:400,maxLT:2,maxP:2,ports:32,cls:1,lvl:2,boot:9,slowP:25,flaky:true,badge:'W',fs:1,chip:tr('routers.tomahack_merchant_silicon'),blurb:tr('routers.a_bare_metal_switch_running_open')},
|
||||
{n:'Arrrhipster 7280R',pn:'400G',cap:4800,cost:42000,mo:1300,maxLT:2,maxP:2,ports:48,cls:1,lvl:2,boot:3,slowP:2,badge:'A',fs:2,chip:tr('routers.jerry_cho_deep_buffer_silicon'),blurb:tr('routers.fixed_config_deep_buffers_a_well')},
|
||||
{n:'Arrrhipster 7800R',pn:'800G',cap:16000,cost:130000,mo:4200,maxLT:3,maxP:3,ports:96,cls:2,lvl:3,boot:7,slowP:4,badge:'A',fs:2,chip:tr('routers.jerry_cho3_deep_buffer_silicon'),blurb:tr('routers.the_modular_one_ninety_six_800g')},
|
||||
{n:'Disco 8K',pn:'800G',cap:12800,cost:80000,mo:4800,maxLT:3,maxP:3,ports:64,cls:2,lvl:3,boot:20,slowP:35,badge:'D',fs:2,chip:'Silly-con One',blurb:tr('routers.cheap_to_buy_expensive_to_own')},
|
||||
{n:'Knockia 7750',pn:'1.6T',cap:40000,cost:200000,mo:7000,maxLT:5,maxP:4,ports:56,cls:3,lvl:4,boot:30,slowP:15,badge:'K',fs:2,chip:tr('routers.fin_p_network_processor'),blurb:tr('routers.finnish_engineering_indestructible')},
|
||||
{n:'Sonic the Whitebox 64',pn:'1.6T',cap:25600,cost:60000,mo:1500,maxLT:5,maxP:4,ports:64,cls:3,lvl:5,boot:9,slowP:25,flaky:true,badge:'W',fs:1,chip:tr('routers.tomahack_5_merchant_silicon'),blurb:tr('routers.sixty_four_1_6t_ports_on')},
|
||||
{n:'Disco 8K Ultra',pn:'1.6T',cap:51200,cost:140000,mo:11000,maxLT:5,maxP:4,ports:72,cls:3,lvl:6,boot:22,slowP:35,badge:'D',fs:2,chip:'Silly-con One G3',blurb:tr('routers.cheap_chassis_eternal_subscription')},
|
||||
{n:'Absolute Unit 3.2T',pn:'3.2T',cap:204800,cost:600000,mo:18000,maxLT:6,maxP:5,ports:48,cls:4,lvl:7,boot:50,slowP:60,fs:2,chip:tr('routers.packetoinker3_a_whole_litter'),blurb:tr('routers.3_2t_ports_and_12_8t')},
|
||||
{n:'Arrrhipster 7800R5',pn:'3.2T',cap:160000,cost:450000,mo:14000,maxLT:6,maxP:5,ports:144,cls:4,lvl:9,boot:8,slowP:4,badge:'A',fs:2,chip:tr('routers.jerry_cho5_deep_buffer_silicon'),blurb:tr('routers.a_hundred_and_forty_four_3')},
|
||||
{n:'Knockia 7950 XRS',pn:'3.2T',cap:180000,cost:520000,mo:15000,maxLT:6,maxP:5,ports:96,cls:4,lvl:10,boot:32,slowP:15,badge:'K',fs:2,chip:tr('routers.fin_p6_network_processor'),blurb:tr('routers.built_like_a_sauna_door_heavy')},
|
||||
{n:'Mikrowtik CCR 3.2T',pn:'3.2T',cap:51200,cost:45000,mo:900,maxLT:6,maxP:5,ports:32,cls:4,lvl:11,boot:3,slowP:5,flaky:true,badge:'M',fs:1,chip:tr('routers.several_hundred_arm_cores_and_a'),blurb:tr('routers.a_3_2t_router_for_the')},
|
||||
{n:'The Router at the End of the Universe',pn:'3.2T',cap:819200,cost:3000000,mo:60000,maxLT:6,maxP:5,ports:256,cls:4,lvl:13,boot:42,slowP:42,badge:'U',fs:2,chip:tr('routers.forty_two_of_them'),blurb:tr('routers.two_hundred_and_fifty_six_3')}
|
||||
{n:'Rusty Router 9000',cr:0,v:'rusty',pn:'100G',cap:400,cost:0,mo:0,maxLT:1,maxP:1,ports:8,cls:0,lvl:1,boot:6,slowP:10,fs:0,chip:tr('routers.a_mystery_asic'),blurb:tr('routers.bought_used_on_ebuy_the_fans')},
|
||||
{n:'Edge Lord 400',cr:0,v:'edge',pn:'400G',cap:3200,cost:30000,mo:1000,maxLT:2,maxP:2,ports:24,cls:1,lvl:2,boot:11,slowP:20,fs:1,chip:tr('common.merchant_silicon'),blurb:tr('routers.sharp_edgy_and_finally_speaks_400g')},
|
||||
{n:'Chonk 800',cr:2,v:'junipurr',pn:'800G',cap:12800,cost:90000,mo:3000,maxLT:3,maxP:3,ports:36,cls:2,lvl:3,boot:25,slowP:45,fs:2,chip:'Junipurr PacketOinker™',blurb:tr('routers.an_absolute_unit_with_800g_ports')},
|
||||
{n:'Absolute Unit 1.6T',cr:3,v:'junipurr',pn:'1.6T',cap:51200,cost:250000,mo:8000,maxLT:5,maxP:4,ports:40,cls:3,lvl:4,boot:40,slowP:60,fs:2,chip:tr('routers.packetoinker2_two_pigs_one_chassis'),blurb:tr('routers.1_6t_ports_its_own_weather')},
|
||||
{n:'Mikrowtik CCR',cr:1,v:'mikrowtik',pn:'100G',cap:300,cost:4000,mo:150,maxLT:1,maxP:1,ports:16,cls:0,lvl:1,boot:2,slowP:5,badge:'M',fs:1,chip:tr('routers.a_few_dozen_arm_cores'),blurb:tr('routers.costs_less_than_lunch_and_has')},
|
||||
{n:'Sonic the Whitebox 32',cr:0,v:'whitebox',pn:'400G',cap:3200,cost:14000,mo:400,maxLT:2,maxP:2,ports:32,cls:1,lvl:2,boot:9,slowP:25,flaky:true,badge:'W',fs:1,chip:tr('routers.tomahack_merchant_silicon'),blurb:tr('routers.a_bare_metal_switch_running_open')},
|
||||
{n:'Arrrhipster 7280R',cr:3,v:'arrrhipster',pn:'400G',cap:4800,cost:42000,mo:1300,maxLT:2,maxP:2,ports:48,cls:1,lvl:2,boot:3,slowP:2,badge:'A',fs:2,chip:tr('routers.jerry_cho_deep_buffer_silicon'),blurb:tr('routers.fixed_config_deep_buffers_a_well')},
|
||||
{n:'Arrrhipster 7800R',cr:3,v:'arrrhipster',pn:'800G',cap:16000,cost:130000,mo:4200,maxLT:3,maxP:3,ports:96,cls:2,lvl:3,boot:7,slowP:4,badge:'A',fs:2,chip:tr('routers.jerry_cho3_deep_buffer_silicon'),blurb:tr('routers.the_modular_one_ninety_six_800g')},
|
||||
{n:'Disco 8K',cr:4,v:'disco',pn:'800G',cap:12800,cost:80000,mo:4800,maxLT:3,maxP:3,ports:64,cls:2,lvl:3,boot:20,slowP:35,badge:'D',fs:2,chip:'Silly-con One',blurb:tr('routers.cheap_to_buy_expensive_to_own')},
|
||||
{n:'Knockia 7750',cr:4,v:'knockia',pn:'1.6T',cap:40000,cost:200000,mo:7000,maxLT:5,maxP:4,ports:56,cls:3,lvl:4,boot:30,slowP:15,badge:'K',fs:2,chip:tr('routers.fin_p_network_processor'),blurb:tr('routers.finnish_engineering_indestructible')},
|
||||
{n:'Sonic the Whitebox 64',cr:4,v:'whitebox',noMpls:true,pn:'1.6T',cap:25600,cost:60000,mo:1500,maxLT:5,maxP:4,ports:64,cls:3,lvl:5,boot:9,slowP:25,flaky:true,badge:'W',fs:1,chip:tr('routers.tomahack_5_merchant_silicon'),blurb:tr('routers.sixty_four_1_6t_ports_on')},
|
||||
{n:'Disco 8K Ultra',cr:4,v:'disco',pn:'1.6T',cap:51200,cost:140000,mo:11000,maxLT:5,maxP:4,ports:72,cls:3,lvl:6,boot:22,slowP:35,badge:'D',fs:2,chip:'Silly-con One G3',blurb:tr('routers.cheap_chassis_eternal_subscription')},
|
||||
{n:'Absolute Unit 3.2T',cr:4,v:'junipurr',pn:'3.2T',cap:204800,cost:600000,mo:18000,maxLT:6,maxP:5,ports:48,cls:4,lvl:7,boot:50,slowP:60,fs:2,chip:tr('routers.packetoinker3_a_whole_litter'),blurb:tr('routers.3_2t_ports_and_12_8t')},
|
||||
{n:'Arrrhipster 7800R5',cr:3,v:'arrrhipster',pn:'3.2T',cap:160000,cost:450000,mo:14000,maxLT:6,maxP:5,ports:144,cls:4,lvl:9,boot:8,slowP:4,badge:'A',fs:2,chip:tr('routers.jerry_cho5_deep_buffer_silicon'),blurb:tr('routers.a_hundred_and_forty_four_3')},
|
||||
{n:'Knockia 7950 XRS',cr:4,v:'knockia',pn:'3.2T',cap:180000,cost:520000,mo:15000,maxLT:6,maxP:5,ports:96,cls:4,lvl:10,boot:32,slowP:15,badge:'K',fs:2,chip:tr('routers.fin_p6_network_processor'),blurb:tr('routers.built_like_a_sauna_door_heavy')},
|
||||
{n:'Mikrowtik CCR 3.2T',cr:1,v:'mikrowtik',pn:'3.2T',cap:51200,cost:45000,mo:900,maxLT:6,maxP:5,ports:32,cls:4,lvl:11,boot:3,slowP:5,flaky:true,badge:'M',fs:1,chip:tr('routers.several_hundred_arm_cores_and_a'),blurb:tr('routers.a_3_2t_router_for_the')},
|
||||
{n:'The Router at the End of the Universe',cr:4,v:'universe',pn:'3.2T',cap:819200,cost:3000000,mo:60000,maxLT:6,maxP:5,ports:256,cls:4,lvl:13,boot:42,slowP:42,badge:'U',fs:2,chip:tr('routers.forty_two_of_them'),blurb:tr('routers.two_hundred_and_fifty_six_3')},
|
||||
{n:'Brocadabra MLX-16',cr:2,v:'brocadabra',pn:'400G',cap:4000,cost:26000,mo:900,maxLT:2,maxP:2,ports:32,cls:1,lvl:2,boot:14,slowP:20,flaky:true,badge:'B',fs:1,noPz:true,chip:tr('routers.a_refurbished_network_processor'),blurb:tr('routers.pulls_rsvp_tunnels_out_of_a')},
|
||||
{n:'Extremely Networks SLX 9740',cr:2,v:'extremely',pn:'1.6T',cap:36000,cost:170000,mo:5500,maxLT:5,maxP:4,ports:48,cls:3,lvl:4,boot:18,slowP:15,badge:'X',fs:2,noPz:true,chip:tr('routers.tridont_merchant_silicon'),blurb:tr('routers.bought_the_magician_s_hat')}
|
||||
];
|
||||
// The biggest model, which is no longer simply the last one.
|
||||
const RG_TOP=RG.reduce((b,r,i)=>r.cap>RG[b].cap?i:b,0);
|
||||
/* Some routers take forever to boot. Each POP's chassis has a personality per model: most come
|
||||
back in minutes, a few sit through every line card self-test known to the vendor. */
|
||||
const SLOW_BOOT=[tr('routers.is_oinking_through_the_self_test'),tr('routers.is_running_fsck_on_a_compact'),tr('routers.found_a_newer_firmware_on_the'),tr('routers.is_counting_to_2_million_routes'),tr('routers.is_waiting_for_the_line_cards'),tr('routers.booted_panicked_about_a_missing_fan'),tr('routers.is_synchronising_the_routing_engines')];
|
||||
|
|
|
|||
172
src/game/10-catalog/25-router-art.js
Normal file
172
src/game/10-catalog/25-router-art.js
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
/* ---------- router pictures: one cartoon per model in RG, same order ----------
|
||||
Drawn as SVG from a small kit in the map's style (navy outlines, candy colours), each with its model's joke. Built
|
||||
only when a panel shows one, then cached; the kit lives in its own scope. */
|
||||
const RG_ART=(()=>{
|
||||
const O='#1E2640',W=4;
|
||||
const st=(f,w=W)=>`fill="${f}" stroke="${O}" stroke-width="${w}" stroke-linejoin="round" stroke-linecap="round"`;
|
||||
const P=(d,f='none',w=W)=>`<path d="${d}" ${st(f,w)}/>`;
|
||||
const R=(x,y,w,h,f,r=10,sw=W)=>`<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="${r}" ${st(f,sw)}/>`;
|
||||
const C=(x,y,r,f,sw=W)=>`<circle cx="${x}" cy="${y}" r="${r}" ${st(f,sw)}/>`;
|
||||
const E=(x,y,rx,ry,f,sw=W,rot=0)=>`<ellipse cx="${x}" cy="${y}" rx="${rx}" ry="${ry}" ${st(f,sw)}${rot?` transform="rotate(${rot} ${x} ${y})"`:''}/>`;
|
||||
const T=(x,y,t,s=10,f=O)=>`<text x="${x}" y="${y}" font-family="'Baloo 2',Nunito,sans-serif" font-weight="800" font-size="${s}" fill="${f}" text-anchor="middle">${t}</text>`;
|
||||
const sh=(w=70,x=100,y=146)=>`<ellipse cx="${x}" cy="${y}" rx="${w}" ry="8" fill="${O}" opacity=".18"/>`;
|
||||
const bob=s=>`<g class="bob">${s}</g>`;
|
||||
const ports=(x,y,w,n,c='#7FD8EE')=>{let s=R(x,y,w,16,O,4,2);const g=(w-8)/n;for(let i=0;i<n;i++)s+=`<rect x="${x+4+i*g+1}" y="${y+4}" width="${(g-3).toFixed(1)}" height="8" rx="1.5" fill="${c}"/>`;return s;};
|
||||
const leds=(x,y,cs,r=4)=>cs.map((c,i)=>C(x+i*(r*3),y,r,c,2)).join('');
|
||||
// faces: eyes at (x,y), d apart from the middle
|
||||
const glint=(x,y)=>`<path d="M${x-3} ${y-2} l3 -1.5" stroke="#fff" stroke-width="1.6" stroke-linecap="round"/>`;
|
||||
const EY={
|
||||
happy:(x,y,d=14)=>P(`M${x-d-6} ${y} q6 -8 12 0 M${x+d-6} ${y} q6 -8 12 0`),
|
||||
sleepy:(x,y,d=14)=>P(`M${x-d-6} ${y} q6 6 12 0 M${x+d-6} ${y} q6 6 12 0`),
|
||||
dots:(x,y,d=14)=>`<circle cx="${x-d}" cy="${y}" r="4.5" fill="${O}"/><circle cx="${x+d}" cy="${y}" r="4.5" fill="${O}"/><circle cx="${x-d+1.6}" cy="${y-1.6}" r="1.4" fill="#fff"/><circle cx="${x+d+1.6}" cy="${y-1.6}" r="1.4" fill="#fff"/>`,
|
||||
angry:(x,y,d=14)=>P(`M${x-d-9} ${y-8} L${x-d+7} ${y-3} M${x+d+9} ${y-8} L${x+d-7} ${y-3}`,'none',5)+`<path d="M${x-d-8} ${y} L${x-d+7} ${y+2} L${x-d-8} ${y+6}Z M${x+d+8} ${y} L${x+d-7} ${y+2} L${x+d+8} ${y+6}Z" ${st('#FF4D5E',2)}/>`,
|
||||
shades:(x,y,d=14)=>`<path d="M${x-d-11} ${y-5} h22 v5 q0 8 -11 8 q-11 0 -11 -8z M${x+d-11} ${y-5} h22 v5 q0 8 -11 8 q-11 0 -11 -8z" ${st(O,2.5)}/>`+P(`M${x-d+11} ${y-3} H${x+d-11}`,'none',3)+glint(x-d,y)+glint(x+d,y),
|
||||
sad:(x,y,d=14)=>EY.dots(x,y+2,d)+P(`M${x-d-7} ${y-9} L${x-d+5} ${y-6} M${x+d+7} ${y-9} L${x+d-5} ${y-6}`,'none',3),
|
||||
dizzy:(x,y,d=14)=>P(`M${x-d-5} ${y-5} l10 10 m0 -10 l-10 10 M${x+d-5} ${y-5} l10 10 m0 -10 l-10 10`,'none',3.5),
|
||||
worried:(x,y,d=14)=>EY.dots(x,y,d)+P(`M${x-d-6} ${y-10} L${x-d+6} ${y-12} M${x+d+6} ${y-10} L${x+d-6} ${y-12}`,'none',3),
|
||||
};
|
||||
EY.wink=(x,y,d=14)=>`<circle cx="${x-d}" cy="${y}" r="4.5" fill="${O}"/><circle cx="${x-d+1.6}" cy="${y-1.6}" r="1.4" fill="#fff"/>`+P(`M${x+d-6} ${y} q6 -8 12 0`);
|
||||
const MO={
|
||||
smile:(x,y,w=9)=>P(`M${x-w} ${y} q${w} ${w*.8} ${2*w} 0`),
|
||||
grin:(x,y,w=10)=>P(`M${x-w} ${y} q${w} ${w*1.2} ${2*w} 0z`,'#7A2633',3),
|
||||
flat:(x,y,w=8)=>P(`M${x-w} ${y} h${2*w}`),
|
||||
frown:(x,y,w=8)=>P(`M${x-w} ${y+4} q${w} ${-w*.8} ${2*w} 0`),
|
||||
o:(x,y)=>E(x,y+2,4,5,'#7A2633',3),
|
||||
smirk:(x,y,w=9)=>P(`M${x-w} ${y+1} q${w*1.2} ${w*.5} ${2*w} -4`),
|
||||
w:(x,y)=>P(`M${x-8} ${y} q4 5 8 0 q4 5 8 0`),
|
||||
teeth:(x,y,w=12)=>R(x-w,y-4,2*w,9,'#fff',3,3)+P(`M${x-w/3} ${y-4} v9 M${x+w/3} ${y-4} v9`,'none',2),
|
||||
};
|
||||
const face=(x,y,e,m,d=14,my=14)=>EY[e](x,y,d)+(m?MO[m](x,y+my):'');
|
||||
const cheeks=(x,y,d=26)=>`<ellipse cx="${x-d}" cy="${y}" rx="7" ry="4.5" fill="#FF4F9A" opacity=".55"/><ellipse cx="${x+d}" cy="${y}" rx="7" ry="4.5" fill="#FF4F9A" opacity=".55"/>`;
|
||||
// props
|
||||
const antenna=(x,y,dx,dy,tip='#FFD23F')=>P(`M${x} ${y} l${dx} ${dy}`)+C(x+dx,y+dy,5,tip,3);
|
||||
const bent=(x,y)=>P(`M${x} ${y} q4 -14 18 -22 q6 4 2 10`);
|
||||
const tapeX=(x,y,w,h)=>P(`M${x} ${y} L${x+w} ${y+h} M${x+w} ${y} L${x} ${y+h}`,'none',13).replace(`stroke="${O}"`,'stroke="#C9D1E6"')+P(`M${x} ${y} L${x+w} ${y+h} M${x+w} ${y} L${x} ${y+h}`,'none',2).replace('stroke-linecap','stroke-dasharray="2 5" stroke-linecap');
|
||||
const cobweb=(x,y)=>P(`M${x} ${y} q10 -10 20 0 M${x+6} ${y} q4 -6 8 0 M${x+10} ${y} v-9`,'none',1.5);
|
||||
const sticker=(x,y,w,h,t,f='#fff',s=8)=>P(`M${x} ${y} h${w} l3 ${h} h${-w}z`,f,2.5)+T(x+w/2+1.5,y+h/2+3,t,s);
|
||||
const spots=(a)=>a.map(([x,y,s])=>P(`M${x} ${y} q${s} ${-s*.6} ${s*1.8} ${s*.2} q${-s*.2} ${s} ${-s*1.2} ${s*.8}z`,'#9A5226',3)).join('');
|
||||
const flames=(x,y,s=1)=>P(`M${x} ${y} q${-14*s} ${-6*s} ${-6*s} ${-24*s} q${4*s} ${8*s} ${10*s} ${8*s} q${-2*s} ${-12*s} ${8*s} ${-20*s} q${2*s} ${14*s} ${10*s} ${16*s} q${2*s} ${-6*s} ${-2*s} ${-12*s} q${14*s} ${8*s} ${8*s} ${32*s}z`,'#FF8A3D',3)+P(`M${x+2*s} ${y-2*s} q${-6*s} ${-4*s} ${-1*s} ${-12*s} q${4*s} ${6*s} ${8*s} ${4*s} q${2*s} ${6*s} ${-1*s} ${8*s}z`,'#FFD23F',2);
|
||||
const feet=(xs,y,f)=>xs.map(x=>P(`M${x-8} ${y} q-2 10 8 10 h6 q8 0 4 -10`,f)).join('');
|
||||
const legs=(xs,y,f='#1E2640',h=12)=>xs.map(x=>P(`M${x} ${y} v${h} h8`,'none',5)).join('');
|
||||
const cloud=(x,y,s=1,f='#fff')=>P(`M${x-22*s} ${y} q-8 -14 8 -14 q4 -12 18 -6 q12 -8 18 6 q14 0 8 14z`,f,3);
|
||||
const rain=(x,y)=>P(`M${x-14} ${y+6} l-3 8 M${x} ${y+6} l-3 8 M${x+14} ${y+6} l-3 8`,'none',3).replace(`stroke="${O}"`,'stroke="#2F8CFF"');
|
||||
const sun=(x,y,r=10)=>C(x,y,r,'#FFD23F',3)+P(`M${x} ${y-r-4} v-6 M${x} ${y+r+4} v6 M${x-r-4} ${y} h-6 M${x+r+4} ${y} h6 M${x-r} ${y-r} l-4 -4 M${x+r} ${y+r} l4 4 M${x+r} ${y-r} l4 -4 M${x-r} ${y+r} l-4 4`,'none',3);
|
||||
const bolt=(x,y,s=1,f='#FFD23F')=>P(`M${x} ${y} l${-10*s} ${18*s} h${8*s} l${-6*s} ${18*s} l${18*s} ${-24*s} h${-9*s} l${7*s} ${-12*s}z`,f,3);
|
||||
const smoke=(x,y)=>C(x,y,6,'#C9D1E6',2.5)+C(x+8,y-10,8,'#C9D1E6',2.5)+C(x+2,y-24,10,'#E8EDF7',2.5);
|
||||
const steam=(x,y)=>P(`M${x} ${y} q-6 -8 0 -16 q6 -8 0 -16 M${x+12} ${y} q-6 -8 0 -16 q6 -8 0 -16`,'none',3).replace(`stroke="${O}"`,'stroke="#fff"').replace('stroke-width="3"','stroke-width="4"');
|
||||
const speed=(x,y)=>P(`M${x} ${y} h-26 M${x-6} ${y+14} h-30 M${x} ${y+28} h-22`,'none',4).replace(`stroke="${O}"`,'stroke="#fff"');
|
||||
const tag=(x,y,l1,l2)=>P(`M${x-24} ${y-20} q-12 2 -12 14`,'none',2.5)+R(x-12,y-6,30,26,'#FFD23F',4,3)+T(x+3,y+5,l1,8)+(l2?T(x+3,y+15,l2,8):'');
|
||||
const disco=(x,y,r=16)=>P(`M${x} ${y-r-12} v12`)+C(x,y,r,'#C9D1E6')+P(`M${x-r+2} ${y-6} h${2*r-4} M${x-r} ${y+2} h${2*r} M${x-r+3} ${y+9} h${2*r-6} M${x} ${y-r} v${2*r} M${x-9} ${y-r+3} q-4 ${r-3} 0 ${2*r-6} M${x+9} ${y-r+3} q4 ${r-3} 0 ${2*r-6}`,'none',2);
|
||||
const beams=(x,y)=>`<path d="M${x} ${y} L${x-60} ${y-30} M${x} ${y} L${x+60} ${y-30} M${x} ${y} L${x-80} ${y+6}" stroke="#FFD23F" stroke-width="7" opacity=".55" stroke-linecap="round"/>`;
|
||||
const coinslot=(x,y)=>R(x,y,24,10,'#FFD23F',3,3)+R(x+6,y+3,12,3,O,1,1);
|
||||
const coins=(x,y,n)=>Array.from({length:n},(_,i)=>E(x,y-i*6,12,5,'#FFD23F',3)).join('');
|
||||
const eyepatch=(x,y)=>C(x,y,8,O,2)+P(`M${x-24} ${y-16} L${x+30} ${y+6}`,'none',2.5);
|
||||
const beanie=(x,y,w,f='#FF8A3D')=>P(`M${x-w/2} ${y} q0 ${-w*.5} ${w/2} ${-w*.5} q${w/2} 0 ${w/2} ${w*.5}z`,f)+R(x-w/2-3,y-6,w+6,12,f,5,3)+C(x,y-w*.5-5,6,f,3);
|
||||
const beard=(x,y,w=30,f='#8A4B22')=>P(`M${x-w/2} ${y} q${w/2} ${w*.9} ${w} 0 q-6 6 ${-w/2} 6 q${-w/2+6} 0 ${-w/2} -6z`,f,3);
|
||||
const capHat=(x,y,w=70)=>P(`M${x-w/2} ${y} q${w/2} -40 ${w} 0 q${-w/2} 12 ${-w} 0z`,'#1E2640',3)+C(x,y-14,5,'#FFD23F',2)+P(`M${x-5} ${y-14} l10 0`,'none',2).replace(`stroke="${O}"`,'stroke="#FFF"');
|
||||
const bandana=(x,y,w)=>P(`M${x-w/2} ${y} q${w/2} -26 ${w} 0z`,'#FF4D5E',3)+P(`M${x+w/2} ${y-2} l14 4 l-6 8z`,'#FF4D5E',3)+`<circle cx="${x-10}" cy="${y-8}" r="2.5" fill="#fff"/><circle cx="${x+8}" cy="${y-10}" r="2.5" fill="#fff"/>`;
|
||||
const parrot=(x,y)=>E(x,y,10,14,'#22C47A',3)+C(x+2,y-14,8,'#22C47A',3)+P(`M${x+9} ${y-15} q8 2 2 8z`,'#FFD23F',2.5)+`<circle cx="${x+4}" cy="${y-16}" r="1.8" fill="${O}"/>`+P(`M${x-6} ${y+10} l-8 10 M${x+2} ${y+12} l2 8`,'none',3).replace(`stroke="${O}"`,'stroke="#FF4D5E"');
|
||||
const chest=(x,y)=>R(x,y,40,26,'#C9B27C',4,3)+P(`M${x} ${y} q20 -18 40 0`,'#C9B27C',3)+R(x+16,y-2,8,8,'#FFD23F',2,2)+coins(x+20,y-12,1);
|
||||
const mast=(x,y,h=70)=>P(`M${x} ${y} v${-h}`)+P(`M${x} ${y-h+4} l34 10 l-34 14z`,'#1E2640',3)+C(x+14,y-h+15,4,'#fff',1.5);
|
||||
const wheel=(x,y,r=16)=>C(x,y,r,'#C9B27C',3)+C(x,y,5,'#FFD23F',2.5)+P(`M${x-r-6} ${y} h${2*r+12} M${x} ${y-r-6} v${2*r+12} M${x-r} ${y-r} l${2*r} ${2*r} M${x+r} ${y-r} l${-2*r} ${2*r}`,'none',3);
|
||||
const anchor=(x,y)=>P(`M${x} ${y} v26 M${x-12} ${y+18} q12 16 24 0 M${x-6} ${y+6} h12`,'none',4)+C(x,y-4,4,'#fff',3);
|
||||
const rivets=(x,y,w,h)=>[[x+8,y+8],[x+w-8,y+8],[x+8,y+h-8],[x+w-8,y+h-8]].map(([a,b])=>C(a,b,3,'#E8EDF7',2)).join('');
|
||||
const pine=(x,y,w,h)=>{let s='';for(let i=1;i<6;i++)s+=P(`M${x+i*w/6} ${y+4} v${h-8}`,'none',2);return s;};
|
||||
const thermo=(x,y,f='#FF4D5E')=>R(x-4,y-26,8,30,'#fff',4,2.5)+C(x,y+6,7,f,2.5)+`<rect x="${x-1.5}" y="${y-18}" width="3" height="22" fill="${f}"/>`;
|
||||
const stars=(pts)=>pts.map(([x,y,r])=>`<circle cx="${x}" cy="${y}" r="${r}" fill="#FFD23F"/>`).join('');
|
||||
const planet=(x,y,r,f,ring)=>C(x,y,r,f,3)+(ring?E(x,y,r+8,4,'none',3,-20):'');
|
||||
const towel=(x,y)=>P(`M${x} ${y} q22 -6 20 26 l-8 36 q-4 -28 -12 -40z`,'#FFD23F',3)+P(`M${x+8} ${y+6} l6 40 M${x+16} ${y+10} l2 20`,'none',3).replace(`stroke="${O}"`,'stroke="#FF4F9A"');
|
||||
const screen=(x,y,w,h,t,s=20)=>R(x,y,w,h,'#0B0F1C',4,3).replace(`stroke="${O}"`,'stroke="#7FD8EE"')+T(x+w/2,y+h/2+s*.35,t,s,'#7FD8EE');
|
||||
const bricks=(x,y,n)=>Array.from({length:n},(_,i)=>R(x+i*36,y,34,16,'#E07A5F',2,3)).join('');
|
||||
const bandaid=(x,y,rot=-30)=>`<g transform="rotate(${rot} ${x} ${y})">${R(x-14,y-5,28,10,'#F4CFA0',4,2.5)}<rect x="${x-5}" y="${y-3}" width="10" height="6" fill="#E3B27E"/></g>`;
|
||||
const knob=(x,y)=>C(x,y,8,'#C9B27C',3)+P(`M${x} ${y} l4 -5`,'none',3);
|
||||
const mustache=(x,y)=>P(`M${x} ${y} q-8 -6 -18 2 q8 2 18 -2 q8 -6 18 2 q-8 2 -18 -2z`,'#8A4B22',2.5);
|
||||
const hood=(x,y,w,h)=>P(`M${x} ${y+h} V${y+24} q0 -30 ${w/2} -30 q${w/2} 0 ${w/2} 30 V${y+h}`,'#3A4266');
|
||||
const katana=(x1,y1,x2,y2)=>P(`M${x1} ${y1} L${x2} ${y2}`,'none',7).replace(`stroke="${O}"`,'stroke="#C9D1E6"')+P(`M${x1} ${y1} L${x2} ${y2}`,'none',2)+P(`M${x2} ${y2} l10 -10`,'none',6).replace(`stroke="${O}"`,'stroke="#7A2633"');
|
||||
const ears=(x,y,d,f)=>P(`M${x-d-14} ${y} l8 -22 l16 16z M${x+d+14} ${y} l-8 -22 l-16 16z`,f);
|
||||
const tail=(x,y,f)=>P(`M${x} ${y} q30 -6 22 -34 q-2 -8 -8 -4`,'none',9).replace(`stroke="${O}"`,`stroke="${O}"`)+P(`M${x} ${y} q30 -6 22 -34 q-2 -8 -8 -4`,'none',5).replace(`stroke="${O}"`,`stroke="${f}"`);
|
||||
const sweat=(x,y)=>P(`M${x} ${y} q-6 8 0 10 q6 -2 0 -10z`,'#7FD8EE',2.5);
|
||||
const arm=(x,y,s)=>P(`M${x} ${y} q${s*22} 4 ${s*26} -18 q${s*-2} -10 ${s*-12} -6`,'none',10)+P(`M${x} ${y} q${s*22} 4 ${s*26} -18 q${s*-2} -10 ${s*-12} -6`,'none',6).replace(`stroke="${O}"`,'stroke="#FF8FBE"')+C(x+s*22,y-8,7,'#FF8FBE',3);
|
||||
const dumbbell=(y)=>P(`M30 ${y} H170`,'none',5)+R(18,y-14,12,28,'#5D6788',3,3)+R(170,y-14,12,28,'#5D6788',3,3)+R(8,y-10,10,20,'#5D6788',3,3)+R(182,y-10,10,20,'#5D6788',3,3);
|
||||
const headband=(x,y,w)=>R(x,y,w,10,'#FF4D5E',3,3);
|
||||
const notes=(x,y)=>P(`M${x} ${y} v-14 l10 -3 v14`,'none',3)+C(x-3,y,3.5,O,0)+C(x+7,y-3,3.5,O,0);
|
||||
const tiles=(y)=>{const cs=['#FF4F9A','#FFD23F','#22C47A','#7FD8EE','#7B61FF'];let s='';for(let i=0;i<8;i++)s+=P(`M${20+i*20} ${y} h20 l-4 14 h-20z`,cs[i%5],2.5);return s;};
|
||||
const headphones=(x,y,w)=>P(`M${x-w/2} ${y} q0 ${-w*.55} ${w/2} ${-w*.55} q${w/2} 0 ${w/2} ${w*.55}`,'none',5)+R(x-w/2-8,y-6,12,18,'#FF4F9A',4,3)+R(x+w/2-4,y-6,12,18,'#FF4F9A',4,3);
|
||||
const afro=(x,y,w)=>{let s='';for(let i=0;i<7;i++){const a=Math.PI*(i/6),r=w/2;s+=C(x-Math.cos(a)*r*.9,y-Math.sin(a)*r*.6,14,'#3A2A20',3);}return s+E(x,y-10,w/2,18,'#3A2A20',0);};
|
||||
const bells=(xs,y)=>xs.map(x=>P(`M${x-5} ${y} l-6 18 h18 l-6 -18z`,'#FF8A3D',3)).join('');
|
||||
const hammer=(x,y)=>P(`M${x} ${y} l26 -8`,'none',6).replace(`stroke="${O}"`,'stroke="#C9B27C"')+P(`M${x} ${y} l26 -8`,'none',2)+R(x+32,y-30,12,22,'#9AA3BE',2,3)+P(`M${x+30} ${y-6} l4 -4 M${x+28} ${y-12} l4 2`,'none',2);
|
||||
const anvil=(x,y)=>P(`M${x-24} ${y} h48 l-6 8 h-10 l4 12 h-24 l4 -12 h-10z M${x-24} ${y} q-14 0 -16 -6 h16z`,'#5D6788',3);
|
||||
const dizzyStars=(x,y)=>stars([[x-12,y,3],[x,y-6,3.5],[x+12,y,3]])+P(`M${x-18} ${y+4} q18 -14 36 0`,'none',2);
|
||||
const icicles=(x,y,w)=>{let s='';for(let i=0;i<5;i++)s+=P(`M${x+i*w/5+4} ${y} l4 ${10+(i%2)*6} l4 ${-10-(i%2)*6}`,'#E8F6FF',2);return s;};
|
||||
const snowcap=(x,y,w)=>P(`M${x-4} ${y+4} q${w/4} -14 ${w/2} -4 q${w/4} -12 ${w/2+8} 4 q-6 8 -14 2 q-10 8 -20 0 q-12 8 -24 0 q-10 8 ${-w/2+22} -2z`,'#fff',3);
|
||||
const racing=(x,y,w)=>`<rect x="${x}" y="${y}" width="${w}" height="7" fill="#FF4D5E"/><rect x="${x}" y="${y+10}" width="${w}" height="7" fill="#2F8CFF"/>`;
|
||||
const roundel=(x,y,t)=>C(x,y,15,'#fff',3)+T(x,y+6,t,16);
|
||||
const fire=(x,y)=>flames(x,y,.55);
|
||||
const extinguisher=(x,y)=>R(x,y,14,34,'#FF4D5E',6,3)+P(`M${x+4} ${y} v-6 h10 l6 6`,'none',3)+P(`M${x-2} ${y+12} h18`,'none',6).replace(`stroke="${O}"`,'stroke="#C9D1E6"');
|
||||
const rope=(x1,x2,y)=>R(x1-4,y-34,8,40,'#FFD23F',3,3)+R(x2-4,y-34,8,40,'#FFD23F',3,3)+P(`M${x1} ${y-26} q${(x2-x1)/2} 18 ${x2-x1} 0`,'none',6).replace(`stroke="${O}"`,'stroke="#C0154F"');
|
||||
const receipt=(x,y)=>P(`M${x} ${y} h18 v34 q-2 10 14 12 h40 v10 h-56 q-16 0 -16 -14z`,'#fff',3)+P(`M${x+4} ${y+8} h10 M${x+4} ${y+16} h10 M${x+4} ${y+24} h10 M${x+26} ${y+52} h30`,'none',2)+T(x+9,y+-2,'€',10);
|
||||
const piglet=(x,y)=>C(x,y,10,'#FF8FBE',3)+E(x,y+3,5,3.5,'#FF4F9A',2)+`<circle cx="${x-4}" cy="${y-3}" r="1.6" fill="${O}"/><circle cx="${x+4}" cy="${y-3}" r="1.6" fill="${O}"/>`+P(`M${x-9} ${y-7} l-3 -6 l6 3 M${x+9} ${y-7} l3 -6 l-6 3`,'#FF8FBE',2);
|
||||
const ladder=(x,y,h)=>P(`M${x} ${y} l10 ${-h} M${x+16} ${y} l10 ${-h}`,'none',3)+Array.from({length:Math.floor(h/12)},(_,i)=>P(`M${x+2+i*1.2*10/h*12} ${y-8-i*12} h16`,'none',2.5)).join('');
|
||||
const rainbow=(x,y,r)=>['#FF4D5E','#FF8A3D','#FFD23F','#22C47A','#2F8CFF'].map((c,i)=>`<path d="M${x-r+i*6} ${y} a${r-i*6} ${r-i*6} 0 0 1 ${2*(r-i*6)} 0" fill="none" stroke="${c}" stroke-width="6"/>`).join('');
|
||||
const nest=(x,y)=>P(`M${x-18} ${y} h36 l-4 14 h-28z`,'#C9B27C',3)+P(`M${x} ${y+14} v24`,'none',4);
|
||||
const scope=(x,y)=>P(`M${x} ${y} l26 -10`,'none',8)+P(`M${x} ${y} l26 -10`,'none',4).replace(`stroke="${O}"`,'stroke="#FFD23F"');
|
||||
const bench=(y)=>R(24,y,152,12,'#C9B27C',3,3)+P(`M40 ${y+12} v14 M160 ${y+12} v14`,'none',5);
|
||||
const vihta=(x,y)=>P(`M${x} ${y} l-6 30`,'none',4).replace(`stroke="${O}"`,'stroke="#8A4B22"')+[[0,0],[-8,6],[8,6],[-4,14],[6,14],[0,-8]].map(([a,b])=>E(x+a,y+b-6,6,9,'#22C47A',2,a*4)).join('');
|
||||
const bucket=(x,y)=>P(`M${x-16} ${y-22} h32 l-4 26 h-24z`,'#C9B27C',3)+P(`M${x-16} ${y-14} h32 M${x-16} ${y-4} h32`,'none',2)+P(`M${x+10} ${y-24} q12 -24 28 -18`,'none',4)+E(x+40,y-40,7,4,'#C9B27C',2.5);
|
||||
const rocks=(x,y)=>[[0,0,9],[14,2,8],[-14,3,7],[6,-9,7],[-6,-8,6]].map(([a,b,r])=>C(x+a,y+b,r,'#9AA3BE',2.5)).join('');
|
||||
const springs=(x,y,dir)=>P(`M${x} ${y} l${8*dir} -6 l${-6*dir} -6 l${8*dir} -6 l${-6*dir} -6 l${8*dir} -6`,'none',3)+R(x+dir*6-5,y-38,10,8,'#FFD23F',2,2.5);
|
||||
const propeller=(x,y)=>beanie(x,y,40,'#22C47A')+P(`M${x} ${y-26} v-8`,'none',3)+E(x-14,y-36,14,4,'#FF4F9A',2.5)+E(x+14,y-36,14,4,'#FFD23F',2.5);
|
||||
const band=(x,y,w,h)=>P(`M${x+w*.3} ${y-2} v${h+4}`,'none',6).replace(`stroke="${O}"`,'stroke="#C0154F"');
|
||||
const awning=(x,y,w)=>{let s='';const n=6,g=w/n;for(let i=0;i<n;i++)s+=P(`M${x+i*g} ${y} h${g} v12 q${-g/2} 8 ${-g} 0z`,i%2?'#fff':'#FF4F9A',2.5);return s;};
|
||||
const table=(x,y)=>E(x,y,18,5,'#fff',3)+P(`M${x} ${y+4} v20 M${x-10} ${y+24} h20`,'none',3)+R(x-2,y-14,4,10,'#fff',1,2)+P(`M${x} ${y-14} q-3 -4 0 -8 q3 4 0 8z`,'#FFD23F',1.5)+P(`M${x-34} ${y+24} v-26 h10 v10 M${x+34} ${y+24} v-26 h-10 v10`,'none',3);
|
||||
const swirl=(x,y)=>`<g fill="none" stroke-linecap="round">${[56,42,28,14].map((r,i)=>`<path d="M${x+r} ${y} A${r} ${r*.45} 0 1 1 ${x-r*.6} ${y-r*.3}" stroke="${['#7B61FF','#FF4F9A','#FFD23F','#fff'][i]}" stroke-width="${5-i*.5}" opacity=".9"/>`).join('')}<ellipse cx="${x}" cy="${y}" rx="10" ry="5" fill="#0B0F1C"/></g>`;
|
||||
const box=(x,y,w,h,f,r=10)=>R(x,y,w,h,f,r);
|
||||
const tower=(x,y,w,h,f)=>R(x,y,w,h,f,10);
|
||||
const raft=(y)=>{let s='';for(let i=0;i<6;i++)s+=R(28+i*24,y,24,12,'#C9B27C',3,3);return s+P(`M14 ${y+18} q14 -8 28 0 q14 8 28 0 q14 -8 28 0 q14 8 28 0 q14 -8 28 0 q14 8 28 0`,'none',4).replace(`stroke="${O}"`,'stroke="#2F8CFF"');};
|
||||
const sail=(x,y)=>P(`M${x} ${y} v-62`)+P(`M${x+3} ${y-58} q30 20 2 48z`,'#fff',3);
|
||||
const hook=(x,y)=>P(`M${x} ${y} h14`,'none',6)+P(`M${x+14} ${y} q14 2 10 16 q-4 8 -12 2`,'none',4).replace(`stroke="${O}"`,'stroke="#C9D1E6"');
|
||||
const glasses=(x,y)=>C(x,y,9,'rgba(255,255,255,.4)',3);
|
||||
const mug=(x,y)=>R(x,y,20,22,'#fff',4,3)+P(`M${x+20} ${y+6} q10 0 10 6 q0 6 -10 6`,'none',3)+P(`M${x+5} ${y-4} q-3 -6 0 -10 M${x+13} ${y-4} q-3 -6 0 -10`,'none',2).replace(`stroke="${O}"`,'stroke="#9AA3BE"');
|
||||
const skates=(xs,y)=>xs.map(x=>R(x-14,y,30,10,'#FF4F9A',4,3)+C(x-6,y+14,5,'#FFD23F',2.5)+C(x+8,y+14,5,'#FFD23F',2.5)).join('');
|
||||
const tray=(y)=>R(18,y,164,12,'#C9D1E6',4,3);
|
||||
const juice=(x,y)=>R(x,y,18,28,'#FFD23F',2,3)+P(`M${x+12} ${y} l6 -14`,'none',3)+T(x+9,y+18,'OJ',8);
|
||||
const apple=(x,y)=>C(x,y,10,'#FF4D5E',3)+P(`M${x} ${y-10} q2 -6 6 -6`,'none',3)+E(x+6,y-12,4,2,'#22C47A',1.5,-20);
|
||||
const sandwich=(x,y)=>P(`M${x} ${y} h50 l-10 -24 q-15 -10 -30 0z`,'#F4CFA0',4)+P(`M${x+4} ${y-12} q10 -6 20 0 q10 6 22 0`,'none',5).replace(`stroke="${O}"`,'stroke="#22C47A"')+P(`M${x+8} ${y-4} h36`,'none',5).replace(`stroke="${O}"`,'stroke="#FF4D5E"');
|
||||
const handle=(x,y,w)=>P(`M${x} ${y} q0 -22 ${w/2} -22 q${w/2} 0 ${w/2} 22`,'none',7);
|
||||
const stickers=(pts)=>pts.map(([x,y,f,k])=>k?R(x-8,y-6,16,12,f,3,2):C(x,y,7,f,2)).join('');
|
||||
const wood=(x,y,w,h)=>{let s='';for(let i=1;i<4;i++)s+=P(`M${x+6} ${y+i*h/4} q${w/2} -4 ${w-12} 0`,'none',1.5);return s;};
|
||||
// magic and extreme sports (Brocadabra, Extremely Networks)
|
||||
const tophat=(x,y,w=56,h=34,band='#FF4F9A')=>R(x-w/2,y-h,w,h,O,4,3)+R(x-w/2-12,y-4,w+24,9,O,4,3)+`<rect x="${x-w/2+2}" y="${y-14}" width="${w-4}" height="7" fill="${band}"/>`;
|
||||
const rabbit=(x,y,f='#fff')=>E(x-7,y-22,5,14,f,3,-8)+E(x+7,y-22,5,14,f,3,8)+E(x-7,y-21,1.8,8,'#FF8FBE',0,-8)+E(x+7,y-21,1.8,8,'#FF8FBE',0,8)+C(x,y,13,f,3)+`<circle cx="${x-5}" cy="${y-2}" r="2" fill="${O}"/><circle cx="${x+5}" cy="${y-2}" r="2" fill="${O}"/>`+E(x,y+4,2.5,2,'#FF4F9A',0);
|
||||
const wand=(x,y,dx=34,dy=-24)=>P(`M${x} ${y} l${dx} ${dy}`,'none',6)+P(`M${x+dx*.8} ${y+dy*.8} l${dx*.2} ${dy*.2}`,'none',6).replace(`stroke="${O}"`,'stroke="#fff"');
|
||||
const sparkle=(x,y,s=7,f='#FFD23F')=>P(`M${x} ${y-s} q${s*.25} ${s*.75} ${s} ${s} q${-s*.75} ${s*.25} ${-s} ${s} q${-s*.25} ${-s*.75} ${-s} ${-s} q${s*.75} ${-s*.25} ${s} ${-s}z`,f,2);
|
||||
const cape=(x,y,w,h,f='#C0154F')=>P(`M${x} ${y} q${-18} ${h*.6} ${-8} ${h} h${w+16} q10 ${-h*.4} ${-8} ${-h}z`,f,3);
|
||||
const helmet=(x,y,w,f='#FF8A3D')=>P(`M${x-w/2} ${y} q0 ${-w*.44} ${w/2} ${-w*.44} q${w/2} 0 ${w/2} ${w*.44}z`,f,3)+P(`M${x-w*.18} ${y-w*.4} v${w*.34} M${x+w*.18} ${y-w*.4} v${w*.34}`,'none',2.5)+R(x-w/2-4,y-4,w+8,9,f,4,3);
|
||||
const goggles=(x,y,d=16)=>R(x-d-12,y-8,24,16,'#7FD8EE',8,3)+R(x+d-12,y-8,24,16,'#7FD8EE',8,3)+P(`M${x-d+12} ${y} H${x+d-12}`,'none',3)+glint(x-d,y-1)+glint(x+d,y-1);
|
||||
const can=(x,y)=>R(x,y,18,32,'#7B61FF',4,3)+R(x+2,y-4,14,6,'#C9D1E6',2,2)+bolt(x+12,y+5,.45,'#FFD23F');
|
||||
const bungee=(x,y1,y2)=>P(`M${x} ${y1} q10 ${(y2-y1)*.25} 0 ${(y2-y1)*.5} q-10 ${(y2-y1)*.25} 0 ${(y2-y1)*.5}`,'none',5).replace(`stroke="${O}"`,'stroke="#22C47A"');
|
||||
return [
|
||||
/* rusty: Vintage set */ ()=>sh()+bob(P('M84 58 L62 18 M116 58 L138 18')+C(62,18,5,'#C9D1E6',3)+C(138,18,5,'#C9D1E6',3)+box(32,56,136,78,'#E8D9B0',14)+wood(32,56,136,78)+R(46,68,72,46,'#5D6788',8,3)+face(82,86,'dots',null,12)+mustache(82,104)+knob(140,78)+knob(140,106)+cobweb(146,56)),
|
||||
/* edgelord: All spikes */ ()=>sh(72)+bob(P('M26 128 L40 52 L58 36 L70 50 L86 30 L100 48 L114 28 L130 48 L144 34 L160 52 L174 128Z','#2E3550')+face(100,80,'angry',null,22)+ports(54,100,92,6,'#FF4D5E')+legs([46,146],128)),
|
||||
/* chonk: Round and content */ ()=>sh(76)+bob(feet([68,128],132,'#FF8FBE')+E(100,82,78,56,'#FF8FBE')+P('M30 92 Q100 116 170 92 L168 108 Q100 128 32 108Z','#1E2640',3)+leds(56,106,['#FFD23F','#FFD23F','#FFD23F','#FFD23F','#FFD23F','#FFD23F','#FFD23F'],3)+face(100,62,'happy','smile',18,14)+cheeks(100,76,34)+C(164,40,3,'#C9B27C',2)+C(172,50,2,'#C9B27C',2)),
|
||||
/* unit16: Flexing */ ()=>sh(78)+bob(arm(46,88,-1)+arm(154,88,1)+box(46,46,108,88,'#FF8FBE',12)+face(100,72,'dots','grin',18,16)+ports(58,108,84,6)+cloud(150,26,.8,'#E8EDF7')+rain(146,26)),
|
||||
/* mikro: Lunchbox */ ()=>sh(74)+bob(handle(64,72,44)+box(40,70,92,64,'#22C47A')+ports(50,104,72,6)+leds(58,86,['#FFD23F'])+T(96,92,'CCR',11)+sandwich(136,128)),
|
||||
/* wb32: Roller skates */ ()=>sh(66)+speed(36,74)+bob(box(46,56,108,64,'#F4F6FB')+face(100,80,'wink','grin',16,14)+ports(58,98,84,7)+skates([70,130],120)),
|
||||
/* ar7280: Flat white */ ()=>sh()+bob(box(40,54,108,80,'#2F8CFF')+beanie(94,56,84,'#22C47A')+eyepatch(78,84)+glasses(112,84)+`<circle cx="112" cy="84" r="3" fill="${O}"/>`+MO.smirk(94,104)+ports(50,116,88,7)+mug(150,96)),
|
||||
/* ar7800: The captain */ ()=>sh(70)+bob(box(46,46,108,90,'#2F8CFF',8)+capHat(100,48,96)+face(100,66,'dots','smirk',16,10)+[86,100,114].map(y=>R(56,y,88,10,'#1E2640',3,2)+[0,1,2,3,4].map(i=>C(68+i*16,y+5,3,'#FFD23F',0)).join('')).join('')),
|
||||
/* disco8k: Disco ball */ ()=>sh()+beams(100,38)+bob(disco(100,38)+box(34,60,132,74,'#7B61FF')+leds(54,80,['#FF4F9A','#FFD23F','#22C47A','#7FD8EE','#FF8A3D'],5)+ports(46,98,108,8,'#fff')+tag(178,104,'€/mo','∞')),
|
||||
/* knockia7750: Minus forty */ ()=>sh()+bob(box(38,58,124,76,'#9AA3BE',6)+snowcap(38,58,124)+icicles(44,134,112)+face(96,86,'dots','smile',14,12)+thermo(144,108,'#2F8CFF')+ports(48,108,80,6))+R(140,30,42,18,'#fff',5,2.5)+T(161,43,'−40°',11,'#2F8CFF'),
|
||||
/* wb64: Race car */ ()=>sh(84)+bob(box(26,62,148,62,'#F4F6FB',14)+racing(26,70,148)+roundel(60,104,'64')+face(124,100,'shades',null,14)+ports(88,108,30,2)+smoke(178,96)),
|
||||
/* disco8ku: Double disco */ ()=>sh()+beams(70,36)+bob(disco(70,36,13)+disco(130,36,13)+box(30,56,140,78,'#7B61FF')+coinslot(88,72)+ports(42,102,116,9,'#fff')+tag(180,108,'€/mo','∞∞')),
|
||||
/* unit32: Litter of pigs */ ()=>sh(84)+bob(box(24,36,152,100,'#FF8FBE',14)+face(100,64,'happy','smile',22,14)+R(38,90,124,30,'#1E2640',6,3)+piglet(58,105)+piglet(100,105)+piglet(142,105)),
|
||||
/* ar7800r5: Ship of the line */ ()=>sh(84)+bob(mast(100,72,62)+P('M20 72 H180 L164 132 H36Z','#2F8CFF')+[0,1,2,3,4,5,6,7].map(i=>C(44+i*16,92,5,'#1E2640',2)+`<circle cx="${44+i*16}" cy="92" r="2" fill="#FFD23F"/>`).join('')+ports(48,108,104,8)),
|
||||
/* knockia7950: Sauna door */ ()=>sh()+steam(70,46)+bob(box(40,50,120,86,'#E6C48E',8)+pine(40,50,120,86)+thermo(68,98)+R(132,78,8,26,'#8A4B22',3,2.5)+face(100,74,'sleepy',null,12))+ports(52,116,96,7),
|
||||
/* mikro32: Propeller hat */ ()=>sh(66)+bob(propeller(100,64)+box(50,66,100,66,'#22C47A')+face(100,88,'happy','grin',16,14)+sweat(154,78)+ports(60,112,80,6,'#FF4F9A')),
|
||||
/* universe: 42 and a towel */ ()=>bob(tower(62,12,76,132,'#1E2640')+stars([[76,28,1.8],[122,40,1.5],[90,112,1.6],[126,96,2],[72,88,1.3],[110,128,1.4]])+screen(74,44,52,30,'42',20)+P('M74 84 H126 M74 92 H126 M74 100 H126','none',2).replace(`stroke="${O}"`,'stroke="#7FD8EE"')+towel(138,30))+`<ellipse cx="100" cy="78" rx="96" ry="22" fill="none" stroke="#FF4F9A" stroke-width="3" stroke-dasharray="1 9" stroke-linecap="round" transform="rotate(-12 100 78)"/>`+planet(22,100,11,'#FF8A3D',1)+planet(178,52,7,'#22C47A')
|
||||
,
|
||||
/* brocadabra: Rabbit out of the hat */ ()=>sh()+bob(box(38,76,124,60,'#2F8CFF')+face(100,98,'happy','smile',16,12)+ports(48,116,104,7)+rabbit(100,46)+tophat(100,76,58,28)+wand(150,104))+sparkle(170,60)+sparkle(30,52,5)+sparkle(176,32,4),
|
||||
/* extremely: Energy drink */ ()=>sh()+bob(box(40,56,120,78,'#FF8A3D')+helmet(100,58,104,'#7B61FF')+goggles(100,80,18)+MO.teeth(100,104,12)+ports(50,118,100,7)+can(160,86))+bolt(28,40,.8)+sweat(42,64)
|
||||
];})();
|
||||
const RG_ART_C=[];
|
||||
// The picture for model g, as inline SVG ('' for a model without one).
|
||||
function rgArt(g){const f=RG_ART[g];if(!f)return '';return RG_ART_C[g]||(RG_ART_C[g]=`<svg class="rgart" viewBox="0 0 200 160" aria-hidden="true">${f()}</svg>`);}
|
||||
|
|
@ -9,12 +9,12 @@ const HW_SHOCK={opt:{mul:1.5,n:N_('common.optics'),msg:N_('supply_chain.laser_sh
|
|||
build:{mul:1.3,n:N_('supply_chain.new_fiber_and_cable_builds'),msg:N_('supply_chain.every_cable_ship_is_booked')}};
|
||||
const hwTrend=d=>Math.min(HW_CAP,1+HW_YR*Math.max(0,(d-HW_FREE)/365));
|
||||
const hwShock=()=>{const s=S&&S.hw&&S.hw.shock;return s&&s.until>S.day?s:null;},hwLock=()=>{const l=S&&S.hw&&S.hw.lock;return l&&l.until>S.day?l:null;};
|
||||
function hwMul(k){if(!S)return 1;const l=hwLock();if(l)return l.mul;const s=hwShock();return hwTrend(S.day)*(s&&s.k===k?s.mul:1);}
|
||||
function hwMul(k){if(!S||!rule('market'))return 1;const l=hwLock();if(l)return l.mul;const s=hwShock();return hwTrend(S.day)*(s&&s.k===k?s.mul:1);}
|
||||
// A lock costs a little more for a bigger network, and twice as much in the middle of a shortage.
|
||||
const hwLockCost=()=>Math.round((80000+30000*Object.keys(S.pops).length)*(hwShock()?2:1)/1000)*1000;
|
||||
function hwShockStart(){const k=pick(Object.keys(HW_SHOCK)),n=45+Math.floor(Math.random()*31);S.hw=S.hw||{};S.hw.shock={k,until:S.day+n,mul:HW_SHOCK[k].mul};
|
||||
toast(tr(HW_SHOCK[k].msg,{n})+(hwLock()?'<br>'+tr('supply_chain.your_price_lock_covers_you_until',{date:dateStr(hwLock().until)}):''),hwLock()?'':'bad');sfx('alert');}
|
||||
function hwCard(){if(!S||(S.day<=HW_FREE&&!hwShock()&&!hwLock()))return '';const t=hwTrend(S.day),s=hwShock(),l=hwLock();
|
||||
function hwCard(){if(!S||!rule('market')||(S.day<=HW_FREE&&!hwShock()&&!hwLock()))return '';const t=hwTrend(S.day),s=hwShock(),l=hwLock();
|
||||
return `<div class="ibx"><div class="nm">📦 ${tr('common.supply_chain')}</div>
|
||||
<div class="kv"><span>${tr('common.hardware_prices')}</span><b>${t>1.005?tr('supply_chain.p_since_you_started',{p:pct(t-1)}):tr('supply_chain.as_when_you_started')}</b></div>
|
||||
${s?`<div class="kv"><span>${tr('common.shortage')}</span><b>${tr('supply_chain.what_p_n_days_left',{what:tr(HW_SHOCK[s.k].n),p:pct(s.mul-1),n:s.until-S.day})}</b></div>`:''}
|
||||
|
|
@ -22,10 +22,10 @@ function hwCard(){if(!S||(S.day<=HW_FREE&&!hwShock()&&!hwLock()))return '';const
|
|||
:`<p class="meta">${tr('supply_chain.routers_optics_and_new_builds_at')}</p><div class="btns">${btn(tr('supply_chain.lock_prices_for_a_year_cost',{cost:fmt$(hwLockCost())}),'hwLock',{},'sm',S.cash<hwLockCost())}</div>`}</div>`;}
|
||||
// Routers past the standard cage (#157) need a cage extension: pricier to install, and rent on top.
|
||||
const RCAGE=6,CAGE_MUL=1.5,CAGE_MO=2000;
|
||||
const routerCost=(g,rt)=>Math.round((ROUTER_COST+RG[g].cost*0.8)*((rt||1)>=RCAGE?CAGE_MUL:1)*hwMul('rt'));
|
||||
const routerCost=(g,rt)=>Math.round((ROUTER_COST+RG[g].cost*0.8)*((rt||1)>=RCAGE?CAGE_MUL:1)*hwMul('rt')*techMul(RG[g].lvl));
|
||||
const routerMo=g=>ROUTER_MO+RG[g].mo,cageMo=rt=>Math.max(0,(rt||1)-RCAGE)*CAGE_MO;
|
||||
// Old routers go on eBuy when you swap models or remove one (#82), like spare optics (#45). Chassis age faster.
|
||||
const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCost=(c,g)=>{const p=S.pops[c],rt=p.routers||1;return Math.max(0,Math.round(RG[g].cost*rt*hwMul('rt'))-tradeIn(p.rgen||0,rt));};
|
||||
const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCost=(c,g)=>{const p=S.pops[c],rt=p.routers||1;return Math.max(0,Math.round(RG[g].cost*rt*hwMul('rt')*techMul(RG[g].lvl))-tradeIn(p.rgen||0,rt));};
|
||||
const RMAX=16;
|
||||
// The plain, badge-less model of each class is the default upgrade path; the others are side-grades.
|
||||
const mainRG=k=>RG.findIndex(r=>r.cls===k&&!r.badge);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
const PORT_SLOT=i=>i===0?0.25:1;
|
||||
function portsUsed(c){let u=0;
|
||||
for(const l of S.links){if(l.a!==c&&l.b!==c||l.kind==='vxc')continue;u+=l.kind==='df'?(l.ch||[]).length:1;}
|
||||
for(const t of S.transit)if(t.city===c)u+=PORT_SLOT(t.tier)*(t.n||1);
|
||||
// A puzzle's content origin (t.pz) hands off on a port of its own: it takes none of yours.
|
||||
for(const t of S.transit)if(t.city===c&&!t.pz)u+=PORT_SLOT(t.tier)*(t.n||1);
|
||||
for(const x of S.pni)if(x.city===c)u+=PORT_SLOT(x.tier)*(x.n||1);
|
||||
for(const x of ixIdsIn(c))if(S.ixp[x]!==undefined&&!S.myIx[x])u+=PORT_SLOT(S.ixp[x])*((S.ixn||{})[x]||1);
|
||||
if(S.myIx[c])u+=1;
|
||||
|
|
@ -17,6 +18,6 @@ const popIdle=c=>{const p=S.pops[c];return !!p&&!p.bb&&portsUsed(c)===0&&!S.biz.
|
|||
const fmtPorts=u=>Number.isInteger(u)?String(u):u.toFixed(2).replace(/0+$/,'');
|
||||
function modelFits(c,g){const G=RG[g],p=S.pops[c];if(!p)return '';
|
||||
if(S.links.some(l=>(l.a===c||l.b===c)&&l.kind==='wave'&&l.tier>G.maxLT))return tr('ports.a_wave_here_is_faster_than',{pn:G.pn});
|
||||
if([...S.transit,...S.pni].some(t=>t.city===c&&t.tier>G.maxP)||ixIdsIn(c).some(x=>S.ixp[x]!==undefined&&!S.myIx[x]&&S.ixp[x]>G.maxP))return tr('ports.a_port_here_is_bigger_than',{pn:G.pn});
|
||||
if([...S.transit,...S.pni].some(t=>t.city===c&&!t.pz&&t.tier>G.maxP)||ixIdsIn(c).some(x=>S.ixp[x]!==undefined&&!S.myIx[x]&&S.ixp[x]>G.maxP))return tr('ports.a_port_here_is_bigger_than',{pn:G.pn});
|
||||
if(S.links.some(l=>(l.a===c||l.b===c)&&l.kind==='df'&&(l.ch||[]).some(o=>OPT[o]&&OPT[o].rg>G.cls)))return tr('ports.a_fibre_here_uses_optics_this');
|
||||
if(portsUsed(c)>portsMax(c,g))return tr('ports.you_use_u_ports_here_and',{u:fmtPorts(portsUsed(c)),r:p.routers||1,model:G.n,max:portsMax(c,g)});return '';}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const AMP_EVERY=100, AMP_COST=8000, AMP_MO=300;
|
|||
/* Your own trench holds more than one fiber pair (#35). Once a ROADMaster is full you can light the next pair:
|
||||
another ROADMaster and another chain of amplifiers, 64 more channels. Regen huts are shared. */
|
||||
const isRdm=y=>y==='roadm'||y==='cl';
|
||||
const PAIRS_MAX=4,PAIRS_BIG=8,PAIRS_LV=12,SUB_PAIRS_MAX=8,SUB_PAIR_UP=1500000,pairsMax=l=>l.sub?SUB_PAIRS_MAX:lvl()>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,chMax=l=>DF_SYS[l.sys].max*(isRdm(l.sys)&&l.own?Math.max(1,l.pairs|0):1),
|
||||
const PAIRS_MAX=4,PAIRS_BIG=8,PAIRS_LV=12,SUB_PAIRS_MAX=8,SUB_PAIR_UP=1500000,pairsMax=l=>l.seat?Math.max(1,l.pairs|0):l.sub?SUB_PAIRS_MAX:lvl()>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,chMax=l=>DF_SYS[l.sys].max*(isRdm(l.sys)&&l.own?Math.max(1,l.pairs|0):1),
|
||||
pairCost=l=>DF_SYS[isRdm(l.sys)?l.sys:'roadm'].cost+(l.sub?SUB_PAIR_UP:ampCount(l.km)*AMP_COST);
|
||||
const OPT={
|
||||
zr4:{n:'Ackackia 400ZR+',g:400,cost:12000,reach:1500,modes:[[400,1500],[200,3000]],rg:1,lvl:2,sys:'lite',blurb:tr('dark_fiber.coherent_pluggable_in_the_router_no')},
|
||||
|
|
@ -18,7 +18,7 @@ const OPT={
|
|||
};
|
||||
const dfLeaseMo=km=>Math.round(400+km*1.0);
|
||||
const dfBuildCost=km=>Math.round((25000+km*120)*hwMul('build'));
|
||||
const dfBuildDays=km=>Math.round(120+km*0.25);
|
||||
const dfBuildDays=km=>leadDays(Math.round(120+km*0.25)),IRU_DAYS=30;
|
||||
const ampCount=km=>Math.max(0,Math.floor(km/AMP_EVERY));
|
||||
const fmtCap=g=>g>=1000?(+(g/1000).toFixed(1))+'T':g+'G';
|
||||
const WAVECO=['Zay-No Fiber','Loomin’ Technologies','Clown Castle Fiber','Bolt Technology','youNetworks','G&T (Gin and Transit)'];
|
||||
|
|
@ -35,7 +35,14 @@ const NNI=[{n:'10G',g:10,mo:500},{n:'100G',g:100,mo:1200}];
|
|||
const VXC=[{n:'10G',g:10,m:1},{n:'50G',g:50,m:2.4},{n:'100G',g:100,m:3.6}];
|
||||
const vxcMo=(km,sub,t)=>Math.round((150+km*0.12)*VXC[t].m*(sub?2:1));
|
||||
const MET={prefer:{l:tr('common.prefer'),f:0.5},normal:{l:tr('common.normal'),f:1},avoid:{l:tr('common.avoid'),f:4},backup:{l:tr('common.backup_only'),f:60}};
|
||||
// Custom metrics: a multiplier on the distance cost (f) or an absolute IGP cost (w), capped like an OSPF metric.
|
||||
const MET_LIM={f:[0.1,100],w:[1,65535]};
|
||||
const clampM=(k,v)=>{const [lo,hi]=MET_LIM[k];v=Math.min(hi,Math.max(lo,v));return k==='w'?Math.round(v):Math.round(v*100)/100;};
|
||||
const PREF={high:tr('common.prefer'),normal:tr('common.normal'),low:tr('common.backup_only')};
|
||||
const edgeKey=l=>l.a<l.b?l.a+'|'+l.b:l.b+'|'+l.a;
|
||||
// The routing metric of a city pair (edgeKey), set for every link between the two cities.
|
||||
function pairMet(k){return (S.pairMet&&S.pairMet[k])||'normal';}
|
||||
// A custom metric is stored as {k:'f'|'w',v}: a multiplier, or an exact cost whatever the distance.
|
||||
function pairMet(k){const m=S.pairMet&&S.pairMet[k];return m?(typeof m==='object'?'custom':m):'normal';}
|
||||
function pairCm(k){const m=S.pairMet&&S.pairMet[k];return m&&typeof m==='object'?m:null;}
|
||||
// The cost of one link of km on the pair k, as Dijkstra sees it.
|
||||
function pairW(k,km){const m=S.pairMet&&S.pairMet[k];return m&&typeof m==='object'?(m.k==='w'?m.v:(km+60)*m.v):(km+60)*MET[m||'normal'].f;}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
const REGEN_COST=30000,REGEN_MO=900,REGEN_CH=0.5,REGEN_MAX=8;
|
||||
const spanKm=l=>Math.ceil(l.km/((l.regen|0)+1));
|
||||
/* Subsea glass is engineered end to end for one route: ultra-low-loss, large-area fiber and a repeater every
|
||||
~70 km, no regens (#66, #68). Optics reach about half as far again as on land, and the same physics caps
|
||||
~70 km, no regens in the middle of the sea (#66, #68). A consortium cable lands in several countries on its way, so a
|
||||
seat on one can regenerate in those landing stations; your own point-to-point cable cannot. Optics reach about half as far again as on land, and the same physics caps
|
||||
every wave on a cable, leased or your own: transatlantic gets 1.6T, transpacific 800G. */
|
||||
const SUB_REACH=1.5,reachOn=(r,sub)=>sub?Math.round(r*SUB_REACH):r;
|
||||
const SUB_MAXKM=()=>subReach(1,1);
|
||||
|
|
@ -53,7 +54,11 @@ const subMaxTier=km=>{let t=0;LT.forEach((T,i)=>{if(!subWaveWhy(i,km,true))t=i;}
|
|||
// What an optic carries depends only on the optic, the span length and subsea or not; the map and compute() ask a lot.
|
||||
// Cached per optic, span and cable state: subsea, and which submarine upgrades are in service (#78).
|
||||
const OPTG={};const optG=(o,l)=>{const km=spanKm(l),fl=l.sub?1+(subUpgradeReady(l,'terminal')?2:0)+(subUpgradeReady(l,'engineering')?4:0):0,c=OPTG[o]||(OPTG[o]=[]),m=c[fl]||(c[fl]=new Map());let g=m.get(km);if(g===undefined){const x=optMode(o,l);m.set(km,g=x?x.g:0);}return g;};
|
||||
const regenNeed=(o,l)=>Math.max(0,Math.ceil(l.km/OPT[o].reach)-1);
|
||||
// Whether upgrade k changes what any optic carries on a subsea cable this long (#198). has: the other upgrade is
|
||||
// already in; otherwise k also counts when it only helps together with the other one.
|
||||
const subOther=k=>k==='terminal'?'engineering':'terminal',subHelps=(km,k,has)=>{const j=subOther(k),c=(on,o)=>({kind:'df',own:true,sub:true,km,['sub'+k]:on?0:undefined,['sub'+j]:o?0:undefined});
|
||||
return (has?[1]:[0,1]).some(o=>Object.keys(OPT).some(x=>optG(x,c(1,o))!==optG(x,c(0,o))));};
|
||||
const regenNeed=(o,l)=>Math.max(0,Math.ceil(l.km/reachOn(OPT[o].reach,l.sub))-1);
|
||||
// The map asks for every fiber's capacity several times per frame (width, colour, label, up or down), each time over
|
||||
// all its channels. Nothing changes while a frame is drawn, so draw() keeps the answers in DFC for that frame.
|
||||
let DFC=null;
|
||||
|
|
|
|||
|
|
@ -1,125 +1,125 @@
|
|||
const CITIES=[
|
||||
{id:'sea',name:'Seattle',x:205,y:245,land:'am',reg:'AM',P:300,ix:'Sea-IX',dc:'Westerly Carrier Hotel'},
|
||||
{id:'sjc',name:'San Jose',x:240,y:345,land:'am',reg:'AM',P:500,ix:'Silly-Con Valley IX',dc:'Equinox SV'},
|
||||
{id:'dal',name:'Dallas',x:385,y:415,land:'am',reg:'AM',P:450,ix:'Yee-Haw-IX',dc:'Infomaniac Building'},
|
||||
{id:'chi',name:'Chicago',x:470,y:270,land:'am',reg:'AM',P:600,ix:'Windy-IX',dc:'350 Cermak'},
|
||||
{id:'ash',name:'Ashburn',x:572,y:332,land:'am',reg:'AM',P:250,ix:'Equinox Ashburn IX',dc:'Data Center Alley',note:tr('cities.the_data_center_capital_rumor_says')},
|
||||
{id:'nyc',name:'New York',x:615,y:283,land:'am',reg:'AM',P:1200,ix:'NY-Yikes',dc:'60 Hudson'},
|
||||
{id:'mia',name:'Miami',x:530,y:482,land:'am',reg:'AM',P:400,ix:'Miam-IX',dc:'Nap of the Americas',note:tr('cities.cable_landing_hub_for_south_america')},
|
||||
{id:'sao',name:'São Paulo',x:640,y:730,land:'sa',reg:'SA',P:900,br:true,andes:'e',ix:'IX.brrr São Paulo',ixCheap:0.3,dc:'Digital Reality SP',note:tr('cities.south_america_s_biggest_market_and')},
|
||||
{id:'lon',name:'London',x:935,y:275,land:'uk',reg:'EU',P:1000,ix:'LYNX',dc:'Telly-House Docklands',note:tr('cities.on_an_island_so_every_link')},
|
||||
{id:'ams',name:'Amsterdam',x:1015,y:245,land:'eu',reg:'EU',P:350,ix:'HAMS-IX',dc:'Science Park'},
|
||||
{id:'fra',name:'Frankfurt',x:1075,y:295,land:'eu',reg:'EU',P:600,ix:'DE-KICKS',dc:'Kleyerstraße Campus',note:tr('cities.europe_s_crossroads_lots_of_networks')},
|
||||
{id:'par',name:'Paris',x:990,y:320,land:'eu',reg:'EU',P:900,ix:'Fromage-IX',dc:'Interaction PAR'},
|
||||
{id:'mrs',name:'Marseille',x:1045,y:378,land:'eu',reg:'EU',P:250,ix:'Bouilla-IX',dc:'Cable Landing Station',note:tr('cities.subsea_cables_to_africa_and_asia')},
|
||||
{id:'tor',name:'Toronto',ca:true,x:548,y:252,land:'am',reg:'AM',P:500,ix:'Sorry-IX',dc:'151 Front Street',note:tr('cities.canada_s_hub_polite_packets_long')},
|
||||
{id:'bru',name:'Brussels',x:0,y:0,land:'eu',reg:'EU',P:150,be:true,tape:true,ix:'Frites-IX',dc:'Digital Unreality BRU1',note:tr('cities.right_between_london_amsterdam_paris')},
|
||||
{id:'oos',name:'Oostkamp',x:0,y:0,land:'eu',reg:'EU',P:30,be:true,tape:true,ix:'',dc:'DC-Starfish Oostkamp',note:tr('cities.inland_from_ostend_where_the_cables')},
|
||||
{id:'bet',name:'Bettembourg',x:0,y:0,land:'eu',reg:'EU',P:60,arpu:1.4,lux:true,ix:'LU-SICK',dc:'LuxDisconnect DC1.2',note:tr('cities.luxembourg_s_data_centers_are_not')},
|
||||
{id:'mtl',name:'Montreal',ca:true,x:598,y:238,land:'am',reg:'AM',P:300,ix:'Poutine-IX',dc:'Hydro-powered Hangar',note:tr('cities.cheap_hydro_power_makes_it_a')},
|
||||
{id:'kcy',name:'Kansas City',x:0,y:0,land:'am',reg:'AM',P:200,ix:'Toto-IX',dc:'The Limestone Cave',note:tr('cities.the_geographic_middle_of_the_us')},
|
||||
{id:'cal',name:'Calgary',x:0,y:0,land:'am',reg:'AM',P:150,ca:true,ix:'Stampede-IX',dc:'Bow & Arrow DC',note:tr('cities.the_prairie_gateway_between')},
|
||||
{id:'van',name:'Vancouver',x:0,y:0,land:'am',reg:'AM',P:250,ca:true,ix:'Raincouver-IX',dc:'Colo-Logics VAN3',note:tr('cities.canada_s_pacific_door_it_rains')},
|
||||
{id:'ott',name:'Ottawa',x:0,y:0,land:'am',reg:'AM',P:120,ca:true,blackout:true,ix:'Bytown-IX',dc:'Purely Colo (Mostly)',note:tr('cities.canada_s_capital_once_called_bytown')},
|
||||
{id:'lax',name:'Los Angeles',x:270,y:395,land:'am',reg:'AM',P:900,ix:'Any2-Anywhere',dc:'One Wilshire',note:tr('cities.pacific_cables_land_nearby_and')},
|
||||
{id:'mex',name:'Mexico City',x:368,y:470,land:'am',reg:'AM',P:700,ix:'',dc:'Querétaro Campus',note:tr('cities.huge_mobile_market_most_of_its')},
|
||||
{id:'rek',name:'Reykjavik',x:850,y:170,land:'is',reg:'EU',P:60,ix:'',dc:'Geothermal Bitcoin Barn',note:tr('cities.free_cooling_and_geothermal_power')},
|
||||
{id:'dub',name:'Dublin',x:876,y:268,land:'ie',reg:'EU',P:250,ix:'Craic-IX',dc:'Clonsilla Hyperscale Campus',note:tr('cities.every_hyperscaler_s_european_hq')},
|
||||
{id:'osl',name:'Oslo',x:1062,y:172,land:'eu',reg:'EU',P:200,ix:'NIX-NIX',dc:'Fjord-cooled Mountain Hall'},
|
||||
{id:'cph',name:'Copenhagen',x:1085,y:215,land:'eu',reg:'EU',P:250,ix:'Hygge-IX',dc:'Danish Design DC',note:tr('cities.landing_point_for_cables_from_the')},
|
||||
{id:'hel',name:'Helsinki',x:1168,y:140,land:'eu',reg:'EU',P:200,ix:'Sauna-IX',dc:'Underground Sauna Bunker',note:tr('cities.fast_fiber_east_and_west_and')},
|
||||
{id:'beg',name:'Belgrade',x:1122,y:338,land:'eu',reg:'EU',P:250,ix:'',dc:'Danube Docks DC'},
|
||||
{id:'sof',name:'Sofia',x:1165,y:358,land:'eu',reg:'EU',P:250,ix:'Rakija-IX',dc:'Vitosha DC',note:tr('cities.balkan_peering_hub_with_famously')},
|
||||
{id:'dxb',name:'Dubai',x:1292,y:428,land:'eu',reg:'AS',P:400,uae:true,ix:'Sand-IX',dc:'Air-conditioned Mirage DC',note:tr('cities.crossroads_for_cables_between_europe')},
|
||||
{id:'mos',name:'Moscow',x:1235,y:192,land:'eu',reg:'EU',P:900,ru:true,arpu:0.5,ix:'Borscht-IX',dc:'Very Secure Bunker',note:tr('cities.sovereign_internet_rules_every_pop')},
|
||||
{id:'akl',name:'Auckland',x:1964,y:826,land:'nz',reg:'OC',P:250,ix:'Kiwi-IX',dc:'Sheep-cooled Shed',note:tr('cities.far_from_everything_every_packet')},
|
||||
{id:'per',name:'Perth',x:1712,y:785,land:'oc',reg:'OC',au:true,arpu:AU_ARPU,P:200,ix:'Beard-IX',dc:'Very Remote DC',dc2:'Next-Door-DC P#',dc2N:2,note:tr('cities.the_most_isolated_big_city_on')},
|
||||
{id:'jkt',name:'Jakarta',x:1614,y:624,land:'idn',reg:'AS',P:900,ix:'Nasi-IX',dc:'Monsoon-proof DC',note:tr('cities.270_million_people_on_17_000')},
|
||||
{id:'mnl',name:'Manila',x:1714,y:494,land:'ph',reg:'AS',P:600,ix:'',dc:'Typhoon-rated DC',note:tr('cities.typhoons_earthquakes_and_a_lot_of')},
|
||||
{id:'ber',name:'Berlin',x:0,y:0,land:'eu',reg:'EU',P:450,ix:'Currywurst-IX',dc:'Former Brewery DC',note:tr('cities.startups_techno_and_a_surprising')},
|
||||
{id:'ham',name:'Hamburg',x:0,y:0,land:'eu',reg:'EU',P:250,ix:'Moin-IX',dc:'Speicherstadt Colo',note:tr('cities.germany_s_port_city_everyone_says')},
|
||||
{id:'dus',name:'Düsseldorf',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Altbier-IX',dc:'Königsallee Cage',note:tr('cities.the_rhine_ruhr_hub_more_carrier')},
|
||||
{id:'muc',name:'Munich',x:0,y:0,land:'eu',reg:'EU',P:250,ix:'Brezn-IX',dc:'Weißwurst Works',note:tr('cities.bavaria_s_capital_cars_insurers_and')},
|
||||
{id:'zrh',name:'Zurich',x:0,y:0,land:'eu',reg:'EU',P:250,ix:'Cuckoo-IX',dc:'Bank Vault DC',note:tr('cities.banks_very_punctual_packets_and')},
|
||||
{id:'sea',name:'Seattle',x:205,y:245,land:'am',reg:'AM',cc:'US',P:300,ix:'Sea-IX',dc:'Westerly Carrier Hotel'},
|
||||
{id:'sjc',name:'San Jose',x:240,y:345,land:'am',reg:'AM',cc:'US',P:500,ix:'Silly-Con Valley IX',dc:'Equinox SV'},
|
||||
{id:'dal',name:'Dallas',x:385,y:415,land:'am',reg:'AM',cc:'US',P:450,ix:'Yee-Haw-IX',dc:'Infomaniac Building'},
|
||||
{id:'chi',name:'Chicago',x:470,y:270,land:'am',reg:'AM',cc:'US',P:600,ix:'Windy-IX',dc:'350 Cermak'},
|
||||
{id:'ash',name:'Ashburn',x:572,y:332,land:'am',reg:'AM',cc:'US',P:250,ix:'Equinox Ashburn IX',dc:'Data Center Alley',note:tr('cities.the_data_center_capital_rumor_says')},
|
||||
{id:'nyc',name:'New York',x:615,y:283,land:'am',reg:'AM',cc:'US',P:1200,ix:'NY-Yikes',dc:'60 Hudson'},
|
||||
{id:'mia',name:'Miami',x:530,y:482,land:'am',reg:'AM',cc:'US',P:400,ix:'Miam-IX',dc:'Nap of the Americas',note:tr('cities.cable_landing_hub_for_south_america')},
|
||||
{id:'sao',name:'São Paulo',x:640,y:730,land:'sa',reg:'SA',cc:'BR',P:900,br:true,andes:'e',ix:'IX.brrr São Paulo',ixCheap:0.3,dc:'Digital Reality SP',note:tr('cities.south_america_s_biggest_market_and')},
|
||||
{id:'lon',name:'London',x:935,y:275,land:'uk',reg:'EU',cc:'GB',P:1000,ix:'LYNX',dc:'Telly-House Docklands',note:tr('cities.on_an_island_so_every_link')},
|
||||
{id:'ams',name:'Amsterdam',x:1015,y:245,land:'eu',reg:'EU',cc:'NL',P:350,ix:'HAMS-IX',dc:'Science Park'},
|
||||
{id:'fra',name:'Frankfurt',x:1075,y:295,land:'eu',reg:'EU',cc:'DE',P:600,ix:'DE-KICKS',dc:'Kleyerstraße Campus',note:tr('cities.europe_s_crossroads_lots_of_networks')},
|
||||
{id:'par',name:'Paris',x:990,y:320,land:'eu',reg:'EU',cc:'FR',P:900,ix:'Fromage-IX',dc:'Interaction PAR'},
|
||||
{id:'mrs',name:'Marseille',x:1045,y:378,land:'eu',reg:'EU',cc:'FR',P:250,ix:'Bouilla-IX',dc:'Cable Landing Station',note:tr('cities.subsea_cables_to_africa_and_asia')},
|
||||
{id:'tor',name:'Toronto',ca:true,x:548,y:252,land:'am',reg:'AM',cc:'CA',P:500,ix:'Sorry-IX',dc:'151 Front Street',note:tr('cities.canada_s_hub_polite_packets_long')},
|
||||
{id:'bru',name:'Brussels',x:0,y:0,land:'eu',reg:'EU',cc:'BE',P:150,be:true,tape:true,ix:'Frites-IX',dc:'Digital Unreality BRU1',note:tr('cities.right_between_london_amsterdam_paris')},
|
||||
{id:'oos',name:'Oostkamp',x:0,y:0,land:'eu',reg:'EU',cc:'BE',P:30,be:true,tape:true,ix:'',dc:'DC-Starfish Oostkamp',note:tr('cities.inland_from_ostend_where_the_cables')},
|
||||
{id:'bet',name:'Bettembourg',x:0,y:0,land:'eu',reg:'EU',cc:'LU',P:60,arpu:1.4,lux:true,ix:'LU-SICK',dc:'LuxDisconnect DC1.2',note:tr('cities.luxembourg_s_data_centers_are_not')},
|
||||
{id:'mtl',name:'Montreal',ca:true,x:598,y:238,land:'am',reg:'AM',cc:'CA',P:300,ix:'Poutine-IX',dc:'Hydro-powered Hangar',note:tr('cities.cheap_hydro_power_makes_it_a')},
|
||||
{id:'kcy',name:'Kansas City',x:0,y:0,land:'am',reg:'AM',cc:'US',P:200,ix:'Toto-IX',dc:'The Limestone Cave',note:tr('cities.the_geographic_middle_of_the_us')},
|
||||
{id:'cal',name:'Calgary',x:0,y:0,land:'am',reg:'AM',cc:'CA',P:150,ca:true,ix:'Stampede-IX',dc:'Bow & Arrow DC',note:tr('cities.the_prairie_gateway_between')},
|
||||
{id:'van',name:'Vancouver',x:0,y:0,land:'am',reg:'AM',cc:'CA',P:250,ca:true,ix:'Raincouver-IX',dc:'Colo-Logics VAN3',note:tr('cities.canada_s_pacific_door_it_rains')},
|
||||
{id:'ott',name:'Ottawa',x:0,y:0,land:'am',reg:'AM',cc:'CA',P:120,ca:true,blackout:true,ix:'Bytown-IX',dc:'Purely Colo (Mostly)',note:tr('cities.canada_s_capital_once_called_bytown')},
|
||||
{id:'lax',name:'Los Angeles',x:270,y:395,land:'am',reg:'AM',cc:'US',P:900,ix:'Any2-Anywhere',dc:'One Wilshire',note:tr('cities.pacific_cables_land_nearby_and')},
|
||||
{id:'mex',name:'Mexico City',x:368,y:470,land:'am',reg:'AM',cc:'MX',P:700,ix:'',dc:'Querétaro Campus',note:tr('cities.huge_mobile_market_most_of_its')},
|
||||
{id:'rek',name:'Reykjavik',x:850,y:170,land:'is',reg:'EU',cc:'IS',P:60,ix:'',dc:'Geothermal Bitcoin Barn',note:tr('cities.free_cooling_and_geothermal_power')},
|
||||
{id:'dub',name:'Dublin',x:876,y:268,land:'ie',reg:'EU',cc:'IE',P:250,ix:'Craic-IX',dc:'Clonsilla Hyperscale Campus',note:tr('cities.every_hyperscaler_s_european_hq')},
|
||||
{id:'osl',name:'Oslo',x:1062,y:172,land:'eu',reg:'EU',cc:'NO',P:200,ix:'NIX-NIX',dc:'Fjord-cooled Mountain Hall'},
|
||||
{id:'cph',name:'Copenhagen',x:1085,y:215,land:'eu',reg:'EU',cc:'DK',P:250,ix:'Hygge-IX',dc:'Danish Design DC',note:tr('cities.landing_point_for_cables_from_the')},
|
||||
{id:'hel',name:'Helsinki',x:1168,y:140,land:'eu',reg:'EU',cc:'FI',P:200,ix:'Sauna-IX',dc:'Underground Sauna Bunker',note:tr('cities.fast_fiber_east_and_west_and')},
|
||||
{id:'beg',name:'Belgrade',x:1122,y:338,land:'eu',reg:'EU',cc:'RS',P:250,ix:'',dc:'Danube Docks DC'},
|
||||
{id:'sof',name:'Sofia',x:1165,y:358,land:'eu',reg:'EU',cc:'BG',P:250,ix:'Rakija-IX',dc:'Vitosha DC',note:tr('cities.balkan_peering_hub_with_famously')},
|
||||
{id:'dxb',name:'Dubai',x:1292,y:428,land:'eu',reg:'AS',cc:'AE',P:400,uae:true,ix:'Sand-IX',dc:'Air-conditioned Mirage DC',note:tr('cities.crossroads_for_cables_between_europe')},
|
||||
{id:'mos',name:'Moscow',x:1235,y:192,land:'eu',reg:'EU',cc:'RU',P:900,ru:true,arpu:0.5,ix:'Borscht-IX',dc:'Very Secure Bunker',note:tr('cities.sovereign_internet_rules_every_pop')},
|
||||
{id:'akl',name:'Auckland',x:1964,y:826,land:'nz',reg:'OC',cc:'NZ',P:250,ix:'Kiwi-IX',dc:'Sheep-cooled Shed',note:tr('cities.far_from_everything_every_packet')},
|
||||
{id:'per',name:'Perth',x:1712,y:785,land:'oc',reg:'OC',cc:'AU',au:true,arpu:AU_ARPU,P:200,ix:'Beard-IX',dc:'Very Remote DC',dc2:'Next-Door-DC P#',dc2N:2,note:tr('cities.the_most_isolated_big_city_on')},
|
||||
{id:'jkt',name:'Jakarta',x:1614,y:624,land:'idn',reg:'AS',cc:'ID',P:900,ix:'Nasi-IX',dc:'Monsoon-proof DC',note:tr('cities.270_million_people_on_17_000')},
|
||||
{id:'mnl',name:'Manila',x:1714,y:494,land:'ph',reg:'AS',cc:'PH',P:600,ix:'',dc:'Typhoon-rated DC',note:tr('cities.typhoons_earthquakes_and_a_lot_of')},
|
||||
{id:'ber',name:'Berlin',x:0,y:0,land:'eu',reg:'EU',cc:'DE',P:450,ix:'Currywurst-IX',dc:'Former Brewery DC',note:tr('cities.startups_techno_and_a_surprising')},
|
||||
{id:'ham',name:'Hamburg',x:0,y:0,land:'eu',reg:'EU',cc:'DE',P:250,ix:'Moin-IX',dc:'Speicherstadt Colo',note:tr('cities.germany_s_port_city_everyone_says')},
|
||||
{id:'dus',name:'Düsseldorf',x:0,y:0,land:'eu',reg:'EU',cc:'DE',P:300,ix:'Altbier-IX',dc:'Königsallee Cage',note:tr('cities.the_rhine_ruhr_hub_more_carrier')},
|
||||
{id:'muc',name:'Munich',x:0,y:0,land:'eu',reg:'EU',cc:'DE',P:250,ix:'Brezn-IX',dc:'Weißwurst Works',note:tr('cities.bavaria_s_capital_cars_insurers_and')},
|
||||
{id:'zrh',name:'Zurich',x:0,y:0,land:'eu',reg:'EU',cc:'CH',P:250,ix:'Cuckoo-IX',dc:'Bank Vault DC',note:tr('cities.banks_very_punctual_packets_and')},
|
||||
{id:'nbo',name:'Nairobi',x:0,y:0,land:'af',reg:'AF',cc:'KE',P:350,ix:'Safari-IX',dc:'Silicon Savannah Campus',note:tr('cities.east_africa_s_hub_cables_land')},
|
||||
{id:'cai',name:'Cairo',x:0,y:0,land:'af',land2:'eu',reg:'AF',cc:'EG',P:600,ix:'Pharaoh-IX',dc:'Pyramid-adjacent DC',note:tr('cities.almost_every_europe_asia_cable')},
|
||||
{id:'stg',name:'Stuttgart',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Spätzle-IX',dc:'Kehrwoche-certified DC',ixOnly:true,note:tr('cities.cars_engineers_and_kehrwoche_every')},
|
||||
{id:'sto',name:'Stockholm',x:1110,y:160,land:'eu',reg:'EU',P:300,ix:'NodNod',dc:'Nuclear Bunker DC'},
|
||||
{id:'bcn',name:'Barcelona',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Catnip-IX',dc:'Poblenou DC',note:tr('cities.catalonia_s_own_exchange_small_and')},
|
||||
{id:'mad',name:'Madrid',x:935,y:392,land:'eu',reg:'EU',P:600,ix:'Siesta-IX',dc:'Interaction MAD'},
|
||||
{id:'stg',name:'Stuttgart',x:0,y:0,land:'eu',reg:'EU',cc:'DE',P:300,ix:'Spätzle-IX',dc:'Kehrwoche-certified DC',ixOnly:true,note:tr('cities.cars_engineers_and_kehrwoche_every')},
|
||||
{id:'sto',name:'Stockholm',x:1110,y:160,land:'eu',reg:'EU',cc:'SE',P:300,ix:'NodNod',dc:'Nuclear Bunker DC'},
|
||||
{id:'bcn',name:'Barcelona',x:0,y:0,land:'eu',reg:'EU',cc:'ES',P:300,ix:'Catnip-IX',dc:'Poblenou DC',note:tr('cities.catalonia_s_own_exchange_small_and')},
|
||||
{id:'mad',name:'Madrid',x:935,y:392,land:'eu',reg:'EU',cc:'ES',P:600,ix:'Siesta-IX',dc:'Interaction MAD'},
|
||||
{id:'lag',name:'Lagos',x:1010,y:565,land:'af',reg:'AF',cc:'NG',P:500,ix:'Jollof-IX',dc:'Rack-n-Roll Centre'},
|
||||
{id:'jnb',name:'Johannesburg',x:1130,y:730,land:'af',reg:'AF',cc:'ZA',P:400,za:true,ix:'Braai-IX',dc:'Tera-Cotta Campus'},
|
||||
{id:'bom',name:'Mumbai',x:1385,y:488,land:'eu',reg:'AS',P:1100,india:true,ix:'Mumb-IX',dc:'Goregaon Tech Park'},
|
||||
{id:'sin',name:'Singapore',x:1556,y:568,land:'eu',reg:'AS',P:450,ix:'Lah-IX',dc:'Equinox SG',note:tr('cities.asia_s_hub_expensive_humid_very')},
|
||||
{id:'hkg',name:'Hong Kong',x:1645,y:440,land:'eu',reg:'AS',P:600,ix:'HK-Kicks',dc:'Mega-Eye Plus'},
|
||||
{id:'icn',name:'Seoul',x:1722,y:302,land:'eu',reg:'AS',P:900,kr:true,ix:'Kimch-IX',dc:'Gasan Digital Complex',note:tr('cities.some_of_the_fastest_home_broadband')},
|
||||
{id:'pek',name:'Beijing',x:1652,y:318,land:'eu',reg:'AS',P:1800,cn:true,arpu:0.6,ix:'',dc:'Zhongguancun DC',note:tr('cities.mainland_china_behind_the_great')},
|
||||
{id:'sha',name:'Shanghai',x:1680,y:388,land:'eu',reg:'AS',P:2200,cn:true,arpu:0.6,ix:'',dc:'Lujiazui Data Center',note:tr('cities.mainland_china_enormous_market')},
|
||||
{id:'tok',name:'Tokyo',x:1795,y:320,land:'jp',reg:'AS',P:1400,ix:'JP-Naptime',dc:'Otemachi Tower'},
|
||||
{id:'syd',name:'Sydney',x:1860,y:790,land:'oc',reg:'OC',au:true,arpu:AU_ARPU,P:500,ix:'IX Straya',dc:'Next-Door-DC S#',dcN:3,dc2:'Equinox SY#',dc2N:7,note:tr('cities.the_harbour_the_bridge_and_most')},
|
||||
{id:'for',name:'Fortaleza',x:0,y:0,land:'sa',reg:'SA',P:250,br:true,andes:'e',ix:'IX.brrr Fortaleza',ixCheap:0.3,dc:'Praia Landing Station',note:tr('cities.where_south_america_s_cables')},
|
||||
{id:'rio',name:'Rio de Janeiro',x:0,y:0,land:'sa',reg:'SA',P:600,br:true,andes:'e',ix:'IX.brrr Rio',ixCheap:0.3,dc:'Copacabana Colo',note:tr('cities.beaches_cable_landings_and_a')},
|
||||
{id:'bsb',name:'Brasília',x:0,y:0,land:'sa',reg:'SA',P:200,br:true,andes:'e',ix:'IX.brrr Brasília',ixCheap:0.3,dc:'Modernist Concrete Colo',note:tr('cities.brazil_s_planned_capital_shaped_like')},
|
||||
{id:'bhz',name:'Belo Horizonte',x:0,y:0,land:'sa',reg:'SA',P:250,br:true,andes:'e',ix:'IX.brrr BH',ixCheap:0.3,dc:'Pão de Queijo Point',note:tr('cities.mountains_mines_and_more_bars_per')},
|
||||
{id:'cwb',name:'Curitiba',x:0,y:0,land:'sa',reg:'SA',P:200,br:true,andes:'e',ix:'IX.brrr Curitiba',ixCheap:0.3,dc:'Pine Nut Park DC',note:tr('cities.brazil_s_coldest_big_city_and')},
|
||||
{id:'poa',name:'Porto Alegre',x:0,y:0,land:'sa',reg:'SA',P:200,br:true,andes:'e',ix:'IX.brrr Porto Alegre',ixCheap:0.3,dc:'Chimarrão Colo',note:tr('cities.the_deep_south_halfway_to_buenos')},
|
||||
{id:'aju',off:true,name:'Aracaju',x:0,y:0,land:'sa',reg:'SA',P:40,br:true,andes:'e',ix:'IX.brrr Aracaju',ixCheap:0.3,dc:'Crab Walk Colo'},
|
||||
{id:'bel',name:'Belém',x:0,y:0,land:'sa',reg:'SA',P:100,br:true,andes:'e',rain:true,ix:'IX.brrr Belém',ixCheap:0.3,dc:'Açaí Bowl DC',note:tr('cities.gateway_to_the_amazon_at_the')},
|
||||
{id:'bvb',name:'Boa Vista',x:0,y:0,land:'sa',reg:'SA',P:20,br:true,andes:'e',rain:true,ix:'IX.brrr Boa Vista',ixCheap:0.3,dc:'Northern Lights Racks',note:tr('cities.brazil_s_northernmost_capital_the')},
|
||||
{id:'cac',off:true,name:'Cascavel',x:0,y:0,land:'sa',reg:'SA',P:20,br:true,andes:'e',ix:'IX.brrr Cascavel',ixCheap:0.3,dc:'Soybean Silo DC'},
|
||||
{id:'cpv',off:true,name:'Campina Grande',x:0,y:0,land:'sa',reg:'SA',P:20,br:true,andes:'e',ix:'IX.brrr Campina Grande',ixCheap:0.3,dc:'Forró Forum DC',note:tr('cities.throws_the_biggest_sao_joao_festival')},
|
||||
{id:'cpq',name:'Campinas',x:0,y:0,land:'sa',reg:'SA',P:130,br:true,andes:'e',ix:'IX.brrr Campinas',ixCheap:0.3,dc:'Silicon Sugarcane Park',note:tr('cities.brazil_s_tech_hub_an_hour')},
|
||||
{id:'cgr',name:'Campo Grande',x:0,y:0,land:'sa',reg:'SA',P:40,br:true,andes:'e',ix:'IX.brrr Campo Grande',ixCheap:0.3,dc:'Pantanal Edge Colo'},
|
||||
{id:'cau',off:true,name:'Caruaru',x:0,y:0,land:'sa',reg:'SA',P:20,br:true,andes:'e',ix:'IX.brrr Caruaru',ixCheap:0.3,dc:'Clay Doll Datacenter'},
|
||||
{id:'cgb',name:'Cuiabá',x:0,y:0,land:'sa',reg:'SA',P:40,br:true,andes:'e',ix:'IX.brrr Cuiabá',ixCheap:0.3,dc:'Forty Degrees DC',note:tr('cities.the_geographic_center_of_south')},
|
||||
{id:'cxj',off:true,name:'Caxias do Sul',x:0,y:0,land:'sa',reg:'SA',P:25,br:true,andes:'e',ix:'IX.brrr Caxias do Sul',ixCheap:0.3,dc:'Wine Cellar Racks',note:tr('cities.italian_immigrants_vineyards_and')},
|
||||
{id:'fec',off:true,name:'Feira de Santana',x:0,y:0,land:'sa',reg:'SA',P:25,br:true,andes:'e',ix:'IX.brrr Feira de Santana',ixCheap:0.3,dc:'Crossroads Colo'},
|
||||
{id:'fln',off:true,name:'Florianópolis',x:0,y:0,land:'sa',reg:'SA',P:50,br:true,andes:'e',ix:'IX.brrr Florianópolis',ixCheap:0.3,dc:'Island Uplink DC',note:tr('cities.an_island_capital_of_beaches_and')},
|
||||
{id:'igu',off:true,name:'Foz do Iguaçu',x:0,y:0,land:'sa',reg:'SA',P:15,br:true,andes:'e',ix:'IX.brrr Foz do Iguaçu',ixCheap:0.3,dc:'Triple Border Racks',note:tr('cities.where_brazil_argentina_and_paraguay')},
|
||||
{id:'gyn',name:'Goiânia',x:0,y:0,land:'sa',reg:'SA',P:100,br:true,andes:'e',ix:'IX.brrr Goiânia',ixCheap:0.3,dc:'Pequi Peak DC',note:tr('cities.agribusiness_capital_and_home_of')},
|
||||
{id:'jpa',off:true,name:'João Pessoa',x:0,y:0,land:'sa',reg:'SA',P:50,br:true,andes:'e',ix:'IX.brrr João Pessoa',ixCheap:0.3,dc:'Sunrise Point DC',note:tr('cities.the_easternmost_city_of_the_americas')},
|
||||
{id:'ljd',off:true,name:'Lajeado',x:0,y:0,land:'sa',reg:'SA',P:10,br:true,andes:'e',ix:'IX.brrr Lajeado',ixCheap:0.3,dc:'Valley Co-op Colo',note:tr('cities.a_small_town_with_its_own')},
|
||||
{id:'ldb',name:'Londrina',x:0,y:0,land:'sa',reg:'SA',P:35,br:true,andes:'e',ix:'IX.brrr Londrina',ixCheap:0.3,dc:'Red Soil DC'},
|
||||
{id:'mcp',name:'Macapá',x:0,y:0,land:'sa',reg:'SA',P:25,br:true,andes:'e',rain:true,blackout:true,ix:'IX.brrr Macapá',ixCheap:0.3,dc:'Equator Line Colo',note:tr('cities.right_on_the_equator_at_the')},
|
||||
{id:'mcz',off:true,name:'Maceió',x:0,y:0,land:'sa',reg:'SA',P:55,br:true,andes:'e',ix:'IX.brrr Maceió',ixCheap:0.3,dc:'Lagoon View Racks'},
|
||||
{id:'mao',name:'Manaus',x:0,y:0,land:'sa',reg:'SA',P:90,br:true,andes:'e',rain:true,ix:'IX.brrr Manaus',ixCheap:0.3,dc:'Free Zone Colo',note:tr('cities.two_million_people_in_the_middle')},
|
||||
{id:'mgf',off:true,name:'Maringá',x:0,y:0,land:'sa',reg:'SA',P:30,br:true,andes:'e',ix:'IX.brrr Maringá',ixCheap:0.3,dc:'Cathedral Cone DC'},
|
||||
{id:'nat',name:'Natal',x:0,y:0,land:'sa',reg:'SA',P:60,br:true,andes:'e',ix:'IX.brrr Natal',ixCheap:0.3,dc:'Dune Buggy DC',note:tr('cities.dunes_buggies_and_the_corner_of')},
|
||||
{id:'pmw',name:'Palmas',x:0,y:0,land:'sa',reg:'SA',P:15,br:true,andes:'e',ix:'IX.brrr Palmas',ixCheap:0.3,dc:'Planned Grid DC',note:tr('cities.brazil_s_youngest_state_capital')},
|
||||
{id:'pvh',name:'Porto Velho',x:0,y:0,land:'sa',reg:'SA',P:25,br:true,andes:'e',rain:true,ix:'IX.brrr Porto Velho',ixCheap:0.3,dc:'Madeira River Racks'},
|
||||
{id:'rao',off:true,name:'Ribeirão Preto',x:0,y:0,land:'sa',reg:'SA',P:50,br:true,andes:'e',ix:'IX.brrr Ribeirão Preto',ixCheap:0.3,dc:'Sugarcane & Servers',note:tr('cities.brazil_s_agribusiness_capital')},
|
||||
{id:'rec',name:'Recife',x:0,y:0,land:'sa',reg:'SA',P:160,br:true,andes:'e',ix:'IX.brrr Recife',ixCheap:0.3,dc:'Frevo Colo',note:tr('cities.the_venice_of_brazil_all_bridges')},
|
||||
{id:'rbr',name:'Rio Branco',x:0,y:0,land:'sa',reg:'SA',P:20,br:true,andes:'e',rain:true,ix:'IX.brrr Rio Branco',ixCheap:0.3,dc:'Acre-ly Real DC',note:tr('cities.the_capital_of_acre_a_state')},
|
||||
{id:'ssa',name:'Salvador',x:0,y:0,land:'sa',reg:'SA',P:160,br:true,andes:'e',ix:'IX.brrr Salvador',ixCheap:0.3,dc:'Axé Uplink DC',note:tr('cities.brazil_s_first_capital_with_cables')},
|
||||
{id:'ria',off:true,name:'Santa Maria',x:0,y:0,land:'sa',reg:'SA',P:15,br:true,andes:'e',ix:'IX.brrr Santa Maria',ixCheap:0.3,dc:'Gaúcho Plains Colo'},
|
||||
{id:'sjp',off:true,name:'São José do Rio Preto',x:0,y:0,land:'sa',reg:'SA',P:25,br:true,andes:'e',ix:'IX.brrr São José do Rio Preto',ixCheap:0.3,dc:'Rio Preto Racks'},
|
||||
{id:'slz',name:'São Luís',x:0,y:0,land:'sa',reg:'SA',P:65,br:true,andes:'e',ix:'IX.brrr São Luís',ixCheap:0.3,dc:'Reggae Island DC',note:tr('cities.an_island_city_of_tiled_colonial')},
|
||||
{id:'the',name:'Teresina',x:0,y:0,land:'sa',reg:'SA',P:50,br:true,andes:'e',ix:'IX.brrr Teresina',ixCheap:0.3,dc:'Sunbaked Server Hall',note:tr('cities.the_only_northeastern_capital_away')},
|
||||
{id:'vix',name:'Vitória',x:0,y:0,land:'sa',reg:'SA',P:80,br:true,andes:'e',ix:'IX.brrr Vitória',ixCheap:0.3,dc:'Moqueca Colo',note:tr('cities.an_island_capital_with_a_big')},
|
||||
{id:'mvd',name:'Montevideo',x:0,y:0,land:'sa',reg:'SA',P:150,andes:'e',ix:'Chivito-IX',dc:'Rambla Racks',note:tr('cities.uruguay_fiber_to_almost_every_home')},
|
||||
{id:'asu',name:'Asunción',x:0,y:0,land:'sa',reg:'SA',P:120,andes:'e',ix:'Chipa-IX',dc:'Hydro Surplus DC',note:tr('cities.paraguay_shares_two_giant_dams_with')},
|
||||
{id:'cor',name:'Córdoba',x:0,y:0,land:'sa',reg:'SA',P:150,andes:'e',arpu:0.7,ix:'Fernet-IX',dc:'Sierras Server Shed',note:tr('cities.argentina_s_second_city_universities')},
|
||||
{id:'lpb',name:'La Paz',x:0,y:0,land:'sa',reg:'SA',P:80,andes:'m',ix:'Salteña-IX',dc:'Cable Car Colo',note:tr('cities.the_highest_seat_of_government_on')},
|
||||
{id:'uio',name:'Quito',x:0,y:0,land:'sa',reg:'SA',P:100,andes:'m',ix:'Equator-IX',dc:'Middle of the World DC',note:tr('cities.a_capital_high_in_the_andes')},
|
||||
{id:'mde',name:'Medellín',x:0,y:0,land:'sa',reg:'SA',P:150,andes:'m',ix:'Paisa-IX',dc:'Eternal Spring DC',note:tr('cities.the_city_of_eternal_spring_with')},
|
||||
{id:'ccs',name:'Caracas',x:0,y:0,land:'sa',reg:'SA',P:120,blackout:true,ix:'Cachapa-IX',dc:'Generator Included DC',note:tr('cities.a_capital_in_a_valley_under')},
|
||||
{id:'gua',name:'Guatemala City',x:0,y:0,land:'am',reg:'AM',P:120,ix:'Quetzal-IX',dc:'Volcano View Colo',note:tr('cities.central_america_s_biggest_city')},
|
||||
{id:'sjo',name:'San José',x:0,y:0,land:'am',reg:'AM',P:80,ix:'Pura Vida-IX',dc:'Cloud Forest DC',note:tr('cities.costa_rica_runs_almost_entirely_on')},
|
||||
{id:'qro',name:'Querétaro',x:0,y:0,land:'am',reg:'AM',P:120,ix:'Gordita-IX',dc:'Bajío Bit Barn',note:tr('cities.mexico_s_data_center_boom_town')},
|
||||
{id:'mty',name:'Monterrey',x:0,y:0,land:'am',reg:'AM',P:200,ix:'Cabrito-IX',dc:'Saddle Mountain Colo',note:tr('cities.mexico_s_industrial_capital_a_few')},
|
||||
{id:'gdl',name:'Guadalajara',x:0,y:0,land:'am',reg:'AM',P:200,ix:'Tequila-IX',dc:'Mariachi Mainframes',note:tr('cities.mexico_s_silicon_valley_home_of')},
|
||||
{id:'bue',name:'Buenos Aires',x:0,y:0,land:'sa',reg:'SA',P:500,andes:'e',arpu:0.7,ix:'Asado-IX',dc:'Puerto Madero DC',note:tr('cities.tango_steak_and_a_currency_that')},
|
||||
{id:'scl',name:'Santiago',x:0,y:0,land:'sa',reg:'SA',P:350,andes:'w',ix:'Empanada-IX',dc:'Andes-view Bunker',note:tr('cities.the_pacific_gateway_the_andes_sit')},
|
||||
{id:'lim',name:'Lima',x:0,y:0,land:'sa',reg:'SA',P:400,andes:'w',ix:'Ceviche-IX',dc:'Fog-cooled DC',note:tr('cities.it_almost_never_rains_but_the')},
|
||||
{id:'bog',name:'Bogotá',x:0,y:0,land:'sa',reg:'SA',P:400,andes:'m',ix:'Arepa-IX',dc:'2,600 m Above Sea Level DC',note:tr('cities.high_up_in_the_andes_no')},
|
||||
{id:'pan',name:'Panama City',x:0,y:0,land:'am',reg:'AM',P:80,ix:'Canal-IX',dc:'Isthmus Interconnect',note:tr('cities.every_cable_between_the_americas')},
|
||||
{id:'del',name:'Delhi',x:0,y:0,land:'eu',reg:'AS',P:1600,arpu:0.4,india:true,ix:'Butter-Chicken-IX',dc:'Smog-filtered DC',note:tr('cities.an_enormous_very_online_city_a')},
|
||||
{id:'maa',name:'Chennai',x:0,y:0,land:'eu',reg:'AS',P:500,arpu:0.5,india:true,ix:'Dosa-IX',dc:'Cyclone-rated Landing Bay',note:tr('cities.india_s_east_coast_landing_hub')},
|
||||
{id:'blr',name:'Bengaluru',x:0,y:0,land:'eu',reg:'AS',P:600,arpu:0.6,india:true,ix:'Filter-Kaapi-IX',dc:'Traffic-jam-adjacent Campus',note:tr('cities.india_s_tech_capital_packets_move')},
|
||||
{id:'hyd',name:'Hyderabad',x:0,y:0,land:'eu',reg:'AS',P:400,arpu:0.5,india:true,ix:'Biryani-IX',dc:'Hyperscale Hills',note:tr('cities.every_hyperscaler_is_building_a')},
|
||||
{id:'tpe',name:'Taipei',x:0,y:0,land:'tw',reg:'AS',P:450,ix:'Bubble-Tea-IX',dc:'Typhoon-proof Tower',note:tr('cities.makes_most_of_the_world_s')},
|
||||
{id:'auh',name:'Abu Dhabi',x:0,y:0,land:'eu',reg:'AS',P:200,arpu:1.4,uae:true,ix:'',dc:'Oasis-cooled Campus',note:tr('cities.the_capital_sovereign_ai_money_and')},
|
||||
{id:'fuj',name:'Fujairah',x:0,y:0,land:'eu',reg:'AS',P:20,uae:true,ix:'',dc:'Cable Landing Sandcastle',note:tr('cities.most_uae_cables_land_on_this')},
|
||||
{id:'bom',name:'Mumbai',x:1385,y:488,land:'eu',reg:'AS',cc:'IN',P:1100,india:true,ix:'Mumb-IX',dc:'Goregaon Tech Park'},
|
||||
{id:'sin',name:'Singapore',x:1556,y:568,land:'eu',reg:'AS',cc:'SG',P:450,ix:'Lah-IX',dc:'Equinox SG',note:tr('cities.asia_s_hub_expensive_humid_very')},
|
||||
{id:'hkg',name:'Hong Kong',x:1645,y:440,land:'eu',reg:'AS',cc:'HK',P:600,ix:'HK-Kicks',dc:'Mega-Eye Plus'},
|
||||
{id:'icn',name:'Seoul',x:1722,y:302,land:'eu',reg:'AS',cc:'KR',P:900,kr:true,ix:'Kimch-IX',dc:'Gasan Digital Complex',note:tr('cities.some_of_the_fastest_home_broadband')},
|
||||
{id:'pek',name:'Beijing',x:1652,y:318,land:'eu',reg:'AS',cc:'CN',P:1800,cn:true,arpu:0.6,ix:'',dc:'Zhongguancun DC',note:tr('cities.mainland_china_behind_the_great')},
|
||||
{id:'sha',name:'Shanghai',x:1680,y:388,land:'eu',reg:'AS',cc:'CN',P:2200,cn:true,arpu:0.6,ix:'',dc:'Lujiazui Data Center',note:tr('cities.mainland_china_enormous_market')},
|
||||
{id:'tok',name:'Tokyo',x:1795,y:320,land:'jp',reg:'AS',cc:'JP',P:1400,ix:'JP-Naptime',dc:'Otemachi Tower'},
|
||||
{id:'syd',name:'Sydney',x:1860,y:790,land:'oc',reg:'OC',cc:'AU',au:true,arpu:AU_ARPU,P:500,ix:'IX Straya',dc:'Next-Door-DC S#',dcN:3,dc2:'Equinox SY#',dc2N:7,note:tr('cities.the_harbour_the_bridge_and_most')},
|
||||
{id:'for',name:'Fortaleza',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:250,br:true,andes:'e',ix:'IX.brrr Fortaleza',ixCheap:0.3,dc:'Praia Landing Station',note:tr('cities.where_south_america_s_cables')},
|
||||
{id:'rio',name:'Rio de Janeiro',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:600,br:true,andes:'e',ix:'IX.brrr Rio',ixCheap:0.3,dc:'Copacabana Colo',note:tr('cities.beaches_cable_landings_and_a')},
|
||||
{id:'bsb',name:'Brasília',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:200,br:true,andes:'e',ix:'IX.brrr Brasília',ixCheap:0.3,dc:'Modernist Concrete Colo',note:tr('cities.brazil_s_planned_capital_shaped_like')},
|
||||
{id:'bhz',name:'Belo Horizonte',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:250,br:true,andes:'e',ix:'IX.brrr BH',ixCheap:0.3,dc:'Pão de Queijo Point',note:tr('cities.mountains_mines_and_more_bars_per')},
|
||||
{id:'cwb',name:'Curitiba',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:200,br:true,andes:'e',ix:'IX.brrr Curitiba',ixCheap:0.3,dc:'Pine Nut Park DC',note:tr('cities.brazil_s_coldest_big_city_and')},
|
||||
{id:'poa',name:'Porto Alegre',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:200,br:true,andes:'e',ix:'IX.brrr Porto Alegre',ixCheap:0.3,dc:'Chimarrão Colo',note:tr('cities.the_deep_south_halfway_to_buenos')},
|
||||
{id:'aju',off:true,name:'Aracaju',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:40,br:true,andes:'e',ix:'IX.brrr Aracaju',ixCheap:0.3,dc:'Crab Walk Colo'},
|
||||
{id:'bel',name:'Belém',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:100,br:true,andes:'e',rain:true,ix:'IX.brrr Belém',ixCheap:0.3,dc:'Açaí Bowl DC',note:tr('cities.gateway_to_the_amazon_at_the')},
|
||||
{id:'bvb',name:'Boa Vista',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:20,br:true,andes:'e',rain:true,ix:'IX.brrr Boa Vista',ixCheap:0.3,dc:'Northern Lights Racks',note:tr('cities.brazil_s_northernmost_capital_the')},
|
||||
{id:'cac',off:true,name:'Cascavel',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:20,br:true,andes:'e',ix:'IX.brrr Cascavel',ixCheap:0.3,dc:'Soybean Silo DC'},
|
||||
{id:'cpv',off:true,name:'Campina Grande',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:20,br:true,andes:'e',ix:'IX.brrr Campina Grande',ixCheap:0.3,dc:'Forró Forum DC',note:tr('cities.throws_the_biggest_sao_joao_festival')},
|
||||
{id:'cpq',name:'Campinas',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:130,br:true,andes:'e',ix:'IX.brrr Campinas',ixCheap:0.3,dc:'Silicon Sugarcane Park',note:tr('cities.brazil_s_tech_hub_an_hour')},
|
||||
{id:'cgr',name:'Campo Grande',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:40,br:true,andes:'e',ix:'IX.brrr Campo Grande',ixCheap:0.3,dc:'Pantanal Edge Colo'},
|
||||
{id:'cau',off:true,name:'Caruaru',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:20,br:true,andes:'e',ix:'IX.brrr Caruaru',ixCheap:0.3,dc:'Clay Doll Datacenter'},
|
||||
{id:'cgb',name:'Cuiabá',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:40,br:true,andes:'e',ix:'IX.brrr Cuiabá',ixCheap:0.3,dc:'Forty Degrees DC',note:tr('cities.the_geographic_center_of_south')},
|
||||
{id:'cxj',off:true,name:'Caxias do Sul',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:25,br:true,andes:'e',ix:'IX.brrr Caxias do Sul',ixCheap:0.3,dc:'Wine Cellar Racks',note:tr('cities.italian_immigrants_vineyards_and')},
|
||||
{id:'fec',off:true,name:'Feira de Santana',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:25,br:true,andes:'e',ix:'IX.brrr Feira de Santana',ixCheap:0.3,dc:'Crossroads Colo'},
|
||||
{id:'fln',off:true,name:'Florianópolis',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:50,br:true,andes:'e',ix:'IX.brrr Florianópolis',ixCheap:0.3,dc:'Island Uplink DC',note:tr('cities.an_island_capital_of_beaches_and')},
|
||||
{id:'igu',off:true,name:'Foz do Iguaçu',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:15,br:true,andes:'e',ix:'IX.brrr Foz do Iguaçu',ixCheap:0.3,dc:'Triple Border Racks',note:tr('cities.where_brazil_argentina_and_paraguay')},
|
||||
{id:'gyn',name:'Goiânia',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:100,br:true,andes:'e',ix:'IX.brrr Goiânia',ixCheap:0.3,dc:'Pequi Peak DC',note:tr('cities.agribusiness_capital_and_home_of')},
|
||||
{id:'jpa',off:true,name:'João Pessoa',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:50,br:true,andes:'e',ix:'IX.brrr João Pessoa',ixCheap:0.3,dc:'Sunrise Point DC',note:tr('cities.the_easternmost_city_of_the_americas')},
|
||||
{id:'ljd',off:true,name:'Lajeado',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:10,br:true,andes:'e',ix:'IX.brrr Lajeado',ixCheap:0.3,dc:'Valley Co-op Colo',note:tr('cities.a_small_town_with_its_own')},
|
||||
{id:'ldb',name:'Londrina',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:35,br:true,andes:'e',ix:'IX.brrr Londrina',ixCheap:0.3,dc:'Red Soil DC'},
|
||||
{id:'mcp',name:'Macapá',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:25,br:true,andes:'e',rain:true,blackout:true,ix:'IX.brrr Macapá',ixCheap:0.3,dc:'Equator Line Colo',note:tr('cities.right_on_the_equator_at_the')},
|
||||
{id:'mcz',off:true,name:'Maceió',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:55,br:true,andes:'e',ix:'IX.brrr Maceió',ixCheap:0.3,dc:'Lagoon View Racks'},
|
||||
{id:'mao',name:'Manaus',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:90,br:true,andes:'e',rain:true,ix:'IX.brrr Manaus',ixCheap:0.3,dc:'Free Zone Colo',note:tr('cities.two_million_people_in_the_middle')},
|
||||
{id:'mgf',off:true,name:'Maringá',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:30,br:true,andes:'e',ix:'IX.brrr Maringá',ixCheap:0.3,dc:'Cathedral Cone DC'},
|
||||
{id:'nat',name:'Natal',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:60,br:true,andes:'e',ix:'IX.brrr Natal',ixCheap:0.3,dc:'Dune Buggy DC',note:tr('cities.dunes_buggies_and_the_corner_of')},
|
||||
{id:'pmw',name:'Palmas',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:15,br:true,andes:'e',ix:'IX.brrr Palmas',ixCheap:0.3,dc:'Planned Grid DC',note:tr('cities.brazil_s_youngest_state_capital')},
|
||||
{id:'pvh',name:'Porto Velho',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:25,br:true,andes:'e',rain:true,ix:'IX.brrr Porto Velho',ixCheap:0.3,dc:'Madeira River Racks'},
|
||||
{id:'rao',off:true,name:'Ribeirão Preto',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:50,br:true,andes:'e',ix:'IX.brrr Ribeirão Preto',ixCheap:0.3,dc:'Sugarcane & Servers',note:tr('cities.brazil_s_agribusiness_capital')},
|
||||
{id:'rec',name:'Recife',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:160,br:true,andes:'e',ix:'IX.brrr Recife',ixCheap:0.3,dc:'Frevo Colo',note:tr('cities.the_venice_of_brazil_all_bridges')},
|
||||
{id:'rbr',name:'Rio Branco',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:20,br:true,andes:'e',rain:true,ix:'IX.brrr Rio Branco',ixCheap:0.3,dc:'Acre-ly Real DC',note:tr('cities.the_capital_of_acre_a_state')},
|
||||
{id:'ssa',name:'Salvador',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:160,br:true,andes:'e',ix:'IX.brrr Salvador',ixCheap:0.3,dc:'Axé Uplink DC',note:tr('cities.brazil_s_first_capital_with_cables')},
|
||||
{id:'ria',off:true,name:'Santa Maria',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:15,br:true,andes:'e',ix:'IX.brrr Santa Maria',ixCheap:0.3,dc:'Gaúcho Plains Colo'},
|
||||
{id:'sjp',off:true,name:'São José do Rio Preto',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:25,br:true,andes:'e',ix:'IX.brrr São José do Rio Preto',ixCheap:0.3,dc:'Rio Preto Racks'},
|
||||
{id:'slz',name:'São Luís',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:65,br:true,andes:'e',ix:'IX.brrr São Luís',ixCheap:0.3,dc:'Reggae Island DC',note:tr('cities.an_island_city_of_tiled_colonial')},
|
||||
{id:'the',name:'Teresina',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:50,br:true,andes:'e',ix:'IX.brrr Teresina',ixCheap:0.3,dc:'Sunbaked Server Hall',note:tr('cities.the_only_northeastern_capital_away')},
|
||||
{id:'vix',name:'Vitória',x:0,y:0,land:'sa',reg:'SA',cc:'BR',P:80,br:true,andes:'e',ix:'IX.brrr Vitória',ixCheap:0.3,dc:'Moqueca Colo',note:tr('cities.an_island_capital_with_a_big')},
|
||||
{id:'mvd',name:'Montevideo',x:0,y:0,land:'sa',reg:'SA',cc:'UY',P:150,andes:'e',ix:'Chivito-IX',dc:'Rambla Racks',note:tr('cities.uruguay_fiber_to_almost_every_home')},
|
||||
{id:'asu',name:'Asunción',x:0,y:0,land:'sa',reg:'SA',cc:'PY',P:120,andes:'e',ix:'Chipa-IX',dc:'Hydro Surplus DC',note:tr('cities.paraguay_shares_two_giant_dams_with')},
|
||||
{id:'cor',name:'Córdoba',x:0,y:0,land:'sa',reg:'SA',cc:'AR',P:150,andes:'e',arpu:0.7,ix:'Fernet-IX',dc:'Sierras Server Shed',note:tr('cities.argentina_s_second_city_universities')},
|
||||
{id:'lpb',name:'La Paz',x:0,y:0,land:'sa',reg:'SA',cc:'BO',P:80,andes:'m',ix:'Salteña-IX',dc:'Cable Car Colo',note:tr('cities.the_highest_seat_of_government_on')},
|
||||
{id:'uio',name:'Quito',x:0,y:0,land:'sa',reg:'SA',cc:'EC',P:100,andes:'m',ix:'Equator-IX',dc:'Middle of the World DC',note:tr('cities.a_capital_high_in_the_andes')},
|
||||
{id:'mde',name:'Medellín',x:0,y:0,land:'sa',reg:'SA',cc:'CO',P:150,andes:'m',ix:'Paisa-IX',dc:'Eternal Spring DC',note:tr('cities.the_city_of_eternal_spring_with')},
|
||||
{id:'ccs',name:'Caracas',x:0,y:0,land:'sa',reg:'SA',cc:'VE',P:120,blackout:true,ix:'Cachapa-IX',dc:'Generator Included DC',note:tr('cities.a_capital_in_a_valley_under')},
|
||||
{id:'gua',name:'Guatemala City',x:0,y:0,land:'am',reg:'AM',cc:'GT',P:120,ix:'Quetzal-IX',dc:'Volcano View Colo',note:tr('cities.central_america_s_biggest_city')},
|
||||
{id:'sjo',name:'San José',x:0,y:0,land:'am',reg:'AM',cc:'CR',P:80,ix:'Pura Vida-IX',dc:'Cloud Forest DC',note:tr('cities.costa_rica_runs_almost_entirely_on')},
|
||||
{id:'qro',name:'Querétaro',x:0,y:0,land:'am',reg:'AM',cc:'MX',P:120,ix:'Gordita-IX',dc:'Bajío Bit Barn',note:tr('cities.mexico_s_data_center_boom_town')},
|
||||
{id:'mty',name:'Monterrey',x:0,y:0,land:'am',reg:'AM',cc:'MX',P:200,ix:'Cabrito-IX',dc:'Saddle Mountain Colo',note:tr('cities.mexico_s_industrial_capital_a_few')},
|
||||
{id:'gdl',name:'Guadalajara',x:0,y:0,land:'am',reg:'AM',cc:'MX',P:200,ix:'Tequila-IX',dc:'Mariachi Mainframes',note:tr('cities.mexico_s_silicon_valley_home_of')},
|
||||
{id:'bue',name:'Buenos Aires',x:0,y:0,land:'sa',reg:'SA',cc:'AR',P:500,andes:'e',arpu:0.7,ix:'Asado-IX',dc:'Puerto Madero DC',note:tr('cities.tango_steak_and_a_currency_that')},
|
||||
{id:'scl',name:'Santiago',x:0,y:0,land:'sa',reg:'SA',cc:'CL',P:350,andes:'w',ix:'Empanada-IX',dc:'Andes-view Bunker',note:tr('cities.the_pacific_gateway_the_andes_sit')},
|
||||
{id:'lim',name:'Lima',x:0,y:0,land:'sa',reg:'SA',cc:'PE',P:400,andes:'w',ix:'Ceviche-IX',dc:'Fog-cooled DC',note:tr('cities.it_almost_never_rains_but_the')},
|
||||
{id:'bog',name:'Bogotá',x:0,y:0,land:'sa',reg:'SA',cc:'CO',P:400,andes:'m',ix:'Arepa-IX',dc:'2,600 m Above Sea Level DC',note:tr('cities.high_up_in_the_andes_no')},
|
||||
{id:'pan',name:'Panama City',x:0,y:0,land:'am',reg:'AM',cc:'PA',P:80,ix:'Canal-IX',dc:'Isthmus Interconnect',note:tr('cities.every_cable_between_the_americas')},
|
||||
{id:'del',name:'Delhi',x:0,y:0,land:'eu',reg:'AS',cc:'IN',P:1600,arpu:0.4,india:true,ix:'Butter-Chicken-IX',dc:'Smog-filtered DC',note:tr('cities.an_enormous_very_online_city_a')},
|
||||
{id:'maa',name:'Chennai',x:0,y:0,land:'eu',reg:'AS',cc:'IN',P:500,arpu:0.5,india:true,ix:'Dosa-IX',dc:'Cyclone-rated Landing Bay',note:tr('cities.india_s_east_coast_landing_hub')},
|
||||
{id:'blr',name:'Bengaluru',x:0,y:0,land:'eu',reg:'AS',cc:'IN',P:600,arpu:0.6,india:true,ix:'Filter-Kaapi-IX',dc:'Traffic-jam-adjacent Campus',note:tr('cities.india_s_tech_capital_packets_move')},
|
||||
{id:'hyd',name:'Hyderabad',x:0,y:0,land:'eu',reg:'AS',cc:'IN',P:400,arpu:0.5,india:true,ix:'Biryani-IX',dc:'Hyperscale Hills',note:tr('cities.every_hyperscaler_is_building_a')},
|
||||
{id:'tpe',name:'Taipei',x:0,y:0,land:'tw',reg:'AS',cc:'TW',P:450,ix:'Bubble-Tea-IX',dc:'Typhoon-proof Tower',note:tr('cities.makes_most_of_the_world_s')},
|
||||
{id:'auh',name:'Abu Dhabi',x:0,y:0,land:'eu',reg:'AS',cc:'AE',P:200,arpu:1.4,uae:true,ix:'',dc:'Oasis-cooled Campus',note:tr('cities.the_capital_sovereign_ai_money_and')},
|
||||
{id:'fuj',name:'Fujairah',x:0,y:0,land:'eu',reg:'AS',cc:'AE',P:20,uae:true,ix:'',dc:'Cable Landing Sandcastle',note:tr('cities.most_uae_cables_land_on_this')},
|
||||
{id:'cpt',name:'Cape Town',x:0,y:0,land:'af',reg:'AF',cc:'ZA',P:250,za:true,ix:'Biltong-IX',dc:'Table Mountain Colo',note:tr('cities.where_the_atlantic_cables_to_africa')},
|
||||
{id:'dkr',name:'Dakar',x:0,y:0,land:'af',reg:'AF',P:140,cc:'SN',ix:'Thieboudienne-IX',dc:'Teranga Racks',note:tr('cities.africa_s_westernmost_capital_where')},
|
||||
{id:'abj',name:'Abidjan',x:0,y:0,land:'af',reg:'AF',P:200,cc:'CI',ix:'Attiéké-IX',dc:'Plateau Point DC',note:tr('cities.the_business_capital_of_french')},
|
||||
|
|
@ -142,14 +142,14 @@ const CITIES=[
|
|||
{id:'lun',name:'Lusaka',x:0,y:0,land:'af',reg:'AF',P:100,cc:'ZM',blackout:true,ix:'Nshima-IX',dc:'Copperbelt Colo',note:tr('cities.zambia_runs_on_hydro_power_from')},
|
||||
{id:'hre',name:'Harare',x:0,y:0,land:'af',reg:'AF',P:70,cc:'ZW',blackout:true,ix:'Sadza-IX',dc:'Jacaranda DC',note:tr('cities.purple_jacaranda_trees_and_long')},
|
||||
{id:'gbe',name:'Gaborone',x:0,y:0,land:'af',reg:'AF',P:25,cc:'BW',ix:'Seswaa-IX',dc:'Diamond Dust DC',note:tr('cities.botswana_quiet_safe_and_rich_in')},
|
||||
{id:'mel',name:'Melbourne',x:0,y:0,land:'oc',reg:'OC',au:true,arpu:AU_ARPU,P:450,ix:'Flat-White-IX',dc:'Four-Seasons-a-Day DC',dc2:'Next-Door-DC M#',dc2N:3,note:tr('cities.four_seasons_in_one_day_and')},
|
||||
{id:'bne',name:'Brisbane',x:0,y:0,land:'oc',reg:'OC',au:true,arpu:AU_ARPU,P:250,ix:'Bris-Vegas-IX',dc:'Sunshine State Shed',dc2:'Next-Door-DC B#',dc2N:2,note:tr('cities.brisvegas_big_sky_a_thunderstorm_at')},
|
||||
{id:'drw',name:'Darwin',x:0,y:0,land:'oc',reg:'OC',au:true,arpu:AU_ARPU,P:15,ix:'Gator-IX',dc:'Crocodile-proof Landing Station',note:tr('cities.tiny_tropical_and_the_closest')},
|
||||
{id:'adl',name:'Adelaide',x:0,y:0,land:'oc',reg:'OC',au:true,arpu:AU_ARPU,P:150,ix:'Vineyard-IX',dc:'OurDC',dc2:'Next-Door-DC A1',note:tr('cities.twenty_minutes_from_everything')},
|
||||
{id:'cbr',capital:true,name:'Canberra',x:0,y:0,land:'oc',reg:'OC',au:true,arpu:AU_ARPU,P:50,ix:'Capital-IX',dc:'Classified Data Cupboard',dc2:'Next-Door-DC C1',note:tr('cities.built_for_the_government_the_data')},
|
||||
{id:'chc',name:'Christchurch',x:0,y:0,land:'nzs',reg:'OC',P:40,ix:'Garden-City-IX',dc:'Mainland Colo',note:tr('cities.the_garden_city_and_the_biggest')},
|
||||
{id:'ivc',name:'Invercargill',x:0,y:0,land:'nzs',reg:'OC',P:10,ix:'',dc:'Sheargrid Makarewa',note:tr('cities.the_bottom_of_the_country_on')},
|
||||
{id:'hba',name:'Hobart',x:0,y:0,land:'tas',reg:'OC',au:true,arpu:AU_ARPU,P:25,ix:'Cousin-IX',dc:'Firmest',note:tr('cities.the_bottom_of_the_map_cool')},
|
||||
{id:'mel',name:'Melbourne',x:0,y:0,land:'oc',reg:'OC',cc:'AU',au:true,arpu:AU_ARPU,P:450,ix:'Flat-White-IX',dc:'Four-Seasons-a-Day DC',dc2:'Next-Door-DC M#',dc2N:3,note:tr('cities.four_seasons_in_one_day_and')},
|
||||
{id:'bne',name:'Brisbane',x:0,y:0,land:'oc',reg:'OC',cc:'AU',au:true,arpu:AU_ARPU,P:250,ix:'Bris-Vegas-IX',dc:'Sunshine State Shed',dc2:'Next-Door-DC B#',dc2N:2,note:tr('cities.brisvegas_big_sky_a_thunderstorm_at')},
|
||||
{id:'drw',name:'Darwin',x:0,y:0,land:'oc',reg:'OC',cc:'AU',au:true,arpu:AU_ARPU,P:15,ix:'Gator-IX',dc:'Crocodile-proof Landing Station',note:tr('cities.tiny_tropical_and_the_closest')},
|
||||
{id:'adl',name:'Adelaide',x:0,y:0,land:'oc',reg:'OC',cc:'AU',au:true,arpu:AU_ARPU,P:150,ix:'Vineyard-IX',dc:'OurDC',dc2:'Next-Door-DC A1',note:tr('cities.twenty_minutes_from_everything')},
|
||||
{id:'cbr',capital:true,name:'Canberra',x:0,y:0,land:'oc',reg:'OC',cc:'AU',au:true,arpu:AU_ARPU,P:50,ix:'Capital-IX',dc:'Classified Data Cupboard',dc2:'Next-Door-DC C1',note:tr('cities.built_for_the_government_the_data')},
|
||||
{id:'chc',name:'Christchurch',x:0,y:0,land:'nzs',reg:'OC',cc:'NZ',P:40,ix:'Garden-City-IX',dc:'Mainland Colo',note:tr('cities.the_garden_city_and_the_biggest')},
|
||||
{id:'ivc',name:'Invercargill',x:0,y:0,land:'nzs',reg:'OC',cc:'NZ',P:10,ix:'',dc:'Sheargrid Makarewa',note:tr('cities.the_bottom_of_the_country_on')},
|
||||
{id:'hba',name:'Hobart',x:0,y:0,land:'tas',reg:'OC',cc:'AU',au:true,arpu:AU_ARPU,P:25,ix:'Cousin-IX',dc:'Firmest',note:tr('cities.the_bottom_of_the_map_cool')},
|
||||
{id:'hnl',name:'Honolulu',x:0,y:0,land:'hi',reg:'OC',cc:'US',P:70,ix:'Poke-IX',dc:'Dr. Fortress of Solitude',note:tr('cities.halfway_between_california_and')},
|
||||
{id:'gum',name:'Guam',x:0,y:0,land:'gu',reg:'OC',cc:'GU',P:15,blackout:true,ix:'Spam-IX',dc:'Typhoon-Proof Bunker',note:tr('cities.a_small_island_where_cables_from')},
|
||||
{id:'ror',name:'Koror',x:0,y:0,land:'pw',reg:'OC',cc:'PW',P:3,ix:'',dc:'Jellyfish Lake Landing',note:tr('cities.palau_on_a_branch_cable_from')},
|
||||
|
|
@ -168,39 +168,39 @@ const CITIES=[
|
|||
{id:'tci',name:'Tenerife',x:0,y:0,land:'ic',reg:'EU',cc:'ES',P:25,ix:'',dc:'Mojo Picón DC',note:tr('cities.the_canary_islands_a_short_hop')},
|
||||
{id:'rai',name:'Praia',x:0,y:0,land:'cv',reg:'AF',cc:'CV',P:5,ix:'Cachupa-IX',dc:'Morabeza Rack',note:tr('cities.cape_verde_s_capital_off_the')},
|
||||
{id:'jam',name:'St Helena',x:0,y:0,land:'sh',reg:'AF',cc:'SH',P:1,blackout:true,ix:'',dc:'Napoleon’s Last Rack',note:tr('cities.one_of_the_most_remote_islands')},
|
||||
{id:'osa',name:'Osaka',x:0,y:0,land:'jp',reg:'AS',P:700,ix:'Takoyaki-IX',dc:'Dojima DC',note:tr('cities.japan_s_second_hub_and_tokyo')},
|
||||
{id:'kul',name:'Kuala Lumpur',x:0,y:0,land:'eu',reg:'AS',P:350,ix:'Satay-IX',dc:'Twin Towers Colo',note:tr('cities.cheaper_than_singapore_next_door_the')},
|
||||
{id:'bkk',name:'Bangkok',x:0,y:0,land:'eu',reg:'AS',P:600,ix:'Tom-Yum-IX',dc:'Floating Market DC',note:tr('cities.big_busy_and_flooded_with_traffic')},
|
||||
{id:'sgn',name:'Ho Chi Minh City',x:0,y:0,land:'eu',reg:'AS',P:500,vn:true,ix:'Pho-IX',dc:'Scooter-cooled DC',note:tr('cities.very_online_and_badly_served_by')},
|
||||
{id:'khi',name:'Karachi',x:0,y:0,land:'eu',reg:'AS',P:500,arpu:0.4,ix:'Chai-IX',dc:'Seaview Landing Station',note:tr('cities.pakistan_s_door_to_the_sea')},
|
||||
{id:'dac',name:'Dhaka',x:0,y:0,land:'eu',reg:'AS',P:700,arpu:0.3,ix:'Rickshaw-IX',dc:'Monsoon-mapped DC',note:tr('cities.huge_dense_and_hungry_its')},
|
||||
{id:'cbo',name:'Colombo',x:0,y:0,land:'lk',reg:'AS',P:120,ix:'Hopper-IX',dc:'Tea-cooled Landing Station',note:tr('cities.a_small_island_at_the_crossroads')},
|
||||
{id:'waw',name:'Warsaw',x:0,y:0,land:'eu',reg:'EU',P:550,ix:'Pierogi-IX',dc:'Palace-of-Culture-adjacent DC',note:tr('cities.central_europe_s_rising_hub_more')},
|
||||
{id:'prg',name:'Prague',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Pilsner-IX',dc:'Castle-view Colo',note:tr('cities.beer_is_cheaper_than_water_here')},
|
||||
{id:'vie',name:'Vienna',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Schnitzel-IX',dc:'Waltz-cooled DC',note:tr('cities.the_old_gateway_to_eastern_europe')},
|
||||
{id:'bud',name:'Budapest',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Goulash-IX',dc:'Thermal Bath DC',note:tr('cities.waste_heat_goes_straight_into_the')},
|
||||
{id:'buh',name:'Bucharest',x:0,y:0,land:'eu',reg:'EU',P:400,ix:'Sarmale-IX',dc:'Parliament-sized DC',note:tr('cities.gigabit_home_broadband_for_the_price')},
|
||||
{id:'tll',name:'Tallinn',x:0,y:0,land:'eu',reg:'EU',P:80,ix:'E-Stonia-IX',dc:'Medieval Wall DC',note:tr('cities.digital_everything_e_residency_for')},
|
||||
{id:'ist',name:'Istanbul',x:0,y:0,land:'eu',reg:'EU',P:900,ix:'Baklava-IX',dc:'Bosphorus Bridge DC',note:tr('cities.one_foot_in_europe_one_in')},
|
||||
{id:'kyv',name:'Kyiv',x:0,y:0,land:'eu',reg:'EU',P:500,blackout:true,ix:'Varenyky-IX',dc:'Generator-backed Bunker DC',note:tr('cities.ukrainian_network_engineers_kept_the')},
|
||||
{id:'jed',name:'Jeddah',x:0,y:0,land:'eu',reg:'AS',P:300,saudi:true,gcc:true,ix:'',dc:'Red Sea Landing Palace',note:tr('cities.saudi_arabia_s_red_sea_cable')},
|
||||
{id:'ruh',name:'Riyadh',x:0,y:0,land:'eu',reg:'AS',P:600,saudi:true,gcc:true,ix:'Kabsa-IX',dc:'Desert Megaproject DC',note:tr('cities.the_capital_building_ai_campuses_at')},
|
||||
{id:'doh',name:'Doha',x:0,y:0,land:'eu',reg:'AS',P:150,arpu:1.5,qa:true,ix:'Pearl-IX',dc:'Air-cooled Stadium DC',note:tr('cities.small_rich_and_very_well_connected')},
|
||||
{id:'mil',name:'Milan',x:0,y:0,land:'eu',reg:'EU',P:450,ix:'MIX-and-Match',dc:'Caldera Park Campus',note:tr('cities.italy_s_digital_capital_fashion_week')},
|
||||
{id:'rom',name:'Rome',x:0,y:0,land:'eu',reg:'EU',P:450,ix:'Carbonara-IX',dc:'Colosseum-adjacent Colo',note:tr('cities.all_roads_lead_to_rome_most')},
|
||||
{id:'pmo',name:'Palermo',x:0,y:0,land:'eu',reg:'EU',P:60,ix:'Cannoli-IX',dc:'Sicilian Hub-a-Dub',note:tr('cities.a_small_city_on_a_big')},
|
||||
{id:'lis',name:'Lisbon',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Pastel-de-Nata-IX',dc:'Seven Hills Colo',note:tr('cities.europe_s_new_atlantic_gateway_cables')},
|
||||
{id:'ath',name:'Athens',x:0,y:0,land:'eu',reg:'EU',P:350,ix:'Souvlaki-IX',dc:'Acropolis-view DC',note:tr('cities.ancient_city_brand_new_cables_greece')},
|
||||
{id:'atn',name:'Atlanta',x:0,y:0,land:'am',reg:'AM',P:450,ix:'Peach-IX',dc:'56 Marietta',note:tr('cities.the_southeast_s_carrier_hotel')},
|
||||
{id:'den',name:'Denver',x:0,y:0,land:'am',reg:'AM',P:250,ix:'Mile-High-IX',dc:'Thin Air DC',note:tr('cities.a_mile_up_and_halfway_between')},
|
||||
{id:'phx',name:'Phoenix',x:0,y:0,land:'am',reg:'AM',P:300,ix:'Cactus-IX',dc:'Dry Heat Campus',note:tr('cities.cheap_land_cheap_power_and_48')},
|
||||
{id:'bos',name:'Boston',x:0,y:0,land:'am',reg:'AM',P:350,ix:'Chowder-IX',dc:'One Summer Street',note:tr('cities.universities_biotech_and_a_carrier')},
|
||||
{id:'hou',name:'Houston',x:0,y:0,land:'am',reg:'AM',P:450,ix:'Rodeo-IX',dc:'Hurricane-hardened DC',note:tr('cities.oil_gas_and_hurricanes_the')},
|
||||
{id:'slc',name:'Salt Lake City',x:0,y:0,land:'am',reg:'AM',P:150,ix:'Fry-Sauce-IX',dc:'Great Salt Lake DC',note:tr('cities.cheap_power_dry_air_and_a')},
|
||||
{id:'man',name:'Manchester',x:0,y:0,land:'uk',reg:'EU',P:350,ix:'Rainy-City-IX',dc:'Old Cotton Mill Colo',note:tr('cities.the_north_s_hub_with_its')},
|
||||
{id:'edi',name:'Edinburgh',x:0,y:0,land:'uk',reg:'EU',P:200,ix:'Haggis-IX',dc:'Castle Rock Colo',note:tr('cities.scotland_s_capital_north_sea_cables')},
|
||||
{id:'bde',name:'Bude',x:0,y:0,land:'uk',reg:'EU',P:3,ix:'',dc:'Clifftop Landing Station',note:tr('cities.a_tiny_surfing_town_in_cornwall')},
|
||||
{id:'svg',name:'Stavanger',x:0,y:0,land:'eu',reg:'EU',P:60,ix:'Brunost-IX',dc:'Inside-a-Mountain DC',note:tr('cities.norway_s_oil_capital_now_full')},
|
||||
{id:'osa',name:'Osaka',x:0,y:0,land:'jp',reg:'AS',cc:'JP',P:700,ix:'Takoyaki-IX',dc:'Dojima DC',note:tr('cities.japan_s_second_hub_and_tokyo')},
|
||||
{id:'kul',name:'Kuala Lumpur',x:0,y:0,land:'eu',reg:'AS',cc:'MY',P:350,ix:'Satay-IX',dc:'Twin Towers Colo',note:tr('cities.cheaper_than_singapore_next_door_the')},
|
||||
{id:'bkk',name:'Bangkok',x:0,y:0,land:'eu',reg:'AS',cc:'TH',P:600,ix:'Tom-Yum-IX',dc:'Floating Market DC',note:tr('cities.big_busy_and_flooded_with_traffic')},
|
||||
{id:'sgn',name:'Ho Chi Minh City',x:0,y:0,land:'eu',reg:'AS',cc:'VN',P:500,vn:true,ix:'Pho-IX',dc:'Scooter-cooled DC',note:tr('cities.very_online_and_badly_served_by')},
|
||||
{id:'khi',name:'Karachi',x:0,y:0,land:'eu',reg:'AS',cc:'PK',P:500,arpu:0.4,ix:'Chai-IX',dc:'Seaview Landing Station',note:tr('cities.pakistan_s_door_to_the_sea')},
|
||||
{id:'dac',name:'Dhaka',x:0,y:0,land:'eu',reg:'AS',cc:'BD',P:700,arpu:0.3,ix:'Rickshaw-IX',dc:'Monsoon-mapped DC',note:tr('cities.huge_dense_and_hungry_its')},
|
||||
{id:'cbo',name:'Colombo',x:0,y:0,land:'lk',reg:'AS',cc:'LK',P:120,ix:'Hopper-IX',dc:'Tea-cooled Landing Station',note:tr('cities.a_small_island_at_the_crossroads')},
|
||||
{id:'waw',name:'Warsaw',x:0,y:0,land:'eu',reg:'EU',cc:'PL',P:550,ix:'Pierogi-IX',dc:'Palace-of-Culture-adjacent DC',note:tr('cities.central_europe_s_rising_hub_more')},
|
||||
{id:'prg',name:'Prague',x:0,y:0,land:'eu',reg:'EU',cc:'CZ',P:300,ix:'Pilsner-IX',dc:'Castle-view Colo',note:tr('cities.beer_is_cheaper_than_water_here')},
|
||||
{id:'vie',name:'Vienna',x:0,y:0,land:'eu',reg:'EU',cc:'AT',P:300,ix:'Schnitzel-IX',dc:'Waltz-cooled DC',note:tr('cities.the_old_gateway_to_eastern_europe')},
|
||||
{id:'bud',name:'Budapest',x:0,y:0,land:'eu',reg:'EU',cc:'HU',P:300,ix:'Goulash-IX',dc:'Thermal Bath DC',note:tr('cities.waste_heat_goes_straight_into_the')},
|
||||
{id:'buh',name:'Bucharest',x:0,y:0,land:'eu',reg:'EU',cc:'RO',P:400,ix:'Sarmale-IX',dc:'Parliament-sized DC',note:tr('cities.gigabit_home_broadband_for_the_price')},
|
||||
{id:'tll',name:'Tallinn',x:0,y:0,land:'eu',reg:'EU',cc:'EE',P:80,ix:'E-Stonia-IX',dc:'Medieval Wall DC',note:tr('cities.digital_everything_e_residency_for')},
|
||||
{id:'ist',name:'Istanbul',x:0,y:0,land:'eu',reg:'EU',cc:'TR',P:900,ix:'Baklava-IX',dc:'Bosphorus Bridge DC',note:tr('cities.one_foot_in_europe_one_in')},
|
||||
{id:'kyv',name:'Kyiv',x:0,y:0,land:'eu',reg:'EU',cc:'UA',P:500,blackout:true,ix:'Varenyky-IX',dc:'Generator-backed Bunker DC',note:tr('cities.ukrainian_network_engineers_kept_the')},
|
||||
{id:'jed',name:'Jeddah',x:0,y:0,land:'eu',reg:'AS',cc:'SA',P:300,saudi:true,gcc:true,ix:'',dc:'Red Sea Landing Palace',note:tr('cities.saudi_arabia_s_red_sea_cable')},
|
||||
{id:'ruh',name:'Riyadh',x:0,y:0,land:'eu',reg:'AS',cc:'SA',P:600,saudi:true,gcc:true,ix:'Kabsa-IX',dc:'Desert Megaproject DC',note:tr('cities.the_capital_building_ai_campuses_at')},
|
||||
{id:'doh',name:'Doha',x:0,y:0,land:'eu',reg:'AS',cc:'QA',P:150,arpu:1.5,qa:true,ix:'Pearl-IX',dc:'Air-cooled Stadium DC',note:tr('cities.small_rich_and_very_well_connected')},
|
||||
{id:'mil',name:'Milan',x:0,y:0,land:'eu',reg:'EU',cc:'IT',P:450,ix:'MIX-and-Match',dc:'Caldera Park Campus',note:tr('cities.italy_s_digital_capital_fashion_week')},
|
||||
{id:'rom',name:'Rome',x:0,y:0,land:'eu',reg:'EU',cc:'IT',P:450,ix:'Carbonara-IX',dc:'Colosseum-adjacent Colo',note:tr('cities.all_roads_lead_to_rome_most')},
|
||||
{id:'pmo',name:'Palermo',x:0,y:0,land:'eu',reg:'EU',cc:'IT',P:60,ix:'Cannoli-IX',dc:'Sicilian Hub-a-Dub',note:tr('cities.a_small_city_on_a_big')},
|
||||
{id:'lis',name:'Lisbon',x:0,y:0,land:'eu',reg:'EU',cc:'PT',P:300,ix:'Pastel-de-Nata-IX',dc:'Seven Hills Colo',note:tr('cities.europe_s_new_atlantic_gateway_cables')},
|
||||
{id:'ath',name:'Athens',x:0,y:0,land:'eu',reg:'EU',cc:'GR',P:350,ix:'Souvlaki-IX',dc:'Acropolis-view DC',note:tr('cities.ancient_city_brand_new_cables_greece')},
|
||||
{id:'atn',name:'Atlanta',x:0,y:0,land:'am',reg:'AM',cc:'US',P:450,ix:'Peach-IX',dc:'56 Marietta',note:tr('cities.the_southeast_s_carrier_hotel')},
|
||||
{id:'den',name:'Denver',x:0,y:0,land:'am',reg:'AM',cc:'US',P:250,ix:'Mile-High-IX',dc:'Thin Air DC',note:tr('cities.a_mile_up_and_halfway_between')},
|
||||
{id:'phx',name:'Phoenix',x:0,y:0,land:'am',reg:'AM',cc:'US',P:300,ix:'Cactus-IX',dc:'Dry Heat Campus',note:tr('cities.cheap_land_cheap_power_and_48')},
|
||||
{id:'bos',name:'Boston',x:0,y:0,land:'am',reg:'AM',cc:'US',P:350,ix:'Chowder-IX',dc:'One Summer Street',note:tr('cities.universities_biotech_and_a_carrier')},
|
||||
{id:'hou',name:'Houston',x:0,y:0,land:'am',reg:'AM',cc:'US',P:450,ix:'Rodeo-IX',dc:'Hurricane-hardened DC',note:tr('cities.oil_gas_and_hurricanes_the')},
|
||||
{id:'slc',name:'Salt Lake City',x:0,y:0,land:'am',reg:'AM',cc:'US',P:150,ix:'Fry-Sauce-IX',dc:'Great Salt Lake DC',note:tr('cities.cheap_power_dry_air_and_a')},
|
||||
{id:'man',name:'Manchester',x:0,y:0,land:'uk',reg:'EU',cc:'GB',P:350,ix:'Rainy-City-IX',dc:'Old Cotton Mill Colo',note:tr('cities.the_north_s_hub_with_its')},
|
||||
{id:'edi',name:'Edinburgh',x:0,y:0,land:'uk',reg:'EU',cc:'GB',P:200,ix:'Haggis-IX',dc:'Castle Rock Colo',note:tr('cities.scotland_s_capital_north_sea_cables')},
|
||||
{id:'bde',name:'Bude',x:0,y:0,land:'uk',reg:'EU',cc:'GB',P:3,ix:'',dc:'Clifftop Landing Station',note:tr('cities.a_tiny_surfing_town_in_cornwall')},
|
||||
{id:'svg',name:'Stavanger',x:0,y:0,land:'eu',reg:'EU',cc:'NO',P:60,ix:'Brunost-IX',dc:'Inside-a-Mountain DC',note:tr('cities.norway_s_oil_capital_now_full')},
|
||||
// The Caribbean (#125)
|
||||
{id:'sju',name:'San Juan',x:0,y:0,land:'pr',reg:'AM',cc:'PR',P:120,ix:'Mofongo-IX',dc:'El Morro Colo',note:tr('cities.puerto_rico_s_capital_where_a')},
|
||||
{id:'sdq',name:'Santo Domingo',x:0,y:0,land:'hs',reg:'AM',cc:'DO',P:150,ix:'',dc:'Merengue Racks',note:tr('cities.the_dominican_republic_s_capital_the')},
|
||||
|
|
@ -224,22 +224,22 @@ const CITIES=[
|
|||
{id:'brw',name:'Utqiaġvik',x:0,y:0,land:'nsl',reg:'AM',cc:'US',P:0.5,blackout:true,ix:'',dc:'Top of the World Colo',note:tr('cities.the_northernmost_town_in_the_united')},
|
||||
{id:'dut',name:'Unalaska',x:0,y:0,land:'al',reg:'AM',cc:'US',P:0.5,ix:'',dc:'Deadliest Catch DC',note:tr('cities.the_aleutians_fishing_capital')},
|
||||
{id:'prr',name:'Prince Rupert',x:0,y:0,land:'am',reg:'AM',cc:'CA',ca:true,P:1.5,ix:'',dc:'Rain Gauge Racks',note:tr('cities.a_pacific_port_in_northern_british')},
|
||||
{id:'mmk',name:'Murmansk',x:0,y:0,land:'eu',reg:'EU',P:25,ru:true,beach:true,arpu:0.5,ix:'',dc:'Polar Night DC',note:tr('cities.the_biggest_city_north_of_the')},
|
||||
{id:'dks',name:'Dikson',x:0,y:0,land:'tay',reg:'AS',P:0.1,ru:true,beach:true,arpu:0.5,blackout:true,ix:'',dc:'Last Weather Station Rack',note:tr('cities.a_weather_station_and_a_port')},
|
||||
{id:'tik',name:'Tiksi',x:0,y:0,land:'lap',reg:'AS',P:0.5,ru:true,beach:true,arpu:0.5,blackout:true,ix:'',dc:'Permafrost Colo',note:tr('cities.a_port_on_the_laptev_sea')},
|
||||
{id:'pvs',name:'Pevek',x:0,y:0,land:'pvk',reg:'AS',P:0.5,ru:true,beach:true,arpu:0.5,ix:'',dc:'Floating Reactor Rack',note:tr('cities.russia_s_northernmost_town_powered_by')},
|
||||
{id:'dyr',name:'Anadyr',x:0,y:0,land:'chu',reg:'AS',P:1.3,ru:true,arpu:0.5,ix:'',dc:'Date Line Colo',note:tr('cities.chukotka_s_capital_closer_to_alaska')},
|
||||
{id:'pkc',name:'Petropavlovsk',x:0,y:0,land:'kam',reg:'AS',P:16,ru:true,arpu:0.5,ix:'',dc:'Volcano Row DC',note:tr('cities.kamchatka_s_capital_ringed_by_volcanoes')},
|
||||
{id:'gdx',name:'Magadan',x:0,y:0,land:'eu',reg:'AS',P:9,ru:true,arpu:0.5,ix:'',dc:'Kolyma Highway Colo',note:tr('cities.once_the_gateway_to_the_kolyma')},
|
||||
{id:'uus',name:'Yuzhno-Sakhalinsk',x:0,y:0,land:'sak',reg:'AS',P:18,ru:true,arpu:0.5,ix:'',dc:'Oil Platform Racks',note:tr('cities.sakhalin_s_capital_on_an_island')},
|
||||
{id:'vvo',name:'Vladivostok',x:0,y:0,land:'eu',reg:'AS',P:60,ru:true,arpu:0.5,ix:'Ikra-IX',dc:'Golden Horn Colo',note:tr('cities.the_end_of_the_trans_siberian')},
|
||||
{id:'mmk',name:'Murmansk',x:0,y:0,land:'eu',reg:'EU',cc:'RU',P:25,ru:true,beach:true,arpu:0.5,ix:'',dc:'Polar Night DC',note:tr('cities.the_biggest_city_north_of_the')},
|
||||
{id:'dks',name:'Dikson',x:0,y:0,land:'tay',reg:'AS',cc:'RU',P:0.1,ru:true,beach:true,arpu:0.5,blackout:true,ix:'',dc:'Last Weather Station Rack',note:tr('cities.a_weather_station_and_a_port')},
|
||||
{id:'tik',name:'Tiksi',x:0,y:0,land:'lap',reg:'AS',cc:'RU',P:0.5,ru:true,beach:true,arpu:0.5,blackout:true,ix:'',dc:'Permafrost Colo',note:tr('cities.a_port_on_the_laptev_sea')},
|
||||
{id:'pvs',name:'Pevek',x:0,y:0,land:'pvk',reg:'AS',cc:'RU',P:0.5,ru:true,beach:true,arpu:0.5,ix:'',dc:'Floating Reactor Rack',note:tr('cities.russia_s_northernmost_town_powered_by')},
|
||||
{id:'dyr',name:'Anadyr',x:0,y:0,land:'chu',reg:'AS',cc:'RU',P:1.3,ru:true,arpu:0.5,ix:'',dc:'Date Line Colo',note:tr('cities.chukotka_s_capital_closer_to_alaska')},
|
||||
{id:'pkc',name:'Petropavlovsk',x:0,y:0,land:'kam',reg:'AS',cc:'RU',P:16,ru:true,arpu:0.5,ix:'',dc:'Volcano Row DC',note:tr('cities.kamchatka_s_capital_ringed_by_volcanoes')},
|
||||
{id:'gdx',name:'Magadan',x:0,y:0,land:'eu',reg:'AS',cc:'RU',P:9,ru:true,arpu:0.5,ix:'',dc:'Kolyma Highway Colo',note:tr('cities.once_the_gateway_to_the_kolyma')},
|
||||
{id:'uus',name:'Yuzhno-Sakhalinsk',x:0,y:0,land:'sak',reg:'AS',cc:'RU',P:18,ru:true,arpu:0.5,ix:'',dc:'Oil Platform Racks',note:tr('cities.sakhalin_s_capital_on_an_island')},
|
||||
{id:'vvo',name:'Vladivostok',x:0,y:0,land:'eu',reg:'AS',cc:'RU',P:60,ru:true,arpu:0.5,ix:'Ikra-IX',dc:'Golden Horn Colo',note:tr('cities.the_end_of_the_trans_siberian')},
|
||||
// More landings around the North Sea and the Baltic, the Gulf of Oman, the Maldives and Kyushu
|
||||
{id:'krs',name:'Kristiansand',x:0,y:0,land:'eu',reg:'EU',cc:'NO',P:12,ix:'',dc:'Skagerrak Shore DC',note:tr('cities.norway_s_southern_tip_where_cables')},
|
||||
{id:'ebj',name:'Esbjerg',x:0,y:0,land:'eu',reg:'EU',cc:'DK',P:12,ix:'',dc:'Wind Farm Racks',note:tr('cities.denmark_s_west_coast_where_the')},
|
||||
{id:'rix',name:'Riga',x:0,y:0,land:'eu',reg:'EU',cc:'LV',P:60,ix:'Black-Balsam-IX',dc:'Art Nouveau DC',note:tr('cities.latvia_s_capital_its_cables_to')},
|
||||
{id:'mct',name:'Muscat',x:0,y:0,land:'eu',reg:'AS',cc:'OM',P:50,ix:'Halwa-IX',dc:'Frankincense Colo',note:tr('cities.oman_s_capital_just_outside_the')},
|
||||
{id:'mle',name:'Malé',x:0,y:0,land:'mv',reg:'AS',cc:'MV',P:4,ix:'',dc:'One-Metre-Up DC',note:tr('cities.the_maldives_capital_a_stop_on')},
|
||||
{id:'fuk',name:'Fukuoka',x:0,y:0,land:'jp',reg:'AS',P:120,ix:'Mentaiko-IX',dc:'Hakata Ramen Racks',note:tr('cities.japan_s_closest_city_to_korea')},
|
||||
{id:'fuk',name:'Fukuoka',x:0,y:0,land:'jp',reg:'AS',cc:'JP',P:120,ix:'Mentaiko-IX',dc:'Hakata Ramen Racks',note:tr('cities.japan_s_closest_city_to_korea')},
|
||||
];
|
||||
// Display-only nudges for cities that sit on top of each other at map scale; distances still use real lon/lat.
|
||||
const CITY_NUDGE={
|
||||
|
|
|
|||
244
src/game/20-world/55-city-pdb.js
Normal file
244
src/game/20-world/55-city-pdb.js
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
/* Real-world calibration, pulled 2026-10-25 (Pacific islands 2026-10-26). Per city: [carrier-neutral facilities, network presences across them,
|
||||
ASNs registered in its country]. Facilities and presences are PeeringDB facilities within 50 km or in the same city
|
||||
(peeringdb.com/api/fac, net_count summed); ASNs per country are from bgp.he.net/report/world.
|
||||
Cities PeeringDB barely knows (added 2026-10-28) are marked: est. is an estimate from what is known to be there, with
|
||||
the country's ASN count. A city missing here keeps the plain regional price. One entry per line, sorted by id. */
|
||||
const CITY_PDB={
|
||||
abj:[5,11,32],
|
||||
acc:[7,78,124],
|
||||
add:[2,3,10],
|
||||
adl:[6,70,3196], // est.
|
||||
aju:[4,3,9693],
|
||||
akl:[27,398,755],
|
||||
alg:[0,0,16],
|
||||
ams:[69,2731,1827],
|
||||
anc:[3,12,33300], // est.
|
||||
apw:[0,0,11],
|
||||
ash:[86,1010,33300],
|
||||
asu:[3,8,124],
|
||||
ath:[6,108,307],
|
||||
atn:[42,589,33300],
|
||||
auh:[4,1,231],
|
||||
bcn:[13,159,1341],
|
||||
bda:[2,8,25], // est.
|
||||
bde:[0,0,4027],
|
||||
beg:[7,49,227],
|
||||
bel:[3,7,9693],
|
||||
ber:[22,351,3705],
|
||||
bet:[16,174,152],
|
||||
bgi:[1,5,20], // est.
|
||||
bhz:[13,40,9693],
|
||||
bkk:[32,397,675],
|
||||
blr:[14,104,6412],
|
||||
bne:[21,277,3196],
|
||||
bog:[16,195,598],
|
||||
bom:[59,1050,6412],
|
||||
bos:[31,209,33300],
|
||||
bru:[33,328,443],
|
||||
brw:[0,0,33300], // est.
|
||||
bsb:[14,108,9693],
|
||||
bud:[6,146,369],
|
||||
bue:[28,372,1357],
|
||||
buh:[23,289,1424],
|
||||
bvb:[3,6,9693],
|
||||
cac:[4,6,9693],
|
||||
cai:[5,28,97],
|
||||
cal:[15,127,2595],
|
||||
cas:[2,2,39],
|
||||
cau:[2,2,9693],
|
||||
cbo:[1,0,33],
|
||||
cbr:[5,60,3196], // est.
|
||||
ccs:[6,32,296],
|
||||
cgb:[4,5,9693],
|
||||
cgr:[4,4,9693],
|
||||
chc:[4,30,755], // est.
|
||||
chi:[64,809,33300],
|
||||
cor:[2,29,1357],
|
||||
cph:[30,290,529],
|
||||
cpq:[19,65,9693],
|
||||
cpt:[6,267,879],
|
||||
cpv:[4,12,9693],
|
||||
cur:[3,20,25], // est.
|
||||
cwb:[11,79,9693],
|
||||
cxj:[2,3,9693],
|
||||
dac:[30,107,2105],
|
||||
dal:[59,969,33300],
|
||||
dar:[9,67,124],
|
||||
del:[31,479,6412],
|
||||
den:[28,310,33300],
|
||||
dkr:[2,4,23],
|
||||
dks:[0,0,6683], // est.
|
||||
dla:[3,14,34],
|
||||
doh:[6,29,31],
|
||||
drw:[3,15,3196],
|
||||
dub:[21,277,350],
|
||||
dur:[4,137,879],
|
||||
dus:[13,350,3705], // 14 listed, one closed; Digital Realty DUS1-3 alone has 141 networks
|
||||
dut:[0,0,33300], // est.
|
||||
dxb:[8,135,231],
|
||||
dyr:[0,0,6683], // est.
|
||||
ebj:[1,5,529], // est.
|
||||
edi:[4,46,4027],
|
||||
fdf:[1,5,10], // est.
|
||||
fec:[5,4,9693],
|
||||
fih:[7,19,57],
|
||||
fln:[5,23,9693],
|
||||
for:[16,362,9693],
|
||||
fra:[56,2450,3705],
|
||||
fuj:[1,49,231],
|
||||
fuk:[5,50,1330], // QTnet QD3 has 14 networks, BBIX Fukuoka is there; the rest est.
|
||||
gbe:[1,2,39],
|
||||
gdl:[4,22,814],
|
||||
gdx:[1,2,6683], // est.
|
||||
gua:[5,16,103],
|
||||
gum:[6,28,11],
|
||||
gyn:[5,28,9693],
|
||||
ham:[26,228,3705],
|
||||
hav:[0,0,8], // est.: no neutral data center
|
||||
hba:[2,10,3196], // est.
|
||||
hel:[23,232,427],
|
||||
hfx:[3,20,2595], // est.
|
||||
hir:[1,0,11],
|
||||
hkg:[57,1107,1514],
|
||||
hnl:[7,33,33300],
|
||||
hou:[21,173,33300],
|
||||
hre:[1,0,37],
|
||||
hyd:[17,152,6412],
|
||||
icn:[37,201,1197],
|
||||
igu:[5,26,124],
|
||||
ist:[28,334,1290],
|
||||
ivc:[1,2,755], // est.
|
||||
jam:[0,0,2], // est.
|
||||
jed:[5,25,220],
|
||||
jib:[3,19,5],
|
||||
jkt:[98,3015,4108],
|
||||
jnb:[14,561,879],
|
||||
jnu:[1,2,33300], // est.
|
||||
jpa:[4,18,9693],
|
||||
kcy:[22,313,33300],
|
||||
kgl:[5,14,34],
|
||||
khi:[7,15,488],
|
||||
kin:[2,10,30], // est.
|
||||
kla:[2,18,71],
|
||||
krs:[3,15,448], // est.
|
||||
kul:[20,210,434],
|
||||
kyv:[33,506,2342],
|
||||
lad:[8,27,79],
|
||||
lag:[13,279,304],
|
||||
lax:[44,939,33300],
|
||||
ldb:[3,7,9693],
|
||||
lim:[12,156,267],
|
||||
lis:[9,129,187],
|
||||
ljd:[1,2,9693],
|
||||
lon:[100,2588,4027],
|
||||
lpb:[1,2,71],
|
||||
lun:[4,3,24],
|
||||
maa:[20,374,6412],
|
||||
mad:[31,578,1341],
|
||||
maj:[0,0,12],
|
||||
man:[29,353,4027],
|
||||
mao:[7,15,9693],
|
||||
mba:[4,176,274],
|
||||
mcp:[2,0,9693],
|
||||
mct:[3,25,45], // Equinix MC1 and WCS; presences est.
|
||||
mcz:[1,5,9693],
|
||||
mde:[2,18,598],
|
||||
mel:[20,395,3196],
|
||||
mex:[18,122,814],
|
||||
mgf:[4,9,9693],
|
||||
mia:[27,553,33300],
|
||||
mil:[29,728,1534],
|
||||
mle:[1,3,15], // est.
|
||||
mmk:[2,4,6683], // est.
|
||||
mnl:[17,352,750],
|
||||
mos:[49,632,6683],
|
||||
mpm:[7,20,36],
|
||||
mrs:[8,273,2249],
|
||||
mru:[3,20,60], // est.
|
||||
mtl:[35,283,2595],
|
||||
mty:[5,27,814],
|
||||
muc:[22,230,3705],
|
||||
mvd:[1,2,53],
|
||||
nas:[1,4,20], // est.
|
||||
nat:[1,3,9693],
|
||||
nbo:[9,283,274],
|
||||
nou:[2,2,19],
|
||||
nyc:[96,1322,33300],
|
||||
ome:[0,0,33300], // est.
|
||||
oos:[5,22,443],
|
||||
osa:[19,229,1330],
|
||||
osl:[20,209,448],
|
||||
ott:[6,21,2595],
|
||||
pan:[8,26,158],
|
||||
par:[77,1528,2249],
|
||||
pcn:[0,0,0], // est.: no network of its own
|
||||
pdl:[1,3,187], // est.
|
||||
pek:[10,15,6717],
|
||||
per:[12,248,3196],
|
||||
phx:[26,279,33300],
|
||||
pkc:[1,2,6683], // est.
|
||||
pmo:[3,46,1534],
|
||||
pmw:[3,8,9693],
|
||||
poa:[22,120,9693],
|
||||
pom:[2,0,46],
|
||||
pos:[2,10,35], // est.
|
||||
ppg:[0,0,2],
|
||||
ppt:[0,0,6],
|
||||
prg:[24,336,775],
|
||||
prr:[0,0,2595], // est.
|
||||
pvh:[3,4,9693],
|
||||
pvs:[0,0,6683], // est.
|
||||
qro:[11,144,814],
|
||||
rai:[1,3,8], // est.
|
||||
rao:[6,3,9693],
|
||||
rbr:[0,0,9693],
|
||||
rec:[6,31,9693],
|
||||
rek:[15,51,93],
|
||||
ria:[2,2,9693],
|
||||
rio:[33,577,9693],
|
||||
rix:[8,60,330], // 8 listed, Perses 2 has 19 networks; presences est.
|
||||
rom:[12,213,1534],
|
||||
ror:[0,0,4],
|
||||
ruh:[8,29,220],
|
||||
run:[3,15,15], // est.
|
||||
sao:[70,1875,9693],
|
||||
scl:[36,274,450],
|
||||
sdq:[4,25,90], // est.
|
||||
sea:[37,539,33300],
|
||||
sez:[1,4,20], // est.
|
||||
sgn:[6,36,1068],
|
||||
sha:[11,27,6717],
|
||||
sin:[58,1271,782],
|
||||
sjc:[57,1048,33300],
|
||||
sjo:[8,6,128],
|
||||
sjp:[2,4,9693],
|
||||
sju:[5,40,60], // est.
|
||||
slc:[22,202,33300],
|
||||
slz:[1,6,9693],
|
||||
sof:[15,451,889],
|
||||
ssa:[13,44,9693],
|
||||
stg:[18,63,3705],
|
||||
sto:[31,539,1011],
|
||||
suv:[0,0,23],
|
||||
svg:[2,14,448],
|
||||
syd:[40,979,3196],
|
||||
tbu:[0,0,5],
|
||||
tci:[3,30,1341], // est.
|
||||
the:[2,1,9693],
|
||||
tik:[0,0,6683], // est.
|
||||
tll:[7,80,256],
|
||||
tnr:[1,4,25], // est.
|
||||
tok:[58,917,1330],
|
||||
tor:[46,509,2595],
|
||||
tpe:[15,274,500],
|
||||
tun:[2,0,30],
|
||||
uio:[9,16,287],
|
||||
uus:[1,3,6683], // est.
|
||||
van:[13,214,2595],
|
||||
vie:[30,377,860],
|
||||
vix:[6,30,9693],
|
||||
vvo:[5,25,6683], // est.
|
||||
waw:[25,855,2743],
|
||||
wdh:[1,2,22],
|
||||
zrh:[38,535,1209],
|
||||
};
|
||||
|
|
@ -6,14 +6,14 @@ const NETS=[
|
|||
{id:'cog',name:'Cogentle',asn:714,type:'t1',pol:'restrictive',share:.04,price:3,col:'#B35CF0',pops:['hfx','bde','man','edi','bcn','mil','rom','lis','ath','atn','den','phx','bos','hou','slc','ber','zrh','dub','hel','sof','beg','tor','lax','mex','cph','icn','sea','sjc','dal','chi','ash','nyc','mia','sao','lon','ams','fra','par','mad','mrs','sto','sin','hkg','tok','rio','bue','scl','bog','lim','osa','waw','prg','vie','bud','buh','ist','kyv','kcy','van','ott','bru','oos','bet','ham','muc','dus','syd','per'],ix:[],blurb:tr('networks.cheapest_transit_on_the_map_famously')},
|
||||
{id:'tat',name:'Ta-Ta Comms',asn:6543,type:'t1',pol:'restrictive',share:.04,price:9,col:'#6A4C93',pops:['tci','gum','mil','pmo','lis','nbo','cai','jkt','dxb','nyc','ash','lon','fra','mrs','lag','jnb','bom','sin','hkg','tok','del','maa','blr','hyd','cpt','fuj','auh','tpe','khi','dac','cbo','kul','bkk','jed','ruh','doh','jib','dar','mba','dkr'],ix:[],blurb:tr('networks.waves_goodbye_to_latency_across_the')},
|
||||
{id:'drz',name:'Drizzle Electric',asn:9369,type:'t2',pol:'open',share:.04,price:4,col:'#1E90FF',auIx:['syd','mel','bne','per'],pops:['man','chc','edi','svg','bde','bcn','mil','rom','pmo','lis','ath','atn','den','phx','bos','hou','slc','ber','zrh','nbo','akl','per','jkt','mnl','dub','rek','tor','mtl','lax','mex','sof','osl','icn','sea','sjc','dal','chi','ash','nyc','mia','lon','ams','fra','par','sto','mad','hkg','sin','tok','syd','jnb','for','rio','bue','scl','lim','bog','pan','del','maa','blr','hyd','tpe','auh','cpt','mel','bne','osa','kul','bkk','sgn','khi','dac','cbo','waw','prg','vie','bud','buh','tll','ist','kyv','jed','ruh','doh','kcy','cal','van','ott','bru','oos','bet','ham','muc','ccs','lpb','alg','tun','cas','dkr','dus'],ix:'ALL',blurb:tr('networks.will_peer_with_anyone_anywhere')},
|
||||
{id:'tng',name:'Tangerine Telecom',asn:5115,type:'t2',pol:'selective',minIx:15,minPni:40,share:.03,price:6,col:'#FF8C42',pops:['tci','bcn','cai','nbo','dxb','par','mrs','mad','lon','ams','lag','jnb','waw','buh','dkr','abj','cas','tun','dla','fih','fdf','run','tnr'],ix:['bcn','par','mrs','mad','lon','ams','lag','jnb','waw','dkr','abj','cas','tun','dla','fih'],blurb:tr('networks.juicy_reach_into_europe_and_africa')},
|
||||
{id:'sgt',name:'SingTell',asn:7474,type:'t2',pol:'selective',minIx:15,minPni:40,share:.03,price:7,col:'#00A6A6',pops:['jkt','mnl','per','akl','icn','sin','hkg','tok','syd','bom','tpe','maa','kul','bkk','sgn','mel','bne'],ix:['sin','hkg','tok','bom','tpe','maa','kul','bkk'],blurb:tr('networks.sings_your_packets_across_asia')},
|
||||
{id:'vdp',name:'Voda-Phony',asn:1373,type:'t2',pol:'paid',freeLv:7,paidFee:8000,share:.03,price:6,col:'#E63946',pops:['man','edi','mil','rom','lis','ath','nbo','cai','ber','dub','dxb','lon','fra','ams','mad','mrs','jnb','bom','lag','cpt','del','maa','ist','prg','bud','buh','doh','acc','dar','fih','mpm','dus'],ix:[],blurb:tr('networks.ended_free_peering_across_europe_and')},
|
||||
{id:'ctc',name:'China Telecomet',asn:4314,type:'t2',pol:'restrictive',share:.02,price:22,premium:2.5,premAt:['hkg','mos'],premOnly:['mos'],cn:true,col:'#0B5CAD',pops:['pek','sha','hkg','sin','tok','lon','fra','nyc','sjc'],ix:[],blurb:tr('networks.the_biggest_network_in_china_its')},
|
||||
{id:'cun',name:'China Unicorn',asn:4837,type:'t2',pol:'restrictive',share:.015,price:16,cn:true,col:'#D7000F',pops:['pek','sha','hkg','fra','sjc','lon'],ix:[],blurb:tr('networks.number_two_in_china_with_a')},
|
||||
{id:'cmb',name:'China Moble',asn:9880,type:'eye',pol:'paid',freeLv:10,paidFee:12000,share:.01,cn:true,col:'#0085CA',pops:['pek','sha','hkg'],ix:[],blurb:tr('networks.the_largest_mobile_network_on_earth')},
|
||||
{id:'cmc',name:'Comecast',asn:7227,type:'eye',pol:'selective',minIx:10,minPni:30,share:.03,col:'#2C7A7B',pops:['atn','den','bos','hou','phx','slc','ash','nyc','chi','sjc','sea','mia'],ix:['atn','den','bos','ash','nyc','chi','sjc','sea'],blurb:tr('networks.huge_eyeball_network_come_for_the')},
|
||||
{id:'dtk',name:'Doitsche Telekomm',asn:3203,type:'eye',pol:'paid',freeLv:6,paidFee:9000,share:.03,col:'#E20074',pops:['fra','ams','lon','ham','muc','dus'],ix:[],blurb:tr('networks.pink_eyeball_giant_peering_is')},
|
||||
{id:'tng',name:'Tangerine Telecom',asn:5115,type:'t2',cc:['CD','CI','CM','EG','ES','FR','MA','MG','MQ','PL','RE','RO','SN','TN'],pol:'selective',minIx:15,minPni:40,share:.03,price:6,col:'#FF8C42',pops:['tci','bcn','cai','nbo','dxb','par','mrs','mad','lon','ams','lag','jnb','waw','buh','dkr','abj','cas','tun','dla','fih','fdf','run','tnr'],ix:['bcn','par','mrs','mad','lon','ams','lag','jnb','waw','dkr','abj','cas','tun','dla','fih'],blurb:tr('networks.juicy_reach_into_europe_and_africa')},
|
||||
{id:'sgt',name:'SingTell',asn:7474,type:'t2',cc:'SG',pol:'selective',minIx:15,minPni:40,share:.03,price:7,col:'#00A6A6',pops:['jkt','mnl','per','akl','icn','sin','hkg','tok','syd','bom','tpe','maa','kul','bkk','sgn','mel','bne'],ix:['sin','hkg','tok','bom','tpe','maa','kul','bkk'],blurb:tr('networks.sings_your_packets_across_asia')},
|
||||
{id:'vdp',name:'Voda-Phony',asn:1373,type:'t2',cc:['CD','CZ','DE','EG','ES','GB','GR','IE','MZ','NL','PT','QA','RO','TR','TZ','ZA'],pol:'paid',freeLv:7,paidFee:8000,share:.03,price:6,col:'#E63946',pops:['man','edi','mil','rom','lis','ath','nbo','cai','ber','dub','dxb','lon','fra','ams','mad','mrs','jnb','bom','lag','cpt','del','maa','ist','prg','bud','buh','doh','acc','dar','fih','mpm','dus'],ix:[],blurb:tr('networks.ended_free_peering_across_europe_and')},
|
||||
{id:'ctc',name:'China Telecomet',asn:4314,type:'t2',cc:'CN',pol:'restrictive',share:.02,price:22,premium:2.5,premAt:['hkg','mos'],premOnly:['mos'],cn:true,col:'#0B5CAD',pops:['pek','sha','hkg','sin','tok','lon','fra','nyc','sjc'],ix:[],blurb:tr('networks.the_biggest_network_in_china_its')},
|
||||
{id:'cun',name:'China Unicorn',asn:4837,type:'t2',cc:'CN',pol:'restrictive',share:.015,price:16,cn:true,col:'#D7000F',pops:['pek','sha','hkg','fra','sjc','lon'],ix:[],blurb:tr('networks.number_two_in_china_with_a')},
|
||||
{id:'cmb',name:'China Moble',asn:9880,type:'eye',cc:'CN',pol:'paid',freeLv:10,paidFee:12000,share:.01,cn:true,col:'#0085CA',pops:['pek','sha','hkg'],ix:[],blurb:tr('networks.the_largest_mobile_network_on_earth')},
|
||||
{id:'cmc',name:'Comecast',asn:7227,type:'eye',cc:'US',pol:'selective',minIx:10,minPni:30,share:.03,col:'#2C7A7B',pops:['atn','den','bos','hou','phx','slc','ash','nyc','chi','sjc','sea','mia'],ix:['atn','den','bos','ash','nyc','chi','sjc','sea'],blurb:tr('networks.huge_eyeball_network_come_for_the')},
|
||||
{id:'dtk',name:'Doitsche Telekomm',asn:3203,type:'eye',cc:'DE',pol:'paid',freeLv:6,paidFee:9000,share:.03,col:'#E20074',pops:['fra','ams','lon','ham','muc','dus'],ix:[],blurb:tr('networks.pink_eyeball_giant_peering_is')},
|
||||
{id:'nfx',name:'NetChill',asn:2906,type:'cdn',pol:'selective',minIx:5,minPni:30,share:.15,cache:{name:'Open Couch',min:12},col:'#C8102E',auIx:['syd','mel'],pops:ALLC,ix:'ALL',blurb:tr('networks.streams_40_of_evening_traffic_hands')},
|
||||
{id:'ggl',name:'Goggle',asn:15961,type:'cdn',pol:'selective',minIx:5,minPni:30,share:.13,cache:{name:'Goggle Global Cache',min:15},col:'#3A7BEA',auIx:['syd','mel'],pops:ALLC,ix:'ALL',blurb:tr('networks.search_video_and_goggles_mostly')},
|
||||
{id:'fbk',name:'Faceplant',asn:32943,type:'cdn',pol:'selective',minIx:5,minPni:25,share:.08,cache:{name:'Faceplant Node Thingy',min:10},col:'#3B5BDB',auIx:['syd','mel'],pops:BIGC,ix:'ALL',blurb:tr('networks.social_media_everyone_keeps_falling')},
|
||||
|
|
@ -29,96 +29,96 @@ NETS.push(
|
|||
{id:'abc',name:'AliBubble Cloud',asn:37936,type:'cdn',pol:'selective',minIx:5,minPni:20,share:.015,cn:true,col:'#FF6A00',pops:['pek','sha','hkg','sin','tok','fra','sjc','syd'],ix:['hkg','sin','tok','fra','sjc'],blurb:tr('networks.shopping_festivals_that_melt_traffic')},
|
||||
{id:'byd',name:'Bye-du',asn:38635,type:'cdn',pol:'selective',minIx:5,minPni:20,share:.01,cn:true,col:'#2932E1',pops:['pek','sha','hkg'],ix:['hkg'],blurb:tr('networks.search_maps_and_a_cheerful_goodbye')});
|
||||
NETS.push(
|
||||
{id:'rtc',name:'Rostelecomedy',asn:12389,type:'t2',pol:'selective',minIx:20,minPni:40,share:.01,price:6,col:'#7700FF',pops:['mos','hel','sto','fra','ams','mmk','vvo','uus','pkc','gdx','dyr','pvs','tik','dks'],ix:['mos','fra','ams'],blurb:tr('networks.the_national_carrier_every_punchline')},
|
||||
{id:'rtc',name:'Rostelecomedy',asn:12389,type:'t2',cc:'RU',pol:'selective',minIx:20,minPni:40,share:.01,price:6,col:'#7700FF',pops:['mos','hel','sto','fra','ams','mmk','vvo','uus','pkc','gdx','dyr','pvs','tik','dks'],ix:['mos','fra','ams'],blurb:tr('networks.the_national_carrier_every_punchline')},
|
||||
{id:'ydx',name:'Yawndex',asn:13238,type:'cdn',pol:'open',share:.008,col:'#FC3F1D',pops:['mos','hel','fra','ams'],ix:['mos','hel','fra','ams'],blurb:tr('networks.search_taxis_and_maps_slightly')},
|
||||
{id:'vkl',name:'VKontakt-lens',asn:47541,type:'cdn',pol:'open',share:.006,col:'#0077FF',pops:['mos','hel'],ix:['mos','hel'],blurb:tr('networks.social_network_with_perfect_vision')},
|
||||
{id:'ets',name:'Etis-a-lot',asn:5384,type:'eye',pol:'paid',freeLv:9,paidFee:8000,share:.006,col:'#719E19',pops:['dxb','mrs','lon','fra','sin','auh','fuj','doh'],ix:[],blurb:tr('networks.charges_a_lot_paid_peering_only')},
|
||||
{id:'tmx',name:'Tel-Mess',asn:8151,type:'eye',pol:'paid',freeLv:8,paidFee:7000,share:.008,col:'#00A0DF',pops:['mex','dal','lax','mia','qro','mty','gdl'],ix:[],blurb:tr('networks.mexico_s_giant_paid_peering_only')},
|
||||
{id:'bcd',name:'Bell Canad-eh',asn:577,type:'eye',pol:'selective',minIx:10,minPni:30,share:.01,col:'#00549A',pops:['hfx','tor','mtl','nyc','chi','ott','cal','van'],ix:['tor','mtl','ott'],blurb:tr('networks.polite_enormous_and_sorry_about_the')});
|
||||
{id:'ets',name:'Etis-a-lot',asn:5384,type:'eye',cc:'AE',pol:'paid',freeLv:9,paidFee:8000,share:.006,col:'#719E19',pops:['dxb','mrs','lon','fra','sin','auh','fuj','doh'],ix:[],blurb:tr('networks.charges_a_lot_paid_peering_only')},
|
||||
{id:'tmx',name:'Tel-Mess',asn:8151,type:'eye',cc:'MX',pol:'paid',freeLv:8,paidFee:7000,share:.008,col:'#00A0DF',pops:['mex','dal','lax','mia','qro','mty','gdl'],ix:[],blurb:tr('networks.mexico_s_giant_paid_peering_only')},
|
||||
{id:'bcd',name:'Bell Canad-eh',asn:577,type:'eye',cc:'CA',pol:'selective',minIx:10,minPni:30,share:.01,col:'#00549A',pops:['hfx','tor','mtl','nyc','chi','ott','cal','van'],ix:['tor','mtl','ott'],blurb:tr('networks.polite_enormous_and_sorry_about_the')});
|
||||
NETS.push(
|
||||
{id:'tsf',name:'Telkom-selfie',asn:7713,type:'eye',pol:'selective',minIx:10,minPni:30,share:.01,col:'#E4002B',pops:['jkt','sin'],ix:['jkt','sin'],blurb:tr('networks.indonesia_s_mobile_giant_every')},
|
||||
{id:'pld',name:'PLDTea Time',asn:9299,type:'eye',pol:'selective',minIx:10,minPni:30,share:.008,col:'#D62027',pops:['mnl','hkg','sin'],ix:['hkg'],blurb:tr('networks.philippine_giant_peering_requests')},
|
||||
{id:'spk',name:'Spark-le',asn:4771,type:'eye',pol:'open',share:.005,col:'#6A2C91',pops:['akl','syd','chc','ivc'],ix:['akl','syd','chc'],blurb:tr('networks.new_zealand_s_shiniest_isp')},
|
||||
{id:'tsy',name:'Telstraya',asn:1221,type:'t2',pol:'selective',minIx:15,minPni:40,share:.01,price:9,col:'#0099F8',pops:['hnl','gum','suv','pom','nou','hir','syd','per','sin','hkg','lax','tpe','mel','bne','drw','adl','cbr','hba'],ix:['gum','sin','hkg'],blurb:tr('networks.australia_s_big_one_g_day')});
|
||||
{id:'tsf',name:'Telkom-selfie',asn:7713,type:'eye',cc:'ID',pol:'selective',minIx:10,minPni:30,share:.01,col:'#E4002B',pops:['jkt','sin'],ix:['jkt','sin'],blurb:tr('networks.indonesia_s_mobile_giant_every')},
|
||||
{id:'pld',name:'PLDTea Time',asn:9299,type:'eye',cc:'PH',pol:'selective',minIx:10,minPni:30,share:.008,up:['ntt','tat'],col:'#D62027',pops:['mnl','hkg','sin'],ix:['hkg'],blurb:tr('networks.philippine_giant_peering_requests')},
|
||||
{id:'spk',name:'Spark-le',asn:4771,type:'eye',cc:'NZ',pol:'open',share:.005,col:'#6A2C91',pops:['akl','syd','chc','ivc'],ix:['akl','syd','chc'],blurb:tr('networks.new_zealand_s_shiniest_isp')},
|
||||
{id:'tsy',name:'Telstraya',asn:1221,type:'t2',cc:'AU',pol:'selective',minIx:15,minPni:40,share:.01,price:9,col:'#0099F8',pops:['hnl','gum','suv','pom','nou','hir','syd','per','sin','hkg','lax','tpe','mel','bne','drw','adl','cbr','hba'],ix:['gum','sin','hkg'],blurb:tr('networks.australia_s_big_one_g_day')});
|
||||
NETS.push(
|
||||
{id:'liq',name:'Liquid Lunch Networks',asn:30846,type:'t2',pol:'open',up:['tat','tly'],share:.006,price:6,col:'#00A0DF',pops:['jnb','cpt','dur','hre','lun','gbe','mpm','dar','nbo','mba','kla','kgl','fih','add','jib','cai','wdh'],ix:['jnb','cpt','dur','hre','lun','gbe','mpm','dar','nbo','mba','kla','kgl','fih','add','jib','cai','wdh'],blurb:tr('networks.cape_to_cairo_fiber_across_a')},
|
||||
{id:'liq',name:'Liquid Lunch Networks',asn:30846,type:'t2',cc:['ZW'],pol:'open',up:['tat','tly'],share:.006,price:6,col:'#00A0DF',pops:['jnb','cpt','dur','hre','lun','gbe','mpm','dar','nbo','mba','kla','kgl','fih','add','jib','cai','wdh'],ix:['jnb','cpt','dur','hre','lun','gbe','mpm','dar','nbo','mba','kla','kgl','fih','add','jib','cai','wdh'],blurb:tr('networks.cape_to_cairo_fiber_across_a')},
|
||||
{id:'scm',name:'Sea-Comedy Networks',asn:37102,type:'t2',pol:'open',up:['ntt','tat'],share:.005,price:5,col:'#1C3F94',pops:['jnb','cpt','dur','mpm','dar','mba','nbo','kla','kgl','jib','cai','mrs','bom','lon'],ix:['jnb','cpt','dur','mpm','dar','mba','nbo','kla','jib','mrs'],blurb:tr('networks.owns_the_cable_that_brought_east')},
|
||||
{id:'agc',name:'Angle-a Cables',asn:37470,type:'t2',pol:'open',up:['tly','cog'],share:.004,price:5,col:'#E30613',pops:['lad','fih','for','sao','mia','lon'],ix:['lad','for','sao','mia'],blurb:tr('networks.owns_the_cables_from_luanda_to')},
|
||||
{id:'djt',name:'Djibouti Calling',asn:30992,type:'t2',pol:'selective',up:['tat','tly'],minIx:3,minPni:15,share:.003,price:8,col:'#0D7F3F',pops:['jib','add','mrs','bom','jed'],ix:['jib'],blurb:tr('networks.a_tiny_telco_in_a_country')},
|
||||
{id:'mtx',name:'Empty-N',asn:29977,type:'eye',pol:'selective',up:['tat','lvl'],minIx:5,minPni:20,share:.008,col:'#FFCB05',pops:['lag','acc','abj','dla','kla','kgl','jnb','cpt','dur','lun','gbe','lad'],ix:['lag','acc','abj','dla','kla','kgl','jnb','cpt','dur','lun','gbe','lad'],blurb:tr('networks.africa_s_mobile_giant_in_a')},
|
||||
{id:'art',name:'Air-Tell Africa',asn:36928,type:'eye',pol:'selective',up:['tat','tly'],minIx:4,minPni:18,share:.006,col:'#ED1C24',pops:['lag','kla','kgl','dar','lun','fih','nbo','tnr','sez'],ix:['lag','kla','kgl','dar','lun','fih','nbo'],blurb:tr('networks.mobile_money_and_prepaid_data_in')},
|
||||
{id:'eth',name:'Ethio-Tele-Calm',asn:24759,type:'eye',pol:'selective',up:['tat'],minIx:2,minPni:12,share:.005,col:'#8DC63F',pops:['add'],ix:['add'],blurb:tr('networks.ethiopia_s_state_telco_a_hundred')},
|
||||
{id:'mrc',name:'Atlas Shrugged Telecom',asn:36905,type:'eye',pol:'selective',up:['lvl','tly'],minIx:3,minPni:15,share:.004,col:'#F28C00',pops:['cas','abj','dkr'],ix:['cas'],blurb:tr('networks.morocco_s_incumbent_with_sister')},
|
||||
{id:'sfc',name:'Safari-Comic',asn:33771,type:'eye',pol:'selective',minIx:5,minPni:20,share:.006,col:'#4CB848',pops:['nbo','mba','add'],ix:['nbo','mba','add'],blurb:tr('networks.kenya_s_mobile_giant_pays_you')},
|
||||
{id:'teg',name:'Tele-Comet Egypt',asn:8452,type:'t2',pol:'selective',minIx:15,minPni:40,share:.006,price:8,col:'#5B2D8E',pops:['cai','mrs','fra','lon'],ix:['cai','mrs'],blurb:tr('networks.owns_the_land_crossing_every_red')});
|
||||
{id:'djt',name:'Djibouti Calling',asn:30992,type:'t2',cc:'DJ',pol:'selective',up:['tat','tly'],minIx:3,minPni:15,share:.003,price:8,col:'#0D7F3F',pops:['jib','add','mrs','bom','jed'],ix:['jib'],blurb:tr('networks.a_tiny_telco_in_a_country')},
|
||||
{id:'mtx',name:'Empty-N',asn:29977,type:'eye',cc:['NG','GH','CI','CM','UG','RW','ZA','ZM'],pol:'selective',up:['tat','lvl'],minIx:5,minPni:20,share:.008,col:'#FFCB05',pops:['lag','acc','abj','dla','kla','kgl','jnb','cpt','dur','lun','gbe','lad'],ix:['lag','acc','abj','dla','kla','kgl','jnb','cpt','dur','lun','gbe','lad'],blurb:tr('networks.africa_s_mobile_giant_in_a')},
|
||||
{id:'art',name:'Air-Tell Africa',asn:36928,type:'eye',cc:['NG','UG','RW','TZ','ZM','CD','KE','MG','SC'],pol:'selective',up:['tat','tly'],minIx:4,minPni:18,share:.006,col:'#ED1C24',pops:['lag','kla','kgl','dar','lun','fih','nbo','tnr','sez'],ix:['lag','kla','kgl','dar','lun','fih','nbo'],blurb:tr('networks.mobile_money_and_prepaid_data_in')},
|
||||
{id:'eth',name:'Ethio-Tele-Calm',asn:24759,type:'eye',cc:'ET',pol:'selective',up:['tat'],minIx:2,minPni:12,share:.005,col:'#8DC63F',pops:['add'],ix:['add'],blurb:tr('networks.ethiopia_s_state_telco_a_hundred')},
|
||||
{id:'mrc',name:'Atlas Shrugged Telecom',asn:36905,type:'eye',cc:'MA',pol:'selective',up:['lvl','tly'],minIx:3,minPni:15,share:.004,col:'#F28C00',pops:['cas','abj','dkr'],ix:['cas'],blurb:tr('networks.morocco_s_incumbent_with_sister')},
|
||||
{id:'sfc',name:'Safari-Comic',asn:33771,type:'eye',cc:['KE','ET'],pol:'selective',minIx:5,minPni:20,share:.006,up:['cog','lvl','scm'],col:'#4CB848',pops:['nbo','mba','add'],ix:['nbo','mba','add'],blurb:tr('networks.kenya_s_mobile_giant_pays_you')},
|
||||
{id:'teg',name:'Tele-Comet Egypt',asn:8452,type:'t2',cc:'EG',pol:'selective',minIx:15,minPni:40,share:.006,price:8,col:'#5B2D8E',pops:['cai','mrs','fra','lon'],ix:['cai','mrs'],blurb:tr('networks.owns_the_land_crossing_every_red')});
|
||||
NETS.push(
|
||||
{id:'clr',name:'Clarovision',asn:28537,type:'t2',pol:'selective',minIx:10,minPni:30,share:.012,price:5,col:'#DA291C',pops:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix','mvd','asu','cor','uio','mde','gua','sjo','qro','mty','gdl','bue','scl','lim','bog','pan','mex','mia','sju','sdq'],ix:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix','mvd','asu','cor','uio','mde','gua','sjo','qro','mty','gdl','bue','scl','lim','bog'],blurb:tr('networks.the_big_regional_carrier_sees')},
|
||||
{id:'viv',name:'Viva Vivo',asn:26959,type:'eye',pol:'selective',minIx:8,minPni:25,share:.01,col:'#660099',pops:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix'],ix:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix'],blurb:tr('networks.brazil_s_mobile_giant_very_much')},
|
||||
{id:'oio',name:'Oi Oi',asn:7739,type:'eye',pol:'selective',up:['lvl','tly'],minIx:6,minPni:20,share:.008,col:'#FFD000',pops:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix'],ix:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix'],blurb:tr('networks.says_oi_to_every_home_in')},
|
||||
{id:'tmt',name:'TIM-TIM Mobile',asn:26616,type:'eye',pol:'selective',up:['skl'],minIx:6,minPni:20,share:.007,col:'#004691',pops:['sao','rio','bsb','bhz','cwb','poa','cpq','rec','ssa','for','gyn','bel','mao','vix','fln'],ix:['sao','rio','bsb','bhz','cwb','poa','cpq','rec','ssa','for','gyn','bel','mao','vix','fln'],blurb:tr('networks.a_mobile_network_named_after_the')},
|
||||
{id:'bsn',name:'Brisanada',asn:28127,type:'eye',pol:'open',up:['lvl'],share:.004,col:'#F7941D',pops:['for','nat','jpa','cpv','rec','cau','mcz','aju','ssa','fec','the','slz'],ix:['for','nat','jpa','cpv','rec','cau','mcz','aju','ssa','fec','the','slz'],blurb:tr('networks.fiber_across_the_sertao_of_the')},
|
||||
{id:'mvs',name:'Moviestar',asn:12957,type:'t2',pol:'selective',up:['tly','lvl'],minIx:8,minPni:25,share:.008,price:6,col:'#019DF4',pops:['mex','gua','bog','mde','uio','lim','lpb','scl','bue','cor','mvd','ccs','sao','mia'],ix:['mex','bog','lim','scl','bue','mvd','ccs','sao'],blurb:tr('networks.a_spanish_carrier_starring_in_every')},
|
||||
{id:'llt',name:'Liberty Latte America',asn:23521,type:'t2',pol:'open',up:['lvl','cog'],share:.005,price:5,col:'#6C2C91',pops:['mia','pan','sjo','gua','bog','mde','ccs','sju','kin','nas','pos','bgi','cur'],ix:['pan','sjo','gua','bog','kin','pos'],blurb:tr('networks.cables_all_around_the_caribbean')},
|
||||
{id:'ant',name:'Antelope',asn:6058,type:'eye',pol:'selective',up:['skl','tly'],minIx:3,minPni:15,share:.004,col:'#0072BC',pops:['mvd'],ix:['mvd'],blurb:tr('networks.uruguay_s_state_telco_fast')},
|
||||
{id:'tgo',name:'Tiger Mobile',asn:27743,type:'eye',pol:'selective',up:['lvl'],minIx:4,minPni:15,share:.005,col:'#00377B',pops:['asu','lpb','gua','sjo','pan','bog','mde'],ix:['asu','lpb','gua','sjo','bog'],blurb:tr('networks.prepaid_mobile_from_paraguay_to')},
|
||||
{id:'clr',name:'Clarovision',asn:28537,type:'t2',cc:['AR','BR','CL','CO','CR','DO','EC','GT','PE','PR','PY','UY'],pol:'selective',minIx:10,minPni:30,share:.012,price:5,col:'#DA291C',pops:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix','mvd','asu','cor','uio','mde','gua','sjo','qro','mty','gdl','bue','scl','lim','bog','pan','mex','mia','sju','sdq'],ix:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix','mvd','asu','cor','uio','mde','gua','sjo','qro','mty','gdl','bue','scl','lim','bog'],blurb:tr('networks.the_big_regional_carrier_sees')},
|
||||
{id:'viv',name:'Viva Vivo',asn:26959,type:'eye',cc:'BR',pol:'selective',minIx:8,minPni:25,share:.01,col:'#660099',pops:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix'],ix:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix'],blurb:tr('networks.brazil_s_mobile_giant_very_much')},
|
||||
{id:'oio',name:'Oi Oi',asn:7739,type:'eye',cc:'BR',pol:'selective',up:['lvl','tly'],minIx:6,minPni:20,share:.008,col:'#FFD000',pops:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix'],ix:['sao','rio','for','bsb','bhz','cwb','poa','aju','bel','bvb','cac','cpv','cpq','cgr','cau','cgb','cxj','fec','fln','igu','gyn','jpa','ljd','ldb','mcp','mcz','mao','mgf','nat','pmw','pvh','rao','rec','rbr','ssa','ria','sjp','slz','the','vix'],blurb:tr('networks.says_oi_to_every_home_in')},
|
||||
{id:'tmt',name:'TIM-TIM Mobile',asn:26616,type:'eye',cc:'BR',pol:'selective',up:['skl'],minIx:6,minPni:20,share:.007,col:'#004691',pops:['sao','rio','bsb','bhz','cwb','poa','cpq','rec','ssa','for','gyn','bel','mao','vix','fln'],ix:['sao','rio','bsb','bhz','cwb','poa','cpq','rec','ssa','for','gyn','bel','mao','vix','fln'],blurb:tr('networks.a_mobile_network_named_after_the')},
|
||||
{id:'bsn',name:'Brisanada',asn:28127,type:'eye',cc:'BR',pol:'open',up:['lvl'],share:.004,col:'#F7941D',pops:['for','nat','jpa','cpv','rec','cau','mcz','aju','ssa','fec','the','slz'],ix:['for','nat','jpa','cpv','rec','cau','mcz','aju','ssa','fec','the','slz'],blurb:tr('networks.fiber_across_the_sertao_of_the')},
|
||||
{id:'mvs',name:'Moviestar',asn:12957,type:'t2',cc:['AR','CL','CO','EC','MX','PE','UY','VE'],pol:'selective',up:['tly','lvl'],minIx:8,minPni:25,share:.008,price:6,col:'#019DF4',pops:['mex','gua','bog','mde','uio','lim','lpb','scl','bue','cor','mvd','ccs','sao','mia'],ix:['bog','lim','scl','bue','mvd','ccs','sao'],blurb:tr('networks.a_spanish_carrier_starring_in_every')},
|
||||
{id:'llt',name:'Liberty Latte America',asn:23521,type:'t2',cc:['BB','BS','CR','CW','JM','PA','PR','TT'],pol:'open',up:['lvl','cog'],share:.005,price:5,col:'#6C2C91',pops:['mia','pan','sjo','gua','bog','mde','ccs','sju','kin','nas','pos','bgi','cur'],ix:['pan','sjo','gua','bog','kin','pos'],blurb:tr('networks.cables_all_around_the_caribbean')},
|
||||
{id:'ant',name:'Antelope',asn:6058,type:'eye',cc:'UY',pol:'selective',up:['skl','tly'],minIx:3,minPni:15,share:.004,col:'#0072BC',pops:['mvd'],ix:['mvd'],blurb:tr('networks.uruguay_s_state_telco_fast')},
|
||||
{id:'tgo',name:'Tiger Mobile',asn:27743,type:'eye',cc:['PY','BO','GT','CR','PA','CO'],pol:'selective',up:['lvl'],minIx:4,minPni:15,share:.005,col:'#00377B',pops:['asu','lpb','gua','sjo','pan','bog','mde'],ix:['asu','lpb','gua','sjo','bog'],blurb:tr('networks.prepaid_mobile_from_paraguay_to')},
|
||||
{id:'mlv',name:'Mercado Livre-ly',asn:52850,type:'cdn',pol:'open',share:.006,col:'#FFE600',pops:['sao','rio','bue','scl','bog','lim','mia'],ix:['sao','rio','bue','scl','bog','lim'],blurb:tr('networks.ships_parcels_and_packets_both')},
|
||||
{id:'jio',name:'Jio-graphy',asn:55863,type:'eye',pol:'selective',minIx:10,minPni:30,share:.02,col:'#0F3CC9',pops:['bom','del','maa','blr','hyd'],ix:['bom','del','maa','blr','hyd'],blurb:tr('networks.gave_a_billion_people_cheap_data')},
|
||||
{id:'atl',name:'Airtel-tale',asn:9849,type:'t2',pol:'selective',minIx:15,minPni:40,share:.01,price:7,col:'#E40000',pops:['bom','del','maa','blr','hyd','sin','lon','dxb','dac','cbo'],ix:['bom','del','maa','blr'],blurb:tr('networks.india_s_other_giant_every_outage')},
|
||||
{id:'cht',name:'Chunghwa Tele-calm',asn:3426,type:'t2',pol:'selective',minIx:10,minPni:30,share:.008,price:7,col:'#00A0E9',pops:['tpe','hkg','tok','lax','sin'],ix:['tpe','hkg'],blurb:tr('networks.taiwan_s_incumbent_stays_calm_while')},
|
||||
{id:'duu',name:'Du-opoly',asn:15820,type:'eye',pol:'paid',freeLv:11,paidFee:6000,share:.004,col:'#00A9CE',pops:['dxb','auh','fuj'],ix:[],blurb:tr('networks.the_other_half_of_the_uae')});
|
||||
{id:'jio',name:'Jio-graphy',asn:55863,type:'eye',cc:'IN',pol:'selective',minIx:10,minPni:30,share:.02,col:'#0F3CC9',pops:['bom','del','maa','blr','hyd'],ix:['bom','del','maa','blr','hyd'],blurb:tr('networks.gave_a_billion_people_cheap_data')},
|
||||
{id:'atl',name:'Airtel-tale',asn:9849,type:'t2',cc:'IN',pol:'selective',minIx:15,minPni:40,share:.01,price:7,col:'#E40000',pops:['bom','del','maa','blr','hyd','sin','lon','dxb','dac','cbo'],ix:['bom','del','maa','blr'],blurb:tr('networks.india_s_other_giant_every_outage')},
|
||||
{id:'cht',name:'Chunghwa Tele-calm',asn:3426,type:'t2',cc:'TW',pol:'selective',minIx:10,minPni:30,share:.008,price:7,col:'#00A0E9',pops:['tpe','hkg','tok','lax','sin'],ix:['tpe','hkg'],blurb:tr('networks.taiwan_s_incumbent_stays_calm_while')},
|
||||
{id:'duu',name:'Du-opoly',asn:15820,type:'eye',cc:'AE',pol:'paid',freeLv:11,paidFee:6000,share:.004,up:['tat','tly'],col:'#00A9CE',pops:['dxb','auh','fuj'],ix:[],blurb:tr('networks.the_other_half_of_the_uae')});
|
||||
NETS.push(
|
||||
{id:'kdi',name:'KD-DIY',asn:2561,type:'t2',pol:'selective',minIx:10,minPni:30,share:.008,price:6,col:'#E85D04',pops:['tok','osa','lax','sin','hkg','fuk'],ix:['tok','osa','fuk'],blurb:tr('networks.japanese_carrier_that_builds')},
|
||||
{id:'opt',name:'Floptus',asn:4804,type:'eye',pol:'selective',minIx:8,minPni:25,share:.006,col:'#00837E',pops:['syd','mel','bne','per'],ix:[],blurb:tr('networks.australia_s_number_two_once_took')},
|
||||
{id:'tpr',name:'Toilet Paper Group',asn:7545,type:'eye',pol:'selective',minIx:8,minPni:25,share:.0035,col:'#4E2A84',pops:['syd','mel','bne','per','adl','cbr'],ix:[],blurb:tr('networks.stockpiled_bandwidth_in_2020_and')},
|
||||
{id:'abb',name:'Aussie Boyband',asn:4764,type:'eye',pol:'open',share:.002,col:'#00B140',pops:['syd','mel','bne','per','adl','cbr','drw','hba'],ix:['syd','mel','bne','per','adl','drw'],blurb:tr('networks.matching_outfits_perfect_harmonies')},
|
||||
{id:'kdi',name:'KD-DIY',asn:2561,type:'t2',cc:'JP',pol:'selective',minIx:10,minPni:30,share:.008,price:6,col:'#E85D04',pops:['tok','osa','lax','sin','hkg','fuk'],ix:['tok','osa','fuk'],blurb:tr('networks.japanese_carrier_that_builds')},
|
||||
{id:'opt',name:'Floptus',asn:4804,type:'eye',cc:'AU',pol:'selective',minIx:8,minPni:25,share:.006,up:['sgt'],col:'#00837E',pops:['syd','mel','bne','per'],ix:[],blurb:tr('networks.australia_s_number_two_once_took')},
|
||||
{id:'tpr',name:'Toilet Paper Group',asn:7545,type:'eye',cc:'AU',pol:'selective',minIx:8,minPni:25,share:.0035,col:'#4E2A84',pops:['syd','mel','bne','per','adl','cbr'],ix:[],blurb:tr('networks.stockpiled_bandwidth_in_2020_and')},
|
||||
{id:'abb',name:'Aussie Boyband',asn:4764,type:'eye',cc:'AU',pol:'open',share:.002,col:'#00B140',pops:['syd','mel','bne','per','adl','cbr','drw','hba'],ix:['syd','mel','bne','per','adl','drw'],blurb:tr('networks.matching_outfits_perfect_harmonies')},
|
||||
{id:'voc',name:'Hocus Pocus',asn:4826,type:'t2',pol:'open',up:['ntt','tly'],share:.002,price:7,col:'#E4002B',pops:['syd','mel','bne','per','adl','cbr','drw','hba','sin'],ix:['syd','mel','bne','per','adl','hba','drw','sin'],blurb:tr('networks.now_you_see_the_fibre_now')},
|
||||
{id:'ddo',name:'Doodoo',asn:9443,type:'eye',pol:'open',up:['voc'],share:.0011,col:'#FFC20E',pops:['syd','mel','bne','per','adl'],ix:[],blurb:tr('networks.the_cheapest_plan_in_the_country')},
|
||||
{id:'stb',name:'Musklink',asn:14593,type:'eye',pol:'selective',minIx:3,minPni:10,share:.001,col:'#1B1F24',pops:['syd','mel','bne','per','drw','sea','lax','dal','chi','ash'],ix:['mel','bne','per','drw'],blurb:tr('networks.beams_the_outback_online_from_550')},
|
||||
{id:'spl',name:'Speedyloop',asn:38195,type:'t2',pol:'open',up:['tly'],share:.001,price:6,col:'#FF5F00',pops:['syd','mel','bne','per','adl','sin','hkg','cbr','drw'],ix:['mel','bne','per','adl','hba','drw','sin','hkg'],blurb:tr('networks.speedy_by_name_owns_a_slice')},
|
||||
{id:'blg',name:'Beshort',asn:135887,type:'eye',pol:'selective',minIx:8,minPni:25,up:['tsy'],share:.0005,col:'#FF5A00',pops:['syd','mel','bne'],ix:[],blurb:tr('networks.telstraya_s_budget_brand_cheaper')},
|
||||
{id:'spn',name:'Spin2wintel',asn:18390,type:'eye',pol:'open',up:['voc'],share:.00015,col:'#0072CE',pops:['syd','mel','bne','per','adl'],ix:['syd','mel','bne','per','adl'],blurb:tr('networks.cheap_broadband_with_the_sales_pitch')},
|
||||
{id:'lpt',name:'Frogtel',asn:134090,type:'eye',pol:'open',share:.0001,col:'#7AC143',pops:['syd','mel','bne','adl','per','drw'],ix:['syd','mel','bne','per','adl'],blurb:tr('networks.small_fast_and_always_leaping_to')},
|
||||
{id:'ext',name:'Lintel',asn:10143,type:'eye',pol:'open',up:['spl'],share:.0001,col:'#F26522',pops:['syd','mel','bne','per','adl'],ix:[],blurb:tr('networks.bought_by_speedyloop_and_still')},
|
||||
{id:'tru',name:'Mostly-True Move',asn:7740,type:'eye',pol:'selective',minIx:5,minPni:20,share:.006,col:'#E4002B',pops:['bkk'],ix:['bkk'],blurb:tr('networks.thailand_s_mobile_giant_its_coverage')},
|
||||
{id:'vtl',name:'Viet-tell',asn:7525,type:'t2',pol:'selective',minIx:10,minPni:30,share:.005,price:7,col:'#EE0033',pops:['sgn','hkg','sin'],ix:['sgn'],blurb:tr('networks.vietnam_s_giant_will_tell_you')},
|
||||
{id:'ptc',name:'PTC-hell',asn:17577,type:'t2',pol:'selective',minIx:10,minPni:30,share:.004,price:8,col:'#00843D',pops:['khi','dxb'],ix:['khi'],blurb:tr('networks.pakistan_s_incumbent_every_session')},
|
||||
{id:'tmy',name:'Telekom Ma-lazy-sia',asn:4877,type:'t2',pol:'selective',minIx:10,minPni:30,share:.004,price:6,col:'#1F2A6B',pops:['kul','sin'],ix:['kul'],blurb:tr('networks.malaysia_s_incumbent_in_no_hurry')},
|
||||
{id:'ttk',name:'Türk Tele-komik',asn:9211,type:'t2',pol:'selective',minIx:10,minPni:30,share:.008,price:6,col:'#1D3F8F',pops:['ath','ist','fra','sof','lon'],ix:['ist'],blurb:tr('networks.bridges_europe_and_asia_and')},
|
||||
{id:'dgi',name:'Digi-tally Cheap',asn:8798,type:'eye',pol:'open',share:.006,col:'#2A5CAA',pops:['buh','bud','mad'],ix:['buh','bud','mad'],blurb:tr('networks.gigabit_to_every_flat_for_the')},
|
||||
{id:'ups',name:'UPC-You-Later',asn:6380,type:'eye',pol:'selective',minIx:8,minPni:25,share:.006,col:'#D8001B',pops:['waw','prg','vie','bud','zrh','kyv'],ix:['waw','prg','vie','kyv'],blurb:tr('networks.cable_broadband_across_central')});
|
||||
{id:'ddo',name:'Doodoo',asn:9443,type:'eye',cc:'AU',pol:'open',up:['voc'],share:.0011,col:'#FFC20E',pops:['syd','mel','bne','per','adl'],ix:[],blurb:tr('networks.the_cheapest_plan_in_the_country')},
|
||||
{id:'stb',name:'Musklink',asn:14593,type:'eye',cc:'US',pol:'selective',minIx:3,minPni:10,share:.001,col:'#1B1F24',pops:['syd','mel','bne','per','drw','sea','lax','dal','chi','ash'],ix:['mel','bne','per','drw'],blurb:tr('networks.beams_the_outback_online_from_550')},
|
||||
{id:'spl',name:'Speedyloop',asn:38195,type:'t2',cc:'AU',pol:'open',up:['tly'],share:.001,price:6,col:'#FF5F00',pops:['syd','mel','bne','per','adl','sin','hkg','cbr','drw'],ix:['mel','bne','per','adl','hba','drw','sin','hkg'],blurb:tr('networks.speedy_by_name_owns_a_slice')},
|
||||
{id:'blg',name:'Beshort',asn:135887,type:'eye',cc:'AU',pol:'selective',minIx:8,minPni:25,up:['tsy'],share:.0005,col:'#FF5A00',pops:['syd','mel','bne'],ix:[],blurb:tr('networks.telstraya_s_budget_brand_cheaper')},
|
||||
{id:'spn',name:'Spin2wintel',asn:18390,type:'eye',cc:'AU',pol:'open',up:['voc'],share:.00015,col:'#0072CE',pops:['syd','mel','bne','per','adl'],ix:['syd','mel','bne','per','adl'],blurb:tr('networks.cheap_broadband_with_the_sales_pitch')},
|
||||
{id:'lpt',name:'Frogtel',asn:134090,type:'eye',cc:'AU',pol:'open',share:.0001,col:'#7AC143',pops:['syd','mel','bne','adl','per','drw'],ix:['syd','mel','bne','per','adl'],blurb:tr('networks.small_fast_and_always_leaping_to')},
|
||||
{id:'ext',name:'Lintel',asn:10143,type:'eye',cc:'AU',pol:'open',up:['spl'],share:.0001,col:'#F26522',pops:['syd','mel','bne','per','adl'],ix:[],blurb:tr('networks.bought_by_speedyloop_and_still')},
|
||||
{id:'tru',name:'Mostly-True Move',asn:7740,type:'eye',cc:'TH',pol:'selective',minIx:5,minPni:20,share:.006,col:'#E4002B',pops:['bkk'],ix:['bkk'],blurb:tr('networks.thailand_s_mobile_giant_its_coverage')},
|
||||
{id:'vtl',name:'Viet-tell',asn:7525,type:'t2',cc:'VN',pol:'selective',minIx:10,minPni:30,share:.005,price:7,col:'#EE0033',pops:['sgn','hkg','sin'],ix:['sgn'],blurb:tr('networks.vietnam_s_giant_will_tell_you')},
|
||||
{id:'ptc',name:'PTC-hell',asn:17577,type:'t2',cc:'PK',pol:'selective',minIx:10,minPni:30,share:.004,price:8,col:'#00843D',pops:['khi','dxb'],ix:['khi'],blurb:tr('networks.pakistan_s_incumbent_every_session')},
|
||||
{id:'tmy',name:'Telekom Ma-lazy-sia',asn:4877,type:'t2',cc:'MY',pol:'selective',minIx:10,minPni:30,share:.004,price:6,col:'#1F2A6B',pops:['kul','sin'],ix:['kul'],blurb:tr('networks.malaysia_s_incumbent_in_no_hurry')},
|
||||
{id:'ttk',name:'Türk Tele-komik',asn:9211,type:'t2',cc:'TR',pol:'selective',minIx:10,minPni:30,share:.008,price:6,col:'#1D3F8F',pops:['ath','ist','fra','sof','lon'],ix:['ist'],blurb:tr('networks.bridges_europe_and_asia_and')},
|
||||
{id:'dgi',name:'Digi-tally Cheap',asn:8798,type:'eye',cc:['ES','RO'],pol:'open',share:.006,col:'#2A5CAA',pops:['buh','bud','mad'],ix:['buh','bud','mad'],blurb:tr('networks.gigabit_to_every_flat_for_the')},
|
||||
{id:'ups',name:'UPC-You-Later',asn:6380,type:'eye',cc:['PL','CZ','AT','HU','CH'],pol:'selective',minIx:8,minPni:25,share:.006,col:'#D8001B',pops:['waw','prg','vie','bud','zrh','kyv'],ix:['waw','prg','vie','kyv'],blurb:tr('networks.cable_broadband_across_central')});
|
||||
NETS.push(
|
||||
{id:'tlu',name:'Tell Us',asn:852,type:'eye',pol:'selective',minIx:10,minPni:30,share:.008,up:['lvl','tly'],col:'#4B286D',pops:['van','cal','tor','mtl','ott','sea','prr'],ix:['van','cal','tor'],blurb:tr('networks.western_canada_s_incumbent_tell_us')},
|
||||
{id:'rgc',name:'Bodgers Communications',asn:812,type:'eye',pol:'selective',minIx:10,minPni:30,share:.01,up:['cog','ntt'],col:'#DA291C',pops:['tor','ott','mtl','van','cal'],ix:['tor','ott','van'],blurb:tr('networks.canada_s_cable_giant_held_together')});
|
||||
{id:'tlu',name:'Tell Us',asn:852,type:'eye',cc:'CA',pol:'selective',minIx:10,minPni:30,share:.008,up:['lvl','tly'],col:'#4B286D',pops:['van','cal','tor','mtl','ott','sea','prr'],ix:['van','cal','tor'],blurb:tr('networks.western_canada_s_incumbent_tell_us')},
|
||||
{id:'rgc',name:'Bodgers Communications',asn:812,type:'eye',cc:'CA',pol:'selective',minIx:10,minPni:30,share:.01,up:['cog','ntt'],col:'#DA291C',pops:['tor','ott','mtl','van','cal'],ix:['tor','ott','van'],blurb:tr('networks.canada_s_cable_giant_held_together')});
|
||||
NETS.push(
|
||||
{id:'tny',name:'Telenyet',asn:6848,type:'eye',pol:'selective',minIx:10,minPni:30,share:.008,up:['lvl'],col:'#FFC421',pops:['bru','oos','ams','fra','lon'],ix:['bru'],blurb:tr('networks.half_of_the_flanders_duopoly_on')},
|
||||
{id:'pxm',name:'Proxyminus',asn:5432,type:'eye',pol:'selective',minIx:15,minPni:40,share:.008,up:['bgs','lvl'],col:'#5C2D91',pops:['bru','oos','ams'],ix:['bru'],blurb:tr('networks.the_other_half_of_the_duopoly')},
|
||||
{id:'tny',name:'Telenyet',asn:6848,type:'eye',cc:'BE',pol:'selective',minIx:10,minPni:30,share:.008,up:['lvl'],col:'#FFC421',pops:['bru','oos','ams','fra','lon'],ix:['bru'],blurb:tr('networks.half_of_the_flanders_duopoly_on')},
|
||||
{id:'pxm',name:'Proxyminus',asn:5432,type:'eye',cc:'BE',pol:'selective',minIx:15,minPni:40,share:.008,up:['bgs','lvl'],col:'#5C2D91',pops:['bru','oos','ams'],ix:['bru'],blurb:tr('networks.the_other_half_of_the_duopoly')},
|
||||
{id:'bgs',name:'B.I.G.S.',asn:6774,type:'t2',pol:'selective',minIx:10,minPni:30,share:.005,price:5,up:['lvl'],col:'#7B2D8E',pops:['bru','bet','ams','fra','lon','par','mrs','nyc','sin'],ix:['bru','bet','ams','fra','lon','par'],blurb:tr('networks.proxyminus_s_wholesale_arm_present')},
|
||||
{id:'cit',name:'Citrus Belgium',asn:47377,type:'eye',pol:'selective',minIx:10,minPni:30,share:.005,up:['lvl'],col:'#FF7900',pops:['bru','par'],ix:['bru'],blurb:tr('networks.tangerine_s_belgian_daughter_mobile')},
|
||||
{id:'pst',name:'Poste Restante',asn:6663,type:'eye',pol:'selective',minIx:4,minPni:15,share:.001,up:['lvl','tly'],col:'#FFCC00',pops:['bet','fra','ams'],ix:['bet','fra'],blurb:tr('networks.luxembourg_s_post_office_which_also')},
|
||||
{id:'cms',name:'CityMess',asn:199095,type:'eye',pol:'open',share:.002,up:['cog'],col:'#00B2A9',pops:['oos','bru'],ix:['bru'],blurb:tr('networks.private_5g_and_business_fiber_from')});
|
||||
NETS.push({id:'kys',name:'Kyiv Superstar',asn:15859,type:'eye',pol:'selective',minIx:5,minPni:20,share:.006,col:'#0055B8',pops:['kyv','waw','fra'],ix:['kyv'],blurb:tr('networks.ukraine_s_biggest_mobile_network_has')});
|
||||
NETS.push({id:'stc',name:'Sticky Telecom',asn:39368,type:'t2',pol:'selective',minIx:10,minPni:30,share:.01,price:8,col:'#4F008C',pops:['ruh','jed','dxb','fra','lon','cai'],ix:['ruh'],blurb:tr('networks.the_kingdom_s_incumbent_once_you')},
|
||||
{id:'ord',name:'Ooh-redoo',asn:8871,type:'eye',pol:'paid',freeLv:11,paidFee:5000,share:.004,col:'#ED1C24',pops:['doh','dxb','jkt','mct'],ix:[],blurb:tr('networks.qatar_s_big_operator_paid_peering')});
|
||||
{id:'cit',name:'Citrus Belgium',asn:47377,type:'eye',cc:'BE',pol:'selective',minIx:10,minPni:30,share:.005,up:['lvl'],col:'#FF7900',pops:['bru','par'],ix:['bru'],blurb:tr('networks.tangerine_s_belgian_daughter_mobile')},
|
||||
{id:'pst',name:'Poste Restante',asn:6663,type:'eye',cc:'LU',pol:'selective',minIx:4,minPni:15,share:.001,up:['lvl','tly'],col:'#FFCC00',pops:['bet','fra','ams'],ix:['bet','fra'],blurb:tr('networks.luxembourg_s_post_office_which_also')},
|
||||
{id:'cms',name:'CityMess',asn:199095,type:'eye',cc:'BE',pol:'open',share:.002,up:['cog'],col:'#00B2A9',pops:['oos','bru'],ix:['bru'],blurb:tr('networks.private_5g_and_business_fiber_from')});
|
||||
NETS.push({id:'kys',name:'Kyiv Superstar',asn:15859,type:'eye',cc:'UA',pol:'selective',minIx:5,minPni:20,share:.006,up:['cog','tly'],col:'#0055B8',pops:['kyv','waw','fra'],ix:['kyv'],blurb:tr('networks.ukraine_s_biggest_mobile_network_has')});
|
||||
NETS.push({id:'stc',name:'Sticky Telecom',asn:39368,type:'t2',cc:'SA',pol:'selective',minIx:10,minPni:30,share:.01,price:8,col:'#4F008C',pops:['ruh','jed','dxb','fra','lon','cai'],ix:['ruh'],blurb:tr('networks.the_kingdom_s_incumbent_once_you')},
|
||||
{id:'ord',name:'Ooh-redoo',asn:8871,type:'eye',cc:['QA','OM','ID'],pol:'paid',freeLv:11,paidFee:5000,share:.004,up:['tat','tly'],col:'#ED1C24',pops:['doh','dxb','jkt','mct'],ix:[],blurb:tr('networks.qatar_s_big_operator_paid_peering')});
|
||||
NETS.push(
|
||||
{id:'tim',name:'TIM-Tam Italia',asn:3269,type:'eye',pol:'selective',minIx:8,minPni:25,share:.008,col:'#004691',pops:['mil','rom','pmo'],ix:['mil','rom'],blurb:tr('networks.italy_s_incumbent_sweet_on_the')},
|
||||
{id:'tim',name:'TIM-Tam Italia',asn:3269,type:'eye',cc:'IT',pol:'selective',minIx:8,minPni:25,share:.008,up:['skl'],col:'#004691',pops:['mil','rom','pmo'],ix:['mil','rom'],blurb:tr('networks.italy_s_incumbent_sweet_on_the')},
|
||||
{id:'skl',name:'Sparkly Seabone',asn:6762,type:'t1',pol:'restrictive',share:.04,price:6,col:'#5B2C83',pops:['pmo','mil','rom','ath','mrs','bcn','mad','lis','par','lon','ams','fra','zrh','vie','bud','prg','waw','buh','sof','ist','ber','sto','nyc','ash','mia','atn','dal','chi','lax','sjc','tor','mex','pan','bog','lim','scl','bue','sao','rio','for','cai','jed','dxb','bom','sin','hkg','tok','hav'],ix:[],blurb:tr('networks.the_tier_1_that_grew_up')},
|
||||
{id:'fwb',name:'Fast-Webby',asn:12874,type:'eye',pol:'open',share:.004,col:'#FDC300',pops:['mil','rom'],ix:['mil','rom'],blurb:tr('networks.fiber_to_the_italian_home_with')},
|
||||
{id:'meo',name:'MEO-w Portugal',asn:3243,type:'eye',pol:'selective',minIx:5,minPni:20,share:.004,col:'#00A3E0',pops:['pdl','lis','mad'],ix:['lis'],blurb:tr('networks.portugal_s_incumbent_purrs_when_you')},
|
||||
{id:'nos',name:'NOS-y Neighbour',asn:2860,type:'eye',pol:'open',share:.003,col:'#111111',pops:['lis'],ix:['lis'],blurb:tr('networks.peers_with_anyone_and_wants_to')},
|
||||
{id:'cos',name:'Cosmo-Note',asn:6799,type:'eye',pol:'selective',minIx:5,minPni:20,share:.004,col:'#7DC242',pops:['ath','sof'],ix:['ath'],blurb:tr('networks.greece_s_incumbent_takes_careful')},
|
||||
{id:'spc',name:'Spectre-um Cable',asn:20115,type:'eye',pol:'selective',minIx:12,minPni:35,share:.02,col:'#0099D8',pops:['nyc','lax','dal','chi','atn','den','phx','slc','hou','bos','sjc'],ix:['nyc','lax','dal','chi','atn','den'],blurb:tr('networks.cable_broadband_for_half_of_america')},
|
||||
{id:'vzn',name:'Very-Zone',asn:701,type:'eye',pol:'paid',paidFee:9000,share:.015,col:'#CD040B',pops:['nyc','ash','bos','dal','lax','chi','atn','mia'],ix:[],blurb:tr('networks.can_you_hear_me_now_only')});
|
||||
{id:'fwb',name:'Fast-Webby',asn:12874,type:'eye',cc:'IT',pol:'open',share:.004,col:'#FDC300',pops:['mil','rom'],ix:['mil','rom'],blurb:tr('networks.fiber_to_the_italian_home_with')},
|
||||
{id:'meo',name:'MEO-w Portugal',asn:3243,type:'eye',cc:'PT',pol:'selective',minIx:5,minPni:20,share:.004,col:'#00A3E0',pops:['pdl','lis','mad'],ix:['lis'],blurb:tr('networks.portugal_s_incumbent_purrs_when_you')},
|
||||
{id:'nos',name:'NOS-y Neighbour',asn:2860,type:'eye',cc:'PT',pol:'open',share:.003,col:'#111111',pops:['lis'],ix:['lis'],blurb:tr('networks.peers_with_anyone_and_wants_to')},
|
||||
{id:'cos',name:'Cosmo-Note',asn:6799,type:'eye',cc:'GR',pol:'selective',minIx:5,minPni:20,share:.004,col:'#7DC242',pops:['ath','sof'],ix:['ath'],blurb:tr('networks.greece_s_incumbent_takes_careful')},
|
||||
{id:'spc',name:'Spectre-um Cable',asn:20115,type:'eye',cc:'US',pol:'selective',minIx:12,minPni:35,share:.02,col:'#0099D8',pops:['nyc','lax','dal','chi','atn','den','phx','slc','hou','bos','sjc'],ix:['nyc','lax','dal','chi','atn','den'],blurb:tr('networks.cable_broadband_for_half_of_america')},
|
||||
{id:'vzn',name:'Very-Zone',asn:701,type:'eye',cc:'US',pol:'paid',paidFee:9000,share:.015,col:'#CD040B',pops:['nyc','ash','bos','dal','lax','chi','atn','mia'],ix:[],blurb:tr('networks.can_you_hear_me_now_only')});
|
||||
NETS.push(
|
||||
{id:'att',name:'AT&Tease',asn:7018,type:'t1',pol:'restrictive',share:.02,price:8,col:'#00A8E0',pops:['nyc','ash','chi','dal','atn','lax','sjc','sea','mia','hou','lon','fra','ams','par'],ix:[],blurb:tr('networks.the_phone_company_s_favourite_child')},
|
||||
{id:'tmo',name:'Tee-Hee Mobile',asn:21928,type:'eye',pol:'selective',minIx:6,minPni:20,share:.01,up:['lvl','ntt'],col:'#E20074',pops:['nyc','bos','den','sea','sjc','lax','mia','chi','sju'],ix:['nyc','bos','den','sea','sjc','lax','mia','sju'],blurb:tr('networks.pink_loud_and_almost_entirely_ipv6')},
|
||||
{id:'cxc',name:'Coax Communications',asn:22773,type:'eye',pol:'selective',minIx:8,minPni:25,share:.006,up:['spc'],col:'#0072CE',pops:['ash','atn','bos','chi','dal','kcy','lax','nyc','sjc','phx'],ix:[],blurb:tr('networks.cable_broadband_for_the_sun_belt')},
|
||||
{id:'pes',name:'Pessimum',asn:6128,type:'eye',pol:'open',share:.005,up:['cog','lvl'],col:'#1A3D8F',pops:['nyc','ash','chi'],ix:['nyc','ash','chi'],blurb:tr('networks.expects_the_worst_from_every_link')},
|
||||
{id:'ftr',name:'Final Frontear',asn:5650,type:'eye',pol:'selective',minIx:6,minPni:20,share:.005,up:['vzn'],col:'#D2232A',pops:['ash','chi','dal','nyc','mia','lax'],ix:['ash','chi','dal','nyc','mia','lax'],blurb:tr('networks.fiber_to_30_million_homes_and')},
|
||||
{id:'gfb',name:'GFibber',asn:16591,type:'eye',pol:'open',share:.002,up:['lvl','cog'],col:'#34A853',pops:['kcy','ash','atn','chi','dal','den','nyc','phx','slc','sjc'],ix:['kcy','ash','atn','chi','dal','den','nyc','phx','slc','sjc'],blurb:tr('networks.started_in_kansas_city_in_2012')},
|
||||
{id:'snc',name:'Sonic Boomer',asn:46375,type:'eye',pol:'open',share:.0008,up:['cog','lvl'],col:'#F7A600',pops:['sjc'],ix:['sjc'],blurb:tr('networks.bay_area_fiber_with_an_old')});
|
||||
{id:'tmo',name:'Tee-Hee Mobile',asn:21928,type:'eye',cc:['US','PR'],pol:'selective',minIx:6,minPni:20,share:.01,up:['lvl','ntt'],col:'#E20074',pops:['nyc','bos','den','sea','sjc','lax','mia','chi','sju'],ix:['nyc','bos','den','sea','sjc','lax','mia','sju'],blurb:tr('networks.pink_loud_and_almost_entirely_ipv6')},
|
||||
{id:'cxc',name:'Coax Communications',asn:22773,type:'eye',cc:'US',pol:'selective',minIx:8,minPni:25,share:.006,up:['spc'],col:'#0072CE',pops:['ash','atn','bos','chi','dal','kcy','lax','nyc','sjc','phx'],ix:[],blurb:tr('networks.cable_broadband_for_the_sun_belt')},
|
||||
{id:'pes',name:'Pessimum',asn:6128,type:'eye',cc:'US',pol:'open',share:.005,up:['cog','lvl'],col:'#1A3D8F',pops:['nyc','ash','chi'],ix:['nyc','ash','chi'],blurb:tr('networks.expects_the_worst_from_every_link')},
|
||||
{id:'ftr',name:'Final Frontear',asn:5650,type:'eye',cc:'US',pol:'selective',minIx:6,minPni:20,share:.005,up:['vzn'],col:'#D2232A',pops:['ash','chi','dal','nyc','mia','lax'],ix:['ash','chi','dal','nyc','mia','lax'],blurb:tr('networks.fiber_to_30_million_homes_and')},
|
||||
{id:'gfb',name:'GFibber',asn:16591,type:'eye',cc:'US',pol:'open',share:.002,up:['lvl','cog'],col:'#34A853',pops:['kcy','ash','atn','chi','dal','den','nyc','phx','slc','sjc'],ix:['kcy','ash','atn','chi','dal','den','nyc','phx','slc','sjc'],blurb:tr('networks.started_in_kansas_city_in_2012')},
|
||||
{id:'snc',name:'Sonic Boomer',asn:46375,type:'eye',cc:'US',pol:'open',share:.0008,up:['cog','lvl'],col:'#F7A600',pops:['sjc'],ix:['sjc'],blurb:tr('networks.bay_area_fiber_with_an_old')});
|
||||
NETS.push(
|
||||
{id:'npt',name:'Neptoon Internet',asn:151660,type:'eye',pol:'open',share:.00008,col:'#3D5AFE',pops:['syd','mel','bne','per','adl'],ix:['syd','mel','bne','per','adl'],blurb:tr('networks.privacy_first_broadband_from_melbourne')},
|
||||
{id:'lnt',name:'Lawn-tel',asn:134697,type:'eye',pol:'selective',minIx:2,minPni:10,share:.00015,col:'#3FA34D',pops:['hba','syd','mel','bne','per','adl'],ix:['hba','syd','mel','bne','per','adl'],blurb:tr('networks.tasmania_s_own_mowing_its_way')},
|
||||
{id:'pnt',name:'Pent-Up Net',asn:10214,type:'eye',pol:'open',share:.0003,col:'#8E24AA',pops:['per','syd'],ix:['per','syd'],blurb:tr('networks.perth_wireless_and_fibre_pent_up')},
|
||||
{id:'npt',name:'Neptoon Internet',asn:151660,type:'eye',cc:'AU',pol:'open',share:.00008,col:'#3D5AFE',pops:['syd','mel','bne','per','adl'],ix:['syd','mel','bne','per','adl'],blurb:tr('networks.privacy_first_broadband_from_melbourne')},
|
||||
{id:'lnt',name:'Lawn-tel',asn:134697,type:'eye',cc:'AU',pol:'selective',minIx:2,minPni:10,share:.00015,col:'#3FA34D',pops:['hba','syd','mel','bne','per','adl'],ix:['hba','syd','mel','bne','per','adl'],blurb:tr('networks.tasmania_s_own_mowing_its_way')},
|
||||
{id:'pnt',name:'Pent-Up Net',asn:10214,type:'eye',cc:'AU',pol:'open',share:.0003,col:'#8E24AA',pops:['per','syd'],ix:['per','syd'],blurb:tr('networks.perth_wireless_and_fibre_pent_up')},
|
||||
{id:'mag',name:'Dive-Bomb Magpie',asn:58511,type:'t2',pol:'open',up:['ntt','cog'],share:.0003,price:7,col:'#212121',pops:['syd','mel','bne','per','adl','akl','sin','sjc','sea','lon','ams','fra','par'],ix:['syd','mel','bne','per','adl','akl','sin','sjc','sea','lon','ams','fra','par'],blurb:tr('networks.dive_bombs_every_exchange_in_the')},
|
||||
{id:'inp',name:'Internope',asn:4739,type:'eye',pol:'restrictive',up:['tpr'],share:.0015,col:'#F57C00',pops:['syd','mel','bne','per','adl','cbr'],ix:[],blurb:tr('networks.once_the_nerds_favourite_isp_now')});
|
||||
{id:'inp',name:'Internope',asn:4739,type:'eye',cc:'AU',pol:'restrictive',up:['tpr'],share:.0015,col:'#F57C00',pops:['syd','mel','bne','per','adl','cbr'],ix:[],blurb:tr('networks.once_the_nerds_favourite_isp_now')});
|
||||
|
|
|
|||
|
|
@ -61,57 +61,64 @@ const TAIL=[
|
|||
['Peach State Hosting','cdn',['atn'],tr('long_tail.sweet_fuzzy_and_surprisingly')],
|
||||
['Chowder Hosting','cdn',['bos'],tr('long_tail.thick_comforting_and_very_new')],
|
||||
];
|
||||
/* Who the long tail buys transit from (#85): small networks almost always buy it from a big carrier where they sit,
|
||||
usually the cheapest Tier 1 in town or two of them. One or two of the founding five Tier 1s with a PoP in their home
|
||||
cities, picked by name so it never changes; where none sits (Auckland), a carrier there that buys from them. */
|
||||
const TAIL_UP=['cog','lvl','tly','ntt','tat'];
|
||||
function tailUp(name,home){const h=hstr(name+'|up'),t1=TAIL_UP.filter(id=>{const n=NETS.find(x=>x.id===id);return home.some(c=>n.pops.includes(c));});
|
||||
if(!t1.length)return NETS.filter(n=>n.price&&n.up&&n.up.some(u=>TAIL_UP.includes(u))&&home.some(c=>n.pops.includes(c))).map(n=>n.id).slice(0,1);
|
||||
const a=t1[h%t1.length],b=t1[(h>>>8)%t1.length];return t1.length>1&&(h>>>16)%100<50&&b!==a?[a,b]:[a];}
|
||||
function ixStatic(c){const o=[];if(CITY[c]&&CITY[c].ix)o.push(c);for(const x of XIX)if(x.c===c)o.push(x.id);return o;}
|
||||
TAIL.forEach(([name,type,home,blurb,sh],i)=>{const h=hstr(name),cand=home.flatMap(ixStatic),ix=[];
|
||||
if(cand.length){ix.push(cand[h%cand.length]);if(cand.length>1&&(h>>>8)%100<40){const o=cand[(h>>>12)%cand.length];if(!ix.includes(o))ix.push(o);}}
|
||||
const sel=(h>>>4)%10>=8;
|
||||
NETS.push({id:'tail'+i,name,asn:200000+(h%190000),type,tail:true,pol:sel?'selective':'open',...(sel?{minIx:1+(h>>>16)%3,minPni:6+(h>>>18)%8}:{}),share:sh||+(0.0006+((h>>>20)%15)*0.0001).toFixed(4),col:`hsl(${h%360} 55% 46%)`,pops:home.slice(),ix,blurb});});
|
||||
NETS.push({id:'tail'+i,name,asn:200000+(h%190000),type,tail:true,up:tailUp(name,home),pol:sel?'selective':'open',...(sel?{minIx:1+(h>>>16)%3,minPni:6+(h>>>18)%8}:{}),share:sh||+(0.0006+((h>>>20)%15)*0.0001).toFixed(4),col:`hsl(${h%360} 55% 46%)`,pops:home.slice(),ix,blurb});});
|
||||
NETS.push(
|
||||
{id:'ktt',name:'Kay-Tea',asn:4766,type:'eye',pol:'paid',paidFee:5000,perG:90,kr:true,share:.012,col:'#E4002B',pops:['icn','hkg','tok','lax'],ix:[],blurb:tr('long_tail.korea_s_incumbent_sender_pays_every')},
|
||||
{id:'skb',name:'SK Broadbandit',asn:9318,type:'eye',pol:'paid',paidFee:4000,perG:110,kr:true,share:.01,col:'#EA002C',pops:['icn','hkg','sjc'],ix:[],blurb:tr('long_tail.took_a_streaming_giant_to_court')},
|
||||
{id:'lgu',name:'LG You-Pay-Plus',asn:3786,type:'eye',pol:'paid',paidFee:3000,perG:80,kr:true,share:.008,col:'#E6007E',pops:['icn','tok'],ix:[],blurb:tr('long_tail.the_plus_is_a_usage_fee')});
|
||||
{id:'ktt',name:'Kay-Tea',asn:4766,type:'eye',cc:'KR',pol:'paid',paidFee:5000,perG:90,kr:true,share:.012,col:'#E4002B',pops:['icn','hkg','tok','lax'],ix:[],blurb:tr('long_tail.korea_s_incumbent_sender_pays_every')},
|
||||
{id:'skb',name:'SK Broadbandit',asn:9318,type:'eye',cc:'KR',pol:'paid',paidFee:4000,perG:110,kr:true,share:.01,col:'#EA002C',pops:['icn','hkg','sjc'],ix:[],blurb:tr('long_tail.took_a_streaming_giant_to_court')},
|
||||
{id:'lgu',name:'LG You-Pay-Plus',asn:3786,type:'eye',cc:'KR',pol:'paid',paidFee:3000,perG:80,kr:true,share:.008,col:'#E6007E',pops:['icn','tok'],ix:[],blurb:tr('long_tail.the_plus_is_a_usage_fee')});
|
||||
NETS.push(
|
||||
{id:'btt',name:'Bee-Tee',asn:2856,type:'eye',pol:'selective',minIx:10,minPni:30,share:.012,col:'#5514B4',pops:['lon','man','edi','bde'],ix:['lon','man'],blurb:tr('long_tail.the_uk_s_incumbent_buzzes_politely')},
|
||||
{id:'sky',name:'Sky-High Broadband',asn:5607,type:'eye',pol:'selective',minIx:6,minPni:25,share:.008,col:'#0072C9',pops:['lon','man','edi','dub'],ix:['lon','man','edi'],blurb:tr('long_tail.football_films_and_a_router_that')},
|
||||
{id:'vmo',name:'Virgin Mediocre',asn:5089,type:'eye',pol:'selective',minIx:6,minPni:25,share:.007,col:'#E10A0A',pops:['lon','man','edi'],ix:['lon','man'],blurb:tr('long_tail.cable_broadband_for_half_of_britain')},
|
||||
{id:'tnr',name:'Tele-Nor-Way',asn:2119,type:'eye',pol:'selective',minIx:5,minPni:20,share:.006,col:'#00A9E0',pops:['osl','svg','sto','cph','krs'],ix:['osl','svg'],blurb:tr('long_tail.norway_s_incumbent_neither_yes_nor')});
|
||||
{id:'btt',name:'Bee-Tee',asn:2856,type:'eye',cc:'GB',pol:'selective',minIx:10,minPni:30,share:.012,col:'#5514B4',pops:['lon','man','edi','bde'],ix:['lon','man'],blurb:tr('long_tail.the_uk_s_incumbent_buzzes_politely')},
|
||||
{id:'sky',name:'Sky-High Broadband',asn:5607,type:'eye',cc:['GB','IE'],pol:'selective',minIx:6,minPni:25,share:.008,up:['tly','lvl'],col:'#0072C9',pops:['lon','man','edi','dub'],ix:['lon','man','edi'],blurb:tr('long_tail.football_films_and_a_router_that')},
|
||||
{id:'vmo',name:'Virgin Mediocre',asn:5089,type:'eye',cc:'GB',pol:'selective',minIx:6,minPni:25,share:.007,up:['lvl','ntt'],col:'#E10A0A',pops:['lon','man','edi'],ix:['lon','man'],blurb:tr('long_tail.cable_broadband_for_half_of_britain')},
|
||||
{id:'tnr',name:'Tele-Nor-Way',asn:2119,type:'eye',cc:['NO','SE'],pol:'selective',minIx:5,minPni:20,share:.006,up:['tly','lvl'],col:'#00A9E0',pops:['osl','svg','sto','cph','krs'],ix:['osl','svg'],blurb:tr('long_tail.norway_s_incumbent_neither_yes_nor')});
|
||||
NETS.push(
|
||||
{id:'hwt',name:'Hawaiian Telecombo',asn:36149,type:'eye',pol:'selective',minIx:3,minPni:15,share:.004,up:['ntt','lvl'],col:'#5B2A86',pops:['hnl'],ix:['hnl'],blurb:tr('long_tail.hawaii_s_incumbent_every_plan_comes')},
|
||||
{id:'gtg',name:'Grand Theft Teleguam',asn:9246,type:'t2',pol:'open',share:.002,price:8,up:['ntt','tat'],col:'#0072CE',pops:['gum','ror','maj','hnl','tok'],ix:['gum','hnl'],blurb:tr('long_tail.guam_s_incumbent_and_the_way')},
|
||||
{id:'dcp',name:'Docomoco Pacific',asn:3605,type:'eye',pol:'selective',minIx:2,minPni:10,share:.002,up:['ntt'],col:'#E4002B',pops:['gum','ror'],ix:['gum'],blurb:tr('long_tail.guam_s_mobile_network_rice_a')},
|
||||
{id:'dsp',name:'Digi-Sell Pacific',asn:38442,type:'t2',pol:'open',share:.005,price:9,up:['ntt','tat'],col:'#E2001A',pops:['pom','suv','tbu','apw','syd'],ix:['suv'],blurb:tr('long_tail.phones_on_every_island_from_papua')},
|
||||
{id:'hwt',name:'Hawaiian Telecombo',asn:36149,type:'eye',cc:'US',pol:'selective',minIx:3,minPni:15,share:.004,up:['ntt','lvl'],col:'#5B2A86',pops:['hnl'],ix:['hnl'],blurb:tr('long_tail.hawaii_s_incumbent_every_plan_comes')},
|
||||
{id:'gtg',name:'Grand Theft Teleguam',asn:9246,type:'t2',cc:'GU',pol:'open',share:.002,price:8,up:['ntt','tat'],col:'#0072CE',pops:['gum','ror','maj','hnl','tok'],ix:['gum','hnl'],blurb:tr('long_tail.guam_s_incumbent_and_the_way')},
|
||||
{id:'dcp',name:'Docomoco Pacific',asn:3605,type:'eye',cc:'GU',pol:'selective',minIx:2,minPni:10,share:.002,up:['ntt'],col:'#E4002B',pops:['gum','ror'],ix:['gum'],blurb:tr('long_tail.guam_s_mobile_network_rice_a')},
|
||||
{id:'dsp',name:'Digi-Sell Pacific',asn:38442,type:'t2',cc:['FJ','PG','TO','WS'],pol:'open',share:.005,price:9,up:['ntt','tat'],col:'#E2001A',pops:['pom','suv','tbu','apw','syd'],ix:['suv'],blurb:tr('long_tail.phones_on_every_island_from_papua')},
|
||||
{id:'fnt',name:'FINTEL-ligent',asn:9241,type:'t2',pol:'open',share:.002,price:8,up:['ntt','tly'],col:'#00A3AD',pops:['suv','tbu','apw','ppg','syd','hnl'],ix:['suv'],blurb:tr('long_tail.fiji_s_international_gateway_very')},
|
||||
{id:'pft',name:'Postes et Télé-Croissant',asn:56055,type:'t2',pol:'selective',minIx:3,minPni:15,share:.003,price:10,up:['tly','cog'],col:'#F7B500',pops:['nou','ppt','syd','lax'],ix:['nou'],blurb:tr('long_tail.runs_the_post_the_phones_and')},
|
||||
{id:'tkp',name:'Telly-Kom PNG',asn:17828,type:'eye',pol:'selective',minIx:2,minPni:10,share:.003,up:['tat'],col:'#C8102E',pops:['pom'],ix:[],blurb:tr('long_tail.papua_new_guinea_s_state_telco')},
|
||||
{id:'otk',name:'Ours-Truly Telekom',asn:45891,type:'eye',pol:'selective',minIx:1,minPni:8,share:.001,up:['tly'],col:'#00843D',pops:['hir'],ix:['hir'],blurb:tr('long_tail.the_solomon_islands_incumbent_yours')},
|
||||
{id:'tcc',name:'Tongue-in-Cheek Comms',asn:38201,type:'eye',pol:'selective',minIx:1,minPni:8,share:.001,up:['ntt'],col:'#C10230',pops:['tbu'],ix:[],blurb:tr('long_tail.tonga_s_own_telco_lived_through')},
|
||||
{id:'bsk',name:'Blue-Sky-Pie Samoa',asn:17993,type:'eye',pol:'selective',minIx:1,minPni:8,share:.001,up:['tly'],col:'#0096D6',pops:['apw','ppg'],ix:[],blurb:tr('long_tail.samoa_s_broadband_promised_with_a')},
|
||||
{id:'pnc',name:'PNC-See',asn:9534,type:'eye',pol:'selective',minIx:1,minPni:8,share:.0005,up:['ntt'],col:'#1B75BB',pops:['ror'],ix:[],blurb:tr('long_tail.palau_s_telco_snorkel_down_and')},
|
||||
{id:'nta',name:'Never Too Atoll',asn:21581,type:'eye',pol:'selective',minIx:1,minPni:8,share:.0005,up:['ntt'],col:'#2E8B57',pops:['maj'],ix:[],blurb:tr('long_tail.the_marshall_islands_telco_two')});
|
||||
{id:'pft',name:'Postes et Télé-Croissant',asn:56055,type:'t2',cc:['NC','PF'],pol:'selective',minIx:3,minPni:15,share:.003,price:10,up:['tly','cog'],col:'#F7B500',pops:['nou','ppt','syd','lax'],ix:['nou'],blurb:tr('long_tail.runs_the_post_the_phones_and')},
|
||||
{id:'tkp',name:'Telly-Kom PNG',asn:17828,type:'eye',cc:'PG',pol:'selective',minIx:2,minPni:10,share:.003,up:['tat'],col:'#C8102E',pops:['pom'],ix:[],blurb:tr('long_tail.papua_new_guinea_s_state_telco')},
|
||||
{id:'otk',name:'Ours-Truly Telekom',asn:45891,type:'eye',cc:'SB',pol:'selective',minIx:1,minPni:8,share:.001,up:['tly'],col:'#00843D',pops:['hir'],ix:['hir'],blurb:tr('long_tail.the_solomon_islands_incumbent_yours')},
|
||||
{id:'tcc',name:'Tongue-in-Cheek Comms',asn:38201,type:'eye',cc:'TO',pol:'selective',minIx:1,minPni:8,share:.001,up:['ntt'],col:'#C10230',pops:['tbu'],ix:[],blurb:tr('long_tail.tonga_s_own_telco_lived_through')},
|
||||
{id:'bsk',name:'Blue-Sky-Pie Samoa',asn:17993,type:'eye',cc:['WS','AS'],pol:'selective',minIx:1,minPni:8,share:.001,up:['tly'],col:'#0096D6',pops:['apw','ppg'],ix:[],blurb:tr('long_tail.samoa_s_broadband_promised_with_a')},
|
||||
{id:'pnc',name:'PNC-See',asn:17893,type:'eye',cc:'PW',pol:'selective',minIx:1,minPni:8,share:.0005,up:['ntt'],col:'#1B75BB',pops:['ror'],ix:[],blurb:tr('long_tail.palau_s_telco_snorkel_down_and')},
|
||||
{id:'nta',name:'Never Too Atoll',asn:24439,type:'eye',cc:'MH',pol:'selective',minIx:1,minPni:8,share:.0005,up:['ntt'],col:'#2E8B57',pops:['maj'],ix:[],blurb:tr('long_tail.the_marshall_islands_telco_two')});
|
||||
NETS.push(
|
||||
{id:'onc',name:'One Commotion',asn:3855,type:'eye',pol:'selective',minIx:1,minPni:8,share:.001,up:['lvl','tly'],col:'#E4007C',pops:['bda'],ix:[],blurb:tr('long_tail.bermuda_s_phones_tv_and_internet')},
|
||||
{id:'cvt',name:'Curriculum Vitae Telecom',asn:37517,type:'t2',pol:'open',share:.002,price:8,up:['tat','tly'],col:'#004B87',pops:['rai','lis','for','dkr'],ix:['rai'],blurb:tr('long_tail.cape_verde_s_incumbent_and_the')},
|
||||
{id:'pss',name:'Pretty Sure South Atlantic',asn:210841,type:'t2',pol:'open',share:.0005,price:12,up:['tat'],col:'#7D2B8B',pops:['jam','cpt'],ix:[],blurb:tr('long_tail.the_telco_for_st_helena_ascension')},
|
||||
{id:'bst',name:'Beastlink',asn:11260,type:'eye',pol:'selective',minIx:2,minPni:10,share:.002,up:['cog','lvl'],col:'#EE3124',pops:['hfx','tor'],ix:['hfx'],blurb:tr('long_tail.atlantic_canada_s_cable_company')});
|
||||
{id:'onc',name:'One Commotion',asn:3855,type:'eye',cc:'BM',pol:'selective',minIx:1,minPni:8,share:.001,up:['lvl','tly'],col:'#E4007C',pops:['bda'],ix:[],blurb:tr('long_tail.bermuda_s_phones_tv_and_internet')},
|
||||
{id:'cvt',name:'Curriculum Vitae Telecom',asn:37517,type:'t2',cc:'CV',pol:'open',share:.002,price:8,up:['tat','tly'],col:'#004B87',pops:['rai','lis','for','dkr'],ix:['rai'],blurb:tr('long_tail.cape_verde_s_incumbent_and_the')},
|
||||
{id:'pss',name:'Pretty Sure South Atlantic',asn:210841,type:'t2',cc:'SH',pol:'open',share:.0005,price:12,up:['tat'],col:'#7D2B8B',pops:['jam','cpt'],ix:[],blurb:tr('long_tail.the_telco_for_st_helena_ascension')},
|
||||
{id:'bst',name:'Beastlink',asn:11260,type:'eye',cc:'CA',pol:'selective',minIx:2,minPni:10,share:.002,up:['cog','lvl'],col:'#EE3124',pops:['hfx','tor'],ix:['hfx'],blurb:tr('long_tail.atlantic_canada_s_cable_company')});
|
||||
NETS.push(
|
||||
{id:'dgc',name:'Digi-Sell Caribbean',asn:40786,type:'eye',pol:'open',share:.002,up:['tly','lvl'],col:'#E2001A',pops:['kin','pos','bgi','fdf','cur','mia'],ix:['kin'],blurb:tr('long_tail.the_same_phone_company_as_in')},
|
||||
{id:'wnt',name:'Whirled Net',asn:11367,type:'eye',pol:'open',share:.0005,up:['lvl'],col:'#1F6FB2',pops:['sju'],ix:['sju'],blurb:tr('long_tail.puerto_rico_s_own_business_isp')},
|
||||
{id:'cbh',name:'Cable Bahamamama',asn:15146,type:'eye',pol:'selective',minIx:2,minPni:10,share:.0008,up:['lvl','cog'],col:'#00A3AD',pops:['nas','mia'],ix:[],blurb:tr('long_tail.cable_tv_and_broadband_for_the')},
|
||||
{id:'etc',name:'Etecs-ah',asn:27725,type:'eye',pol:'open',share:.002,up:['skl'],col:'#0055A4',pops:['hav'],ix:[],blurb:tr('long_tail.cuba_s_state_telco_and_only')},
|
||||
{id:'tst',name:'TSTT (This Should Take Time)',asn:5639,type:'eye',pol:'selective',minIx:2,minPni:10,share:.001,up:['lvl'],col:'#C8102E',pops:['pos'],ix:['pos'],blurb:tr('long_tail.trinidad_and_tobago_s_incumbent_your')},
|
||||
{id:'cwt',name:'Curaçao Teal-ecom',asn:27660,type:'eye',pol:'open',share:.0004,up:['tly'],col:'#00A6A6',pops:['cur'],ix:['cur'],blurb:tr('long_tail.the_island_s_own_telco_the')},
|
||||
{id:'cnp',name:'Canal Minus',asn:21351,type:'eye',pol:'selective',minIx:2,minPni:8,share:.0006,up:['tly'],col:'#111111',pops:['fdf','run','par'],ix:['run'],blurb:tr('long_tail.french_pay_tv_that_also_runs')},
|
||||
{id:'zeo',name:'Zealot',asn:37002,type:'eye',pol:'open',share:.0005,up:['tly'],col:'#7A1FA2',pops:['run'],ix:['run'],blurb:tr('long_tail.r_union_s_fiber_challenger_very')},
|
||||
{id:'srr',name:'Signal Frequently Ruined',asn:49902,type:'eye',pol:'selective',minIx:1,minPni:8,share:.0005,up:['tly'],col:'#E2001A',pops:['run'],ix:['run'],blurb:tr('long_tail.mobile_and_broadband_on_r_union')},
|
||||
{id:'mtc',name:'Dodo Telecom',asn:23889,type:'t2',pol:'open',share:.001,price:9,up:['tat','tly'],col:'#D52B1E',pops:['mru','run','tnr','jnb','mrs'],ix:['mru'],blurb:tr('long_tail.the_island_s_incumbent_and_a')},
|
||||
{id:'emt',name:'Em-Tell',asn:30999,type:'eye',pol:'open',share:.0004,up:['tat'],col:'#00953B',pops:['mru'],ix:['mru'],blurb:tr('long_tail.mauritius_number_two_telling_everyone')},
|
||||
{id:'tlm',name:'Telmaybe',asn:37054,type:'t2',pol:'open',share:.0015,price:10,up:['tat','tly'],col:'#FFCC00',pops:['tnr','run','mru','jnb'],ix:['tnr'],blurb:tr('long_tail.madagascar_s_incumbent_and_the_only')},
|
||||
{id:'cws',name:'Cable & Witless Seychelles',asn:36958,type:'t2',pol:'open',share:.0003,price:12,up:['tat'],col:'#E4007C',pops:['sez','mba'],ix:[],blurb:tr('long_tail.the_seychelles_old_telco_open_to')},
|
||||
{id:'acs',name:'Alaska Commotions',asn:7782,type:'eye',pol:'open',share:.0008,up:['lvl','cog'],col:'#0072CE',pops:['anc','jnu','sea'],ix:['anc'],blurb:tr('long_tail.alaska_s_old_phone_company_and')},
|
||||
{id:'gci',name:'Glacier Comms Inc.',asn:8047,type:'t2',pol:'open',share:.0015,price:11,up:['lvl','ntt'],col:'#00467F',pops:['anc','jnu','ome','brw','dut','sea'],ix:['sea'],blurb:tr('long_tail.alaska_s_biggest_network_from_anchorage')},
|
||||
{id:'mgf',name:'MegaPhone',asn:31133,type:'eye',pol:'selective',minIx:4,minPni:15,share:.003,up:['rtc'],col:'#00B956',pops:['mos','vvo','uus','pkc','mmk','gdx'],ix:['mos','vvo'],blurb:tr('long_tail.one_of_russia_s_big_mobile')},
|
||||
{id:'ert',name:'Er-Um Telecom',asn:9049,type:'eye',pol:'open',share:.002,up:['rtc'],col:'#E30613',pops:['mos','vvo'],ix:['mos','vvo'],blurb:tr('long_tail.broadband_in_dozens_of_russian_cities')});
|
||||
{id:'dgc',name:'Digi-Sell Caribbean',asn:40786,type:'eye',cc:['JM','TT','BB','MQ','CW'],pol:'open',share:.002,up:['tly','lvl'],col:'#E2001A',pops:['kin','pos','bgi','fdf','cur','mia'],ix:['kin'],blurb:tr('long_tail.the_same_phone_company_as_in')},
|
||||
{id:'wnt',name:'Whirled Net',asn:11367,type:'eye',cc:'PR',pol:'open',share:.0005,up:['lvl'],col:'#1F6FB2',pops:['sju'],ix:['sju'],blurb:tr('long_tail.puerto_rico_s_own_business_isp')},
|
||||
{id:'cbh',name:'Cable Bahamamama',asn:15146,type:'eye',cc:'BS',pol:'selective',minIx:2,minPni:10,share:.0008,up:['lvl','cog'],col:'#00A3AD',pops:['nas','mia'],ix:[],blurb:tr('long_tail.cable_tv_and_broadband_for_the')},
|
||||
{id:'etc',name:'Etecs-ah',asn:27725,type:'eye',cc:'CU',pol:'open',share:.002,up:['skl'],col:'#0055A4',pops:['hav'],ix:[],blurb:tr('long_tail.cuba_s_state_telco_and_only')},
|
||||
{id:'tst',name:'TSTT (This Should Take Time)',asn:5639,type:'eye',cc:'TT',pol:'selective',minIx:2,minPni:10,share:.001,up:['lvl'],col:'#C8102E',pops:['pos'],ix:['pos'],blurb:tr('long_tail.trinidad_and_tobago_s_incumbent_your')},
|
||||
{id:'cwt',name:'Curaçao Teal-ecom',asn:27660,type:'eye',cc:'CW',pol:'open',share:.0004,up:['tly'],col:'#00A6A6',pops:['cur'],ix:['cur'],blurb:tr('long_tail.the_island_s_own_telco_the')},
|
||||
{id:'cnp',name:'Canal Minus',asn:21351,type:'eye',cc:['MQ','RE'],pol:'selective',minIx:2,minPni:8,share:.0006,up:['tly'],col:'#111111',pops:['fdf','run','par'],ix:['run'],blurb:tr('long_tail.french_pay_tv_that_also_runs')},
|
||||
{id:'zeo',name:'Zealot',asn:37002,type:'eye',cc:'RE',pol:'open',share:.0005,up:['tly'],col:'#7A1FA2',pops:['run'],ix:['run'],blurb:tr('long_tail.r_union_s_fiber_challenger_very')},
|
||||
{id:'srr',name:'Signal Frequently Ruined',asn:49902,type:'eye',cc:'RE',pol:'selective',minIx:1,minPni:8,share:.0005,up:['tly'],col:'#E2001A',pops:['run'],ix:['run'],blurb:tr('long_tail.mobile_and_broadband_on_r_union')},
|
||||
{id:'mtc',name:'Dodo Telecom',asn:23889,type:'t2',cc:'MU',pol:'open',share:.001,price:9,up:['tat','tly'],col:'#D52B1E',pops:['mru','run','tnr','jnb','mrs'],ix:['mru'],blurb:tr('long_tail.the_island_s_incumbent_and_a')},
|
||||
{id:'emt',name:'Em-Tell',asn:30999,type:'eye',cc:'MU',pol:'open',share:.0004,up:['tat'],col:'#00953B',pops:['mru'],ix:['mru'],blurb:tr('long_tail.mauritius_number_two_telling_everyone')},
|
||||
{id:'tlm',name:'Telmaybe',asn:37054,type:'t2',cc:'MG',pol:'open',share:.0015,price:10,up:['tat','tly'],col:'#FFCC00',pops:['tnr','run','mru','jnb'],ix:['tnr'],blurb:tr('long_tail.madagascar_s_incumbent_and_the_only')},
|
||||
{id:'cws',name:'Cable & Witless Seychelles',asn:36958,type:'t2',cc:'SC',pol:'open',share:.0003,price:12,up:['tat'],col:'#E4007C',pops:['sez','mba'],ix:[],blurb:tr('long_tail.the_seychelles_old_telco_open_to')},
|
||||
{id:'acs',name:'Alaska Commotions',asn:7782,type:'eye',cc:'US',pol:'open',share:.0008,up:['lvl','cog'],col:'#0072CE',pops:['anc','jnu','sea'],ix:['anc'],blurb:tr('long_tail.alaska_s_old_phone_company_and')},
|
||||
{id:'gci',name:'Glacier Comms Inc.',asn:8047,type:'t2',cc:'US',pol:'open',share:.0015,price:11,up:['lvl','ntt'],col:'#00467F',pops:['anc','jnu','ome','brw','dut','sea'],ix:['sea'],blurb:tr('long_tail.alaska_s_biggest_network_from_anchorage')},
|
||||
{id:'mgf',name:'MegaPhone',asn:31133,type:'eye',cc:'RU',pol:'selective',minIx:4,minPni:15,share:.003,up:['rtc'],col:'#00B956',pops:['mos','vvo','uus','pkc','mmk','gdx'],ix:['mos','vvo'],blurb:tr('long_tail.one_of_russia_s_big_mobile')},
|
||||
{id:'ert',name:'Er-Um Telecom',asn:9049,type:'eye',cc:'RU',pol:'open',share:.002,up:['rtc'],col:'#E30613',pops:['mos','vvo'],ix:['mos','vvo'],blurb:tr('long_tail.broadband_in_dozens_of_russian_cities')});
|
||||
NETS.push(
|
||||
{id:'tet',name:'Tet-à-Tête',asn:12578,type:'eye',pol:'selective',minIx:2,minPni:10,share:.001,up:['tly'],col:'#3F2A56',pops:['rix','sto'],ix:['rix'],blurb:tr('long_tail.latvia_s_incumbent_peers_face_to')},
|
||||
{id:'omt',name:'Omantell',asn:8529,type:'t2',pol:'selective',minIx:3,minPni:12,share:.002,price:9,up:['tat','tly'],col:'#2F6E3B',pops:['mct','fuj','mrs','lon','bom'],ix:['mct'],blurb:tr('long_tail.oman_s_incumbent_and_owner_of')},
|
||||
{id:'dhr',name:'Dhiraa-goo',asn:7642,type:'t2',pol:'open',share:.0003,price:12,up:['tat'],col:'#E2231A',pops:['mle','cbo'],ix:[],blurb:tr('long_tail.the_maldives_telco_on_islands_one')});
|
||||
{id:'tet',name:'Tet-à-Tête',asn:12578,type:'eye',cc:'LV',pol:'selective',minIx:2,minPni:10,share:.001,up:['tly'],col:'#3F2A56',pops:['rix','sto'],ix:['rix'],blurb:tr('long_tail.latvia_s_incumbent_peers_face_to')},
|
||||
{id:'omt',name:'Omantell',asn:8529,type:'t2',cc:'OM',pol:'selective',minIx:3,minPni:12,share:.002,price:9,up:['tat','tly'],col:'#2F6E3B',pops:['mct','fuj','mrs','lon','bom'],ix:['mct'],blurb:tr('long_tail.oman_s_incumbent_and_owner_of')},
|
||||
{id:'dhr',name:'Dhiraa-goo',asn:7642,type:'t2',cc:'MV',pol:'open',share:.0003,price:12,up:['tat'],col:'#E2231A',pops:['mle','cbo'],ix:[],blurb:tr('long_tail.the_maldives_telco_on_islands_one')});
|
||||
|
|
|
|||
70
src/game/30-networks/32-homegrown-eyeballs.js
Normal file
70
src/game/30-networks/32-homegrown-eyeballs.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* Homegrown eyeballs: every country on the map has at least two consumer networks of its own (gameplay rule W2,
|
||||
tests/gameplay-rules.test.js). Each is a real operator of that country, with its real ASN, a traffic share scaled by
|
||||
subscribers like the rest, presence where it really peers, and a realistic upstream (a big carrier where it sits, or
|
||||
its group's own carrier), so it sits in a founding Tier 1's customer cone: Tier 1 is no harder for anyone, old saves included,
|
||||
and older saves reach them by the courtesy route for their first 60 days (sanitize(), S.seen). One per line, sorted by id.
|
||||
Sits before 40-traffic-shares.js, which indexes NETS. */
|
||||
NETS.push(
|
||||
{id:'a1b',name:'A-Wan Bulgaria',asn:8717,type:'eye',cc:'BG',pol:'open',share:.0015,up:['aat'],col:'#DA291C',pops:['sof','vie'],ix:['sof'],blurb:tr('homegrown_eyeballs.a_wan_telekom_s_bulgarian_sister')},
|
||||
{id:'aat',name:'A-Wan Telekom',asn:8447,type:'eye',cc:'AT',pol:'selective',minIx:6,minPni:20,share:.003,up:['tly','lvl'],col:'#DA291C',pops:['vie','fra','prg','bud'],ix:['vie'],blurb:tr('homegrown_eyeballs.austria_s_incumbent_first_in_line')},
|
||||
{id:'agt',name:'Algérie Comme-Ci Comme-Ça',asn:36947,type:'eye',cc:'DZ',pol:'selective',minIx:2,minPni:12,share:.003,up:['tly','cog'],col:'#0B7A3E',pops:['alg','mrs'],ix:['alg'],blurb:tr('homegrown_eyeballs.algeria_s_state_incumbent_some_days')},
|
||||
{id:'ais',name:'AIS-cream',asn:45430,type:'eye',cc:'TH',pol:'selective',minIx:4,minPni:15,share:.006,up:['ntt','tat'],col:'#B5D334',pops:['bkk','sin','hkg'],ix:['bkk'],blurb:tr('homegrown_eyeballs.thailand_s_biggest_mobile_network_cool')},
|
||||
{id:'alb',name:'Altibox of Chocolates',asn:29695,type:'eye',cc:'NO',pol:'open',share:.002,up:['tly','cog'],col:'#2D2A6E',pops:['osl','svg','krs'],ix:['osl','svg'],blurb:tr('homegrown_eyeballs.norwegian_fibre_from_the_power_company')},
|
||||
{id:'alt',name:'Alt-Ctrl-Dominicana',asn:28118,type:'eye',cc:'DO',pol:'selective',minIx:2,minPni:10,share:.0015,up:['lvl','cog'],col:'#1A1A1A',pops:['sdq','mia'],ix:[],blurb:tr('homegrown_eyeballs.the_dominican_republic_s_other_big')},
|
||||
{id:'ast',name:'Pay-Go Pay-Go Telecom',asn:9751,type:'eye',cc:'AS',pol:'selective',minIx:1,minPni:8,share:.0004,up:['fnt','tly'],col:'#00539B',pops:['ppg'],ix:[],blurb:tr('homegrown_eyeballs.american_samoa_s_own_telco_prepaid')},
|
||||
{id:'bmo',name:'To Be Mobile',asn:132462,type:'eye',cc:'SB',pol:'open',share:.0002,up:['tly'],col:'#E4007C',pops:['hir'],ix:['hir'],blurb:tr('homegrown_eyeballs.the_solomon_islands_mobile_challenger_to')},
|
||||
{id:'btc',name:'Botswana Tele-cow',asn:14988,type:'eye',cc:'BW',pol:'selective',minIx:1,minPni:8,share:.0006,up:['liq'],col:'#0072BC',pops:['gbe','jnb'],ix:['gbe'],blurb:tr('homegrown_eyeballs.botswana_s_incumbent_counts_subscribers_like')},
|
||||
{id:'clc',name:'Seldom-Digi',asn:10030,type:'eye',cc:'MY',pol:'selective',minIx:4,minPni:15,share:.003,up:['ntt','tat'],col:'#0019FF',pops:['kul','sin'],ix:['kul'],blurb:tr('homegrown_eyeballs.malaysia_s_biggest_mobile_network_seldom')},
|
||||
{id:'cnl',name:'Can’t’L',asn:17480,type:'eye',cc:'NC',pol:'open',share:.0003,up:['pft','tly'],col:'#E30613',pops:['nou'],ix:['nou'],blurb:tr('homegrown_eyeballs.new_caledonia_s_cable_operator_can')},
|
||||
{id:'ctv',name:'Can’t-V',asn:8048,type:'eye',cc:'VE',pol:'selective',minIx:2,minPni:10,share:.002,up:['tly','lvl'],col:'#0055A5',pops:['ccs','mia'],ix:['ccs'],blurb:tr('homegrown_eyeballs.venezuela_s_state_telco_can_t')},
|
||||
{id:'dcm',name:'Docomo Arigato',asn:9605,type:'eye',cc:'JP',pol:'selective',minIx:6,minPni:20,share:.008,up:['ntt'],col:'#CC0033',pops:['tok','osa','fuk'],ix:['tok','osa'],blurb:tr('homegrown_eyeballs.japan_s_biggest_mobile_network_bows')},
|
||||
{id:'djz',name:'Djezzy Does It',asn:327931,type:'eye',cc:'DZ',pol:'open',share:.002,up:['tly'],col:'#E2001A',pops:['alg'],ix:['alg'],blurb:tr('homegrown_eyeballs.algeria_s_biggest_mobile_network_easy')},
|
||||
{id:'dlg',name:'Inner Dialog',asn:18001,type:'eye',cc:'LK',pol:'open',share:.0015,up:['tat','ntt'],col:'#E5202E',pops:['cbo'],ix:['cbo'],blurb:tr('homegrown_eyeballs.sri_lanka_s_biggest_mobile_network_talks')},
|
||||
{id:'dna',name:'DNA Test Results',asn:16086,type:'eye',cc:'FI',pol:'open',share:.002,up:['tly'],col:'#FF4F00',pops:['hel'],ix:['hel'],blurb:tr('homegrown_eyeballs.finnish_broadband_and_mobile_it_s')},
|
||||
{id:'ele',name:'Für Elisa Eesti',asn:2586,type:'eye',cc:'EE',pol:'open',share:.0008,up:['els'],col:'#0068B4',pops:['tll'],ix:['tll'],blurb:tr('homegrown_eyeballs.fur_elisa_across_the_gulf_of')},
|
||||
{id:'els',name:'Für Elisa',asn:719,type:'eye',cc:'FI',pol:'selective',minIx:5,minPni:20,share:.003,up:['tly','cog'],col:'#0068B4',pops:['hel','sto'],ix:['hel'],blurb:tr('homegrown_eyeballs.finland_s_biggest_mobile_network_unlimited')},
|
||||
{id:'ent',name:'Entel-ligence',asn:6568,type:'eye',cc:'BO',pol:'selective',minIx:2,minPni:10,share:.0012,up:['tly','lvl'],col:'#0033A0',pops:['lpb'],ix:['lpb'],blurb:tr('homegrown_eyeballs.bolivia_s_state_telco_thinking_hard')},
|
||||
{id:'fet',name:'Far EasTone-Deaf',asn:9674,type:'eye',cc:'TW',pol:'selective',minIx:3,minPni:12,share:.003,up:['ntt'],col:'#E60012',pops:['tpe','hkg'],ix:['tpe'],blurb:tr('homegrown_eyeballs.taiwan_s_number_three_never_hears')},
|
||||
{id:'fre',name:'Free as in Beer',asn:12322,type:'eye',cc:'FR',pol:'selective',minIx:6,minPni:20,share:.006,up:['cog','lvl'],col:'#CD1E25',pops:['par','mrs','ams','lon','fra'],ix:['par','mrs'],blurb:tr('homegrown_eyeballs.the_challenger_that_made_french_broadband')},
|
||||
{id:'frs',name:'Yas Queen Sénégal',asn:37649,type:'eye',cc:'SN',pol:'open',share:.0008,up:['tat','tly'],col:'#FFD100',pops:['dkr'],ix:['dkr'],blurb:tr('homegrown_eyeballs.senegal_s_number_two_freshly_renamed')},
|
||||
{id:'glb',name:'Globe-Trotter Telecom',asn:4775,type:'eye',cc:'PH',pol:'selective',minIx:3,minPni:15,share:.006,up:['ntt','tat'],col:'#0056A2',pops:['mnl','hkg','sin'],ix:['hkg','sin'],blurb:tr('homegrown_eyeballs.the_philippines_other_mobile_giant_roaming')},
|
||||
{id:'gph',name:'Grameen Machine',asn:24389,type:'eye',cc:'BD',pol:'selective',minIx:3,minPni:12,share:.004,up:['tat','ntt'],col:'#19AAF8',pops:['dac','sin'],ix:['dac'],blurb:tr('homegrown_eyeballs.bangladesh_s_biggest_mobile_network_a')},
|
||||
{id:'hkb',name:'Ding-Ding Broadband',asn:9269,type:'eye',cc:'HK',pol:'open',share:.002,up:['ntt','cog'],col:'#6A2C91',pops:['hkg'],ix:['hkg'],blurb:tr('homegrown_eyeballs.fibre_to_every_tower_block_rung')},
|
||||
{id:'hkt',name:'Net-Vigour HK',asn:4760,type:'eye',cc:'HK',pol:'selective',minIx:5,minPni:20,share:.004,up:['ntt','tat'],col:'#00A0E1',pops:['hkg','sin','tok','lax'],ix:['hkg'],blurb:tr('homegrown_eyeballs.hong_kong_s_incumbent_broadband_full')},
|
||||
{id:'jaz',name:'All That Jazz',asn:45669,type:'eye',cc:'PK',pol:'selective',minIx:2,minPni:10,share:.004,up:['tat'],col:'#ED1C24',pops:['khi','dxb'],ix:['khi'],blurb:tr('homegrown_eyeballs.pakistan_s_biggest_mobile_network_improvising')},
|
||||
{id:'kpn',name:'Kay-Pea-Nuts',asn:1136,type:'eye',cc:'NL',pol:'selective',minIx:6,minPni:20,share:.005,up:['lvl','tly'],col:'#00C300',pops:['ams','fra','lon'],ix:['ams'],blurb:tr('homegrown_eyeballs.the_dutch_incumbent_peers_for_peanuts')},
|
||||
{id:'lfc',name:'Half-Life-cell',asn:34058,type:'eye',cc:'UA',pol:'open',share:.002,up:['cog','tly'],col:'#FFCC00',pops:['kyv','waw','fra'],ix:['kyv'],blurb:tr('homegrown_eyeballs.ukraine_s_third_mobile_network_kept')},
|
||||
{id:'lmt',name:'Let Me Talk',asn:12847,type:'eye',cc:'LV',pol:'selective',minIx:2,minPni:8,share:.0008,up:['tly'],col:'#4E2C82',pops:['rix','sto'],ix:['rix'],blurb:tr('homegrown_eyeballs.latvia_s_mobile_leader_let_me')},
|
||||
{id:'mca',name:'MT-Sea',asn:37009,type:'eye',cc:'NA',pol:'selective',minIx:1,minPni:8,share:.0005,up:['liq'],col:'#0067B1',pops:['wdh'],ix:['wdh'],blurb:tr('homegrown_eyeballs.namibia_s_mobile_network_lots_of')},
|
||||
{id:'mgt',name:'Magenta Paprika',asn:5483,type:'eye',cc:'HU',pol:'selective',minIx:4,minPni:15,share:.003,up:['dtk','tly'],col:'#E20074',pops:['bud','vie','fra'],ix:['bud'],blurb:tr('homegrown_eyeballs.doitsche_telekomm_s_hungarian_daughter_pink')},
|
||||
{id:'mob',name:'Mobily-zation',asn:35819,type:'eye',cc:'SA',pol:'selective',minIx:3,minPni:12,share:.004,up:['tat','tly'],col:'#00A7E1',pops:['ruh','jed','dxb','fra'],ix:['ruh'],blurb:tr('homegrown_eyeballs.the_kingdom_s_challenger_always_mobilising')},
|
||||
{id:'msc',name:'Mascot Wireless',asn:37014,type:'eye',cc:'BW',pol:'open',share:.0006,up:['liq'],col:'#008FD5',pops:['gbe'],ix:['gbe'],blurb:tr('homegrown_eyeballs.botswana_s_biggest_mobile_network_with')},
|
||||
{id:'mts',name:'Serve-ia Telekom',asn:8400,type:'eye',cc:'RS',pol:'selective',minIx:3,minPni:12,share:.003,up:['tly','cog'],col:'#E2001A',pops:['beg','fra','sof'],ix:[],blurb:tr('homegrown_eyeballs.serbia_s_incumbent_at_your_service')},
|
||||
{id:'mvc',name:'Movi-Sell',asn:37081,type:'eye',cc:'AO',pol:'open',share:.0008,up:['agc'],col:'#F7941D',pops:['lad'],ix:['lad'],blurb:tr('homegrown_eyeballs.angola_s_number_two_always_on')},
|
||||
{id:'mvt',name:'Movie-Tell',asn:37342,type:'eye',cc:'MZ',pol:'open',share:.0006,up:['liq'],col:'#E30613',pops:['mpm'],ix:['mpm'],blurb:tr('homegrown_eyeballs.mozambique_s_rural_mobile_network_towers')},
|
||||
{id:'nov',name:'Super-Nova hf.',asn:43571,type:'eye',cc:'IS',pol:'open',share:.0004,up:['tly','cog'],col:'#ED1F7F',pops:['rek'],ix:[],blurb:tr('homegrown_eyeballs.iceland_s_mobile_challenger_burning_bright')},
|
||||
{id:'nrl',name:'Northern Lights Out',asn:8273,type:'eye',cc:'DK',pol:'open',share:.002,up:['tly','cog'],col:'#00A651',pops:['cph','ebj'],ix:['cph'],blurb:tr('homegrown_eyeballs.danish_fibre_from_the_power_company')},
|
||||
{id:'omv',name:'Ooh-redoo Atolls',asn:55944,type:'eye',cc:'MV',pol:'open',share:.0003,up:['ord','tat'],col:'#ED1C24',pops:['mle'],ix:[],blurb:tr('homegrown_eyeballs.ooh_redoo_s_maldives_branch_four')},
|
||||
{id:'onz',name:'Won New Zealand',asn:4768,type:'eye',cc:'NZ',pol:'selective',minIx:3,minPni:12,share:.002,up:['ntt','tly'],col:'#E4002B',pops:['akl','chc','syd'],ix:['akl','chc'],blurb:tr('homegrown_eyeballs.new_zealand_s_number_two_renamed')},
|
||||
{id:'otn',name:'Ooh-redoo Tunisie',asn:37693,type:'eye',cc:'TN',pol:'open',share:.0012,up:['ord','tly'],col:'#ED1C24',pops:['tun','mrs'],ix:['tun'],blurb:tr('homegrown_eyeballs.ooh_redoo_s_tunisian_network_mint')},
|
||||
{id:'pmc',name:'Pal-O-Mine Mobile',asn:58932,type:'eye',cc:'PW',pol:'open',share:.0002,up:['ntt'],col:'#0099CC',pops:['ror'],ix:[],blurb:tr('homegrown_eyeballs.palau_s_mobile_challenger_your_pal')},
|
||||
{id:'prm',name:'Paradise Lost Mobile',asn:55159,type:'eye',cc:'BM',pol:'open',share:.0003,up:['lvl'],col:'#00B2A9',pops:['bda'],ix:[],blurb:tr('homegrown_eyeballs.bermuda_s_newest_mobile_network_the')},
|
||||
{id:'rob',name:'Robi-n Hood',asn:24432,type:'eye',cc:'BD',pol:'open',share:.002,up:['tat'],col:'#E2231A',pops:['dac'],ix:['dac'],blurb:tr('homegrown_eyeballs.takes_from_the_big_carriers_and')},
|
||||
{id:'slt',name:'SLT-and-Pepper',asn:9329,type:'eye',cc:'LK',pol:'selective',minIx:2,minPni:10,share:.0015,up:['tat'],col:'#0070C0',pops:['cbo','sin'],ix:['cbo'],blurb:tr('homegrown_eyeballs.sri_lanka_s_incumbent_adds_a')},
|
||||
{id:'smn',name:'Símon Says',asn:215793,type:'eye',cc:'IS',pol:'selective',minIx:1,minPni:8,share:.0006,up:['tly'],col:'#4A2B83',pops:['rek','lon'],ix:[],blurb:tr('homegrown_eyeballs.iceland_s_incumbent_when_simon_says')},
|
||||
{id:'sth',name:'StarHubble',asn:4657,type:'eye',cc:'SG',pol:'selective',minIx:4,minPni:15,share:.003,up:['ntt','tat'],col:'#68B030',pops:['sin','hkg'],ix:['sin'],blurb:tr('homegrown_eyeballs.singapore_s_number_two_with_a')},
|
||||
{id:'swc',name:'Swiss-Cheese-com',asn:3303,type:'eye',cc:'CH',pol:'selective',minIx:8,minPni:25,share:.004,up:['lvl','tly'],col:'#001155',pops:['zrh','fra'],ix:['zrh'],blurb:tr('homegrown_eyeballs.switzerland_s_incumbent_the_holes_in')},
|
||||
{id:'tcg',name:'Tele-Sell Ghana',asn:29614,type:'eye',cc:'GH',pol:'selective',minIx:2,minPni:10,share:.0015,up:['tat','tly'],col:'#E30613',pops:['acc','lag'],ix:['acc'],blurb:tr('homegrown_eyeballs.ghana_s_number_two_a_new')},
|
||||
{id:'tdc',name:'YouSee-Me-Now',asn:3292,type:'eye',cc:'DK',pol:'selective',minIx:5,minPni:20,share:.003,up:['tly'],col:'#0B2D71',pops:['cph','ebj','sto','ham'],ix:['cph'],blurb:tr('homegrown_eyeballs.denmark_s_incumbent_you_see_it')},
|
||||
{id:'tee',name:'Tell-Ya Eesti',asn:3249,type:'eye',cc:'EE',pol:'selective',minIx:3,minPni:12,share:.001,up:['tly'],col:'#990AE3',pops:['tll','hel','sto'],ix:['tll'],blurb:tr('homegrown_eyeballs.tell_ya_s_estonian_daughter_e')},
|
||||
{id:'tel',name:'Tell No One',asn:37204,type:'eye',cc:'ZW',pol:'selective',minIx:1,minPni:8,share:.0005,up:['liq'],col:'#0D4C92',pops:['hre'],ix:['hre'],blurb:tr('homegrown_eyeballs.zimbabwe_s_fixed_line_incumbent_what')},
|
||||
{id:'tfl',name:'Telecom Fidget',asn:45349,type:'eye',cc:'FJ',pol:'selective',minIx:1,minPni:8,share:.0004,up:['fnt','ntt'],col:'#00A3E0',pops:['suv'],ix:['suv'],blurb:tr('homegrown_eyeballs.fiji_s_fixed_line_incumbent_never')},
|
||||
{id:'tgd',name:'Tango-Down',asn:48526,type:'eye',cc:'LU',pol:'selective',minIx:2,minPni:8,share:.0005,up:['bgs'],col:'#FF6600',pops:['bet'],ix:['bet'],blurb:tr('homegrown_eyeballs.proxyminus_s_dancing_brand_in_luxembourg')},
|
||||
{id:'tlt',name:'Tele-Two-Many',asn:1257,type:'eye',cc:'SE',pol:'selective',minIx:4,minPni:15,share:.003,up:['tly','cog'],col:'#000000',pops:['sto','cph','osl'],ix:['sto'],blurb:tr('homegrown_eyeballs.sweden_s_challenger_that_took_on')},
|
||||
{id:'tnm',name:'Tele-Namib',asn:36996,type:'eye',cc:'NA',pol:'open',share:.0004,up:['liq','tat'],col:'#00529B',pops:['wdh'],ix:['wdh'],blurb:tr('homegrown_eyeballs.namibia_s_state_incumbent_wired_across')},
|
||||
{id:'utl',name:'Unitel-ly Yours',asn:37119,type:'eye',cc:'AO',pol:'selective',minIx:3,minPni:12,share:.002,up:['agc'],col:'#F28C00',pops:['lad','lis'],ix:['lad'],blurb:tr('homegrown_eyeballs.angola_s_mobile_giant_sincerely_yours')},
|
||||
{id:'utp',name:'Unitel T-Plus-Plus',asn:37575,type:'eye',cc:'CV',pol:'open',share:.0003,up:['cvt','tat'],col:'#F28C00',pops:['rai'],ix:['rai'],blurb:tr('homegrown_eyeballs.cape_verde_s_challenger_one_more')},
|
||||
{id:'vin',name:'Vini Vidi Vici',asn:9471,type:'eye',cc:'PF',pol:'open',share:.0003,up:['pft','tly'],col:'#E2001A',pops:['ppt'],ix:[],blurb:tr('homegrown_eyeballs.french_polynesia_s_mobile_network_came')},
|
||||
{id:'vnp',name:'VNPT (Very Nice Packet Times)',asn:45899,type:'eye',cc:'VN',pol:'selective',minIx:3,minPni:12,share:.004,up:['ntt','tat'],col:'#0066B3',pops:['sgn','hkg','sin'],ix:['sgn'],blurb:tr('homegrown_eyeballs.vietnam_s_posts_and_telecoms_giant')},
|
||||
{id:'vvc',name:'Viva la Vidacom',asn:8866,type:'eye',cc:'BG',pol:'selective',minIx:4,minPni:15,share:.002,up:['tly','cog'],col:'#E2001A',pops:['sof','fra'],ix:['sof'],blurb:tr('homegrown_eyeballs.bulgaria_s_incumbent_living_la_vida')},
|
||||
{id:'yet',name:'Not Yettel',asn:31042,type:'eye',cc:'RS',pol:'open',share:.0015,up:['tly'],col:'#B4FF00',pops:['beg'],ix:[],blurb:tr('homegrown_eyeballs.the_mobile_network_formerly_known_as')});
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
(far), so it never undercuts the locals there. Sits before 40-traffic-shares.js, which indexes NETS. */
|
||||
const GSL_POPS=['adl','akl','ams','bne','bom','chi','dal','fra','hkg','icn','ist','jkt','lax','lon','mel','mia','mil','mnl','nyc','osa','par','per','phx','sin','syd','tok','waw'];
|
||||
NETS.push(
|
||||
{id:'gsl',name:'Glowball Sakura Lager',asn:137409,type:'t2',pol:'open',up:['lvl','cog','ntt'],share:.02,price:5,far:{AS:1.6,OC:2},col:'#C94F7C',auIx:['syd','mel','bne','per'],pops:GSL_POPS,ix:GSL_POPS,blurb:tr('glowball_sakura_lager.on_tap_in_the_big_hubs')});
|
||||
{id:'gsl',name:'Glowball Sakura Lager',asn:137409,type:'t2',pol:'open',up:['lvl','cog','ntt'],share:.02,price:5,far:{AS:1.6,OC:2},col:'#C94F7C',auIx:['syd','mel','bne','per'],pops:GSL_POPS,ix:GSL_POPS.filter(c=>CITY[c].ix),blurb:tr('glowball_sakura_lager.on_tap_in_the_big_hubs')});
|
||||
/* Its downstreams: networks that buy their transit from it, so a PNI with it reaches them too. Only where it has
|
||||
PoPs itself, and no Australians: a PNI with it is no back door into Australia. One per line, sorted within each. */
|
||||
const GSL_DOWN=[
|
||||
|
|
|
|||
|
|
@ -1,6 +1,24 @@
|
|||
const NET=Object.fromEntries(NETS.map(n=>[n.id,n])),NET_IDS=NETS.map(n=>n.id);
|
||||
// The networks a PNI with each upstream reaches: the upstream itself plus everyone who buys transit from it.
|
||||
const PNI_NETS={};for(const n of NETS)PNI_NETS[n.id]=[n.id].concat(NETS.filter(x=>x.up&&x.up.includes(n.id)).map(x=>x.id));
|
||||
/* Customer cones (#85): a network announces to its peers itself and everyone who buys transit from it, and their
|
||||
customers in turn. So a PNI or a session with a network reaches its whole cone, and peering with every Tier 1 brings
|
||||
their customers along. Built once at load: CONE[id] lists the network first, then its cone; CONE_S is the same as a
|
||||
Set, and DOWN[id] holds the cone without the network itself (empty for most). */
|
||||
/* Who buys from whom follows the real networks' upstreams (bgp.he.net, CAIDA AS Rank, Oct 2026). Added in 2.0: Kyiv
|
||||
Superstar (Cogentle, Tell-Ya), Ooh-redoo and Du-opoly (Ta-Ta, Tell-Ya), Safari-Comic (Cogentle, Level Tree, Sea-Comedy),
|
||||
PLDTea Time (Not That, Ta-Ta), TIM-Tam (its sibling Sparkly Seabone), Floptus (its parent SingTell), Sky-High and
|
||||
Tele-Nor-Way (Tell-Ya, Level Tree), Virgin Mediocre (Level Tree, Not That), and the long tail (tailUp()). The rest stay
|
||||
islands because they are too: the content giants, the transit-free incumbents (Doitsche, Comecast, Jio-graphy, Bee-Tee),
|
||||
China and Korea, and Australia's big ISPs, which buy only from Australian carriers. Smaller Australians do sit in Tier 1
|
||||
cones: Kangaroo Courier buys from Cogentle, Doodoo and Spin2wintel from Hocus Pocus (Not That, Tell-Ya), Lintel from
|
||||
Speedyloop (Tell-Ya). */
|
||||
const CONE={},CONE_S={},DOWN={};
|
||||
{const dn={};for(const n of NETS)for(const u of n.up||[])(dn[u]||(dn[u]=[])).push(n.id);
|
||||
for(const n of NETS){const s=new Set([n.id]),q=[n.id];while(q.length){for(const y of dn[q.pop()]||[])if(!s.has(y)){s.add(y);q.push(y);}}
|
||||
CONE[n.id]=[...s];CONE_S[n.id]=s;DOWN[n.id]=CONE[n.id].slice(1);}}
|
||||
// ANC[id]: every network whose cone holds it, nearest upstream first (who brings it along, for the panels).
|
||||
const ANC={};for(const n of NETS){const o=[],q=(n.up||[]).slice();while(q.length){const u=q.shift();if(o.includes(u)||!NETS.some(x=>x.id===u))continue;o.push(u);q.push(...(NETS.find(x=>x.id===u).up||[]));}ANC[n.id]=o;}
|
||||
// The networks a PNI with each network reaches: its customer cone. CONE_RANK: where routing tries a peer's cone.
|
||||
const PNI_NETS=CONE,CONE_RANK=2.5;
|
||||
for(const X of XIX){X.members=NETS.filter(n=>Array.isArray(n.ix)&&n.ix.includes(X.id)||!n.tail&&(X.core?X.core.includes(n.id):(n.ix==='ALL'||Array.isArray(n.ix)&&n.ix.includes(X.c))&&hstr(n.id+'|'+X.id)%100<(n.ix==='ALL'?72:X.take*100))).map(n=>n.id);}
|
||||
const NSH={}; {const t=NETS.reduce((a,n)=>a+n.share,0); NETS.forEach(n=>NSH[n.id]=n.share/t);}
|
||||
// After Glitch leaves Korea, Seoul viewers watch half as much of it and the rest moves to everyone else.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* ================= BUSINESSES ================= */
|
||||
const BIZ_T={
|
||||
dia:{l:tr('common.enterprise_dia'),opts:[1,2,5,10],rate:600},
|
||||
game:{l:tr('common.game_servers'),opts:[5,10,20,40],rate:120},
|
||||
game:{l:tr('common.game_servers'),gaming:true,opts:[5,10,20,40],rate:120},
|
||||
host:{l:tr('common.hosting'),opts:[10,20,40,80],rate:60},
|
||||
isp:{l:tr('businesses.downstream_isp_buys_transit'),opts:[100,200,400,800],rate:15,lv:2},
|
||||
l2vpn:{l:tr('common.l2vpn_circuit'),opts:[1,10,40,100],rate:0,l2:true,km:1,lv:1},
|
||||
|
|
@ -26,7 +26,7 @@ const BIZ_T={
|
|||
pairs:{l:tr('businesses.hundreds_of_fiber_pairs'),opts:[1],rate:0,fiber:true,mega:true,lv:4,names:['A Hyperscaler Who Shall Not Be Named','Planet-Scale AI WAN Team','The Fiber-Hungry Giant','Project Very Long Glass']},
|
||||
esport:{l:tr('businesses.esports_world_final'),opts:[400,800,1600,3200],rate:0,event:true,lv:5,names:['League of Lag Finals','Counter-Ping Major','Fortnightly World Cup','Dota Two Many Viewers','Rocket Leak Championship','Street Frighter Evo']},
|
||||
sov:{l:tr('businesses.sovereign_cloud_region'),opts:[400,800,1600],rate:0,l2:true,div:true,km:0.6,lv:6,names:['Gaia-Ex Sovereign Cloud','Bundeswolke (Very Secure)','Le Cloud Souverain','Datenschutz Deluxe','Your Data Stays Here, Probably','A Cloud With a Flag on It','Data Residency Is a State of Mind']},
|
||||
cgame:{l:tr('businesses.cloud_gaming_platform'),opts:[800,1600,3200],rate:45,lv:8,names:['Stadia-ium (Back Again)','GeForce Later','Ping Station Now','Luna-tick Gaming','Shadow of a Doubt Cloud PC','Input Lag Arcade','Bufferbloat Bros. Streaming']},
|
||||
cgame:{l:tr('businesses.cloud_gaming_platform'),gaming:true,opts:[800,1600,3200],rate:45,lv:8,names:['Stadia-ium (Back Again)','GeForce Later','Ping Station Now','Luna-tick Gaming','Shadow of a Doubt Cloud PC','Input Lag Arcade','Bufferbloat Bros. Streaming']},
|
||||
metav:{l:tr('common.metaverse_platform'),opts:[1600,3200,6400],rate:35,lv:9,names:['Meh-taverse','Second Second Life','Horizon Worlds Apart','The Oasis (Ready Player Done)','Legs Finally Shipped Inc.','Decentra-landlocked']},
|
||||
agi:{l:tr('businesses.agi_lab_allegedly'),opts:[12800,25600],rate:0,l2:true,div:true,mega:true,km:0.4,lv:11,names:['Almost General Intelligence Inc.','Superintelligence Pending','The Lab That Said Two More Years','Paperclip Maximizer Labs','Deep Thought Two','Benevolent Overlord Research']},
|
||||
mars:{l:tr('businesses.mars_mission_ground_station'),opts:[100,200,400],rate:0,l2:true,lat:true,km:4,lv:13,names:['Red Planet Relay','Ares Ground Segment','Olympus Mons Uplink','Mars or Bust Mission Control','Interplanetary Ping Society','Light-Minute Logistics','RFC 1149 Avian Carriers (Mars Division)']},
|
||||
|
|
@ -50,7 +50,8 @@ const LEVELS=[
|
|||
// What each level asks for (peak Gbps, POPs, continents). Continents carry over to the levels above.
|
||||
const LV_REQ=[null,{pk:200,pops:3},{pk:1000,pops:6},{pk:3000,pops:10,reg:3},{pk:6000,pops:15,reg:4},{pk:9000,pops:20},{pk:12000,pops:25,reg:5},{pk:16000,pops:32},{pk:21000,pops:40,reg:6},{pk:26000,pops:50},{pk:33000,pops:60},{pk:40000,pops:70},{pk:50000,pops:80}];
|
||||
const lvReg=i=>Math.max(0,...LV_REQ.slice(1,i+1).map(q=>q.reg||0));
|
||||
const lvl=()=>(S&&S.lvl)||1;
|
||||
// Open gates (sandbox, puzzles): every level's unlocks are there from the start.
|
||||
const lvl=()=>S&&S.rules&&S.rules.gates==='open'?LEVELS.length:(S&&S.lvl)||1;
|
||||
// Lower-case just the first word for mid-sentence use, so names like Tel-Mess or AGI keep their capitals.
|
||||
const lc1=t=>/^[A-Z][a-z]/.test(t)?t[0].toLowerCase()+t.slice(1):t;
|
||||
function custLevel(){const pops=Object.keys(S.pops).length,pk=S.stats.peak,rc=regionsCount();let lv=1;for(let i=1;i<LV_REQ.length;i++){const q=LV_REQ[i];if(pk>=q.pk&&pops>=q.pops&&rc>=lvReg(i))lv=i+1;else break;}return lv;}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ const GOALS=[
|
|||
{id:'c5',t:tr('common.five_continents'),d:tr('goals.pops_in_five_of_the_six'),r:100000,ok:()=>regionsCount()>=5},
|
||||
{id:'gi',t:tr('goals.sign_a_giant'),d:tr('goals.land_an_ai_wan_a_multi'),r:150000,ok:()=>S.biz.some(b=>BIZ_T[b.type]&&BIZ_T[b.type].mega&&!BIZ_T[b.type].event)},
|
||||
{id:'t10',t:tr('goals.serve_10_tbps'),d:tr('goals.ten_terabits_per_second_of_happy'),r:250000,ok:()=>R.served>=10000},
|
||||
{id:'t1',t:tr('common.go_transit_free_tier_1'),d:tr('goals.peer_with_every_tier_1_over'),r:0,win:true,ok:()=>isTier1()},
|
||||
{id:'t1',t:tr('common.go_transit_free_tier_1'),d:tr('goals.peer_with_every_tier_1_their_customers'),r:0,win:true,ok:()=>isTier1()},
|
||||
];
|
||||
|
||||
|
|
|
|||
48
src/game/40-progress/30-rules.js
Normal file
48
src/game/40-progress/30-rules.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/* ---------- The ruleset: one game, many doors ----------
|
||||
Every network carries its own rules (S.rules), picked when it starts and locked from then on. Modes are presets of
|
||||
these rules, not separate code: Normal comes as Change Freeze, On-call (the classic game) and BGP at 3 a.m.;
|
||||
Sandbox and Puzzles are presets too. Saves without rules load as On-call, so nothing changes for them.
|
||||
Scenarios and the weekly challenge run on On-call plus their own S.scn.rules (scnRule()). */
|
||||
const RULE_DEF={clock:true,chaos:'normal',lead:'real',market:true,money:'normal',gates:'ladder',mods:[]};
|
||||
const RULE_OK={clock:[true,false],chaos:['none','calm','normal','spicy'],lead:['real','quick'],market:[true,false],money:['normal','infinite'],gates:['ladder','open']};
|
||||
// i: icon, n: name, d: the one-line joke, x: what is different, in small print.
|
||||
const PRESETS={
|
||||
freeze:{i:'🧊',n:tr('rules.change_freeze'),d:tr('rules.nobody_touches_prod_even_the_backhoes'),x:tr('rules.a_third_of_the_outages_no_ddos_pnis'),clock:true,chaos:'calm',lead:'quick',market:false,money:'normal',gates:'ladder'},
|
||||
oncall:{i:'📟',n:tr('rules.on_call'),d:tr('rules.the_real_thing_your_pager_has'),x:tr('rules.real_lead_times_real_outages_a_real'),clock:true,chaos:'normal',lead:'real',market:true,money:'normal',gates:'ladder'},
|
||||
bgp:{i:'🔥',n:tr('rules.bgp_at_3_a_m'),d:tr('rules.everything_is_on_fire_and_it'),x:tr('rules.more_and_longer_outages_more_ddos'),clock:true,chaos:'spicy',lead:'real',market:true,money:'normal',gates:'ladder'},
|
||||
sandbox:{i:'🏖️',n:tr('common.sandbox'),d:tr('rules.a_billion_dollars_every_unlock_your'),x:tr('rules.infinite_money_everything_unlocked_quick'),clock:true,chaos:'none',lead:'quick',market:true,money:'infinite',gates:'open'},
|
||||
puzzle:{i:'🧩',n:tr('rules.puzzle'),d:tr('rules.one_small_network_one_tricky_goal'),x:tr('rules.no_clock_no_bills_nothing_breaks'),clock:false,chaos:'none',lead:'quick',market:false,money:'normal',gates:'open'},
|
||||
};
|
||||
const NORMAL_PRESETS=['freeze','oncall','bgp'];
|
||||
// How often things break, against the classic game. Spicy outages also last half as long again.
|
||||
const CHAOS={none:{i:'😴',n:tr('rules.chaos_none'),d:tr('rules.nothing_ever_breaks'),m:0},calm:{i:'🧊',n:tr('rules.chaos_calm'),d:tr('rules.a_cut_now_and_then'),m:0.35},normal:{i:'📟',n:tr('rules.chaos_normal'),d:tr('rules.like_the_real_game'),m:1},spicy:{i:'🔥',n:tr('rules.chaos_spicy'),d:tr('rules.your_pager_never_sleeps'),m:1.8}};
|
||||
const SPICY_LONG=1.5,LEAD_QUICK=10;
|
||||
function rule(k){const r=S&&S.rules;return r&&r[k]!==undefined?r[k]:RULE_DEF[k];}
|
||||
function rulePreset(){const p=S&&S.rules&&S.rules.preset;return p&&Object.prototype.hasOwnProperty.call(PRESETS,p)?p:'oncall';}
|
||||
function gatesOpen(){return rule('gates')==='open';}
|
||||
function chaosMul(){const c=CHAOS[rule('chaos')];return c?c.m:1;}
|
||||
// Days until something ordered arrives: as quoted, or a tenth of it (at least a day) with quick lead times.
|
||||
function leadDays(n){return rule('lead')==='quick'?Math.max(1,Math.round(n/LEAD_QUICK)):n;}
|
||||
// A fresh, valid rules object: the preset's values, with any valid overrides on top.
|
||||
function makeRules(preset,o){const p=Object.prototype.hasOwnProperty.call(PRESETS,preset)?preset:'oncall',P=PRESETS[p],r={preset:p};o=o&&typeof o==='object'?o:{};
|
||||
for(const k of Object.keys(RULE_OK)){const d=P[k]!==undefined?P[k]:RULE_DEF[k];r[k]=RULE_OK[k].includes(o[k])?o[k]:d;}
|
||||
r.mods=Array.isArray(o.mods)?[...new Set(o.mods.filter(m=>typeof m==='string'&&/^[a-z0-9_-]{1,24}$/.test(m)))].slice(0,16):[];
|
||||
return r;}
|
||||
// What the HUD and the share card say about the rules. On-call says nothing: it is the game.
|
||||
function ruleTag(){const p=rulePreset();if(S&&S.mode==='sandbox'){const c=CHAOS[rule('chaos')];return tr('common.sandbox')+(c&&rule('chaos')!=='none'?' '+c.i:'');}
|
||||
return p==='oncall'||p==='sandbox'?'':PRESETS[p].i+' '+PRESETS[p].n;}
|
||||
/* Spicy outages last longer: stretch a fresh incident by half, and exactly what it holds down (found by its ref, as
|
||||
clearInc() finds it), never something else that happens to end the same day. */
|
||||
function stretchInc(i){if(rule('chaos')!=='spicy'||!i||!(i.until>S.day)||i.start!==S.day)return;const U=i.until,V=S.day+Math.ceil((U-S.day)*SPICY_LONG);if(V===U)return;i.until=V;
|
||||
const f=(o,k)=>{if(o&&o[k]===U)o[k]=V;},E=S.ev,T=i.type,r=i.ref,L=()=>S.links.find(l=>l.id===r);
|
||||
if(T==='cut'||T==='redsea'){for(const l of S.links)if((l.trench||l.id)===r)f(l,'cut');}
|
||||
else if(T==='fatwave'||T==='label')f(L(),'cut');
|
||||
else if(T==='ctrlplane'){for(const id of Array.isArray(i.links)?i.links:[])f(S.links.find(l=>l.id===id),'cut');}
|
||||
else if(T==='amp'||T==='roadmff')f(L(),'eqDown');else if(T==='mtu')f(L(),'deg');else if(T==='loss')f(L()?.loss,'until');else if(T==='optic')f(L()?.chFail,'until');
|
||||
else if(['crash','power','oops','cleaner','maint','shutdown'].includes(T))f(S.pops[r],'down');
|
||||
else if(T==='ring')f(S.pops[r],'ringcut');else if(T==='ac')f(S.pops[r],'hot');
|
||||
else if(T==='transit'||T==='prepend')f(S.transit.find(t=>t.id===r),'down');
|
||||
else if(T==='ixloop'&&E.ixdown)f(E.ixdown,r);else if(T==='fabric'&&E.fab)f(E.fab,r);
|
||||
else if(T==='lacp'){const [k,...x]=String(r).split(':'),id=x.join(':');f(k==='ix'?E.ixlacp&&E.ixlacp[id]:(k==='t'?S.transit:S.pni).find(o=>o.id===id)?.lacp,'until');}
|
||||
else if(T==='rpki'||T==='hijack')f(E.rpki,'until');else if(T==='leak'||T==='pmtud')f(E[T],'until');else if(T==='krroute'||T==='depeer')f(E,T);
|
||||
else if(T==='ddos')f(ddosAll(S,false).find(a=>a.id===i.atk),'until');}
|
||||
|
|
@ -2,4 +2,4 @@
|
|||
let S=null, R=emptyR();
|
||||
const UI={sel:null,tab:'cust',left:'goals',speed:1,hover:null,drag:null,snap:null,pending:null,confirm:null,leftOpen:false,muted:false,startCity:'fra',hintOff:false};
|
||||
let uidN=1; const uid=()=>'i'+(Date.now()%1e7).toString(36)+(uidN++);
|
||||
function emptyR(){return {nt:{},reachNT:0,teBlack:0,tNet:{},egT:{},netEg:{},l2lat:{},nodeLoad:{},nodeCap:{},div:{},l2:{},gfwLost:0,gfwCross:0,ef:{},egDesc:{},p95:{},peered:0,peerShare:0,load:{},useT:{},useIx:{},usePni:{},useCache:{},cityDem:{},citySrv:{},cityEye:{},latF:{},latFar:{},demTo:{},served:0,demand:0,reach:0,sessions:0,revMo:0,costMo:0,cost:{},rev:{},reachable:{}};}
|
||||
function emptyR(){return {nt:{},cone:{},reachNT:0,teBlack:0,tNet:{},egT:{},netEg:{},l2lat:{},nodeLoad:{},nodeCap:{},div:{},l2:{},gfwLost:0,gfwCross:0,ef:{},egDesc:{},p95:{},peered:0,peerShare:0,load:{},useT:{},useIx:{},usePni:{},useCache:{},cityDem:{},citySrv:{},cityEye:{},latF:{},latFar:{},demTo:{},served:0,demand:0,reach:0,sessions:0,revMo:0,costMo:0,cost:{},rev:{},reachable:{}};}
|
||||
|
|
|
|||
|
|
@ -2,41 +2,56 @@
|
|||
gives the same world. Free play keeps using the browser's Math.random. */
|
||||
const _rand=Math.random;
|
||||
Math.random=function(){if(S&&typeof S.rng==='number'){let t=(S.rng=(S.rng+0x6D2B79F5)|0);t=Math.imul(t^t>>>15,1|t);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;}return _rand();};
|
||||
function isoWeek(dt){const d=new Date(Date.UTC(dt.getFullYear(),dt.getMonth(),dt.getDate()));const n=d.getUTCDay()||7;d.setUTCDate(d.getUTCDate()+4-n);const y0=new Date(Date.UTC(d.getUTCFullYear(),0,1));return {y:d.getUTCFullYear(),w:Math.ceil(((d-y0)/864e5+1)/7)};}
|
||||
const hopG=l=>l.kind==='vxc'?(VXC[l.vt]||VXC[0]).g:l.kind==='df'?Math.max(0,...(l.ch||[]).map(c=>optG(c,l))):LT[l.tier].g;
|
||||
function fastPath(a,b,g){if(!S.pops[a]||!S.pops[b])return false;const adj={};for(const l of S.links){if(linkDown(l)||hopG(l)<g)continue;(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;}
|
||||
function pathExists(a,b){if(!S.pops[a]||!S.pops[b])return false;const adj={};for(const l of S.links){if(linkDown(l))continue;(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;}
|
||||
// Looked up rather than read from the save, so it follows a language switch mid-scenario.
|
||||
const scnName=()=>S.scn.id==='weekly'?tr('scenarios.weekly_key',{key:S.scn.key}):SCN.find(x=>x.id===S.scn.id)?.n||S.scn.name;
|
||||
const scnName=()=>S.scn.wk?wsTxt(S.scn.wk.name):S.scn.id==='weekly'?tr('scenarios.weekly_key',{key:S.scn.key}):SCN.find(x=>x.id===S.scn.id)?.n||S.scn.name;
|
||||
const AU_BB=['syd','mel','bne','adl','per'],auExits=()=>new Set(S.links.filter(l=>l.sub&&!!CITY[l.a].au!==!!CITY[l.b].au&&!(l.ready>S.day)).map(l=>l.cable||l.id)).size;
|
||||
const brIxN=()=>CITIES.filter(c=>c.br&&S.ixp[c.id]!==undefined).length;
|
||||
// Ports count only on POPs your backbone joins to São Paulo: islands of POPs with a port each skipped the Amazon (playtest).
|
||||
const FTTB_G=500;
|
||||
// Gangnam Style Peering: traffic, how well Seoul is served (delivered and fast) and a monthly profit.
|
||||
const GN_G=700,GN_Q=0.92;
|
||||
const brIxN=()=>CITIES.filter(c=>c.br&&S.ixp[c.id]!==undefined&&(c.id==='sao'||pathExists('sao',c.id))).length;
|
||||
// Days and cash were tuned in the 2.0.0 playtest (tests/scenarios-playtest.test.js): a reference player wins each one in
|
||||
// roughly a fifth to a half of its days, and the obvious shortcut does not win. The 1.6T scenarios start with enough cash to
|
||||
// build the whole chain on day 0 and still last until the traffic goal.
|
||||
const SCN=[
|
||||
{id:'stg',n:tr('scenarios.only_spatzle_ix'),city:'stg',cash:400000,days:730,rules:{noTransit:true,local:true},d:tr('scenarios.start_in_stuttgart_where_nobody'),goal:tr('scenarios.reach_45_of_the_internet_and'),ok:()=>R.reach>=0.45&&R.served>=300},
|
||||
{id:'redsea',n:tr('scenarios.red_sea_crisis'),city:'mrs',cash:2500000,days:540,rules:{banCities:['cai','jed'],banPairs:['eig:dxb-mrs','gbi:fuj-mrs','smw4:khi-mrs','smw6:mrs-bom','smw6:mrs-sin','peace:mrs-sin','aae:mrs-hkg','twoaf:mrs-bom','medn:cai-mrs','medn:ist-mrs','twoaf:jnb-mrs','eassy:nbo-mrs']},d:tr('scenarios.every_cable_through_the_red_sea'),goal:tr('scenarios.a_path_from_marseille_to_singapore'),ok:()=>pathExists('mrs','sin')&&(S.stats.asiaRun||0)>=RS_DAYS},
|
||||
{id:'spat',n:tr('scenarios.the_cogentle_spat'),city:'nyc',cash:700000,days:540,rules:{spat:true},d:tr('scenarios.cogentle_and_goggle_are_not_speaking'),goal:tr('scenarios.99_reach_and_150_gbps_served'),ok:()=>R.reach>=0.99&&R.served>=150},
|
||||
{id:'stg',n:tr('scenarios.only_spatzle_ix'),city:'stg',cash:400000,days:365,rules:{noTransit:true,local:true},d:tr('scenarios.start_in_stuttgart_where_nobody'),goal:tr('scenarios.reach_50_of_the_internet_and'),ok:()=>R.reach>=0.5&&R.served>=300},
|
||||
{id:'redsea',n:tr('scenarios.red_sea_crisis'),city:'mrs',cash:2500000,days:365,rules:{banCities:['cai','jed'],banPairs:['eig:dxb-mrs','gbi:fuj-mrs','smw4:khi-mrs','smw6:mrs-bom','smw6:mrs-sin','peace:mrs-sin','aae:mrs-hkg','twoaf:mrs-bom','medn:cai-mrs','medn:ist-mrs','twoaf:jnb-mrs','eassy:nbo-mrs']},d:tr('scenarios.every_cable_through_the_red_sea'),goal:tr('scenarios.a_path_from_marseille_to_singapore'),ok:()=>pathExists('mrs','sin')&&(S.stats.asiaRun||0)>=RS_DAYS},
|
||||
{id:'spat',n:tr('scenarios.the_cogentle_spat'),city:'nyc',cash:700000,days:240,rules:{spat:true},d:tr('scenarios.cogentle_and_goggle_are_not_speaking'),goal:tr('scenarios.99_reach_and_150_gbps_served'),ok:()=>R.reach>=0.99&&R.served>=150},
|
||||
{id:'carnaval',n:tr('common.carnaval'),city:'rio',cash:600000,days:100,rules:{},setup:()=>{S.biz.push({id:uid(),scripted:true,city:'rio',city2:null,reqs:[],name:'Carnaval Parade in Rio de Janeiro',type:'event',bw:400,rate:0,mood:100,since:0,start:90,dur:5,fee:400*5*70});},d:tr('scenarios.rio_from_scratch_carnaval_starts_in'),goal:tr('scenarios.deliver_carnaval_in_full'),ok:()=>(S.stats.evFull||0)>=1},
|
||||
{id:'darien',n:tr('common.mind_the_gap'),city:'pan',cash:900000,days:730,rules:{},d:tr('scenarios.start_in_panama_city_nothing_crosses'),goal:tr('scenarios.pops_in_bogota_lima_santiago_and'),ok:()=>['bog','lim','scl','sao'].every(c=>S.pops[c])&&R.served>=150},
|
||||
{id:'c2c',n:tr('scenarios.cape_to_cairo'),city:'cpt',cash:2000000,days:1095,rules:{},d:tr('scenarios.cape_town_build_a_network_across'),goal:tr('scenarios.a_path_from_cape_town_to'),ok:()=>pathExists('cpt','cai')&&S.pops.lag&&S.pops.nbo&&R.served>=150},
|
||||
{id:'ixbr',n:tr('scenarios.order_and_progress'),city:'sao',cash:2500000,days:1095,rules:{},d:tr('scenarios.sao_paulo_brazil_is_a_continent'),goal:tr('scenarios.ports_on_15_ix_brrr_exchanges'),ok:()=>brIxN()>=15&&S.ixp.mao!==undefined&&R.served>=200},
|
||||
{id:'gangnam',n:tr('scenarios.gangnam_style_peering'),city:'icn',cash:900000,days:365,rules:{},d:tr('scenarios.seoul_the_fastest_hungriest_eyeballs'),goal:tr('scenarios.99_reach_and_200_gbps_served'),ok:()=>R.reach>=0.99&&R.served>=200},
|
||||
// Connected, not just present: four island POPs with local transit won on day 40 without crossing anything (playtest).
|
||||
{id:'darien',n:tr('common.mind_the_gap'),city:'pan',cash:900000,days:180,rules:{},d:tr('scenarios.start_in_panama_city_nothing_crosses'),goal:tr('scenarios.connect_panama_city_to_bogota_lima'),ok:()=>['bog','lim','scl','sao'].every(c=>pathExists('pan',c))&&R.served>=150},
|
||||
// Lagos and Nairobi on the network too: one long wave to Cairo plus two empty POPs was not a network across Africa.
|
||||
{id:'c2c',n:tr('scenarios.cape_to_cairo'),city:'cpt',cash:2000000,days:365,rules:{},d:tr('scenarios.cape_town_build_a_network_across'),goal:tr('scenarios.a_path_from_cape_town_to_cairo_lagos'),ok:()=>pathExists('cpt','cai')&&pathExists('cpt','lag')&&pathExists('cpt','nbo')&&R.served>=150},
|
||||
{id:'ixbr',n:tr('scenarios.order_and_progress'),city:'sao',cash:600000,days:240,rules:{},d:tr('scenarios.sao_paulo_brazil_is_a_continent'),goal:tr('scenarios.ports_on_15_ix_brrr_exchanges_backbone'),ok:()=>brIxN()>=15&&S.ixp.mao!==undefined&&R.served>=200},
|
||||
// Sender pays, turned up: with Korea at the usual prices broadband swamped every bill and Seoul alone won on day 73
|
||||
// (playtest). Now Seoul transit is dear, the incumbents want a paid PNI and Korean users mind every far exit.
|
||||
{id:'gangnam',n:tr('scenarios.gangnam_style_peering'),city:'icn',cash:900000,days:240,rules:{sender:true},d:tr('scenarios.seoul_sender_pays_d'),goal:tr('scenarios.seoul_sender_pays_goal',{g:GN_G,q:Math.round(GN_Q*100)}),ok:()=>R.reach>=0.99&&R.served>=GN_G&&sfOf(R,'icn')>=GN_Q&&R.revMo>=R.costMo},
|
||||
{id:'flood',n:tr('common.flood_season'),city:'ams',cash:2000000,days:365,rules:{ddos:true},setup:()=>{S.lvl=Math.max(S.lvl||1,3);},d:tr('scenarios.amsterdam_hosting_capital_of_europe'),goal:tr('scenarios.hold_20_floods_5_of_them'),ok:()=>(S.stats.ddosOk||0)>=20&&(S.stats.ddosOkBig||0)>=5},
|
||||
{id:'fttb',n:tr('scenarios.fibre_to_the_basement'),city:'syd',cash:1500000,days:730,rules:{levy:true},d:tr('scenarios.sydney_2013_the_toilet_paper_group'),goal:tr('scenarios.broadband_in_sydney_melbourne'),ok:()=>AU_BB.every(c=>S.pops[c]&&S.pops[c].bb)&&auExits()>=2},
|
||||
{id:'baltic',n:tr('common.anchors_away'),city:'tll',cash:500000,days:540,rules:{anchors:3},d:tr('scenarios.tallinn_ships_drag_their_anchors'),goal:tr('scenarios.90_days_in_a_row_with'),ok:()=>(S.stats.clean||0)>=90},
|
||||
{id:'pac',n:tr('common.stepping_stones'),city:'hnl',cash:3000000,days:1095,rules:{},setup:()=>{S.lvl=Math.max(S.lvl||1,4);},d:tr('scenarios.honolulu_in_the_middle_of_the'),goal:tr('scenarios.a_path_from_los_angeles_to'),ok:()=>fastPath('lax','syd',1600)&&pathExists('lax','tok')&&R.served>=150},
|
||||
{id:'atl',n:tr('scenarios.mid_atlantic_accent'),city:'pdl',cash:3000000,days:1095,rules:{},setup:()=>{S.lvl=Math.max(S.lvl||1,4);},d:tr('scenarios.ponta_delgada_in_the_azores_halfway'),goal:tr('scenarios.1_6t_on_every_hop_from'),ok:()=>fastPath('mia','mad',1600)&&fastPath('lis','lag',1600)&&R.served>=100},
|
||||
// Traffic served too: broadband in five cities and two cables were bought on day 1 and won on day 2 (playtest).
|
||||
{id:'fttb',n:tr('scenarios.fibre_to_the_basement'),city:'syd',cash:1500000,days:365,rules:{levy:true},d:tr('scenarios.sydney_2013_the_toilet_paper_group'),goal:tr('scenarios.broadband_in_sydney_melbourne_served'),ok:()=>AU_BB.every(c=>S.pops[c]&&S.pops[c].bb)&&auExits()>=2&&R.served>=FTTB_G},
|
||||
// Nobody sells transit in Tallinn here: with local transit, a network that never crossed the water won (playtest).
|
||||
{id:'baltic',n:tr('common.anchors_away'),city:'tll',cash:500000,days:365,rules:{anchors:3,noTransitIn:['tll']},d:tr('scenarios.tallinn_nobody_sells_transit_anchors'),goal:tr('scenarios.90_days_in_a_row_with'),ok:()=>(S.stats.clean||0)>=90},
|
||||
{id:'pac',n:tr('common.stepping_stones'),city:'hnl',cash:5000000,days:240,rules:{},setup:()=>{S.lvl=Math.max(S.lvl||1,4);},d:tr('scenarios.honolulu_in_the_middle_of_the'),goal:tr('scenarios.a_path_from_los_angeles_to'),ok:()=>fastPath('lax','syd',1600)&&pathExists('lax','tok')&&R.served>=150},
|
||||
{id:'atl',n:tr('scenarios.mid_atlantic_accent'),city:'pdl',cash:5000000,days:240,rules:{},setup:()=>{S.lvl=Math.max(S.lvl||1,4);},d:tr('scenarios.ponta_delgada_azores_lisbon_lagos'),goal:tr('scenarios.1_6t_on_every_hop_from'),ok:()=>fastPath('mia','mad',1600)&&fastPath('lis','lag',1600)&&R.served>=100},
|
||||
];
|
||||
const WEEK_CITIES=['fra','ams','lon','nyc','ash','sjc','sin','tok','syd','sao','jnb','bom','waw','ist','scl','hkg'];
|
||||
const WEEK_MODS=[{id:'pricey',n:tr('scenarios.transit_costs_30_more')},{id:'chaos',n:tr('scenarios.twice_the_failures')},{id:'poor',n:tr('scenarios.start_with_only_100k')},{id:'boom',n:tr('scenarios.eyeballs_grow_50_faster')},{id:'dk',n:tr('scenarios.every_ix_is_run_by_de')},{id:'sharks',n:tr('scenarios.shark_season_subsea_cuts_twice_as')}];
|
||||
function weekly(){const {y,w}=isoWeek(new Date());let r=(y*100+w)*2654435761>>>0;const nx=()=>{r=(r*1103515245+12345)>>>0;return r/4294967296;};const city=WEEK_CITIES[Math.floor(nx()*WEEK_CITIES.length)];const mods=[];while(mods.length<2){const m=WEEK_MODS[Math.floor(nx()*WEEK_MODS.length)];if(!mods.includes(m))mods.push(m);}return {id:'weekly',key:`${y}-W${String(w).padStart(2,'0')}`,seed:y*100+w,city,mods,days:365};}
|
||||
// The in-browser weekly, when no published scenario came: same weeks as the published one (Sunday 06:00 Berlin).
|
||||
function weekly(){const [y,w]=pzWeekKey(new Date()).split('-W').map(Number);let r=(y*100+w)*2654435761>>>0;const nx=()=>{r=(r*1103515245+12345)>>>0;return r/4294967296;};const city=WEEK_CITIES[Math.floor(nx()*WEEK_CITIES.length)];const mods=[];while(mods.length<2){const m=WEEK_MODS[Math.floor(nx()*WEEK_MODS.length)];if(!mods.includes(m))mods.push(m);}return {id:'weekly',key:`${y}-W${String(w).padStart(2,'0')}`,seed:y*100+w,city,mods,days:365};}
|
||||
const scnRule=k=>!!(S&&S.scn&&S.scn.rules&&S.scn.rules[k]);
|
||||
function scnHof(){try{return JSON.parse(localStorage.getItem('sot-scn')||'{}')||{};}catch(e){return {};}}
|
||||
function beginGame(nm,city,o={}){if(needPitch()&&!UI.pitched){UI.pendGame=[nm,city,o];openModal(pitchHtml(true));return;}newGame(nm,city);S.mode=o.mode||'normal';
|
||||
if(S.mode==='sandbox'){S.cash=1e9;S.lvl=LEVELS.length;S.nextFail=1e9;S.nextEvent=1e9;}
|
||||
function beginGame(nm,city,o={}){if(needPitch()&&!UI.pitched){UI.pendGame=[nm,city,o];openModal(pitchHtml(true));return;}if(pzOn())pzLeave();slotLeave();slotNew();newGame(nm,city);{const a=+(UI.asnTxt||UI.asnSug||0);if(asnOk(a))S.asn=a;UI.asnSug=null;}S.mode=o.mode||'normal';
|
||||
// The rules are picked here and locked for the life of the network. Scenarios run on On-call plus their own rules.
|
||||
{const pr=o.scn?'oncall':S.mode==='sandbox'?'sandbox':S.mode==='puzzle'?'puzzle':own(PRESETS,o.preset)&&o.preset!=='sandbox'&&o.preset!=='puzzle'?o.preset:'oncall';S.rules=makeRules(pr,o.scn?{}:o.rules);}
|
||||
if(S.mode==='sandbox'){S.cash=1e9;S.lvl=LEVELS.length;if(!chaosMul()){S.nextFail=1e9;S.nextEvent=1e9;}}
|
||||
if(o.scn){const sc=o.scn;S.scn={id:sc.id,rules:sc.rules||{},days:sc.days,name:sc.n||tr('features.weekly_challenge_key',{key:sc.key}),key:sc.key||null,mods:(sc.mods||[]).map(m=>m.id)};S.rng=(o.seed||hstr(sc.id))|0;S.mode='scenario';S.asn=200000+Math.floor(Math.random()*15000);
|
||||
if(sc.cash)S.cash=sc.cash;if(sc.setup)sc.setup();
|
||||
for(const m of S.scn.mods){if(m==='pricey')S.priceMul=1.3;if(m==='poor')S.cash=100000;if(m==='chaos')S.scn.rules.chaos=true;if(m==='boom')S.scn.rules.boom=true;if(m==='dk')S.scn.rules.dkAll=true;if(m==='sharks')S.scn.rules.sharks=true;}}
|
||||
// Every new network starts at ½ speed (#186), whatever the last one ran at: slow enough to look around, but things happen.
|
||||
UI.speed=UI.lastSpeed=0.5;UI.resumeSpeed=null;
|
||||
UI.speed=UI.lastSpeed=rule('clock')?0.5:0;UI.resumeSpeed=null;
|
||||
track('game_new');UI.started=true;closeModal();compute();cam.x=CITY[city].x;cam.y=CITY[city].y;cam.z=innerWidth<760?1.1:1.4;selectCity(city);
|
||||
toast(S.scn?`<b>${esc(S.scn.name)}</b><br>${o.scn.goal?esc(o.scn.goal)+'.':tr('common.serve_as_much_traffic_as_you')} ${tr('scenarios.you_have_n_days',{n:S.scn.days})}`:S.mode==='sandbox'?tr('scenarios.sandbox_mode_a_billion_dollars_every'):tr('scenarios.welcome_name_the_ripe_ncc_assigned',{name:esc(nm),asn:S.asn,city:CITY[city].name}),'goal');
|
||||
renderAll();save();if(!S.scn&&S.mode!=='sandbox')tutorialStart();}
|
||||
toast(S.scn?`<b>${esc(S.scn.name)}</b><br>${o.scn.goal?esc(o.scn.goal)+'.':tr('common.serve_as_much_traffic_as_you')} ${tr('scenarios.you_have_n_days',{n:S.scn.days})}`:S.mode==='sandbox'?(chaosMul()?tr('scenarios.sandbox_mode_a_billion_dollars_chaos',{chaos:CHAOS[rule('chaos')].n}):tr('scenarios.sandbox_mode_a_billion_dollars_every')):tr('scenarios.welcome_name_the_ripe_ncc_assigned',{name:esc(nm),asn:S.asn,city:CITY[city].name}),'goal');
|
||||
renderAll();save();if(!S.scn&&S.mode!=='sandbox'&&S.mode!=='puzzle')tutorialStart();}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ function capOffer(a,b,t,nm){const T=BIZ_T[t],km=kmBetween(a,b),n=pick(T.opts),o=
|
|||
if(t==='capfib'){o.bw=1;o.slots=n;o.rate=Math.round(dfLeaseMo(km)*n*1.5);o.win=dfBuildDays(km)+150;}
|
||||
else{o.bw=t==='capw'?n*400:n;o.rate=Math.round((150+km*0.08)*T.km);o.win=t==='capsub'?300+Math.floor(Math.random()*121):180+Math.floor(Math.random()*91);}
|
||||
return o;}
|
||||
function capDealTick(d){const q=S.capDeal;if(!q||q.at!==d)return;S.capDeal=null;const pool=(CAP_ROUTES[q.c]||[]).filter(r=>isCity(r[0])&&isCity(r[1])).slice(),out=[];
|
||||
function capDealTick(d){const q=S.capDeal;if(!q||q.at!==d)return;S.capDeal=null;seatConf(q.c);const pool=(CAP_ROUTES[q.c]||[]).filter(r=>isCity(r[0])&&isCity(r[1])).slice(),out=[];
|
||||
while(out.length<3&&pool.length){const [a,b,t]=pool.splice(Math.floor(Math.random()*pool.length),1)[0],T=BIZ_T[t];
|
||||
const nm=()=>{const list=T.names.filter(n=>!S.usedNames.includes(n)),n=list.length?pick(list):pick(T.names);useName(n);return n;};out.push(capOffer(a,b,t,nm));}
|
||||
if(!out.length)return;S.offers.push(...out);
|
||||
|
|
|
|||
96
src/game/60-features/36-specialist.js
Normal file
96
src/game/60-features/36-specialist.js
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/* ---------- Specialist play (#187, #173) ----------
|
||||
You do not have to grow everywhere to grow up. Customers call when your network can already serve them, not only
|
||||
when your level says so; gear one level ahead comes early as a vendor demo unit at a premium; a seat on a
|
||||
consortium cable is the way onto your own subsea glass before Tier 1; and a charter picks what you set out to be. */
|
||||
const FIN=['nyc','chi','lon','fra','tok','sin','hkg','ams','ash'];
|
||||
// What a capability brings in, and why the offer says it came.
|
||||
const SPOT_W={lat:N_('specialist.spotted_your_ms_ms_a_b_path'),df:N_('specialist.spotted_your_cap_of_dark_fiber'),div:N_('specialist.spotted_your_two_diverse_paths_a'),eye:N_('specialist.spotted_your_broadband_in_a_one')};
|
||||
const SPOT_BIG=12,SPOT_DF=0.75;
|
||||
const latMaxOf=(a,b)=>+(kmBetween(a,b)/200*1.35).toFixed(1);
|
||||
let BIGEYE=null;const bigEye=()=>BIGEYE||(BIGEYE=CITIES.slice().sort((x,y)=>y.P-x.P).slice(0,SPOT_BIG).map(c=>c.id));
|
||||
// Worked out at most once a day (and again when the network changes shape): offers spawn far less often than that.
|
||||
let SPOTC=null;
|
||||
function spots(){const lv=lvl(),k=S.day+'|'+lv+'|'+S.links.length+'|'+Object.keys(S.pops).length+'|'+charter();if(SPOTC&&SPOTC.s===S&&SPOTC.k===k)return SPOTC.v;const v=spots0(lv);SPOTC={s:S,k,v};return v;}
|
||||
function spots0(lv){const out=[];if(gatesOpen()||S.scn)return out;const up=t=>BIZ_T[t].lv>lv,mine=Object.keys(S.pops);
|
||||
if(up('hft')){const f=FIN.filter(c=>S.pops[c]);for(let i=0;i<f.length;i++)for(let j=i+1;j<f.length;j++){const a=f[i],b=f[j],ms=bestLat(a,b);if(ms<=latMaxOf(a,b))out.push({t:'hft',a,b,k:'lat',n:+ms.toFixed(1)});}}
|
||||
const dci=['onramp','ai','hyper'].filter(up);
|
||||
if(dci.length)for(const l of S.links){if(l.kind!=='df'||l.sub||l.ready>S.day||linkDown(l))continue;const g=dfCap(l);
|
||||
for(const t of dci){const T=BIZ_T[t];if(g>=T.opts[0]*SPOT_DF&&(!T.div||reqCan('diverse',{city:l.a,city2:l.b})))out.push({t,a:l.a,b:l.b,k:'df',n:g});}}
|
||||
if(up('sov')){const by={};for(const c of mine)(by[CITY[c].cc]=by[CITY[c].cc]||[]).push(c);
|
||||
for(const cs of Object.values(by))for(let i=0;i<cs.length;i++)for(let j=i+1;j<cs.length;j++)if(diversePaths(cs[i],cs[j]))out.push({t:'sov',a:cs[i],b:cs[j],k:'div',n:0});}
|
||||
if(up('cgame')&&R)for(const c of bigEye())if(S.pops[c]&&S.pops[c].bb&&sfOf(R,c)>=0.95)out.push({t:'cgame',a:c,b:null,k:'eye',n:0});
|
||||
return out;}
|
||||
// A spotted customer starts at the smallest size its type comes in; your level makes them bigger and more frequent.
|
||||
function spawnSpot(t,s){const T=BIZ_T[t],list=T.names.filter(n=>!S.usedNames.includes(n)),name=list.length?pick(list):pick(T.names);useName(name);
|
||||
const o={id:uid(),city:s.a,city2:s.b,name,type:t,bw:T.opts[0],reqs:[],exp:S.day+40,spot:{k:s.k,n:s.n}};
|
||||
o.rate=T.l2?Math.round((150+kmBetween(s.a,s.b)*0.08)*T.km*(T.lat?latPay():1)*(T.div?1+REQS.diverse.bonus:1)):T.rate;
|
||||
if(T.lat){o.reqs=['lat'];o.latMax=latMaxOf(s.a,s.b);}else if(T.div)o.reqs=['diverse'];
|
||||
S.offers.push(o);}
|
||||
function spotWhy(o){const s=o&&o.spot;if(!s||!own(SPOT_W,s.k))return '';
|
||||
return `<div class="meta">🔭 ${tr(SPOT_W[s.k],{ms:s.n,cap:fmtCap(s.n),a:CITY[o.city].name,b:o.city2?CITY[o.city2].name:''})}</div>`;}
|
||||
|
||||
/* Vendor demo units: gear one level above yours, early, at a markup and after a short wait. Never two levels ahead. */
|
||||
const DEMO_MUL=1.6,DEMO_DAYS=14;
|
||||
function demoItem(k,id){return k==='rg'?RG[+id]||null:k==='sys'?(own(DF_SYS,id)?DF_SYS[id]:null):k==='opt'?(own(OPT,id)?OPT[id]:null):null;}
|
||||
const demoAt=(k,id)=>{const d=S&&S.demo&&S.demo[k+':'+id];return d===undefined?null:d;};
|
||||
const demoCan=L=>!gatesOpen()&&L===lvl()+1;
|
||||
function techOk(k,id,L){if(L<=lvl())return true;const d=demoAt(k,id);return demoCan(L)&&d!==null&&d<=S.day;}
|
||||
const techMul=L=>L>lvl()?DEMO_MUL:1;
|
||||
function demoBtn(k,id,L,lock,cls){const d=demoAt(k,id);if(!demoCan(L))return btn(lock,'demoAsk',{k,id},cls,true);
|
||||
if(d!==null&&d>S.day)return btn(tr('specialist.demo_unit_ships_in_n_days',{n:d-S.day}),'demoAsk',{k,id},cls,true);
|
||||
return btn(tr('specialist.ask_for_a_demo_unit_p_n',{p:Math.round((DEMO_MUL-1)*100),n:leadDays(DEMO_DAYS)}),'demoAsk',{k,id},cls);}
|
||||
const sysCost=k=>Math.round(DF_SYS[k].cost*techMul(DF_SYS[k].lvl));
|
||||
// Digging your own fiber before level 3: the pioneer pays for the permits nobody has asked for yet.
|
||||
const PIONEER=1.6;
|
||||
const digMul=()=>lvl()>=3?1:PIONEER,digCost=km=>Math.round(dfBuildCost(km)*digMul());
|
||||
|
||||
/* A seat on a consortium cable (#173): pay your share of the build, wait for the ship, and own fiber pairs on it,
|
||||
lit with your own optics like your own cable. Capacity conferences offer them, and now and then a consortium calls. */
|
||||
const SEAT_ROUTES={
|
||||
lon:[['nyc','bde','Amity Ville'],['lis','for','Ella Fitz-Link'],['mrs','sin','Sea, Me, We, Us, Them'],['lon','lag','Equi-Not']],
|
||||
hnl:[['syd','lax','Southern Double-Cross'],['tok','sea','Kuro-Show'],['sin','hkg','Dim Sum Express'],['syd','akl','Tasman Devil']],
|
||||
};
|
||||
const SEAT_N=[1,2,4],SEAT_SHARE=10,SEAT_LV=2,SEAT_ODDS=240,SEAT_EXP=30;
|
||||
const seatKm=(a,b)=>Math.round(kmBetween(a,b)*1.2),seatCost=(km,n)=>Math.round(ownCabCost(km)*n/SEAT_SHARE),seatMo=(km,n)=>Math.round(ownCabMo(km)*n/SEAT_SHARE),seatDays=km=>Math.max(1,Math.round(ownCabDays(km)*0.6));
|
||||
const seatRoute=name=>Object.values(SEAT_ROUTES).flat().find(r=>r[2]===name);
|
||||
// A conference names its own routes; a cold call is about a route with one of your POPs at an end. Picked by a hash, not
|
||||
// by the dice, so the rest of the game rolls exactly as before.
|
||||
function seatOffer(c,d){const rs=(c?SEAT_ROUTES[c]||[]:Object.values(SEAT_ROUTES).flat()).filter(r=>isCity(r[0])&&isCity(r[1])&&(c||S.pops[r[0]]||S.pops[r[1]])&&!S.links.some(l=>l.seat&&l.cname===r[2]));
|
||||
if(!rs.length)return null;const r=rs[hstr(S.asn+'|seat|'+d)%rs.length];return {a:r[0],b:r[1],name:r[2],km:seatKm(r[0],r[1]),exp:d+SEAT_EXP};}
|
||||
function seatConf(c){if(S.seatOff||lvl()<SEAT_LV||S.scn)return;S.seatOff=seatOffer(c,S.day);if(S.seatOff)toast(tr('specialist.a_consortium_is_selling_seats_on',{name:esc(S.seatOff.name),a:CITY[S.seatOff.a].name,b:CITY[S.seatOff.b].name}),'goal',[{l:tr('common.show_me'),act:'leftTab',args:{t:'deals'}}]);}
|
||||
function seatSection(){const o=S.seatOff;if(!o||o.exp<=S.day)return '';const pop=[o.a,o.b].filter(c=>!S.pops[c]).reduce((x,c)=>x+popCost(c),0);
|
||||
return `<div class="inc" style="background:#E6F4FF"><div class="nm">🚢 ${tr('specialist.consortium_seat_name',{name:esc(o.name)})}</div><div class="meta">${tr('specialist.a_b_km_km_ready_in',{a:CITY[o.a].name,b:CITY[o.b].name,km:o.km.toLocaleString(),n:seatDays(o.km),ms:linkLat({kind:'df',own:true,sub:true,km:o.km,seaDesign:'standard'}).toFixed(1)})} · ${tr('ui.n_d_left',{n:o.exp-S.day})}</div>
|
||||
<div class="meta">${tr('specialist.your_own_fiber_pairs_on_a')}${pop?' '+tr('specialist.includes_pops_at_the_landings_price',{price:fmt$(pop)}):''}</div>
|
||||
<div class="btns">${SEAT_N.map(n=>{const c=seatCost(o.km,n)+pop;return btn(`${trn('specialist.n_fiber_pairs',n)} <small>${fmt$(c)} · ${tr('common.price_mo',{price:fmt$(seatMo(o.km,n))})}</small>`,'seatBuy',{n},'sm',S.cash<c);}).join('')}${btn(tr('common.decline'),'seatNo',{},'ghost sm')}</div></div>`;}
|
||||
function seatPanel(l){if(!l.seat)return '';return `<div class="kv"><span>${tr('specialist.consortium_seat')}</span><b>${esc(l.cname||'')} · ${trn('specialist.n_fiber_pairs',Math.max(1,l.pairs|0))}</b></div><p class="note">${tr('specialist.the_consortium_runs_the_cable_your')}</p>`;}
|
||||
|
||||
/* Charters: what the network sets out to be, picked once at the start of a Normal game. Global backbone is the game as
|
||||
it always was; the Low-latency boutique sells speed to traders and has its own win, Speed of Light. */
|
||||
const CHARTERS={global:{i:'🌐',n:N_('specialist.global_backbone'),d:N_('specialist.the_classic_game_grow_everywhere_and')},boutique:{i:'⚡',n:N_('specialist.low_latency_boutique'),d:N_('specialist.trading_firms_and_other_latency_customers')}};
|
||||
const CHARTER_DAYS=30,LAT_PAY=1.4,SOL_ROUTES=3,SOL_CUST=2;
|
||||
const charter=()=>S&&!S.scn&&S.mode==='normal'&&S.charter==='boutique'?'boutique':'global';
|
||||
const latPay=()=>charter()==='boutique'?LAT_PAY:1;
|
||||
// The fastest a leased wave or fiber gets between two cities: overland, or the quickest cable on the route.
|
||||
function leasedLat(a,b){let best=isSub(a,b)?Infinity:kmBetween(a,b)*1.25/200;for(const c of cablesFor(a,b))best=Math.min(best,c.km*Math.min(CAB[c.cid].lat||1,1.25)/200);return best;}
|
||||
const ownGlass=l=>l.kind==='df'&&l.own&&l.ready<=S.day&&dfCap(l)>0;
|
||||
let SOLC=null;
|
||||
function solRoutes(){const k=S.day+'|'+S.links.length+'|'+S.links.reduce((n,l)=>n+(l.ch||[]).length,0);if(SOLC&&SOLC.s===S&&SOLC.k===k)return SOLC.v;
|
||||
const f=FIN.filter(c=>S.pops[c]),v=[];if(S.links.some(ownGlass))for(let i=0;i<f.length;i++)for(let j=i+1;j<f.length;j++){const a=f[i],b=f[j],o=bestLat(a,b,ownGlass),l=leasedLat(a,b);if(isFinite(o)&&isFinite(l)&&o<l)v.push({a,b,o,l});}
|
||||
SOLC={s:S,k,v};return v;}
|
||||
const solCust=()=>S.biz.filter(b=>BIZ_T[b.type]&&BIZ_T[b.type].lat&&b.mood>=50&&reqOk(b)).length;
|
||||
function charterCard(){if(S.scn||S.mode!=='normal')return '';
|
||||
if(!S.chartSet&&S.day<=CHARTER_DAYS)return `<div class="inc" style="background:#EEF0FF"><div class="nm">${tr('specialist.pick_a_charter')}</div><div class="meta">${tr('specialist.what_kind_of_network_are_you',{n:CHARTER_DAYS-S.day})}</div>${Object.entries(CHARTERS).map(([k,C])=>`<div class="row"><div class="grow"><div class="nm">${C.i} ${tr(C.n)}</div><div class="meta">${tr(C.d,{p:Math.round((LAT_PAY-1)*100),r:SOL_ROUTES,c:SOL_CUST})}</div></div>${btn(charter()===k?tr('specialist.keep_it'):tr('specialist.pick'),'charter',{k},k==='global'?'ghost sm':'pink sm')}</div>`).join('')}</div>`;
|
||||
if(charter()!=='boutique')return '';
|
||||
if(S.solWon)return `<div class="inc" style="background:#EAF7EE"><div class="nm">⚡ ${tr('specialist.speed_of_light')}</div><div class="meta">${tr('specialist.won_on_date_your_own_glass',{date:dateStr(S.solWon)})}</div></div>`;
|
||||
const r=solRoutes();return `<div class="inc" style="background:#EEF0FF"><div class="nm">⚡ ${tr('specialist.speed_of_light')}</div><div class="meta">${tr('specialist.routes_r_of_n_beat_the',{r:Math.min(r.length,SOL_ROUTES),n:SOL_ROUTES,c:Math.min(solCust(),SOL_CUST),m:SOL_CUST})}</div>${r.slice(0,SOL_ROUTES).map(x=>`<div class="meta">✓ ${CITY[x.a].name} ⇄ ${CITY[x.b].name}: ${tr('common.ms_ms_one_way',{ms:x.o.toFixed(1)})} < ${x.l.toFixed(1)}</div>`).join('')}</div>`;}
|
||||
// Once a day: seats expire or call, and the boutique checks its win.
|
||||
function specDay(d){if(S.seatOff&&S.seatOff.exp<=d)S.seatOff=null;
|
||||
if(!S.seatOff&&!S.scn&&S.mode!=='puzzle'&&lvl()>=SEAT_LV&&hstr(S.asn+'|seatcall|'+d)%SEAT_ODDS===0)seatConf(null);
|
||||
if(charter()==='boutique'&&!S.solWon&&solRoutes().length>=SOL_ROUTES&&solCust()>=SOL_CUST){S.solWon=Math.max(1,d);track('win_sol');toast(`<b>⚡ ${tr('specialist.speed_of_light')}</b><br>${tr('specialist.your_own_glass_beats_every_leased')}`,'goal');sfx('coin');checkBadges();}}
|
||||
// Saves: the charter, demo orders, a seat on offer and the boutique's win. Old saves are Global backbone, picked.
|
||||
function specSanitize(s){s.charter=s.charter==='boutique'&&s.mode==='normal'&&!s.scn?'boutique':'global';s.chartSet=s.chartSet===false&&s.day<=CHARTER_DAYS?false:true;
|
||||
const dm={};if(s.demo&&typeof s.demo==='object'&&!Array.isArray(s.demo))for(const key of Object.keys(s.demo).slice(0,64)){const [k,id]=key.split(':');if(demoItem(k,id)&&Number.isFinite(+s.demo[key]))dm[key]=Math.round(+s.demo[key]);}s.demo=dm;
|
||||
const o=s.seatOff;s.seatOff=o&&typeof o==='object'&&typeof o.name==='string'&&seatRoute(o.name)&&seatRoute(o.name)[0]===o.a&&seatRoute(o.name)[1]===o.b?{a:o.a,b:o.b,name:o.name,km:seatKm(o.a,o.b),exp:num(o.exp,0)}:null;
|
||||
s.solWon=Number.isFinite(+s.solWon)&&+s.solWon>0?Math.round(+s.solWon):0;
|
||||
for(const l of s.links)if(l.seat!==undefined){if(l.seat===true&&l.kind==='df'&&l.own&&l.sub)l.pairs=Math.max(1,Math.min(Math.max(...SEAT_N),l.pairs|0));else delete l.seat;}
|
||||
for(const b of [...s.biz,...s.offers])if(b.spot!==undefined){const x=b.spot;if(x&&typeof x==='object'&&own(SPOT_W,x.k))b.spot={k:x.k,n:num(x.n,0)};else delete b.spot;}}
|
||||
30
src/game/60-features/37-fiber-broker.js
Normal file
30
src/game/60-features/37-fiber-broker.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ---------- the capacity broker: a listing that sells as the market wants (#203) ----------
|
||||
You list some alien waves (and, on your own build, spare pairs) on a dark fiber; the broker keeps the listing and
|
||||
sells it off over the months, as carriers between those two cities want capacity. A route's market is how many 400G
|
||||
waves other carriers want there, sized by the eyeballs at both ends (a landing town counts the big city it serves),
|
||||
and everything you already rent out between those cities fills it: a busy route sells in days, a road to nowhere
|
||||
maybe once. The broker keeps 10% of the monthly price, as before. l.list = {w: waves left to sell, p: pairs}. */
|
||||
const BR_DIV=40,BR_MAX=48,BR_PAIR=8,BR_NEAR=350;
|
||||
// What a city weighs for the market: its own eyeballs, or half of a big city's within reach of its backhaul.
|
||||
const BR_W=new Map();
|
||||
function brWeight(c){let b=BR_W.get(c);if(b===undefined){const C=CITY[c];b=C.P;
|
||||
for(const D of CITIES)if(D.id!==c&&!D.off&&D.land===C.land&&kmBetween(c,D.id)<=BR_NEAR)b=Math.max(b,D.P*0.5);BR_W.set(c,b);}
|
||||
return b*eraMul();}
|
||||
// 400G waves carriers want between two cities, and how many of them you already rent out there (a pair counts as 8).
|
||||
const brMarket=(a,b)=>clamp(Math.round(Math.sqrt(brWeight(a)*brWeight(b))/BR_DIV),1,BR_MAX);
|
||||
function brSold(a,b){const k=edgeKey({a,b});let n=0;const ls=new Set(S.links.filter(l=>l.kind==='df'&&edgeKey(l)===k).map(l=>l.id));
|
||||
for(const x of S.biz)if(ls.has(x.link))n+=x.type==='wwave'?(x.slots||0):x.type==='dfpair'?BR_PAIR:0;return n;}
|
||||
const brFree=l=>Math.max(0,brMarket(l.a,l.b)-brSold(l.a,l.b));
|
||||
// Once a day, each listing may find a buyer: the more room the route has left, the sooner.
|
||||
function brTick(){for(const l of S.links){const L=l.list;if(!L||l.kind!=='df'||!fiberOk({link:l.id,type:'wwave'}))continue;
|
||||
const free=brFree(l);if(!free)continue;
|
||||
if(L.w>0&&freeCh(l)>=1&&Math.random()<Math.min(0.3,free/45)){const n=Math.max(1,Math.min(L.w,freeCh(l),free,1+Math.floor(Math.random()*4)));brSell(l,'wwave',n);L.w-=n;}
|
||||
else if(L.p>0&&pairFree(l)&&free>=BR_PAIR&&Math.random()<1/90){brSell(l,'dfpair',1);L.p--;}
|
||||
if(!(L.w>0)&&!(L.p>0))delete l.list;}}
|
||||
// A sale: a new carrier on this fiber, or more waves for one that already rents here.
|
||||
function brSell(l,t,n){const T=BIZ_T[t],nm=()=>{const list=T.names.filter(x=>!S.usedNames.includes(x)),x=list.length?pick(list):pick(T.names);useName(x);return x;};
|
||||
const o=fiberOffer(t,l,nm,0.9);if(t==='wwave'){o.slots=n;o.rate=Math.round(waveMo(l.km,false,2)*0.55*n*0.9);o.what=wwWhat(l,n);}
|
||||
const more=t==='wwave'&&S.biz.find(b=>b.type==='wwave'&&b.link===l.id&&b.name===o.name);
|
||||
if(more){more.slots=(more.slots||0)+n;more.rate+=o.rate;more.what=wwWhat(l,more.slots);}else S.biz.push(offerCustomer(o));
|
||||
toast(tr('broker.sold',{name:esc(o.name),what:esc(t==='wwave'?wwWhat(l,n):o.what),price:fmt$(o.rate)}),'good');
|
||||
floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,tr('common.signed'),'#16A866');}
|
||||
|
|
@ -2,16 +2,20 @@
|
|||
const slug=t=>String(t).toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g,'').replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'x';
|
||||
function trPaths(src){const live=S.links.filter(l=>!linkDown(l)),rem=remoteCities(),ok=c=>popUp(c)||rem.includes(c),adj={};
|
||||
// Every link between two cities costs what the pair costs, as in compute(); the trace shows an active link over one on standby.
|
||||
const pw={};for(const l of live){const k=edgeKey(l);pw[k]=Math.min(pw[k]??Infinity,(l.km+60)*MET[pairMet(k)].f);}
|
||||
const pw={};for(const l of live){const k=edgeKey(l);pw[k]=Math.min(pw[k]??Infinity,pairW(k,l.km));}
|
||||
for(const l of live){if(!ok(l.a)||!ok(l.b))continue;const w=pw[edgeKey(l)]+(l.standby?1e-6:0);(adj[l.a]=adj[l.a]||[]).push([l.b,l,w]);(adj[l.b]=adj[l.b]||[]).push([l.a,l,w]);}
|
||||
const dist={[src]:0},prev={},done=new Set();for(;;){let u=null,ud=Infinity;for(const k in dist)if(!done.has(k)&&dist[k]<ud){u=k;ud=dist[k];}if(u===null)break;done.add(u);for(const [v,l,w] of adj[u]||[]){const nd=ud+w;if(nd<(dist[v]??Infinity)){dist[v]=nd;prev[v]=l;}}}
|
||||
const path=dst=>{if(dist[dst]===undefined)return null;const out=[];let v=dst;while(v!==src){const l=prev[v];out.unshift({l,from:l.a===v?l.b:l.a,to:v});v=l.a===v?l.b:l.a;}return out;};return {dist,path};}
|
||||
function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev.leak.net:null,out=[];
|
||||
for(const x of S.caches)if(x.net===net&&popUp(x.city)&&!siteDown(x.city,'a'))out.push({k:'c',rank:0,city:x.city,pref:'normal',lab:tr('common.name_cache',{name:NET[net].cache.name}),used:R.useCache[x.id]||0,cap:CACHE_CAP});
|
||||
for(const p of S.pni)if(p.net===net&&pniOn(p)&&popUp(p.city)&&liveN(p.city,p.site,p.n))out.push({k:'p',rank:1,city:p.city,pref:p.pref||'normal',lab:tr('common.pni_with_net',{net:NET[net].name}),used:R.usePni[p.id]||0,cap:liveCap(pniG(p),p.city,p.site,p.n)});
|
||||
for(const c in S.ixp)if(ixSessions(c).has(net)&&(popUp(ixCity(c))||remoteCities().includes(ixCity(c)))&&!(ev.ixdown&&ev.ixdown[c]>day))out.push({k:'ix',rank:2,city:ixCity(c),id:c,pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('common.ix_peering',{ix:ixName(c)}),used:R.useIx[c]||0,cap:ixCap(c)});
|
||||
for(const t of S.transit)if(popUp(t.city)&&!(t.down>day)&&liveN(t.city,t.site,t.n)&&net!==leak&&!((ev.depeer>day||scnRule('spat'))&&t.net==='cog'&&net==='ggl'))out.push({k:'t',rank:3,city:t.city,pref:t.pref||'normal',carry:!!t.carry,lab:tr('traceroute.name_transit',{name:NET[t.net].name}),tnet:t.net,used:R.useT[t.id]||0,cap:liveCap(PORT[t.tier].g,t.city,t.site,t.n)});
|
||||
// A peer's customer cone (#85): one AS hop more, so tried after direct peering and before transit, as in compute().
|
||||
for(const p of S.pni)if(CONE_S[p.net].has(net)&&pniOn(p)&&popUp(p.city)&&liveN(p.city,p.site,p.n))out.push({k:'p',rank:p.net===net?1:CONE_RANK,via:p.net===net?null:p.net,city:p.city,pref:p.pref||'normal',lab:tr('common.pni_with_net',{net:NET[p.net].name}),used:R.usePni[p.id]||0,cap:liveCap(pniG(p),p.city,p.site,p.n)});
|
||||
for(const c in S.ixp){const ses=ixSessions(c),via=ses.has(net)?null:ANC[net].find(u=>ses.has(u))||null;if((ses.has(net)||via)&&(popUp(ixCity(c))||remoteCities().includes(ixCity(c)))&&!(ev.ixdown&&ev.ixdown[c]>day))out.push({k:'ix',rank:via?CONE_RANK:2,via,city:ixCity(c),id:c,pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('common.ix_peering',{ix:ixName(c)}),used:R.useIx[c]||0,cap:ixCap(c)});}
|
||||
for(const t of S.transit)if(popUp(t.city)&&!(t.down>day)&&liveN(t.city,t.site,t.n)&&net!==leak&&!((ev.depeer>day||scnRule('spat'))&&t.net==='cog'&&net==='ggl'))out.push({k:'t',rank:3,city:t.city,pref:t.pref||'normal',lab:tr('traceroute.name_transit',{name:NET[t.net].name}),tnet:t.net,used:R.useT[t.id]||0,cap:liveCap(PORT[t.tier].g,t.city,t.site,t.n)});
|
||||
return out;}
|
||||
// coneChain(peer,net): [peer, …, net], the shortest walk down customer links (the network's up lists, read backwards).
|
||||
function coneChain(top,id){const prev={[id]:null},q=[id];while(q.length){const x=q.shift();if(x===top)break;for(const u of NET[x].up||[])if(NET[u]&&!(u in prev)){prev[u]=x;q.push(u);}}
|
||||
if(!(top in prev))return [top,id];const out=[];for(let x=top;x!==null;x=prev[x])out.push(x);return out;}
|
||||
function traceroute(src,to){const P=trPaths(src),me=slug(S.name)+'.net',lines=[],ip=(a,b)=>`100.64.${a%250}.${b%250}`;let rtt=0.3,n=1;
|
||||
const hop=(host,addr,extra,note)=>{rtt+=extra;lines.push(`${String(n++).padStart(2)} ${host} (${addr}) ${rtt.toFixed(1)} ms${note?' ← '+note:''}`);};
|
||||
hop(`lo0.cr1.${src}.${me}`,ip(hstr(src),1),0,tr('traceroute.city_your_router',{city:CITY[src].name}));
|
||||
|
|
@ -32,10 +36,12 @@ function traceroute(src,to){const P=trPaths(src),me=slug(S.name)+'.net',lines=[]
|
|||
hop(`ae-2.core.${far}.${slug(T.name)}.net`,`203.0.113.${(hstr(far)+7)%250}`,km*1.3/100+0.3,CITY[far]?tr('traceroute.net_carries_it_to_city',{net:T.name,city:CITY[far].name}):'');
|
||||
hop(`${slug(N.name)}-peer.${far}.${slug(T.name)}.net`,`198.51.100.${hstr(N.id)%250}`,0.4,tr('traceroute.net_hands_it_to_to',{net:T.name,to:N.name}));}}
|
||||
else if(e.k==='ix'){hop(`${slug(ixName(e.city))}.peering.${e.city}`,`185.0.${hstr(e.city)%250}.${hstr(N.id)%250}`,0.3,tr('traceroute.across_the_ix_switch',{ix:ixName(e.city)}));}
|
||||
else if(e.k==='p'){hop(`pni-${slug(N.name)}.${e.city}.${me}`,ip(hstr(N.id),3),0.2,tr('traceroute.private_cross_connect'));}
|
||||
else if(e.k==='p'){hop(`pni-${slug(NET[e.via||N.id].name)}.${e.city}.${me}`,ip(hstr(N.id),3),0.2,tr('traceroute.private_cross_connect'));}
|
||||
// Down the cone one customer at a time: the shortest chain of upstreams from the peer to the network, each AS on the path.
|
||||
if(e.via){const ch=coneChain(e.via,N.id);for(let i=0;i<ch.length-1;i++){const V=NET[ch[i]],C=NET[ch[i+1]];asPath.push(V.asn);hop(`${slug(C.name)}-cust.${e.city}.${slug(V.name)}.net`,`198.51.100.${(hstr(V.id)+3)%250}`,1.2,tr('traceroute.net_hands_it_to_its_customer',{net:V.name,to:C.name}));}}
|
||||
else{hop(`cache-${slug(N.name)}.${e.city}.${me}`,ip(hstr(N.id),4),0.1,tr('traceroute.embedded_cache_in_your_rack'));}
|
||||
asPath.push(N.asn);if(e.k!=='c')hop(`www.${slug(N.name)}.example`,`198.51.100.${(hstr(N.id)+1)%250}`,0.5+(e.k==='t'?1:0.2),`${N.name}`);
|
||||
const order={c:tr('traceroute.caches_beat_pnis'),p:tr('traceroute.pnis_beat_ix_peering'),ix:tr('traceroute.ix_peering_beats_transit'),t:tr('traceroute.transit_is_the_last_resort')}[e.k];
|
||||
const order=e.via?tr('traceroute.a_peer_s_customers_come_after'):{c:tr('traceroute.caches_beat_pnis'),p:tr('traceroute.pnis_beat_ix_peering'),ix:tr('traceroute.ix_peering_beats_transit'),t:tr('traceroute.transit_is_the_last_resort')}[e.k];
|
||||
const cn=cnCity(src)!==!!N.cn?' '+tr('traceroute.crossing_the_great_firewall_here',{p:S.ev.gfw>S.day?35:20}):'';
|
||||
return {text:lines.join('\n'),why:`${tr('traceroute.exit_exit_in_city',{exit:e.lab,city:CITY[e.city].name})} ${tr('traceroute.rule_and_closer_exits_win_ties',{rule:order[0].toUpperCase()+order.slice(1)})}${e.pref!=='normal'?tr('traceroute.this_one_is_set_to_mode',{mode:e.pref==='high'?tr('common.prefer'):tr('common.backup_only')}):''}.${direct}${e.used>=e.cap*0.999?' '+tr('traceroute.it_is_full_so_some_traffic'):''}${cn}`,asPath};}
|
||||
function traceModal(src,to){const pops=Object.keys(S.pops).sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name));src=src&&S.pops[src]?src:UI.trFrom&&S.pops[UI.trFrom]?UI.trFrom:S.home&&S.pops[S.home]?S.home:pops[0];
|
||||
|
|
|
|||
|
|
@ -13,13 +13,17 @@ function shareCanvas(){const Wc=1200,Hc=630,cv=document.createElement('canvas');
|
|||
g.restore();g.strokeStyle='#1E2640';g.lineWidth=5;g.strokeRect(mx,my,mw,mh);
|
||||
// header
|
||||
g.fillStyle='#1E2640';g.font='900 54px "Baloo 2", sans-serif';g.textBaseline='top';g.fillText(S.name,40,28);
|
||||
g.font='800 26px Nunito, sans-serif';g.fillText(`AS${S.asn} · ${tierLabel()} · ${dateStr(S.day)}${S.mode==='sandbox'?' · '+tr('common.sandbox'):''}`,42,92);
|
||||
g.font='800 26px Nunito, sans-serif';g.fillText(`AS${S.asn} · ${tierLabel()} · ${dateStr(S.day)}${ruleTag()?' · '+ruleTag():''}`,42,92);
|
||||
// stats
|
||||
const got=BADGES.filter(b=>S.ach&&S.ach[b.id]!==undefined),rk={l:0,e:1,r:2,c:3},top=got.slice().sort((a,b)=>rk[a.r]-rk[b.r]).slice(0,8);
|
||||
const got=BADGES.filter(b=>S.ach&&S.ach[b.id]!==undefined),rk={l:0,e:1,r:2,c:3},lv=b=>bvar(S.achP&&S.achP[b.id]).lv,top=got.slice().sort((a,b)=>rk[a.r]-rk[b.r]||lv(b)-lv(a)).slice(0,8);
|
||||
const rows=[[tr('common.peak_traffic'),fmtG(S.stats.peak||0)],[tr('common.peered'),pct(R.peerShare||0)],[tr('common.pops'),tr('share_card.n_in_r_regions',{n:Object.keys(S.pops).length,r:regionsCount()})],[tr('common.links'),String(S.links.length)],[tr('common.customers'),String(S.biz.length)],[tr('common.incidents_survived'),String(S.stats.survived||0)],[tr('common.shark_bites'),String(S.stats.sharks||0)],[tr('common.badges'),`${got.length}/${BADGES.length}`]];
|
||||
if(S.solWon)rows.unshift(['⚡ '+tr('specialist.speed_of_light'),dateStr(S.solWon)]);
|
||||
if(S.scn)rows.unshift([scnName(),S.scn.done?(S.scn.id==='weekly'?tr('share_card.score_v',{v:fmtG(S.scn.score||S.stats.peak||0)}):tr('features.done_in_d_days',{d:S.scn.done})):S.scn.failed?tr('share_card.not_this_time'):tr('common.in_progress')]);
|
||||
let y=150;for(const [k,v] of rows.slice(0,9)){g.fillStyle='#fff';g.strokeStyle='#1E2640';g.lineWidth=3;g.beginPath();g.roundRect?g.roundRect(770,y,390,42,12):g.rect(770,y,390,42);g.fill();g.stroke();g.fillStyle='#5A6280';g.font='800 18px Nunito, sans-serif';g.fillText(k,786,y+11);g.fillStyle='#1E2640';g.font='900 22px Nunito, sans-serif';const tw=g.measureText(v).width;g.fillText(v,1146-tw,y+9);y+=48;}
|
||||
// Badge variants show as a ring: frosted for Change Freeze, fiery for BGP at 3 a.m.
|
||||
top.forEach((b,i)=>{const v=S.achP&&S.achP[b.id];if(v&&v!=='oncall'&&own(BVAR,v)){g.strokeStyle=BVAR[v].col;g.lineWidth=4;g.beginPath();g.arc(60+i*48,537,22,0,7);g.stroke();}});
|
||||
g.font='34px sans-serif';top.forEach((b,i)=>g.fillText(b.i,40+i*48,520));
|
||||
{const n=v=>got.filter(b=>(S.achP&&S.achP[b.id]||'oncall')===v).length,f=n('freeze'),h=n('bgp');if(f||h){g.fillStyle='#1E2640';g.font='800 18px Nunito, sans-serif';g.fillText([h?`🔥 ${h}`:'',f?`🧊 ${f}`:''].filter(Boolean).join(' '),40+Math.max(1,top.length)*48+8,526);}}
|
||||
g.fillStyle='#1E2640';g.font='900 30px "Baloo 2", sans-serif';g.fillText('seriesoftub.es',40,572);g.font='700 20px Nunito, sans-serif';g.fillText(tr('share_card.build_the_internet_one_tube_at'),300,580);
|
||||
return cv;}
|
||||
function shareModal(){const cv=shareCanvas();if(!cv){toast(tr('share_card.your_browser_cannot_draw_the_card'),'bad');return;}let url='';try{url=cv.toDataURL('image/png');}catch(e){}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
function scnTick(d){const sc=S.scn;if(!sc||sc.done||sc.failed)return;
|
||||
if(sc.id==='weekly'&&sc.wk){wsTick(d);return;}
|
||||
if(sc.id==='weekly'){if(d>=sc.days){sc.done=d;const score=Math.round(S.stats.peak||0);sc.score=score;let best=null;try{const wk=JSON.parse(localStorage.getItem('sot-weekly')||'{}');best=wk[sc.key];if(!best||score>best){wk[sc.key]=score;localStorage.setItem('sot-weekly',JSON.stringify(wk));}}catch(e){}
|
||||
const h=scnHof();h.weekly=h.weekly||{d:new Date().toISOString().slice(0,10)};try{localStorage.setItem('sot-scn',JSON.stringify(h));}catch(e){}
|
||||
openModal(`<div class="eyebrow">${tr('features.weekly_challenge_key',{key:esc(sc.key)})}</div><h2 style="font-size:30px">${tr('scenario_progress.your_score_score',{score:fmtG(score)})}</h2><p class="tagline">${best&&best>score?tr('scenario_progress.peak_traffic_served_in_one_year',{best:fmtG(best)}):best?tr('scenario_progress.peak_traffic_served_in_one_year_c7e5'):tr('scenario_progress.peak_traffic_served_in_one_year_a67b')}</p><div class="btns">${btn(tr('scenario_progress.share_my_result'),'share',{},'pink big')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost big')}</div>`);track('weekly_done');}return;}
|
||||
|
|
@ -6,7 +7,7 @@ function scnTick(d){const sc=S.scn;if(!sc||sc.done||sc.failed)return;
|
|||
if(ok){sc.done=d;const h=scnHof();if(!h[sc.id]||h[sc.id].days>d)h[sc.id]={d:new Date().toISOString().slice(0,10),days:d};try{localStorage.setItem('sot-scn',JSON.stringify(h));}catch(e){}track('scenario_'+sc.id);
|
||||
openModal(`<div class="eyebrow">${tr('common.scenario_complete')}</div><h2 style="font-size:30px">${tr('scenario_progress.name_done_in_d_days',{name:esc(def.n),d})}</h2><p class="tagline">${esc(def.goal)}. ${d<def.days/2?tr('scenario_progress.with_time_to_spare'):tr('scenario_progress.just_in_time')}</p><div class="btns">${btn(tr('scenario_progress.share_my_result'),'share',{},'pink big')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost big')}${btn(tr('common.more_scenarios'),'scenarios',{},'ghost')}</div>`);sfx('coin');}
|
||||
else if(d>=def.days){sc.failed=d;openModal(`<div class="eyebrow">${tr('common.scenario_over')}</div><h2 style="font-size:30px">${tr('common.time_s_up')}</h2><p class="tagline">${tr('scenario_progress.goal_was_not_reached_in_d',{goal:esc(def.goal),d:def.days})}</p><div class="btns">${btn(tr('common.try_again'),'startScn',{id:def.id},'pink big')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost big')}</div>`);}}
|
||||
function scenarioModal(){const wk=weekly(),h=scnHof();let best=null;try{best=JSON.parse(localStorage.getItem('sot-weekly')||'{}')[wk.key];}catch(e){}
|
||||
function scenarioModal(){wsEnsure();const h=scnHof();
|
||||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('common.scenarios')}</div><h2 style="font-size:28px">${tr('scenario_progress.pick_a_challenge')}</h2></div><button class="x" data-act="${UI.started?'closeModal':'helpClose'}" aria-label="${tr('common.close')}">×</button></div>
|
||||
<div class="scn wk"><div class="grow"><div class="nm">${tr('features.weekly_challenge_key',{key:esc(wk.key)})}</div><div class="meta">${tr('scenario_progress.start_in_city_mods_one_year',{city:esc(CITY[wk.city].name),mods:wk.mods.map(m=>esc(m.n)).join(' · ')})}${best?' '+tr('scenario_progress.your_best_best',{best:fmtG(best)}):''}</div></div>${btn(tr('common.play'),'startWeekly',{},'pink')}</div>
|
||||
${wsRow()}
|
||||
${SCN.map(x=>`<div class="scn"><div class="grow"><div class="nm">${esc(x.n)} ${h[x.id]?`<span class="tag open">${tr('features.done_in_d_days',{d:h[x.id].days})}</span>`:''}</div><div class="meta">${esc(x.d)}</div><div class="meta">${tr('scenario_progress.goal_goal_time_d_days_start',{goal:esc(x.goal),d:x.days,city:esc(CITY[x.city].name)})}</div></div>${btn(tr('common.play'),'startScn',{id:x.id},'')}</div>`).join('')}`);}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function newGame(name,home){
|
||||
S={v:1,name,asn:200000+Math.floor(_rand()*15000),home,day:0,cash:START_CASH,
|
||||
ltv:2,t1v:3,auV:1,seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{},pairMet:{},
|
||||
done:{},inc:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',capDeal:null,won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,inbox:{items:[],down:{},tiny:{},rep:0,bot:false,log:[],seq:0},hw:{}};
|
||||
ltv:2,t1v:3,auV:1,ops:opsNew(),achP:{},seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{},pairMet:{},
|
||||
done:{},inc:[],ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',capDeal:null,core:{lv:0,run:0},won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,ppol:'open',pdesk:null,pdeskRep:null,hw:{},rules:makeRules('oncall'),charter:'global',chartSet:false,demo:{},seatOff:null,solWon:0,monkey:{next:null,on:0}};
|
||||
}
|
||||
|
||||
|
|
|
|||
24
src/game/60-features/90-automation.js
Normal file
24
src/game/60-features/90-automation.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* The sales engine of #185: would this offer work if signed now? The intern's sales order runs it once a day.
|
||||
It trials the new demand on a copy of the game, so a failed trial leaves the live game untouched. */
|
||||
function offerCustomer(o){return {id:o.id,city:o.city,city2:o.city2||null,reqs:o.reqs||[],latMax:o.latMax||null,route:BIZ_T[o.type].scenic?'scenic':BIZ_T[o.type].lat?'fast':'normal',name:o.name,type:o.type,bw:o.bw,rate:o.rate,mood:100,since:S.day,sites:o.sites||null,start:o.start,dur:o.dur,fee:o.fee,link:o.link,slots:o.slots||0,what:o.what,prov:o.prov,due:BIZ_T[o.type].cap?S.day+o.win:undefined};}
|
||||
function autoOffer(o){if(!o||!own(BIZ_T,o.type)||!(o.exp>S.day)||!(o.bw>0)||o.rate<0||!bCities(o).length||!bCities(o).every(popUp)||!reqOk(o))return null;
|
||||
const T=BIZ_T[o.type],b=offerCustomer(o);if(T.event&&(!(o.start>S.day)||!(o.dur>0)))return null;
|
||||
if(o.type==='capfib'&&S.biz.some(x=>x.type==='capfib'&&capPend(x)&&!x.link&&((x.city===o.city&&x.city2===o.city2)||(x.city===o.city2&&x.city2===o.city))))return null;
|
||||
if(T.fiber){const l=o.type==='capfib'?capFibLink(b):S.links.find(x=>x.id===o.link);if(!l)return null;b.link=l.id;
|
||||
if(!fiberOk(b)||(o.type==='wwave'&&(!(o.slots>0)||freeCh(l)<o.slots))||(o.type==='dfpair'&&!pairFree(l))||
|
||||
(o.type==='pairs'&&(!l.own||S.biz.some(x=>x.link===l.id&&['pairs','capfib','dfpair'].includes(x.type)))))return null;}
|
||||
const state=S,result=R,hot=UI.hotMap,future=S.biz.some(x=>BIZ_T[x.type].event&&x.start>S.day);
|
||||
// Trial the added demand before signing; failed trials leave the live game untouched.
|
||||
try{S={...S,biz:S.biz};
|
||||
// shortcut: future events reserve capacity together; use per-date trials if separate bookings must share capacity.
|
||||
if(future){S.biz=S.biz.map(x=>BIZ_T[x.type].event&&x.start>S.day?{...x,start:S.day}:x);
|
||||
/* Signed if the offer works and nobody who works without it breaks. compute() reads the last result only for
|
||||
scenic circuits, so without them the pass with the offer can go first: when the offer fails, or nobody is
|
||||
unhappy with it, the pass without it cannot change the answer and is skipped. */
|
||||
const fut=S.biz,all=fut.concat(b);
|
||||
if(!all.some(x=>x.route==='scenic')){if(T.event)b.start=S.day;if(T.cap)b.live=true;S.biz=all;compute();if(bizWhy(b).length)return null;
|
||||
const bad=fut.filter(x=>bizWhy(x).length);if(!bad.length)return b;S.biz=fut;compute();return bad.every(x=>bizWhy(x).length)?b:null;}
|
||||
compute();}
|
||||
const healthy=S.biz.filter(x=>!bizWhy(x).length);if(T.event)b.start=S.day;if(T.cap)b.live=true;S.biz=S.biz.concat(b);compute();
|
||||
return !bizWhy(b).length&&healthy.every(x=>!bizWhy(x).length)?b:null;
|
||||
}finally{S=state;R=result;UI.hotMap=hot;b.start=o.start;if(T.cap)delete b.live;}}
|
||||
42
src/game/60-features/90-puzzles-data.js
Normal file
42
src/game/60-features/90-puzzles-data.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* Puzzles: one entry per line, in play order. A puzzle is data:
|
||||
id, pack, n (name), j (one-line joke), src (the content origins: eyeballs pull from the nearest), dem (the traffic:
|
||||
{t:'eye',a,g} eyeballs in city a want g Gbps; {t:'l2',a,b,g,ms} a circuit of g Gbps between a and b, under ms
|
||||
milliseconds one way; be:1 marks a flow best effort, which may drop when something is cut), via (suggested stepping
|
||||
stones), budget (setup + a year of monthly, 0 = no budget star to chase: it is given), and at most a twist:
|
||||
noSub (no subsea cables), ring (one ring through every POP), avoid (cities you may not build in).
|
||||
Each pack teaches one idea; the budgets sit a little above the cheapest 3-star build found (tests/puzzles.test.js). */
|
||||
const PZ_PACKS=[
|
||||
{id:'hello',n:tr('puzzles.fat_pipes'),d:tr('puzzles.capacity_first_every_link_has_a'),need:0},
|
||||
{id:'rodeo',n:tr('puzzles.router_rodeo'),d:tr('puzzles.routers_have_ports_and_a_limit'),need:10},
|
||||
{id:'cops',n:tr('puzzles.traffic_cops'),d:tr('puzzles.your_routers_pick_the_path'),need:18},
|
||||
{id:'n1',n:tr('puzzles.n_1_club'),d:tr('puzzles.survive_any_single_cut_with_the'),need:26},
|
||||
{id:'final',n:tr('puzzles.grand_tour'),d:tr('puzzles.everything_at_once_across_oceans'),need:36},
|
||||
];
|
||||
const PZ=[
|
||||
{id:'hello',pack:'hello',n:tr('puzzles.hello_world'),j:tr('puzzles.every_internet_starts_with_one_tube'),src:['nyc'],dem:[{t:'eye',a:'lon',g:8}],budget:0},
|
||||
{id:'eurotrip',pack:'hello',n:tr('puzzles.euro_trip'),j:tr('puzzles.three_cities_two_currencies_one_very'),src:['ams'],dem:[{t:'eye',a:'lon',g:30},{t:'eye',a:'fra',g:60}],budget:0},
|
||||
{id:'bigboat',pack:'hello',n:tr('puzzles.a_bigger_boat'),j:tr('puzzles.paris_wants_150g_one_100g_wave'),src:['fra'],dem:[{t:'eye',a:'par',g:150}],budget:175000},
|
||||
{id:'shining',pack:'hello',n:tr('puzzles.sea_to_shining_sea'),j:tr('puzzles.four_cities_one_continent_and_a'),src:['nyc'],dem:[{t:'eye',a:'chi',g:40},{t:'eye',a:'dal',g:30},{t:'eye',a:'sjc',g:60}],budget:715000},
|
||||
{id:'downunder',pack:'hello',n:tr('puzzles.down_under_up_and_running'),j:tr('puzzles.one_very_big_island_and_a'),src:['syd'],dem:[{t:'eye',a:'mel',g:50},{t:'eye',a:'bne',g:30},{t:'eye',a:'adl',g:20}],budget:585000},
|
||||
{id:'edgelord',pack:'rodeo',n:tr('puzzles.edge_lord'),j:tr('puzzles.london_wants_half_a_terabit_your'),src:['ams'],dem:[{t:'eye',a:'lon',g:500}],budget:240000},
|
||||
{id:'hubcap',pack:'rodeo',n:tr('puzzles.hub_cap'),j:tr('puzzles.all_of_europe_s_cat_videos'),src:['lon'],dem:[{t:'eye',a:'ams',g:150},{t:'eye',a:'par',g:150},{t:'eye',a:'fra',g:120}],budget:455000},
|
||||
{id:'ports',pack:'rodeo',n:tr('puzzles.port_authority'),j:tr('puzzles.six_cities_a_few_gigs_each'),src:['zrh'],dem:[{t:'eye',a:'mil',g:12},{t:'eye',a:'muc',g:12},{t:'eye',a:'fra',g:12},{t:'eye',a:'par',g:12},{t:'eye',a:'vie',g:12},{t:'eye',a:'prg',g:12}],budget:470000},
|
||||
{id:'flash',pack:'cops',n:tr('puzzles.flash_boys'),j:tr('puzzles.traders_paid_millions_to_shave_milliseconds'),src:['nyc'],dem:[{t:'l2',a:'nyc',b:'lon',g:10,ms:26},{t:'eye',a:'lon',g:80,be:1}],budget:660000},
|
||||
{id:'baltic',pack:'cops',n:tr('puzzles.baltic_shortcut'),j:tr('puzzles.the_road_to_tallinn_is_short'),src:['fra'],dem:[{t:'eye',a:'tll',g:60},{t:'l2',a:'fra',b:'tll',g:10,ms:8.8}],via:['hel'],budget:285000},
|
||||
{id:'fjord',pack:'cops',n:tr('puzzles.fjord_focus'),j:tr('puzzles.the_oil_rigs_want_their_numbers'),src:['par'],dem:[{t:'eye',a:'svg',g:30},{t:'l2',a:'par',b:'svg',g:10,ms:7.2}],via:['lon'],budget:265000},
|
||||
{id:'braces',pack:'n1',n:tr('puzzles.belt_and_braces'),j:tr('puzzles.two_cables_across_the_atlantic_because'),src:['nyc'],dem:[{t:'eye',a:'lon',g:60},{t:'eye',a:'dub',g:40}],budget:840000},
|
||||
{id:'sharks',pack:'n1',n:tr('puzzles.the_shark_tank'),j:tr('puzzles.the_sharks_have_been_biting_again'),src:['lis'],dem:[{t:'eye',a:'mad',g:40},{t:'eye',a:'par',g:60},{t:'eye',a:'mil',g:30}],via:['bcn','mrs'],noSub:true,budget:450000},
|
||||
{id:'nofra',pack:'n1',n:tr('puzzles.not_through_frankfurt'),j:tr('puzzles.de_kicks_sales_has_your_number'),src:['ams'],dem:[{t:'eye',a:'ber',g:50},{t:'eye',a:'muc',g:50},{t:'eye',a:'zrh',g:40}],via:['ham','dus'],avoid:['fra'],budget:390000},
|
||||
{id:'fire',pack:'n1',n:tr('puzzles.ring_of_fire'),j:tr('puzzles.four_cities_four_cables_one_ring'),src:['tok'],dem:[{t:'eye',a:'hkg',g:20},{t:'eye',a:'sin',g:20},{t:'eye',a:'syd',g:10}],ring:true,budget:4070000},
|
||||
{id:'suez',pack:'final',n:tr('puzzles.suez_you_later'),j:tr('puzzles.frankfurt_to_singapore_the_short_way'),src:['fra'],dem:[{t:'l2',a:'fra',b:'sin',g:10,ms:68},{t:'eye',a:'sin',g:30,be:1}],via:['mrs','bom'],budget:1790000},
|
||||
{id:'kiwi',pack:'final',n:tr('puzzles.kiwi_fruit_salad'),j:tr('puzzles.new_zealand_is_far_from_everything'),src:['sea'],dem:[{t:'eye',a:'akl',g:20},{t:'eye',a:'syd',g:40}],via:['hnl','suv','lax'],budget:4200000},
|
||||
{id:'samba',pack:'final',n:tr('puzzles.samba_sprint'),j:tr('puzzles.sao_paulo_to_miami_before_the'),src:['mia'],dem:[{t:'l2',a:'sao',b:'mia',g:10,ms:45},{t:'eye',a:'sao',g:40},{t:'eye',a:'rio',g:20,be:1}],via:['for'],budget:2655000},
|
||||
];
|
||||
// Weekly puzzle pools: each is one landmass and one region, so every pair has an overland route.
|
||||
const PZ_WEEK_POOLS=[
|
||||
['fra','ams','par','mad','mil','ber','waw','vie','sto','cph','prg','zrh','bcn','mrs','muc','bud'],
|
||||
['nyc','chi','dal','sea','sjc','lax','mia','ash','atn','den','bos','hou','phx','tor','mtl'],
|
||||
['sao','rio','bsb','bhz','cwb','poa','ssa','rec','for','cpq'],
|
||||
['syd','mel','bne','adl','cbr','per'],
|
||||
['bom','del','maa','blr','hyd'],
|
||||
];
|
||||
158
src/game/60-features/92-puzzles.js
Normal file
158
src/game/60-features/92-puzzles.js
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
/* ================= PUZZLES (#190) =================
|
||||
Small, calm builds that carry real traffic: every puzzle has demand (eyeballs pulling from a content origin, circuits
|
||||
between two cities with a latency cap), and the game's own compute() routes it: metrics, standby, LAGs, router
|
||||
capacity and ports all behave as in the main game. A puzzle runs as its own S (S.mode='puzzle'): no clock, no bills,
|
||||
no incidents, links up at once. The demand is ordinary game state, so compute() needs no puzzle cases: an origin is a
|
||||
transit port (t.pz, which takes no router port), a circuit is an L2VPN customer, eyeballs are broadband with a fixed
|
||||
demand. That S is never saved. Only progress (stars and best spend per puzzle, weekly results and the weekly streak)
|
||||
is kept, under its own key, so the main save is never touched. */
|
||||
const PZ_KEY='sot-puzzles',PZ_YEAR=12,PZ_SET=2;
|
||||
const pzOn=()=>!!(S&&S.mode==='puzzle'&&S.pz);
|
||||
const pzDef=id=>PZ.find(p=>p.id===id)||null;
|
||||
// goal: a city the traffic starts or ends in; via: a suggested stepping stone; avoid: off limits; off: any other city
|
||||
// (the whole world is open, it just is not part of the plan).
|
||||
const pzKind=c=>!pzOn()?null:S.ar?arKind(c):S.pz.cities.includes(c)?'goal':S.pz.via.includes(c)?'via':S.pz.avoid.includes(c)?'avoid':pzCityOk(c)?'off':null;
|
||||
const pzName=d=>d.id==='weekly'?(d.wn?pzTxt(d.wn):tr('puzzles.weekly_puzzle_key',{key:d.key})):d.n;
|
||||
const pzStarStr=n=>'⭐'.repeat(n)+'⬜'.repeat(3-n);
|
||||
// Every city a puzzle's traffic touches, origins first.
|
||||
const pzCities=d=>[...new Set([...(d.src||[]),...d.dem.flatMap(f=>f.t==='l2'?[f.a,f.b]:[f.a])])];
|
||||
// ---------- progress (localStorage, never trusted) ----------
|
||||
// `set` is the puzzle set the stars belong to: the set with traffic (2) started again, and the stars won before hang
|
||||
// framed on the wall (`old`), with a note shown once (`noted`). Weekly results and the streak carry on.
|
||||
function pzClean(j){const o={set:PZ_SET,s:{},wk:{},streak:{last:null,n:0,best:0},old:null,noted:1};if(!j||typeof j!=='object')return o;
|
||||
const rec=r=>{if(!r||typeof r!=='object')return null;const o={st:int(r.st,0,3,0),sp:r.sp==null||!isFinite(+r.sp)||+r.sp<0?null:Math.round(+r.sp)},rv=int(r.rv,1,999,1);if(rv>1)o.rv=rv;return o;};
|
||||
const cur=j.set===PZ_SET;
|
||||
if(j.s&&typeof j.s==='object'){if(cur){for(const k of Object.keys(j.s)){const r=rec(j.s[k]);if(pzDef(k)&&r)o.s[k]=r;}}
|
||||
else{let n=0;for(const k of Object.keys(j.s).slice(0,200)){const r=rec(j.s[k]);if(r&&/^[a-z0-9]{1,20}$/.test(k))n+=r.st;}if(n){o.old=n;o.noted=0;}}}
|
||||
if(cur){o.old=j.old==null?null:int(j.old,0,9999,0)||null;o.noted=j.noted?1:0;if(o.old==null)o.noted=1;}
|
||||
if(j.wk&&typeof j.wk==='object')for(const k of Object.keys(j.wk)){const r=rec(j.wk[k]);if(/^\d{4}-W\d{2}$/.test(k)&&r)o.wk[k]=r;}
|
||||
const st=j.streak;if(st&&typeof st==='object'){o.streak.last=typeof st.last==='string'&&/^\d{4}-W\d{2}$/.test(st.last)?st.last:null;o.streak.n=int(st.n,0,9999,0);o.streak.best=int(st.best,0,9999,0);}
|
||||
return o;}
|
||||
// A weekly's stars belong to the revision they were earned on: a week regenerated for new prices starts again.
|
||||
const pzWkRec=(p,d)=>{const r=p.wk[d.key];return r&&(r.rv||1)===(d.rev||1)?r:null;};
|
||||
function pzLoad(){try{return pzClean(JSON.parse(localStorage.getItem(PZ_KEY)||'{}'));}catch(e){return pzClean(null);}}
|
||||
function pzStore(p){try{localStorage.setItem(PZ_KEY,JSON.stringify(p));}catch(e){}}
|
||||
const pzStarsTotal=p=>PZ.reduce((a,x)=>a+((p.s[x.id]||{}).st|0),0);
|
||||
const pzPackOpen=(k,p)=>{const P=PZ_PACKS.find(x=>x.id===k);return !!P&&pzStarsTotal(p||pzLoad())>=P.need;};
|
||||
// ---------- prices: the real game's waves and routers, on day 0, for a year ----------
|
||||
const pzMood=(a,b,sub)=>{const k=waveMarket(a,b,sub);return k.m/k.ero;};
|
||||
// Overland (when the two cities share a landmass) and every cable between them, each with its price factor and latency.
|
||||
function pzRoutes(a,b){const out=[],sub=isSub(a,b);
|
||||
if(!sub){const km=kmBetween(a,b);out.push({via:'land',cab:null,km,sub:false,f:landMult(a,b)*pzMood(a,b,false),ms:km*1.3/200});}
|
||||
for(const c of cablesFor(a,b))if(!out.some(r=>r.via===c.cid))out.push({via:c.cid,cab:c.cid,km:c.km,sub:true,f:CAB[c.cid].price*pzMood(a,b,true),ms:c.km*(CAB[c.cid].lat||1)/200});
|
||||
return out;}
|
||||
const pzMo=(r,tier,div)=>Math.round(waveMo(r.km,r.sub,tier)*r.f*(div?DIVERSE:1));
|
||||
const pzLinkCost=(r,tier,div)=>pzMo(r,tier,div)*PZ_YEAR;// leased waves have no setup fee: a year of rent
|
||||
const pzPopCost=c=>popCost(c)+PZ_YEAR*popMo(c);// thin markets cost more every month too (#94)
|
||||
// 10G to 800G: an 800G wave needs an 800G router at both ends, as in the main game.
|
||||
const PZ_TIERS=[0,1,2,3];
|
||||
// Router models on offer: the main game's catalogue up to its level-3 gear, cheapest class first.
|
||||
const PZ_RG=RG.map((r,i)=>i).filter(i=>RG[i].lvl<=3&&!RG[i].noPz).sort((a,b)=>RG[a].cls-RG[b].cls||RG[a].cost-RG[b].cost);
|
||||
// A POP's routers for a year: the chassis (the first Rusty Router is free), each extra one as the main game prices it
|
||||
// (#157 cages included), and their rent.
|
||||
function pzRtCost(g,rt){let s=Math.round(RG[g].cost*hwMul('rt'));for(let k=1;k<rt;k++)s+=routerCost(g,k);return s+PZ_YEAR*((rt-1)*ROUTER_MO+cageMo(rt)+rt*RG[g].mo);}
|
||||
const pzRouterCost=c=>{const p=S.pops[c];return p?pzRtCost(p.rgen||0,p.routers||1):0;};
|
||||
function pzSpend(){let s=0;for(const c in S.pops)s+=pzPopCost(c)+pzRouterCost(c);for(const l of S.links)s+=l.mo*PZ_YEAR;return s;}
|
||||
// What one backhoe or one anchor takes out: waves in the same trench, or every wave on the same cable (a cable fails
|
||||
// as a whole, as in the main game's diversity checks).
|
||||
const pzUnit=l=>l.cable?'cab:'+l.cable:String(l.trench||l.id);
|
||||
// ---------- the traffic ----------
|
||||
// Origins are transit ports the size of a content farm; circuits are L2VPN customers; eyeballs come with their POP.
|
||||
const PZ_NET='lvl',PZ_ORIG=5;
|
||||
const pzFlowId=i=>'pzf'+i;
|
||||
const pzFlowName=f=>f.t==='l2'?tr('puzzles.flow_circuit_a_b',{a:CITY[f.a].name,b:CITY[f.b].name}):tr('puzzles.flow_eyeballs_in_city',{city:CITY[f.a].name});
|
||||
function pzDemand(){const P=S.pz;S.transit=P.src.map((c,i)=>({id:'pzo'+i,city:c,net:PZ_NET,tier:PZ_ORIG,n:1,pz:1,pref:'normal',hist:[]}));
|
||||
S.biz=P.dem.map((f,i)=>f.t==='l2'?{id:pzFlowId(i),type:'l2vpn',name:pzFlowName(f),city:f.a,city2:f.b,bw:f.g,rate:0,route:'normal',reqs:[],day:0}:null).filter(Boolean);}
|
||||
const pzEye=c=>{const f=pzOn()&&S.pz.dem.find(x=>x.t==='eye'&&x.a===c);return f?f.g:0;};
|
||||
const pzNewPop=c=>{const g=pzEye(c);return {day:0,bb:g?{d:g}:null,boost:0,down:0,routers:1,gen:false,br:S.ar?S.ar.bi:0};};
|
||||
// What each flow gets from the last compute(): Gbps delivered, and a circuit's latency.
|
||||
// Eyeball traffic to networks behind the Great Firewall loses a fifth at the border, as in the main game; that is not
|
||||
// the player's doing, so a puzzle counts what crosses the border as delivered (pzGfw: the share that arrives).
|
||||
let PZ_GFW=null;const pzGfw=()=>PZ_GFW||(PZ_GFW=1-0.2*NETS.filter(n=>n.cn).reduce((a,n)=>a+(NSH[n.id]||0),0));
|
||||
function pzGot(){return S.pz.dem.map((f,i)=>f.t==='l2'?{g:R.l2[pzFlowId(i)]||0,ms:isFinite(R.l2lat[pzFlowId(i)])?R.l2lat[pzFlowId(i)]:null}:{g:S.pops[f.a]?(R.citySrv[f.a]||0)/pzGfw():0,ms:null});}
|
||||
const pzFull=(f,x)=>x.g>=f.g*0.999-1e-6;
|
||||
const pzFast=(f,x)=>!f.ms||(x.ms!=null&&x.ms<=f.ms+1e-9);
|
||||
// ---------- checks ----------
|
||||
function pzRingOk(ls){const nb={};for(const l of ls){(nb[l.a]=nb[l.a]||new Set()).add(l.b);(nb[l.b]=nb[l.b]||new Set()).add(l.a);}
|
||||
const ns=Object.keys(nb);if(ns.length<3||!S.pz.cities.every(c=>nb[c])||!Object.keys(S.pops).every(c=>nb[c])||!ns.every(c=>nb[c].size===2))return false;
|
||||
let prev=null,cur=ns[0],n=0;do{const nx=[...nb[cur]].find(x=>x!==prev);prev=cur;cur=nx;n++;}while(cur!==ns[0]&&n<=ns.length);return cur===ns[0]&&n===ns.length;}
|
||||
// The same build always gets the same answer, so pzEval() keeps the last one (it routes once, then once per cut).
|
||||
const pzSig=()=>JSON.stringify([S.pops,S.links,S.pairMet||null,S.biz.map(b=>b.route),S.pz.budget]);
|
||||
/* ⭐ every flow delivered in full (circuits within their latency cap), and the twists; ⭐⭐ the year's spend within
|
||||
budget; ⭐⭐⭐ N-1 under load: whichever single trench or cable is cut, every priority flow still gets all of its traffic
|
||||
(best-effort flows may drop). The cut is routed by compute() like the real thing. */
|
||||
function pzEval(){const sig=pzSig(),c0=UI.pzEv;if(c0&&(c0.sig===sig||UI.pzMk))return c0.e;// mid-scene the monkey's cuts are not the build
|
||||
const P=S.pz,hot=UI.hotMap;compute();const R0=R,got=pzGot(),spend=pzSpend(),peak={},pk=()=>{for(const c in R.nodeLoad)peak[c]=Math.max(peak[c]||0,R.nodeLoad[c]);};pk();
|
||||
const flows=P.dem.map((f,i)=>({f,i,g:got[i].g,ms:got[i].ms,full:pzFull(f,got[i]),fast:pzFast(f,got[i])}));
|
||||
const tw=[];if(P.noSub)tw.push({k:'sub',ok:!S.links.some(l=>l.sub)});
|
||||
if(P.ring)tw.push({k:'ring',ok:pzRingOk(S.links)});
|
||||
if(P.avoid.length)tw.push({k:'avoid',ok:P.avoid.every(c=>!S.pops[c])});
|
||||
const del=flows.every(x=>x.full&&x.fast),goal=del&&tw.every(t=>t.ok),units=[...new Set(S.links.map(pzUnit))],cuts=[];
|
||||
if(goal)try{for(const u of units){const ls=S.links.filter(l=>pzUnit(l)===u);for(const l of ls)l.cut=1;
|
||||
try{compute();pk();const g=pzGot(),lost=[];P.dem.forEach((f,i)=>{if(!f.be&&!pzFull(f,g[i]))lost.push({i,g:Math.max(0,f.g-g[i].g)});});if(lost.length)cuts.push({u,lost,g:lost.reduce((a,x)=>a+x.g,0)});}
|
||||
finally{for(const l of ls)l.cut=0;}}}
|
||||
finally{R=R0;UI.hotMap=hot;}
|
||||
cuts.sort((a,b)=>b.g-a.g);
|
||||
const n1=goal&&units.length>0&&!cuts.length,cheap=!P.budget||spend<=P.budget;
|
||||
const e={flows,del,tw,goal,spend,cheap,n1,weak:cuts.map(x=>x.u),worst:cuts[0]||null,peak,stars:goal?1+(cheap?1:0)+(n1?1:0):0};
|
||||
UI.pzEv={sig,e};return e;}
|
||||
// ---------- the seeded weekly puzzle: the same for everyone, and the stand-in when the published one (93-puzzles-weekly.js) is not there ----------
|
||||
function pzWeekly(dt){const key=pzWeekKey(dt||new Date());let r=hstr('puzzle|'+key)||1;const nx=()=>{r=(Math.imul(r,1103515245)+12345)>>>0;return r/4294967296;};
|
||||
const pool=PZ_WEEK_POOLS[Math.floor(nx()*PZ_WEEK_POOLS.length)].slice(),n=4+Math.floor(nx()*2),cities=[];
|
||||
while(cities.length<n&&pool.length)cities.push(pool.splice(Math.floor(nx()*pool.length),1)[0]);
|
||||
// Content sits in the first city, eyeballs in the others, and all of it fits one 10G wave: so a 10G ring through the
|
||||
// cities, nearest first, on the cheapest route of each hop, carries everything whichever hop is cut. A ring survives
|
||||
// any single cut only if no two hops share a cable, so each hop takes the cheapest route on a cable the ring has not
|
||||
// used yet (overland is always there: a pool is one landmass). The budget is that ring plus 10%.
|
||||
const ring=[cities[0]],left=cities.slice(1);while(left.length){const u=ring[ring.length-1];left.sort((a,b)=>kmBetween(u,a)-kmBetween(u,b));ring.push(left.shift());}
|
||||
let cost=cities.reduce((a,c)=>a+pzPopCost(c),0);const used=new Set(),via=[];
|
||||
for(let i=0;i<ring.length;i++){const r=pzRoutes(ring[i],ring[(i+1)%ring.length]).filter(x=>!x.cab||!used.has(x.cab)).sort((x,y)=>pzLinkCost(x,0,false)-pzLinkCost(y,0,false))[0];
|
||||
if(r.cab)used.add(r.cab);via.push(r.via);cost+=pzLinkCost(r,0,false);}
|
||||
const g=Math.floor(9/(n-1)),dem=cities.slice(1).map(c=>({t:'eye',a:c,g}));
|
||||
return {id:'weekly',key,cities,src:[cities[0]],dem,via:[],budget:Math.ceil(cost*1.1/10000)*10000,ref:ring,refVia:via};}
|
||||
function pzStreak(p,key){const st=p.streak;if(st.last===key)return;st.n=st.last&&st.last===pzPrevKey(key)?st.n+1:1;st.last=key;st.best=Math.max(st.best,st.n);}
|
||||
function pzShareText(e){const P=S.pz;return tr('puzzles.share_line',{what:P.id==='weekly'?P.key:pzName(pzDef(P.id)),stars:pzStarStr(e.stars),spend:fmt$(e.spend)});}
|
||||
// ---------- entering and leaving ----------
|
||||
// Toasts from one world never carry over into the other (their buttons act on the S they came from).
|
||||
const pzToastsClear=()=>{$('toasts').textContent='';};
|
||||
// The running game gets its usual save first and is kept in memory, set aside: save() keeps writing it to its slot
|
||||
// (leaving the page mid-puzzle), and leaving the puzzle picks it up again.
|
||||
function pzFlush(){save(true);UI.pzKeep=S;}
|
||||
function pzBegin(def){if(!def)return;pzMkStop();mkStop();
|
||||
const go=()=>{const cs=pzCities(def);newGame(pzName(def),cs[0]);S.pops={};S.mode='puzzle';S.rules=makeRules('puzzle');S.nextFail=S.nextEvent=1e9;S.tut=null;
|
||||
S.pz={id:def.id,key:def.key||null,cities:cs,src:(def.src||[]).slice(),dem:def.dem.map(f=>({t:f.t,a:f.a,b:f.t==='l2'?f.b:null,g:f.g,ms:f.ms||0,be:!!f.be})),
|
||||
via:(def.via||[]).slice(),avoid:(def.avoid||[]).slice(),budget:def.budget||0,noSub:!!def.noSub,ring:!!def.ring,wn:def.wn||null,wj:def.wj||null,theme:def.theme||null,rev:def.rev||1};
|
||||
pzDemand();
|
||||
UI.pzHist=[];UI.pzTop=0;UI.pzEv=null;UI.speed=0;UI.resumeSpeed=null;UI.started=true;UI.sel=null;UI.leftOpen=false;UI.confirm=null;UI._pzh=null;
|
||||
$('dash').hidden=true;$('bankBox').hidden=true;closeModal();pzToastsClear();document.body.classList.add('pz');
|
||||
compute();pzCam();renderAll();track('puzzle_'+def.id);
|
||||
toast(`<b>${esc(pzName(def))}</b><br>${tr('puzzles.carry_list',{list:S.pz.dem.map(f=>`${esc(pzFlowName(f))} ${fmtG(f.g)}`).join(', ')})}`,'goal');};
|
||||
if(pzOn()){go();return;}
|
||||
const live=!!(S&&UI.started&&!S.lost);UI.pzFrom=live?'game':'title';
|
||||
if(live)pzFlush();go();}
|
||||
function pzLeave(){pzMkStop();if(S&&S.ar)arStop(true);mkStop();const from=UI.pzFrom;pzToastsClear();document.body.classList.remove('pz');UI.sel=null;UI.pzHist=null;UI.pzFrom=null;UI.pzEv=null;closeModal();$('panel').hidden=true;$('pzBox').hidden=true;S=null;R=emptyR();UI.started=false;
|
||||
if(from==='game'){const sv=UI.pzKeep||loadSave();UI.pzKeep=null;
|
||||
if(sv){try{S=migrate(sv);compute();UI.started=true;UI.speed=[0,0.5,1,2,4,8].includes(S.uiSpeed)?S.uiSpeed:1;if(S.cam&&isFinite(S.cam.x))Object.assign(cam,S.cam);renderAll();return;}catch(e){console.error('[tubes] loading the network failed',e);S=null;UI.started=false;}}
|
||||
// It cannot be loaded back: marked damaged (kept, so it can be exported), and the player is told.
|
||||
if(UI.slot&&(sv||UI.loadBad)){slotBroke(UI.slot);return;}}
|
||||
renderAll();showTitle();}
|
||||
// The camera frames the puzzle's cities beside the puzzle card: left on wide screens, right on phones on their side, a bottom sheet on phones.
|
||||
function pzCam(){const cs=[...S.pz.cities,...S.pz.via].map(c=>CITY[c]),x0=cs[0].x;let a=Infinity,b=-Infinity,c=Infinity,d=-Infinity;
|
||||
for(const C of cs){const x=x0+wrapDx(x0,C.x);a=Math.min(a,x);b=Math.max(b,x);c=Math.min(c,C.y);d=Math.max(d,C.y);}
|
||||
const ph=isPhone(),side=ph&&CW>CH,pl=side?-Math.min(360,CW*0.52):ph?0:S.ar&&CW>760&&CH>500?410:330,pb=ph&&!side?Math.min(230,CH*0.4):0,aw=Math.max(120,CW-Math.abs(pl)-90),ah=Math.max(120,CH-pb-150);
|
||||
cam.z=clamp(Math.min(aw/Math.max(40,b-a),ah/Math.max(40,d-c)),0.5,4);cam.x=(a+b)/2-pl/2/cam.z;cam.y=(c+d)/2+(pb/2-30)/cam.z;wrapCam();}
|
||||
// ---------- building ----------
|
||||
function pzSnap(){pzMkStop();if(S.ar)arStop();const h=UI.pzHist||(UI.pzHist=[]);h.push(JSON.stringify({p:S.pops,l:S.links,m:S.pairMet||{},r:S.biz.map(b=>b.route),k:S.ar?S.ar.sunk:0}));if(h.length>60)h.shift();}
|
||||
function pzAfter(){if(UI.sel&&((UI.sel.type==='link'&&!S.links.some(l=>l.id===UI.sel.id))||(UI.sel.type==='city'&&!pzKind(UI.sel.id))))UI.sel=null;
|
||||
if(S.ar)arRouters();compute();renderAll();pzCheck();}
|
||||
// Stars count the moment they are earned.
|
||||
// Every solved state is recorded, so a cheaper build at the same stars counts too.
|
||||
// A new star below three is a cheer and a nudge, and play goes on; the results card opens at three stars, or when the
|
||||
// player says they are done (the card's Finish button).
|
||||
function pzCheck(){if(arOn())return null;const e=pzEval();if(e.stars)pzRecord(e);if(e.stars<=(UI.pzTop||0))return e;const prev=UI.pzTop||0;UI.pzTop=e.stars;const show=()=>{if(e.stars>=3)pzResults(e,prev);else{pzCheer(e,prev);renderAll();}};if(pzMkCan())pzMonkey(show);else show();return e;}
|
||||
// The best spend belongs to the best star count: more stars start it again, the same stars keep the lower spend.
|
||||
function pzRecord(e){const p=pzLoad(),P=S.pz,bag=P.id==='weekly'?p.wk:p.s,k=P.id==='weekly'?P.key:P.id,r=(P.id==='weekly'?pzWkRec(p,P):bag[k])||{st:0,sp:null};
|
||||
if(e.stars<r.st||(e.stars===r.st&&r.sp!=null&&r.sp<=e.spend))return;
|
||||
r.sp=e.spend;r.st=e.stars;if(P.id==='weekly'&&P.rev>1)r.rv=P.rev;else delete r.rv;bag[k]=r;if(P.id==='weekly')pzStreak(p,P.key);pzStore(p);}
|
||||
// The next puzzle in the list whose pack is open.
|
||||
function pzNextDef(){const p=pzLoad(),i=PZ.findIndex(x=>x.id===S.pz.id);for(let j=i+1;j<PZ.length;j++)if(pzPackOpen(PZ[j].pack,p))return PZ[j];return null;}
|
||||
88
src/game/60-features/93-puzzles-weekly.js
Normal file
88
src/game/60-features/93-puzzles-weekly.js
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/* ================= THE PUBLISHED WEEKLY PUZZLE =================
|
||||
A puzzle week runs from Sunday 06:00 Berlin time to the next Sunday 06:00. Its key is the ISO week of its Monday
|
||||
(the week starting Sunday 1 Nov 2026 is 2026-W45), so keys look like the old ISO-week keys and old streaks carry on.
|
||||
Every Sunday a GitHub workflow publishes puzzles/weekly/<key>.json (scripts/weekly-puzzle.js): a static file next to
|
||||
the page, fetched only when the player opens Puzzles. It is checked field by field; when it is missing, offline or
|
||||
wrong, the seeded weekly in 92-puzzles.js stands in, so the weekly puzzle never breaks. */
|
||||
// Europe/Berlin is UTC+1, and UTC+2 from the last Sunday of March to the last Sunday of October, 01:00 UTC both times.
|
||||
const pzLastSun=(y,m)=>{const d=new Date(Date.UTC(y,m+1,0));return Date.UTC(y,m,d.getUTCDate()-d.getUTCDay(),1);};
|
||||
const pzBerlinOff=t=>{const y=new Date(t).getUTCFullYear();return t>=pzLastSun(y,2)&&t<pzLastSun(y,9)?2:1;};
|
||||
// 06:00 Berlin on the Sunday at UTC midnight `sun`; the clocks change at 01:00 UTC, well before.
|
||||
const pzSunStart=sun=>sun+(6-pzBerlinOff(sun+4*3600e3))*3600e3;
|
||||
function pzIso(t){const d=new Date(t);d.setUTCHours(0,0,0,0);d.setUTCDate(d.getUTCDate()+4-(d.getUTCDay()||7));const y=d.getUTCFullYear();return `${y}-W${String(Math.ceil(((d-Date.UTC(y,0,1))/864e5+1)/7)).padStart(2,'0')}`;}
|
||||
// The key of the puzzle week holding this moment.
|
||||
function pzWeekKey(dt){const t=+dt,d=new Date(t);let sun=Date.UTC(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate())-d.getUTCDay()*864e5;
|
||||
if(t<pzSunStart(sun))sun-=7*864e5;return pzIso(sun+864e5);}
|
||||
// When a week starts (UTC ms), or null for a key that is not a real week.
|
||||
function pzWeekStart(key){const m=/^(\d{4})-W(\d{2})$/.exec(String(key));if(!m)return null;const j4=Date.UTC(+m[1],0,4),mon=j4-((new Date(j4).getUTCDay()+6)%7)*864e5+(+m[2]-1)*7*864e5;
|
||||
const t=pzSunStart(mon-864e5);return pzWeekKey(t)===key?t:null;}
|
||||
// n weeks on (or back). Weeks are 7 days plus or minus the hour the clocks change, so aim 3 hours into the week.
|
||||
const pzKeyAdd=(key,n)=>{const t=pzWeekStart(key);return t==null?null:pzWeekKey(t+n*7*864e5+3*3600e3);};
|
||||
const pzPrevKey=key=>pzKeyAdd(key,-1);
|
||||
// ---------- themes and their text: labels, so the file names a label and the player reads their language ----------
|
||||
// A file may only use these labels (N_: kept whole in the shipped page, since the file names them in full).
|
||||
const PZ_WK_THEMES={
|
||||
detour:{i:'🚧',t:N_('puzzles_weekly.detour'),names:[N_('puzzles_weekly.name_anywhere_but_hub'),N_('puzzles_weekly.name_who_needs_hub')],jokes:[N_('puzzles_weekly.joke_hub_is_having_a_very'),N_('puzzles_weekly.joke_the_obvious_path_goes_through')]},
|
||||
islands:{i:'🏝️',t:N_('puzzles_weekly.island_hopping'),names:[N_('puzzles_weekly.name_hop_skip_and_a_cable'),N_('puzzles_weekly.name_sun_sea_and_subsea')],jokes:[N_('puzzles_weekly.joke_every_hop_is_a_cable'),N_('puzzles_weekly.joke_the_cheapest_way_between_two')]},
|
||||
ocean:{i:'🌊',t:N_('puzzles_weekly.ocean_crossing'),names:[N_('puzzles_weekly.name_sea_you_in_b'),N_('puzzles_weekly.name_across_the_big_blue')],jokes:[N_('puzzles_weekly.joke_the_ocean_is_big_and'),N_('puzzles_weekly.joke_somewhere_between_a_and_b')]},
|
||||
ring:{i:'💍',t:N_('puzzles_weekly.ring'),names:[N_('puzzles_weekly.name_one_ring_to_rule_reg'),N_('puzzles_weekly.name_ring_around_reg')],jokes:[N_('puzzles_weekly.joke_one_ring_through_every_pop'),N_('puzzles_weekly.joke_a_ring_survives_one_cut')]},
|
||||
sprint:{i:'⚡',t:N_('puzzles_weekly.latency_sprint'),names:[N_('puzzles_weekly.name_race_to_b'),N_('puzzles_weekly.name_ms_ms_or_bust')],jokes:[N_('puzzles_weekly.joke_a_to_b_under_ms'),N_('puzzles_weekly.joke_the_speed_of_light_is')]},
|
||||
tour:{i:'🗺️',t:N_('puzzles_weekly.region_tour'),names:[N_('puzzles_weekly.name_tour_de_reg'),N_('puzzles_weekly.name_are_we_there_yet_a')],jokes:[N_('puzzles_weekly.joke_n_cities_one_landmass_and'),N_('puzzles_weekly.joke_a_road_trip_for_photons')]},
|
||||
};
|
||||
// What each {placeholder} in those labels holds: c a city id, r a region code, n a whole number.
|
||||
const PZ_WK_P={a:'c',b:'c',hub:'c',reg:'r',ms:'n',n:'n'};
|
||||
const pzCityOk=c=>isCity(c)&&!CITY[c].off&&!CITY[c].cn;
|
||||
const pzTxt=o=>{const v={};for(const k in o.p){const x=o.p[k],t=PZ_WK_P[k];v[k]=t==='c'?CITY[x].name:t==='r'?WAVE_NAME[x]:x;}return tr(o.l,v);};
|
||||
// ---------- the file: never trusted. Only known fields, known cities, known labels and sane numbers get through ----------
|
||||
const pzObj=o=>!!o&&typeof o==='object'&&!Array.isArray(o);
|
||||
function pzWkTxt(o,list){if(!pzObj(o)||typeof o.l!=='string'||!list.includes(o.l))return null;const p=o.p==null?{}:o.p;if(!pzObj(p))return null;
|
||||
const need=[...new Set([...String(EN[o.l]).matchAll(/\{(\w+)\}/g)].map(m=>m[1]))],out={};
|
||||
if(Object.keys(p).length!==need.length)return null;
|
||||
for(const k of need){const t=PZ_WK_P[k],v=own(p,k)?p[k]:undefined;
|
||||
if(t==='c'&&pzCityOk(v))out[k]=v;else if(t==='r'&&typeof v==='string'&&own(WAVE_NAME,v))out[k]=v;else if(t==='n'&&Number.isInteger(v)&&v>0&&v<1000)out[k]=v;else return null;}
|
||||
return {l:o.l,p:out};}
|
||||
// rev: the file's revision, from 2 when a release's new prices made the week regenerate (scripts/weekly-puzzle.js).
|
||||
const PZ_WK_FIELDS=['v','key','theme','cities','src','dem','via','avoid','budget','twist','name','joke','ref','rev'];
|
||||
// Schema 2 (puzzles with traffic): `src` the content origins, `dem` the flows ({t:'eye',a,g} eyeballs in a; {t:'l2',a,b,g,ms}
|
||||
// a circuit, ms its latency cap; be:true best effort), `cities` exactly the cities they touch. Older files are refused.
|
||||
const PZ_WK_V=2;
|
||||
function pzWkDem(a){if(!Array.isArray(a)||a.length<1||a.length>6)return null;const out=[],eye=new Set();
|
||||
for(const f of a){if(!pzObj(f)||Object.keys(f).some(k=>!['t','a','b','g','ms','be'].includes(k))||!pzCityOk(f.a)||!Number.isInteger(f.g)||f.g<1||f.g>2000)return null;
|
||||
if(own(f,'be')&&f.be!==true)return null;
|
||||
if(f.t==='eye'){if(own(f,'b')||own(f,'ms')||eye.has(f.a))return null;eye.add(f.a);out.push({t:'eye',a:f.a,g:f.g,be:!!f.be});}
|
||||
else if(f.t==='l2'){if(!pzCityOk(f.b)||f.b===f.a||(own(f,'ms')&&!(typeof f.ms==='number'&&isFinite(f.ms)&&f.ms>=1&&f.ms<=500)))return null;out.push({t:'l2',a:f.a,b:f.b,g:f.g,ms:f.ms||0,be:!!f.be});}
|
||||
else return null;}
|
||||
return out;}
|
||||
function pzWkValid(j,key){if(!pzObj(j)||Object.keys(j).some(k=>!PZ_WK_FIELDS.includes(k))||j.v!==PZ_WK_V||j.key!==key||pzWeekStart(key)==null||typeof j.theme!=='string'||!own(PZ_WK_THEMES,j.theme))return null;
|
||||
const T=PZ_WK_THEMES[j.theme],ids=(a,lo,hi)=>Array.isArray(a)&&a.length>=lo&&a.length<=hi&&a.every(pzCityOk)&&new Set(a).size===a.length?a.slice():null;
|
||||
const cities=ids(j.cities,2,6),src=ids(j.src==null?[]:j.src,0,3),via=ids(j.via==null?[]:j.via,0,4),avoid=ids(j.avoid==null?[]:j.avoid,0,2),dem=pzWkDem(j.dem);if(!cities||!src||!via||!avoid||!dem)return null;
|
||||
// Eyeballs need somewhere to pull from; an origin is not also a city of eyeballs.
|
||||
if(dem.some(f=>f.t==='eye')&&!src.length||dem.some(f=>f.t==='eye'&&src.includes(f.a)))return null;
|
||||
const d0={src,dem},cs=pzCities(d0);if(cs.length!==cities.length||!cs.every(c=>cities.includes(c)))return null;
|
||||
const all=[...cities,...via,...avoid];if(new Set(all).size!==all.length)return null;
|
||||
if(!Number.isInteger(j.budget)||j.budget<50000||j.budget>2e7)return null;
|
||||
const tw=j.twist==null?{}:j.twist;if(!pzObj(tw)||Object.keys(tw).some(k=>!['ring','noSub'].includes(k)))return null;
|
||||
if(j.rev!==undefined&&!(Number.isInteger(j.rev)&&j.rev>=2&&j.rev<=999))return null;
|
||||
const d={id:'weekly',key,theme:j.theme,cities,src,dem,via,avoid,budget:j.budget,noSub:false,ring:false,rev:j.rev||1};
|
||||
if(own(tw,'ring')){if(tw.ring!==true)return null;d.ring=true;}
|
||||
if(own(tw,'noSub')){if(tw.noSub!==true)return null;d.noSub=true;}
|
||||
d.wn=pzWkTxt(j.name,T.names);d.wj=pzWkTxt(j.joke,T.jokes);if(!d.wn||!d.wj)return null;
|
||||
return d;}
|
||||
// ---------- fetching it: when Puzzles opens, never on page load ----------
|
||||
function pzWkEnsure(){const key=pzWeekKey(new Date()),w=UI.pzWk;
|
||||
if(w&&w.key===key&&(w.st!=='fb'||Date.now()-w.at<5*60e3))return;
|
||||
const st=UI.pzWk={key,st:w&&w.key===key&&w.def?'ok':'load',def:w&&w.key===key?w.def:null,at:Date.now()};
|
||||
let done=false;const fin=def=>{if(done)return;done=true;clearTimeout(to);if(UI.pzWk!==st)return;if(def){st.def=def;st.st='ok';}else if(!st.def)st.st='fb';st.at=Date.now();pzWkRefresh();};
|
||||
const ac=window.AbortController?new AbortController():null,to=setTimeout(()=>{if(ac)ac.abort();fin(null);},5000);
|
||||
if(!window.fetch||location.protocol==='file:'){fin(null);return;}
|
||||
// Relative and same origin; each week has its own file name, so caches never serve last week's.
|
||||
try{fetch(`puzzles/weekly/${key}.json`,ac?{signal:ac.signal}:{}).then(r=>r.ok?r.json():null).then(j=>pzWkValid(j,key),()=>null).then(fin,()=>fin(null));}catch(e){fin(null);}}
|
||||
// This week's puzzle: the published one when it came, else the seeded one.
|
||||
function pzWkDef(){const key=pzWeekKey(new Date()),w=UI.pzWk;return w&&w.key===key&&w.def?w.def:pzWeekly();}
|
||||
const pzWkLoading=()=>{const w=UI.pzWk;return !!w&&w.st==='load'&&w.key===pzWeekKey(new Date());};
|
||||
function pzWkRefresh(){const el=$('pzWk');if(el)el.outerHTML=pzWkRow();}
|
||||
// "Next weekly puzzle in 2 d 14 h".
|
||||
function pzWkNext(now){const key=pzWeekKey(now),t=pzWeekStart(pzKeyAdd(key,1))-now,m=Math.max(1,Math.ceil(t/60e3)),d=Math.floor(m/1440),h=Math.floor(m%1440/60);
|
||||
return d?tr('puzzles.next_weekly_in_d_h',{d,h}):tr('puzzles.next_weekly_in_h_m',{h,m:m%60});}
|
||||
// The Puzzles door says so when this week's puzzle has not been played yet.
|
||||
function pzWkNew(){try{const k=pzWeekKey(new Date()),w=UI.pzWk;return !pzWkRec(pzLoad(),w&&w.key===k&&w.def?w.def:{key:k});}catch(e){return false;}}
|
||||
125
src/game/60-features/94-scenarios-weekly.js
Normal file
125
src/game/60-features/94-scenarios-weekly.js
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/* ================= THE PUBLISHED WEEKLY SCENARIO =================
|
||||
The twin of the weekly puzzle: the same weeks (Sunday 06:00 Berlin, pzWeekKey), one themed scenario per week,
|
||||
published by a GitHub workflow as scenarios/weekly/<key>.json (scripts/weekly-scenario.js) and fetched only when the
|
||||
Scenarios list opens. The file is data only: a theme, a start, rules from the scenario vocabulary, and a goal TYPE
|
||||
with its parameters; every goal type is implemented once here, with its progress card. Missing, offline or wrong,
|
||||
the in-browser weekly() stands in. Like every scenario it runs On-call plus its own rules (M4). */
|
||||
// What a {placeholder} holds: c a city, r a region, n a whole number, k a cable id.
|
||||
const WS_P={a:'c',b:'c',city:'c',reg:'r',n:'n',g:'n',day:'n',ms:'n',cab:'k'};
|
||||
const WS_THEMES={
|
||||
budget:{i:'🪙',names:[N_('wkscn.name_shoestring_backbone'),N_('wkscn.name_ramen_profitable')],descs:[N_('wkscn.desc_city_on_a_shoestring'),N_('wkscn.desc_start_in_city_with_pocket')]},
|
||||
cable:{i:'✂️',names:[N_('wkscn.name_suez_you_later'),N_('wkscn.name_cut_and_run')],descs:[N_('wkscn.desc_cab_is_cut_for_the'),N_('wkscn.desc_a_ship_dragged_its_anchor')]},
|
||||
event:{i:'🎉',names:[N_('wkscn.name_party_like_its_1999'),N_('wkscn.name_stream_team')],descs:[N_('wkscn.desc_a_g_event_comes_to'),N_('wkscn.desc_the_whole_city_is_watching')]},
|
||||
flood:{i:'🌊',names:[N_('wkscn.name_flood_week'),N_('wkscn.name_packet_monsoon')],descs:[N_('wkscn.desc_city_hosts_the_internets_favourite'),N_('wkscn.desc_booters_picked_city_for_their')]},
|
||||
island:{i:'🏝️',names:[N_('wkscn.name_island_hopper'),N_('wkscn.name_sea_you_soon')],descs:[N_('wkscn.desc_start_on_city_and_string'),N_('wkscn.desc_city_is_surrounded_by_water')]},
|
||||
latency:{i:'⚡',names:[N_('wkscn.name_ludicrous_speed'),N_('wkscn.name_light_speed_please')],descs:[N_('wkscn.desc_a_trading_firm_needs_a'),N_('wkscn.desc_every_millisecond_between_a_and')]},
|
||||
region:{i:'🗺️',names:[N_('wkscn.name_continental_breakfast'),N_('wkscn.name_planting_flags')],descs:[N_('wkscn.desc_city_is_just_the_start'),N_('wkscn.desc_every_exchange_in_reg_wants')]},
|
||||
spat:{i:'🙊',names:[N_('wkscn.name_not_on_speaking_terms'),N_('wkscn.name_peering_pressure')],descs:[N_('wkscn.desc_cogentle_and_goggle_stopped_talking'),N_('wkscn.desc_two_giants_de_peered_over')]},
|
||||
};
|
||||
const wsRun=()=>S.scn.run|0;
|
||||
const wsIxN=reg=>Object.keys(S.ixp).filter(c=>isIx(c)&&CITY[ixCity(c)]&&CITY[ixCity(c)].reg===reg).length;
|
||||
const wsCs=p=>p.cs.map(c=>CITY[c].name).join(', ');
|
||||
// The goal types. p: each parameter's kind and range ([kind,lo,hi]); ok(p) won; m(p) a number the generator calibrates
|
||||
// against (and the progress bar reads); daily: the goal counts days in a row; prog(p) the card's rows.
|
||||
const WS_GOALS={
|
||||
served:{p:{g:['n',5,50000]},l:N_('wkscn.goal_serve_g'),ok:p=>R.served>=p.g,m:()=>R.served,prog:p=>[pSrv(p.g)]},
|
||||
reach:{p:{r:['n',50,99],g:['n',1,50000]},l:N_('wkscn.goal_reach_r_and_serve_g'),ok:p=>R.reach>=p.r/100&&R.served>=p.g,m:()=>R.served,prog:p=>[{l:tr('common.reach'),v:R.reach,max:p.r/100,txt:`${pct(R.reach)} / ${p.r}%`},pSrv(p.g)]},
|
||||
path:{p:{a:['c'],b:['c'],g:['n',10,12800],n:['n',1,120]},daily:p=>fastPath(p.a,p.b,p.g),l:N_('wkscn.goal_g_on_every_hop_from'),ok:p=>wsRun()>=p.n,m:()=>wsRun(),
|
||||
prog:p=>[pChk(tr('wkscn.p_path_g_a_b',{g:fmtG(p.g),a:CITY[p.a].name,b:CITY[p.b].name}),fastPath(p.a,p.b,p.g)),{l:tr('wkscn.p_days_in_a_row'),v:wsRun(),max:p.n,txt:`${wsRun()} / ${p.n}`}]},
|
||||
ix:{p:{reg:['r'],n:['n',2,60]},l:N_('wkscn.goal_ports_on_n_exchanges_in'),ok:p=>wsIxN(p.reg)>=p.n,m:p=>wsIxN(p.reg),prog:p=>{const n=wsIxN(p.reg);return [{l:tr('wkscn.p_exchange_ports_in_reg',{reg:WAVE_NAME[p.reg]}),v:n,max:p.n,txt:`${n} / ${p.n}`}];}},
|
||||
pops:{p:{cs:['cs',1,8]},l:N_('wkscn.goal_a_connected_pop_in_list'),ok:p=>p.cs.every(c=>pathExists(S.scn.home,c)),m:p=>p.cs.filter(c=>pathExists(S.scn.home,c)).length,prog:p=>p.cs.map(c=>pChk(tr('progress.city_on_your_network',{city:CITY[c].name}),pathExists(S.scn.home,c)))},
|
||||
event:{p:{city:['c'],g:['n',10,6400],day:['n',20,360],dur:['n',1,10]},l:N_('wkscn.goal_deliver_the_event_in_city'),ok:()=>(S.stats.evFull||0)>=1,m:()=>S.stats.evFull||0,
|
||||
setup:p=>S.biz.push({id:uid(),scripted:true,city:p.city,city2:null,reqs:[],name:tr('wkscn.event_name_city',{city:CITY[p.city].name}),type:'event',bw:p.g,rate:0,mood:100,since:0,start:p.day,dur:p.dur,fee:p.g*p.dur*70}),
|
||||
prog:p=>[pChk(tr('wkscn.p_event_delivered_in_full'),(S.stats.evFull||0)>=1),{l:tr('common.traffic_served'),v:0,max:0,txt:tr('wkscn.p_g_on_day_d',{g:fmtG(p.g),d:p.day})}]},
|
||||
floods:{p:{n:['n',1,60],big:['n',0,20]},l:N_('wkscn.goal_hold_n_floods_big_of'),ok:p=>(S.stats.ddosOk||0)>=p.n&&(S.stats.ddosOkBig||0)>=p.big,m:()=>S.stats.ddosOk||0,
|
||||
prog:p=>[{l:tr('common.floods_held'),v:S.stats.ddosOk||0,max:p.n,txt:`${S.stats.ddosOk||0} / ${p.n}`},...(p.big?[{l:tr('progress.terabit_floods_held'),v:S.stats.ddosOkBig||0,max:p.big,txt:`${S.stats.ddosOkBig||0} / ${p.big}`}]:[])]},
|
||||
lat:{p:{a:['c'],b:['c'],ms:['n',1,400],n:['n',1,120]},daily:p=>bestLat(p.a,p.b)<=p.ms,l:N_('wkscn.goal_a_to_b_under_ms'),ok:p=>wsRun()>=p.n,m:()=>wsRun(),
|
||||
prog:p=>{const v=bestLat(p.a,p.b);return [pChk(tr('wkscn.p_a_b_now',{a:CITY[p.a].name,b:CITY[p.b].name,ms:isFinite(v)?v.toFixed(1)+' ms':tr('common.no_path')}),v<=p.ms),{l:tr('wkscn.p_days_in_a_row'),v:wsRun(),max:p.n,txt:`${wsRun()} / ${p.n}`}];}},
|
||||
};
|
||||
// Filled-in text: a label from the file and its typed parameters, in the player's language.
|
||||
const wsVal=(k,x)=>{const t=WS_P[k];return t==='c'?CITY[x].name:t==='r'?WAVE_NAME[x]:t==='k'?CAB[x].name:k==='g'?fmtG(x):x;};
|
||||
const wsTxt=o=>{const v={};for(const k in o.p)v[k]=wsVal(k,o.p[k]);return tr(o.l,v);};
|
||||
function wsGoalTxt(j){const G=j.goal,p=G.p,v={};for(const k in p)v[k]=k==='cs'?wsCs(p):WS_P[k]?wsVal(k,p[k]):p[k];return tr(G.t==='floods'&&!p.big?N_('wkscn.goal_hold_n_floods'):WS_GOALS[G.t].l,v);}
|
||||
// ---------- the file: never trusted ----------
|
||||
const WS_FIELDS=['v','key','theme','city','cash','days','lvl','rules','mods','goal','name','desc','seed','par','ref','rev'];
|
||||
const WS_V=1,WS_RULES=['anchors','banCities','banPairs','ddos','spat'];
|
||||
const wsPairOk=s=>typeof s==='string'&&CABLE_PAIRS.some(c=>s===`${c.cid}:${c.a}-${c.b}`);
|
||||
function wsLab(o,list){if(!pzObj(o)||typeof o.l!=='string'||!list.includes(o.l))return null;const p=o.p==null?{}:o.p;if(!pzObj(p))return null;
|
||||
const need=[...new Set([...String(EN[o.l]).matchAll(/\{(\w+)\}/g)].map(m=>m[1]))],out={};if(Object.keys(p).length!==need.length)return null;
|
||||
for(const k of need){const t=WS_P[k],v=own(p,k)?p[k]:undefined;
|
||||
if(t==='c'&&pzCityOk(v)||t==='r'&&typeof v==='string'&&own(WAVE_NAME,v)||t==='k'&&typeof v==='string'&&own(CAB,v)||t==='n'&&Number.isInteger(v)&&v>0&&v<1e6)out[k]=v;else return null;}
|
||||
return {l:o.l,p:out};}
|
||||
function wsGoal(o){if(!pzObj(o)||typeof o.t!=='string'||!own(WS_GOALS,o.t)||!pzObj(o.p))return null;const G=WS_GOALS[o.t],out={};
|
||||
if(Object.keys(o.p).length!==Object.keys(G.p).length)return null;
|
||||
for(const k in G.p){const [t,lo,hi]=G.p[k],v=o.p[k];
|
||||
if(t==='c'){if(!pzCityOk(v))return null;}else if(t==='r'){if(typeof v!=='string'||!own(WAVE_NAME,v))return null;}
|
||||
else if(t==='cs'){if(!Array.isArray(v)||v.length<lo||v.length>hi||!v.every(pzCityOk)||new Set(v).size!==v.length)return null;}
|
||||
else if(!Number.isInteger(v)||v<lo||v>hi)return null;
|
||||
out[k]=Array.isArray(v)?v.slice():v;}
|
||||
if(out.a&&out.a===out.b)return null;return {t:o.t,p:out};}
|
||||
// A checked copy of the file, or null. The copy is what a game stores and reloads (sanitize() checks it again).
|
||||
function wsValid(j,key){if(!pzObj(j)||Object.keys(j).some(k=>!WS_FIELDS.includes(k))||j.v!==WS_V||j.key!==key||pzWeekStart(key)==null||typeof j.theme!=='string'||!own(WS_THEMES,j.theme))return null;
|
||||
const T=WS_THEMES[j.theme],I=(v,lo,hi)=>Number.isInteger(v)&&v>=lo&&v<=hi;
|
||||
if(!pzCityOk(j.city)||!I(j.cash,50000,2e7)||!I(j.days,60,400)||!I(j.lvl,1,4)||!I(j.seed,1,2**31-1)||!I(j.par,1,j.days))return null;
|
||||
if(j.rev!==undefined&&!I(j.rev,2,999))return null;if(j.ref!==undefined&&!pzObj(j.ref))return null;
|
||||
const r=j.rules==null?{}:j.rules;if(!pzObj(r)||Object.keys(r).some(k=>!WS_RULES.includes(k)))return null;const rules={};
|
||||
for(const k in r){const v=r[k];
|
||||
if(k==='spat'||k==='ddos'){if(v!==true)return null;rules[k]=true;}
|
||||
else if(k==='anchors'){if(!I(v,1,5))return null;rules[k]=v;}
|
||||
else if(k==='banCities'){if(!Array.isArray(v)||v.length>6||!v.every(isCity)||v.includes(j.city))return null;rules[k]=v.slice();}
|
||||
else{if(!Array.isArray(v)||v.length<1||v.length>40||!v.every(wsPairOk))return null;rules[k]=v.slice();}}
|
||||
const mods=j.mods==null?[]:j.mods;if(!Array.isArray(mods)||mods.length>2||new Set(mods).size!==mods.length||!mods.every(m=>WEEK_MODS.some(x=>x.id===m)))return null;
|
||||
const goal=wsGoal(j.goal);if(!goal)return null;
|
||||
// A city the goal needs is never one the rules ban.
|
||||
if(rules.banCities&&Object.values(goal.p).flat().some(c=>rules.banCities.includes(c)))return null;
|
||||
if(goal.t==='event'&&goal.p.day+goal.p.dur>=j.days||goal.t==='floods'&&!rules.ddos)return null;
|
||||
const name=wsLab(j.name,T.names),desc=wsLab(j.desc,T.descs);if(!name||!desc)return null;
|
||||
const o={v:WS_V,key,theme:j.theme,city:j.city,cash:j.cash,days:j.days,lvl:j.lvl,rules,mods:mods.slice(),goal,name,desc,seed:j.seed,par:j.par};if(j.rev)o.rev=j.rev;return o;}
|
||||
// ---------- fetching it: when the Scenarios list opens, never on page load ----------
|
||||
function wsEnsure(){const key=pzWeekKey(new Date()),w=UI.wsWk;
|
||||
if(w&&w.key===key&&(w.st!=='fb'||Date.now()-w.at<5*60e3))return;
|
||||
const st=UI.wsWk={key,st:w&&w.key===key&&w.def?'ok':'load',def:w&&w.key===key?w.def:null,at:Date.now()};
|
||||
let done=false;const fin=def=>{if(done)return;done=true;clearTimeout(to);if(UI.wsWk!==st)return;if(def){st.def=def;st.st='ok';}else if(!st.def)st.st='fb';st.at=Date.now();wsRefresh();};
|
||||
const ac=window.AbortController?new AbortController():null,to=setTimeout(()=>{if(ac)ac.abort();fin(null);},5000);
|
||||
if(!window.fetch||location.protocol==='file:'){fin(null);return;}
|
||||
try{fetch(`scenarios/weekly/${key}.json`,ac?{signal:ac.signal}:{}).then(r=>r.ok?r.json():null).then(j=>wsValid(j,key),()=>null).then(fin,()=>fin(null));}catch(e){fin(null);}}
|
||||
const wsDef=()=>{const key=pzWeekKey(new Date()),w=UI.wsWk;return w&&w.key===key&&w.def?w.def:null;};
|
||||
const wsLoading=()=>{const w=UI.wsWk;return !!w&&w.st==='load'&&w.key===pzWeekKey(new Date());};
|
||||
function wsRefresh(){const el=$('wsRow');if(el)el.outerHTML=wsRow();}
|
||||
// ---------- the player's record: started weeks (for the badge), wins and the streak ----------
|
||||
function wsLoad(){let j=null;try{j=JSON.parse(localStorage.getItem('sot-wkscn')||'null');}catch(e){}const o={go:{},w:{},streak:{last:null,n:0,best:0}};if(!pzObj(j))return o;
|
||||
const K=/^\d{4}-W\d{2}$/;if(pzObj(j.go))for(const k in j.go)if(K.test(k))o.go[k]=1;
|
||||
if(pzObj(j.w))for(const k in j.w){const x=j.w[k];if(K.test(k)&&pzObj(x)&&Number.isInteger(x.d)&&x.d>0)o.w[k]={d:x.d,rv:Number.isInteger(x.rv)?x.rv:1};}
|
||||
const s=j.streak;if(pzObj(s)){o.streak.last=typeof s.last==='string'&&K.test(s.last)?s.last:null;for(const k of ['n','best'])o.streak[k]=Number.isInteger(s[k])&&s[k]>=0?s[k]:0;}return o;}
|
||||
const wsStore=o=>{try{localStorage.setItem('sot-wkscn',JSON.stringify(o));}catch(e){}};
|
||||
// A win counts for its revision: when a week is regenerated (rev), last week's result for it no longer shows.
|
||||
const wsWin=(o,d)=>{const x=d&&o.w[d.key];return x&&x.rv===(d.rev||1)?x:null;};
|
||||
function wsNew(){try{return !wsLoad().go[pzWeekKey(new Date())];}catch(e){return false;}}
|
||||
const wsStreak=(o,key)=>{const s=o.streak;return s.last===key||s.last===pzPrevKey(key)?s.n:0;};
|
||||
// ---------- playing it ----------
|
||||
function wsBegin(j,nm){const d=wsValid(j,j&&j.key);if(!d)return false;const G=WS_GOALS[d.goal.t];
|
||||
const o=wsLoad();o.go[d.key]=1;wsStore(o);
|
||||
beginGame(nm||UI.nm||(S&&S.name)||randomNetworkName(),d.city,{seed:d.seed,scn:{id:'weekly',key:d.key,n:wsTxt(d.name),days:d.days,cash:d.cash,rules:JSON.parse(JSON.stringify(d.rules)),
|
||||
mods:d.mods.map(m=>WEEK_MODS.find(x=>x.id===m)),goal:wsGoalTxt(d),setup:()=>{S.scn.wk=d;S.scn.home=d.city;S.scn.run=0;S.lvl=Math.max(S.lvl||1,d.lvl);if(G.setup)G.setup(d.goal.p);}}});
|
||||
return true;}
|
||||
const wsOk=()=>{const sc=S&&S.scn;if(!sc||!sc.wk)return false;const G=sc.wk.goal;try{return !!WS_GOALS[G.t].ok(G.p);}catch(e){return false;}};
|
||||
const wsMeasure=()=>{const G=S.scn.wk.goal;try{return +WS_GOALS[G.t].m(G.p)||0;}catch(e){return 0;}};
|
||||
function wsShareText(){const sc=S.scn,d=sc.wk;return tr('wkscn.share_line',{key:sc.key,name:wsTxt(d.name),d:sc.done,par:d.par});}
|
||||
// Called by scnTick once a day for a published weekly scenario.
|
||||
function wsTick(d){const sc=S.scn,w=sc.wk,G=WS_GOALS[w.goal.t];
|
||||
if(G.daily){let on=false;try{on=!!G.daily(w.goal.p);}catch(e){}sc.run=on?(sc.run|0)+1:0;}
|
||||
if(wsOk()){sc.done=d;const o=wsLoad(),x=wsWin(o,w);if(!x||x.d>d)o.w[w.key]={d,rv:w.rev||1};const s=o.streak;if(s.last!==w.key){s.n=s.last===pzPrevKey(w.key)?s.n+1:1;s.last=w.key;s.best=Math.max(s.best,s.n);}wsStore(o);track('wkscn_won');
|
||||
openModal(`<div class="eyebrow">${T_WS(w)} ${tr('wkscn.weekly_scenario_key',{key:esc(w.key)})}</div><h2 style="font-size:30px">${tr('wkscn.won_on_day_d',{d})}</h2><p class="tagline">${esc(wsGoalTxt(w))}. ${d<=w.par?tr('wkscn.under_par_par',{par:w.par}):tr('wkscn.par_was_day_par',{par:w.par})}</p><p class="meta">${esc(wsShareText())}</p><div class="btns">${btn(tr('wkscn.copy_my_result'),'wsShare',{},'pink big')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost big')}</div>`);sfx('coin');}
|
||||
else if(d>=sc.days){sc.failed=d;openModal(`<div class="eyebrow">${tr('common.scenario_over')}</div><h2 style="font-size:30px">${tr('common.time_s_up')}</h2><p class="tagline">${tr('scenario_progress.goal_was_not_reached_in_d',{goal:esc(wsGoalTxt(w)),d:sc.days})}</p><div class="btns">${btn(tr('common.try_again'),'startWeekly',{},'pink big')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost big')}</div>`);}}
|
||||
const T_WS=w=>(WS_THEMES[w.theme]||{}).i||'📅';
|
||||
// The top row of the Scenarios list.
|
||||
function wsRow(){const d=wsDef(),o=wsLoad(),key=pzWeekKey(new Date()),st=wsStreak(o,key),badge=o.go[key]?'':` <span class="pznew">${tr('puzzles.new_this_sunday')}</span>`,cd=`<div class="meta pzcd">⏳ ${wsNext(Date.now())}</div>`;
|
||||
if(!d){const wk=weekly();let best=null;try{best=JSON.parse(localStorage.getItem('sot-weekly')||'{}')[wk.key];}catch(e){}
|
||||
return `<div class="scn wk" id="wsRow"><div class="grow"><div class="eyebrow">📅 ${tr('wkscn.weekly_scenario_key',{key:esc(wk.key)})}${badge}</div><div class="nm">${wsLoading()?tr('wkscn.loading_this_week_s_scenario'):tr('features.weekly_challenge_key',{key:esc(wk.key)})}</div><div class="meta">${tr('scenario_progress.start_in_city_mods_one_year',{city:esc(CITY[wk.city].name),mods:wk.mods.map(m=>esc(m.n)).join(' · ')})}${best?' '+tr('scenario_progress.your_best_best',{best:fmtG(best)}):''}</div>${cd}</div>${btn(tr('common.play'),'startWeekly',{},'pink',wsLoading())}</div>`;}
|
||||
const x=wsWin(o,d),mods=d.mods.map(m=>esc(WEEK_MODS.find(y=>y.id===m).n));
|
||||
return `<div class="scn wk" id="wsRow"><div class="grow"><div class="eyebrow">📅 ${tr('wkscn.weekly_scenario_key',{key:esc(d.key)})}${badge}</div>
|
||||
<div class="nm">${T_WS(d)} ${esc(wsTxt(d.name))} ${x?`<span class="tag open">${tr('wkscn.won_day_d_par_par',{d:x.d,par:d.par})}</span>`:''}</div><div class="meta">${esc(wsTxt(d.desc))}</div>
|
||||
<div class="meta">🎯 ${esc(wsGoalTxt(d))}</div><div class="meta">${tr('wkscn.start_in_city_d_days_cash',{city:esc(CITY[d.city].name),d:d.days,cash:fmt$(d.cash)})}${mods.length?' · '+mods.join(' · '):''} · ${tr('wkscn.par_day_par',{par:d.par})}</div>
|
||||
<div class="meta">${tr('wkscn.same_scenario_for_everyone_this_week')}${st?' · 🔥 '+trn('puzzles.n_week_streak',st):''}</div>${cd}</div>${btn(tr('common.play'),'startWeekly',{},x?'ghost':'pink')}</div>`;}
|
||||
function wsNext(now){const key=pzWeekKey(now),t=pzWeekStart(pzKeyAdd(key,1))-now,m=Math.max(1,Math.ceil(t/60e3)),d=Math.floor(m/1440),h=Math.floor(m%1440/60);
|
||||
return d?tr('wkscn.next_weekly_in_d_h',{d,h}):tr('wkscn.next_weekly_in_h_m',{h,m:m%60});}
|
||||
217
src/game/60-features/95-standing-orders.js
Normal file
217
src/game/60-features/95-standing-orders.js
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
/* ---------- Standing orders (#98) ----------
|
||||
A NOC intern runs the player's standing orders once per game day. Every job goes through the same action a click
|
||||
would (ACT.*, pniPlace, the #185/#192 planners), so it costs exactly what the click costs, with toasts and redraws
|
||||
muted and one recompute at the end. Without an intern nothing here runs and no random numbers are drawn. */
|
||||
const INTERN_MO=6000,OPS_LOG=12,OPS_CAPS=[10000,50000,250000,1e6,5e6,0],OPS_CAPS_MO=[1000,2500,5000,10000,25000,0],OPS_FLOORS=[0,50000,250000,1e6,5e6];
|
||||
const INTERNS={
|
||||
annie:{i:'📡',n:N_('ops.anycast_annie'),s:N_('ops.annie'),d:N_('ops.annie_d')},
|
||||
kevin:{i:'🌙',n:N_('ops.kevin_from_the_night_shift'),s:N_('ops.kevin'),d:N_('ops.kevin_d')},
|
||||
tracy:{i:'🧭',n:N_('ops.tracy_route'),s:N_('ops.tracy'),d:N_('ops.tracy_d')},
|
||||
};
|
||||
// The orders, in the order the panel shows them. pop: can be switched off per POP. cap: default monthly budget, of setup
|
||||
// fees, or (mo) of the running costs the order adds, for caches, which are free to rack but cost rent every month.
|
||||
const OPS=[
|
||||
{k:'transit',i:'📈',pop:1,cap:50000,t:N_('ops.o_transit'),d:N_('ops.o_transit_d'),p:{x:{d:1.5,v:[1.25,1.5,2,3],l:N_('ops.p_x'),f:v=>v+'×'},prov:{d:'cheap',ok:v=>v==='cheap'||(isNet(v)&&!!NET[v].price),l:N_('ops.p_prov')}}},
|
||||
{k:'routers',i:'🧠',pop:1,cap:250000,t:N_('ops.o_routers'),d:N_('ops.o_routers_d'),p:{at:{d:80,v:[60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'},how:{d:'auto',v:['auto','add','swap'],l:N_('ops.p_how'),f:v=>tr({auto:N_('ops.how_auto'),add:N_('ops.how_add'),swap:N_('ops.how_swap')}[v])}}},
|
||||
{k:'caches',i:'📦',pop:1,cap:5000,mo:1,t:N_('ops.o_caches'),d:N_('ops.o_caches_d'),p:{g:{d:5,v:[1,5,10,25,50],l:N_('ops.p_g'),f:v=>fmtG(v)}}},
|
||||
{k:'ix',i:'🔀',t:N_('ops.o_ix'),d:N_('ops.o_ix_d'),p:{}},
|
||||
{k:'pni',i:'🤝',pop:1,cap:50000,t:N_('ops.o_pni'),d:N_('ops.o_pni_d'),p:{g:{d:25,v:[5,10,25,50,100],l:N_('ops.p_g'),f:v=>fmtG(v)},tier:{d:0,v:[0,1,2],l:N_('ops.p_tier'),f:v=>tr('ops.at_least_port',{port:PORT[v].n})},paid:{d:false,v:[false,true],l:N_('ops.p_paid'),f:v=>tr(v?'common.on':'common.off')}}},
|
||||
{k:'sales',i:'💼',t:N_('ops.o_sales'),d:N_('ops.o_sales_d'),p:{acc:{d:true,v:[true,false],l:N_('ops.p_acc'),f:v=>tr(v?'common.on':'common.off')},min:{d:0,v:[0,2000,5000,10000,25000,50000],l:N_('ops.p_min'),f:v=>v?tr('common.price_mo',{price:fmt$(v)}):tr('ops.never')}}},
|
||||
{k:'repair',i:'🔧',cap:50000,t:N_('ops.o_repair'),d:N_('ops.o_repair_d'),p:{}},
|
||||
{k:'optics',i:'🌈',cap:250000,t:N_('ops.o_optics'),d:N_('ops.o_optics_d'),p:{at:{d:70,v:[50,60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'}}},
|
||||
{k:'decom',i:'🧹',t:N_('ops.o_decom'),d:N_('ops.o_decom_d'),p:{keep:{d:true,v:[true,false],l:N_('ops.p_keep'),f:v=>tr(v?'common.on':'common.off')}}},
|
||||
];
|
||||
const OPSK=Object.fromEntries(OPS.map(o=>[o.k,o])),OPS_POP=OPS.filter(o=>o.pop).map(o=>o.k);
|
||||
const OPS_TPL=['bb','transit','ix','kit'];
|
||||
// What the shift log can say. One line per day: "{name} did this, that and the other."
|
||||
const OPS_SAY={transit:N_('ops.l_transit'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),sales:N_('ops.l_sales'),decline:N_('ops.l_decline'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')};
|
||||
// Fat fingers: rare, visible, harmless. Only the LAG one costs anything, and only a little.
|
||||
const OPS_FF=[N_('ops.ff_desc'),N_('ops.ff_hostname'),N_('ops.ff_typo'),N_('ops.ff_lag'),N_('ops.ff_ping')];
|
||||
const OPS_TRIALS=1,OPS_FF_RATE={oncall:1/150,bgp:1/60};
|
||||
function opsNew(){return {intern:null,hired:0,on:Object.fromEntries(OPS.map(o=>[o.k,false])),p:{},cap:{},spent:Object.fromEntries(OPS.filter(o=>o.cap).map(o=>[o.k,0])),addMo:{},mon:0,skip:{},log:[],wk:null,rep:null,floor:50000,tpl:{bb:true,transit:true,ix:true,kit:true}};}
|
||||
const opsO=()=>S.ops||(S.ops=opsNew());
|
||||
const opsHired=()=>!!(S&&S.ops&&S.ops.intern&&own(INTERNS,S.ops.intern));
|
||||
const opsCanHire=()=>lvl()>=2;
|
||||
const opsName=(long)=>{const I=INTERNS[S.ops.intern];return I?tr(long?I.n:I.s):'';};
|
||||
function opsP(k,p){const P=OPSK[k].p[p],v=S.ops.p[k]&&S.ops.p[k][p];return v!==undefined&&(P.ok?P.ok(v):P.v.includes(v))?v:P.d;}
|
||||
const opsCaps=k=>OPSK[k].mo?OPS_CAPS_MO:OPS_CAPS;
|
||||
function opsCap(k){const c=S.ops.cap[k];return opsCaps(k).includes(c)?c:OPSK[k].cap||0;}
|
||||
const opsHere=(k,c)=>!(S.ops.skip[c]||[]).includes(k);
|
||||
const opsPops=k=>Object.keys(S.pops).filter(c=>opsHere(k,c));
|
||||
// Saves are untrusted: rebuild ops from known orders, params, cities and log shapes. Runs after the POPs are repaired,
|
||||
// so exceptions only survive for POPs that still exist. Old saves get no intern,
|
||||
// and the two #185 toggles (auto-accept, auto-pay repairs) become the sales and repair orders.
|
||||
function opsSanitize(s){const o=s.ops&&typeof s.ops==='object'&&!Array.isArray(s.ops)?s.ops:{},n=opsNew(),ob=x=>x&&typeof x==='object'&&!Array.isArray(x)?x:{};
|
||||
n.intern=typeof o.intern==='string'&&own(INTERNS,o.intern)?o.intern:null;n.hired=int(o.hired,0,1e7,0);n.mon=int(o.mon,0,1e6,0);
|
||||
n.floor=OPS_FLOORS.includes(o.floor)?o.floor:n.floor;
|
||||
const on=ob(o.on),p=ob(o.p),cap=ob(o.cap),sp=ob(o.spent);
|
||||
for(const d of OPS){const k=d.k;n.on[k]=on[k]===true;const q=ob(p[k]),r={};
|
||||
for(const pk of Object.keys(d.p)){const P=d.p[pk];if(own(q,pk)&&(P.ok?P.ok(q[pk]):P.v.includes(q[pk])))r[pk]=q[pk];}n.p[k]=r;
|
||||
if(d.cap&&opsCaps(k).includes(cap[k]))n.cap[k]=cap[k];if(d.cap)n.spent[k]=Math.max(0,num(sp[k],0));
|
||||
{const v=num(ob(o.addMo)[k],0);if(v)n.addMo[k]=Math.max(-1e9,Math.min(1e9,v));}}
|
||||
{const t=ob(o.tpl);for(const k of OPS_TPL)if(typeof t[k]==='boolean')n.tpl[k]=t[k];}
|
||||
{const sk=ob(o.skip);for(const c of Object.keys(sk))if(isCity(c)&&own(s.pops,c)&&Array.isArray(sk[c])){const ks=[...new Set(sk[c].filter(k=>OPS_POP.includes(k)))];if(ks.length)n.skip[c]=ks;}}
|
||||
if(Array.isArray(o.log))n.log=o.log.map(opsLogOk).filter(Boolean).slice(0,OPS_LOG);
|
||||
n.wk=opsWkOk(o.wk);n.rep=opsWkOk(o.rep);
|
||||
if(s.autoSales===true)n.on.sales=true;if(s.autoRepair===true)n.on.repair=true;delete s.autoSales;delete s.autoRepair;
|
||||
s.ops=n;}
|
||||
// A log entry: {d, i: intern, r: [[kind, n, [where…]]], f: fat-finger index, c: its city, up: paid up front, mo: running costs added}.
|
||||
const opsWhereOk=w=>typeof w==='string'&&w.length<=48&&/^[a-z0-9~|]+( [+\w.×→⇧]+)?$/i.test(w)&&w.split(' ')[0].split('|').every(x=>isIx(x)||own(OPSK,x)||isNet(x));
|
||||
function opsLogOk(e){if(!e||typeof e!=='object'||!own(INTERNS,e.i))return null;const r=Array.isArray(e.r)?e.r.filter(x=>Array.isArray(x)&&own(OPS_SAY,x[0])&&Array.isArray(x[2])).map(x=>[x[0],int(x[1],1,1e6,1),x[2].filter(opsWhereOk).slice(0,3)]).slice(0,16):[];
|
||||
const f=Number.isInteger(e.f)&&OPS_FF[e.f]?e.f:undefined,up=int(e.up,0,1e12,0),mo=int(e.mo,-1e9,1e9,0);
|
||||
return {d:int(e.d,0,1e7,0),i:e.i,r,...(f!==undefined&&isCity(e.c)?{f,c:e.c}:{}),...(up?{up}:{}),...(mo?{mo}:{})};}
|
||||
// A week's tally, for the shift report and the one NOC notice a week: {w: week, i: intern, n: {kind: count}, wh: {kind: [where…]}, up, mo, rev, ff}.
|
||||
function opsWkOk(x){if(!x||typeof x!=='object'||Array.isArray(x)||!own(INTERNS,x.i))return null;const n={},wh={},xn=x.n&&typeof x.n==='object'?x.n:{},xw=x.wh&&typeof x.wh==='object'?x.wh:{};
|
||||
for(const k of Object.keys(OPS_SAY)){if(own(xn,k)){const v=int(xn[k],0,1e6,0);if(v)n[k]=v;}if(own(xw,k)&&Array.isArray(xw[k])){const w=xw[k].filter(opsWhereOk).slice(0,3);if(w.length)wh[k]=w;}}
|
||||
return {w:int(x.w,0,1e6,0),i:x.i,n,wh,up:int(x.up,0,1e12,0),mo:int(x.mo,-1e9,1e9,0),rev:int(x.rev,0,1e9,0),ff:int(x.ff,0,7,0)};}
|
||||
const opsWkNew=w=>({w,i:S.ops.intern,n:{},wh:{},up:0,mo:0,rev:0,ff:0});
|
||||
const opsWkAny=x=>!!x&&(Object.keys(x.n).length>0||x.ff>0);
|
||||
// "Kevin's week: signed 3 customers (+$41k/mo), topped up transit 2 times (Frankfurt +1×100G), declined 17 tiny offers. Week total: …"
|
||||
function opsWeekLine(x){const I=INTERNS[x.i],name=I?tr(I.s):'',ks=Object.keys(x.n).sort((a,b)=>(a==='sales'?-1:b==='sales'?1:0)||(a==='broke')-(b==='broke'));
|
||||
const parts=ks.map(k=>k==='sales'?trn('ops.w_sales',x.n[k],{rev:opsMo$(x.rev)}):trn(OPS_SAY[k],x.n[k],{where:(x.wh[k]||[]).map(w=>opsWhere(w,k)).join(', ')}));
|
||||
if(x.ff)parts.push(trn('ops.w_oops',x.ff));
|
||||
return tr('ops.w_line',{name,list:parts.join(', ')})+(x.up||x.mo?' '+tr('ops.w_money',{cost:fmt$(x.up),mo:opsMo$(x.mo)}):'');}
|
||||
// The intern's mood, from what the week has been like. No dice: the same day always reads the same.
|
||||
function opsMood(){const O=S.ops,x=O.wk&&O.wk.w===Math.floor(S.day/7)?O.wk:null,n=x?x.n:{},jobs=Object.keys(n).filter(k=>k!=='broke'&&k!=='decline').reduce((a,k)=>a+n[k],0);
|
||||
const k=S.day-O.hired<7?'new':x&&x.ff?'oops':n.snag?'snag':S.inc.some(i=>i.until>S.day&&i.type!=='ddos')?'outage':n.sales?'sales':n.broke?'broke':jobs>=5?'busy':S.day%2?'quiet':O.intern;
|
||||
return tr({new:N_('ops.mood_new'),oops:N_('ops.mood_oops'),snag:N_('ops.mood_snag'),outage:N_('ops.mood_outage'),sales:N_('ops.mood_sales'),broke:N_('ops.mood_broke'),busy:N_('ops.mood_busy'),quiet:N_('ops.mood_quiet'),
|
||||
annie:N_('ops.mood_annie'),kevin:N_('ops.mood_kevin'),tracy:N_('ops.mood_tracy')}[k],{name:opsName()});}
|
||||
// "fra +1×100G", "fra|ams", "ams~3", "transit" (an order, for the budget line) or "ggl" (a network).
|
||||
// Peering is always at an exchange, and a city's first exchange has the city's id ("lon" is LYNX): name the exchange (#228).
|
||||
function opsWhere(w,k){if(k==='peer'&&isIx(w)&&ixName(w))return ixName(w);const [a,x]=w.split(' '),nm=a.split('|').map(p=>own(OPSK,p)?tr(OPSK[p].t):isCity(p)?CITY[p].name:isNet(p)?NET[p].name:ixName(p)).join('–');return x?nm+' '+(isNet(x)?NET[x].name:x):nm;}
|
||||
function opsLine(e){const I=INTERNS[e.i],name=I?tr(I.s):'',parts=e.r.map(([k,n,w])=>trn(OPS_SAY[k],n,{where:w.map(x=>opsWhere(x,k)).join(', ')}));
|
||||
return (parts.length?tr('ops.l_line',{name,list:parts.join(', ')}):tr('ops.l_quiet',{name}))+opsPaid(e);}
|
||||
const opsMo$=v=>(v>0?'+':'')+fmt$(v);
|
||||
const opsPaid=e=>e.up||e.mo?' '+tr('ops.l_paid',{cost:fmt$(e.up||0),mo:opsMo$(e.mo||0)}):'';
|
||||
// What the network costs every month before traffic: what a job adds to the bill (ports, routers, rent, links, cache boxes).
|
||||
// PNIs count from the day they are ordered, at the size they are going to be.
|
||||
function opsMoNow(){let m=S.caches.length*CACHE_MO;
|
||||
for(const c in S.pops){const p=S.pops[c],rt=p.routers||1;m+=(rt-1)*ROUTER_MO+cageMo(rt)+rt*RG[p.rgen||0].mo;}
|
||||
for(const l of S.links)m+=(l.mo||0)+(l.kind==='df'?(l.spares?Math.round(150+(l.ch||[]).length*80):0)+(l.regen|0)*REGEN_MO:0);
|
||||
for(const t of S.transit)m+=transitMo(t,0);
|
||||
for(const p of S.pni){const q=p.up||p,N=NET[p.net];m+=(q.g1?Math.round(PORT[0].pni/2):PORT[q.tier].pni)*(q.n||1)+(N.pol==='paid'&&!paidFree(N)?N.paidFee:0);}
|
||||
return m;}
|
||||
const opsFFLine=e=>tr('ops.ff_line',{name:tr(INTERNS[e.i].s),what:tr(OPS_FF[e.f],{city:CITY[e.c].name})});
|
||||
// Mute what a click would show (toasts, sounds, floaters, the full redraw) and keep the player's selection.
|
||||
function opsQuiet(fn){const a=after,t=toast,s=sfx,f=floater,sel=UI.sel,cf=UI.confirm,tab=UI.tab;after=()=>{};toast=()=>{};sfx=()=>{};floater=()=>{};
|
||||
try{return fn();}finally{after=a;toast=t;sfx=s;floater=f;UI.confirm=cf;UI.tab=tab;UI.sel=sel&&(sel.type!=='link'||S.links.some(l=>l.id===sel.id))&&(sel.type!=='city'||isCity(sel.id))?sel:null;}}
|
||||
// One shift's bookkeeping: what got done, and whether a job had to wait for next month's budget.
|
||||
// dirty: a job changed the network, so R (loads, routing) is out of date until the next compute().
|
||||
// up/mo/rev: what this shift paid up front, added to the monthly bill, and signed in monthly revenue.
|
||||
function opsShift(){const r=new Map(),broke=new Set();
|
||||
return {r,broke,dirty:false,up:0,mo:0,rev:0,did(k,w){if(k!=='decline')this.dirty=true;const x=r.get(k)||{n:0,w:[]};x.n++;if(w&&x.w.length<3&&!x.w.includes(w))x.w.push(w);r.set(k,x);},
|
||||
// A job that costs nothing up front still has to pass the cash floor if it adds to the monthly bill.
|
||||
can(k,cost,mo=0){const O=S.ops,cap=opsCap(k);if(cost<=0&&!(mo>0))return true;
|
||||
if(S.cash-Math.max(0,cost)<O.floor||(cap&&(OPSK[k].mo?(O.addMo[k]||0)+mo:(O.spent[k]||0)+cost)>cap)){broke.add(k);return false;}return true;},
|
||||
book(k,d,dm){const O=S.ops;if(d>0){this.up+=d;if(OPSK[k].cap)O.spent[k]=(O.spent[k]||0)+d;}if(dm){this.mo+=dm;O.addMo[k]=(O.addMo[k]||0)+dm;}},
|
||||
// Run a click and book what it really cost; false when the action refused (no ports, no cash, a quote changed).
|
||||
pay(k,fn){const c0=S.cash,m0=opsMoNow(),x=fn();this.book(k,c0-S.cash,opsMoNow()-m0);return x===undefined?c0-S.cash>0:x;}};}
|
||||
// Never buy from a provider that breaks a promise: a customer's "no Cogentle" or "two upstreams", a bank's covenant,
|
||||
// or Cogentle while it is not speaking to Goggle (the Spat scenario, a de-peering). Only met → failed counts.
|
||||
const OPS_TREQ=['nocog','twoup'];
|
||||
function opsTransitOk(n,c){if(n.id==='cog'&&(scnRule('spat')||S.ev.depeer>S.day))return false;
|
||||
const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>OPS_TREQ.includes(k))),ls=(S.loans||[]).filter(l=>(l.covs||[]).includes('nocog'));if(!bz.length&&!ls.length)return true;
|
||||
const chk=()=>bz.map(b=>b.reqs.every(k=>!OPS_TREQ.includes(k)||REQS[k].ok(b))).concat(ls.map(l=>COVS.nocog.ok(l)));
|
||||
const was=chk(),all=S.transit;S.transit=all.concat({net:n.id,city:c});try{const now=chk();return was.every((v,i)=>!v||now[i]);}finally{S.transit=all;}}
|
||||
const cheapestTransit=c=>NETS.filter(n=>sellsAt(n,c)&&opsTransitOk(n,c)).sort((a,b)=>transitPerG(a,c,premOnlyAt(a,c))-transitPerG(b,c,premOnlyAt(b,c)))[0];
|
||||
const opsProv=c=>{const pv=opsP('transit','prov');return pv!=='cheap'&&sellsAt(NET[pv],c)&&opsTransitOk(NET[pv],c)?NET[pv]:cheapestTransit(c);};
|
||||
// The orders. Each takes the shift and does its jobs through the player's own actions.
|
||||
const OPS_RUN={
|
||||
repair(X){purgeInc();for(const i of S.inc.slice())if(i.type!=='ddos'&&i.until>S.day&&i.cost>0&&!(i.slow&&i.rushed)&&X.can('repair',i.cost)&&X.pay('repair',()=>ACT.fixInc({id:i.id})))X.did('repair');},
|
||||
sales(X){const min=opsP('sales','min'),acc=opsP('sales','acc');let tries=0;
|
||||
for(const o of S.offers.slice()){const T=BIZ_T[o.type];if(!T)continue;const v=T.event?(o.fee||0):bizMo(o);
|
||||
if(min&&v<min){S.offers=S.offers.filter(x=>x!==o);X.did('decline');continue;}
|
||||
// Each trial is a full routing pass: at most one a shift, and an offer that did not fit waits a week.
|
||||
if(acc&&o.exp>S.day&&bCities(o).every(popUp)&&reqOk(o)&&tries<OPS_TRIALS&&!(UI.opsTried&&UI.opsTried.s===S&&UI.opsTried.m.get(o.id)>S.day-7)){tries++;ACT.accept({id:o.id,auto:true});
|
||||
if(!S.offers.includes(o)){X.did('sales');X.rev+=bizMo(o);}else{if(!UI.opsTried||UI.opsTried.s!==S)UI.opsTried={s:S,m:new Map()};UI.opsTried.m.set(o.id,S.day);}}}},
|
||||
routers(X){const at=opsP('routers','at')/100,how=opsP('routers','how');
|
||||
for(const c of opsPops('routers')){const p=S.pops[c];if(p.rupDay===S.day)continue;
|
||||
const ld=Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));if(ld<at)continue;
|
||||
const rt=p.routers||1,g=p.rgen||0,nx=mainRG(RG[g].cls+1);
|
||||
// A swap with one router is a maintenance window: the intern only swaps where a second router carries the traffic.
|
||||
const swap=nx>=0&&RG[nx].lvl<=lvl()&&!modelFits(c,nx)&&(rt>1||popIdle(c)),add=rt<RMAX;
|
||||
const doSwap=how==='swap'?swap:how==='add'?false:swap&&(rt>=4||!add);if(!doSwap&&(how==='swap'||!add))continue;
|
||||
const cost=doSwap?swapCost(c,nx):routerCost(g,rt);if(!X.can('routers',cost))continue;
|
||||
if(X.pay('routers',()=>doSwap?ACT.upRouter({city:c,g:nx}):ACT.addRouter({city:c})))X.did('routers',c+(doSwap?' ⇧'+RG[nx].pn:' +1'));}},
|
||||
transit(X){if(scnRule('noTransit'))return;const N=opsP('transit','x');
|
||||
for(const c of opsPops('transit')){let ts=S.transit.filter(t=>t.city===c);if(!ts.length)continue;
|
||||
// Thirty days of 95th-percentile-ish history per port; their peaks summed is a safe (high) estimate of the POP's peak.
|
||||
const peak=ts.reduce((a,t)=>a+(t.hist||[]).reduce((m,v)=>Math.max(m,v),0),0);if(!(peak>0))continue;
|
||||
const n=opsProv(c);if(!n)continue;
|
||||
for(let step=0;step<4;step++){const cap=ts.reduce((a,t)=>a+lagCap(PORT[t.tier].g,t.n),0);if(cap>=N*peak)break;
|
||||
const t=ts.find(x=>x.net===n.id);let job=null;
|
||||
if(t){const k=t.n||1,up=t.tier+1;
|
||||
if(k<4&&portOk(c,t.tier))job={cost:PORT[t.tier].setup,go:()=>ACT.lagT({id:t.id,d:1}),w:'+1×'+PORT[t.tier].n};
|
||||
else if(PORT[up]&&portShown(up)&&portOk(c,up))job={cost:PORT[up].setup*k,go:()=>ACT.buyTransit({city:c,net:n.id,tier:up}),w:PORT[t.tier].n+'→'+PORT[up].n};
|
||||
else if(k<LAG_MAX&&portOk(c,t.tier))job={cost:PORT[t.tier].setup,go:()=>ACT.lagT({id:t.id,d:1}),w:'+1×'+PORT[t.tier].n};}
|
||||
else{const need=N*peak-cap,ok=PORT.map((P,i)=>i).filter(i=>portShown(i)&&portOk(c,i)),i=ok.find(i=>PORT[i].g>=need)??ok.at(-1);
|
||||
if(i!==undefined)job={cost:PORT[i].setup,go:()=>ACT.buyTransit({city:c,net:n.id,tier:i}),w:'+'+PORT[i].n};}
|
||||
if(!job||!X.can('transit',job.cost)||!X.pay('transit',job.go))break;
|
||||
X.did('transit',c+' '+job.w);ts=S.transit.filter(t=>t.city===c);}}},
|
||||
optics(X){const at=opsP('optics','at')/100;
|
||||
for(const l of S.links){if(l.kind!=='df'||l.ready>S.day||l.eqDown>S.day||l.standby||l.cut>S.day)continue;
|
||||
let cap=dfCap(l);const load=(R.load&&R.load[l.id])||0;
|
||||
// New fiber gets its first channel; lit fiber gets more while it runs hot.
|
||||
for(let step=0;step<8&&(cap<=0?!(l.ch||[]).length:load>=cap*at);step++){if(chMax(l)-(l.ch||[]).length-soldSlots(l)<=0)break;
|
||||
const cnt={};for(const k of l.ch||[])cnt[k]=(cnt[k]||0)+1;
|
||||
// More of what is already lit, or else the most Gbps per dollar that reaches.
|
||||
const fit=Object.keys(OPT).filter(o=>!chWhy(l,o)),o=fit.filter(o=>cnt[o]).sort((a,b)=>cnt[b]-cnt[a])[0]||fit.sort((a,b)=>optG(b,l)/optCost(b)-optG(a,l)/optCost(a))[0];if(!o)break;
|
||||
const n=(cnt[o]||0)+1,cost=opticCountCost(l,o,n),before=(l.ch||[]).length;if(!X.can('optics',cost))break;
|
||||
X.pay('optics',()=>{ACT.setChCount({id:l.id,o,n});return (l.ch||[]).length>before;});if((l.ch||[]).length<=before)break;
|
||||
cap+=optG(o,l);X.did('optics',l.a+'|'+l.b);}}},
|
||||
caches(X){const g=opsP('caches','g');
|
||||
for(const c of opsPops('caches')){const q=utilityCaches(c);if(!q||!q.add.length)continue;
|
||||
const want=q.add.filter(x=>(R.cityDem[c]||0)*(NSH[x.net]||0)>=g),free=Math.floor(portsMax(c)-portsUsed(c)+1e-9);
|
||||
for(const x of want.slice(0,Math.max(0,free))){if(!X.can('caches',0,CACHE_MO))return;S.caches.push({id:uid(),city:c,net:x.net,site:x.site});X.book('caches',0,CACHE_MO);X.did('caches',c);}}},
|
||||
// Weekly, like a person going through PeeringDB on a Monday: route servers, then every willing member (#192).
|
||||
ix(X){if(S.day%7)return;for(const ix of utilityRouteServers()){S.rs[ix]=true;X.did('rs');}
|
||||
for(const row of utilityPeers())for(const id of row.requests){S.peers[id+'@'+row.ix]=true;X.did('peer',row.ix);}},
|
||||
// Weekly too: every willing network above the threshold, at its own minimum size and lead time (#181).
|
||||
pni(X){if(S.day%7!==3)return;const b=pniBatch(null,opsP('pni','tier'));if(!b)return;const g=opsP('pni','g'),paid=opsP('pni','paid');
|
||||
const loc=q=>(R.cityDem[q.city]||0)*(NSH[q.net]||0);
|
||||
for(const q of b.orders.filter(q=>opsHere('pni',q.city)&&loc(q)>=g&&(paid||NET[q.net].pol!=='paid'||paidFree(NET[q.net]))).sort((a,b)=>loc(b)-loc(a))){
|
||||
if(!X.can('pni',q.cost))break;if(X.pay('pni',()=>{if(!spend(q.cost))return false;pniPlace(q);return true;}))X.did('pni',q.city+' '+q.net);}},
|
||||
// Hand back smaller waves once a bigger link between the same cities carries the pair with a quarter to spare (#102).
|
||||
decom(X){const keep=opsP('decom','keep'),by=new Map();for(const l of S.links)if(l.kind!=='vxc'){const k=edgeKey(l);(by.get(k)||by.set(k,[]).get(k)).push(l);}
|
||||
// Loads must include what this shift already did (a customer just signed, a repair): recompute first, if anything could go.
|
||||
if(X.dirty&&[...by.values()].some(ls=>ls.length>1&&ls.some(l=>l.kind==='wave'))){compute();X.dirty=false;}
|
||||
for(const ls of by.values()){if(ls.length<2)continue;const live=ls.filter(l=>!linkDown(l)),big=live.reduce((a,l)=>!a||capOf(l)>capOf(a)?l:a,null);if(!big)continue;
|
||||
let cap=live.reduce((a,l)=>a+capOf(l),0);const load=ls.reduce((a,l)=>a+((R.load&&R.load[l.id])||0),0);
|
||||
const small=live.filter(l=>l!==big&&l.kind==='wave'&&!l.standby&&!l.premium&&capOf(l)<capOf(big)&&!S.biz.some(b=>b.link===l.id)).sort((a,b)=>capOf(b)-capOf(a));
|
||||
// The spare is there for when the big link's trench is cut, so it has to live in another trench.
|
||||
if(keep&&small.length){const tr=l=>l.trench||l.id,i=small.findIndex(l=>tr(l)!==tr(big));small.splice(Math.max(0,i),1);}
|
||||
for(const l of small.reverse()){if(cap-capOf(l)<load*1.25)break;if(!opsDecomSafe(l))continue;cap-=capOf(l);UI.confirm=l.id;X.pay('decom',()=>ACT.rmLink({id:l.id}));if(!S.links.includes(l))X.did('decom',l.a+'|'+l.b);}}},
|
||||
};
|
||||
// A wave can carry a promise: diverse paths, no subsea, a latency budget. Try the network without it first.
|
||||
function opsDecomSafe(l){const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>k==='diverse'||k==='sharks'||k==='lat')&&b.city2);if(!bz.length)return true;
|
||||
const chk=b=>(b.reqs||[]).every(k=>k==='diverse'?diversePaths(b.city,b.city2):k==='sharks'?terrestrialPath(b.city,b.city2):k==='lat'?bestLat(b.city,b.city2)<=b.latMax:true);
|
||||
const was=bz.filter(chk),all=S.links;S.links=all.filter(x=>x!==l);try{return was.every(chk);}finally{S.links=all;}}
|
||||
const OPS_ORDER=['repair','sales','routers','transit','optics','caches','ix','pni','decom'];
|
||||
// The shift: once per game day from dayTick, after outages and events have had their turn.
|
||||
function opsDay(d){if(!opsHired())return;const O=S.ops,m=Math.floor(d/30);if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;O.addMo={};}
|
||||
// A new week: last week's tally becomes the shift report, and the one NOC notice of the week.
|
||||
const w=Math.floor(d/7);if(!O.wk||O.wk.w!==w){if(opsWkAny(O.wk)&&O.wk.w<w){O.rep=O.wk;logNote(`<b>${esc(tr('ops.shift_report',{name:opsName()}))}</b> ${esc(opsWeekLine(O.rep))}`,O.rep.rev>0?'good':'',[],{a:'ops'});}O.wk=opsWkNew(w);}
|
||||
const X=opsShift();
|
||||
// One order that trips over something (an odd save, a bug) is paused and noted; payday, goals and the save still happen.
|
||||
opsQuiet(()=>{for(const k of OPS_ORDER)if(O.on[k])try{OPS_RUN[k](X);}catch(err){O.on[k]=false;X.dirty=true;X.did('snag',k);console.error('[tubes] standing order failed',k,err);}});
|
||||
const e={d,i:O.intern,r:[]};for(const [k,x] of X.r)e.r.push([k,x.n,x.w]);if(X.broke.size)e.r.push(['broke',X.broke.size,[...X.broke]]);
|
||||
// Very rarely, and never under Change Freeze, the intern fat-fingers something harmless.
|
||||
const ff=OPS_FF_RATE[rulePreset()];if(ff&&Object.keys(S.pops).length&&Math.random()<ff){const c=pick(Object.keys(S.pops));let f=Math.floor(Math.random()*OPS_FF.length);
|
||||
if(f===3){const t=O.on.transit&&opsHere('transit',c)&&!scnRule('noTransit')&&S.transit.find(t=>t.city===c&&(t.n||1)<LAG_MAX&&portOk(c,t.tier)&&PORT[t.tier].setup<=Math.min(20000,S.cash*0.05));if(!t||!opsQuiet(()=>X.pay('transit',()=>ACT.lagT({id:t.id,d:1}))))f=0;else X.dirty=true;}
|
||||
e.f=f;e.c=c;toast(esc(opsFFLine(e)),'',[{l:tr('ops.ops'),act:'opsOpen',args:{}}]);}
|
||||
if(X.up)e.up=Math.round(X.up);if(Math.round(X.mo))e.mo=Math.round(X.mo);
|
||||
// Declining an offer or stopping at a budget changes nothing a route depends on: no recompute for those.
|
||||
if(X.dirty)compute();
|
||||
if(e.r.length||e.f!==undefined){O.log.unshift(e);O.log.length=Math.min(O.log.length,OPS_LOG);}
|
||||
// The day's detail stays in the Ops sheet; the NOC gets one notice a week (above).
|
||||
const W=O.wk;for(const [k,n,ws] of e.r){W.n[k]=(W.n[k]||0)+n;const a=W.wh[k]||(W.wh[k]=[]);for(const x of ws)if(a.length<3&&!a.includes(x))a.push(x);}
|
||||
W.up+=e.up||0;W.mo+=e.mo||0;W.rev+=Math.round(X.rev);if(e.f!==undefined)W.ff=Math.min(7,W.ff+1);}
|
||||
// New POP from the template: price the whole bundle first, then click through it in one go.
|
||||
function opsTplQuote(c){if(!S||S.pops[c]||!cityOn(c)||(cnCity(c)&&!cnOk()))return null;const T=S.ops.tpl,parts=[];let cost=popCost(c),net=null,ix=null,kit=null;
|
||||
if(T.bb){cost+=bbCost(c);parts.push(tr('ops.tpl_bb'));}
|
||||
if(T.transit&&!scnRule('noTransit')){net=opsProv(c);if(net){cost+=PORT[0].setup;parts.push(tr('ops.tpl_transit'));}}
|
||||
// Priced as if the POP were already there (an IX port is dearer from afar). DE-KICKS wants a sales call first, so not those.
|
||||
S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};
|
||||
try{if(T.ix&&CITY[c].ix&&!isDk(c)&&S.ixp[c]===undefined){ix=c;cost+=ixPortMo(c,0);parts.push(tr('ops.tpl_ix'));}
|
||||
if(T.kit){kit=utilityKit(c);if(kit&&kit.cost){cost+=kit.cost;parts.push(tr('ops.tpl_kit'));}}}finally{delete S.pops[c];}
|
||||
return {cost,net:net&&net.id,ix,kit:!!(kit&&kit.cost),parts};}
|
||||
164
src/game/60-features/96-architect.js
Normal file
164
src/game/60-features/96-architect.js
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
/* ================= ARCHITECT RUNS (prototype) =================
|
||||
One network, built brief by brief. A brief adds sites, makes some of them gold (a gold site must stay connected to HQ
|
||||
whichever single trench or cable is cut), sets a latency cap, or closes a city. The build carries over: what earlier
|
||||
briefs built is paid for, so removing it gives nothing back. ▶ lets the chaos monkey loose: it cuts every trench and cable one
|
||||
at a time, and the brief is done when every gold site survives. Runs on the puzzle machinery (S.mode 'puzzle' with
|
||||
S.ar), so there is no clock, no bills, no incidents, and the main save is never touched.
|
||||
Capacity: every site pulls its traffic from HQ, and the review also checks that the detour has room: after any single
|
||||
cut, everything still connected gets all of its traffic. Tubes come in three sizes; routers follow by themselves (the
|
||||
cheapest model that takes the tubes), and traffic finds the detour by itself (Auto-TE): models, ports and metrics are
|
||||
someone else's job. */
|
||||
const AR_KEY='sot-architect',AR_TIER=1,AR_TIERS=[0,1,2],AR_RUN=550,AR_HOLD=650; // ms: the monkey's run to a tube, then how long the cut shows
|
||||
// A brief: add (new sites), gold (sites that must survive any single cut), ring (sites that must sit on one ring), drop
|
||||
// (close a city: no POP allowed there any more), dem {city: Gbps} (what a site pulls from HQ, 10G unless set; a later
|
||||
// brief can raise it), lat [a,b,ms] (the fastest path between two sites under ms), tubes (the
|
||||
// plan: how many new tubes this brief should take; going over is allowed and costs a star), t (the brief).
|
||||
// budget: one round number for the whole run, a little above the best plan found (tests/architect.test.js), and below
|
||||
// the obvious one. Money never blocks a brief. ⭐ every brief done, ⭐ never over a brief's tubes, ⭐ within budget.
|
||||
const AR_RUNS=[
|
||||
{id:'euro',n:tr('architect.euro_run'),j:tr('architect.euro_run_joke'),hq:'ams',via:[],budget:410000,briefs:[
|
||||
{add:['fra'],dem:{fra:40},tubes:1,t:tr('architect.euro_1')},
|
||||
{add:['par','lon'],dem:{par:50,lon:60},tubes:2,t:tr('architect.euro_2b')},
|
||||
{gold:['fra','par'],tubes:1,t:tr('architect.euro_3b')},
|
||||
{add:['zrh'],dem:{zrh:40},gold:['zrh'],tubes:2,t:tr('architect.euro_5')},
|
||||
{ring:['ams','par','lon'],dem:{par:100},tubes:2,t:tr('architect.euro_ring_grow')},
|
||||
{drop:['fra'],add:['dus'],dem:{dus:60},gold:['dus'],tubes:2,t:tr('architect.euro_6')},
|
||||
]},
|
||||
{id:'usa',n:tr('architect.coast_to_coast'),j:tr('architect.coast_to_coast_joke'),hq:'ash',via:[],budget:610000,briefs:[
|
||||
{add:['nyc'],t:tr('architect.usa_1')},
|
||||
{add:['chi'],t:tr('architect.usa_2')},
|
||||
{gold:['nyc'],t:tr('architect.usa_3')},
|
||||
{lat:['nyc','chi',8],t:tr('architect.usa_4')},
|
||||
{add:['dal','sjc'],t:tr('architect.usa_5')},
|
||||
{gold:['sjc'],t:tr('architect.usa_6')},
|
||||
]},
|
||||
{id:'pacific',n:tr('architect.pacific_rim'),j:tr('architect.pacific_rim_joke'),hq:'tok',via:[],budget:2350000,briefs:[
|
||||
{add:['hkg'],t:tr('architect.pac_1')},
|
||||
{add:['sin'],t:tr('architect.pac_2')},
|
||||
{gold:['hkg'],t:tr('architect.pac_3')},
|
||||
{gold:['sin'],t:tr('architect.pac_4')},
|
||||
{add:['syd'],t:tr('architect.pac_5')},
|
||||
]},
|
||||
];
|
||||
const arOn=()=>pzOn()&&!!S.ar;
|
||||
const arRunDef=id=>AR_RUNS.find(r=>r.id===id)||arWkRun(id);
|
||||
const arRun=()=>arRunDef(S.ar.id);
|
||||
const arBrief=()=>arRun().briefs[S.ar.bi];
|
||||
const arLast=()=>S.ar.bi>=arRun().briefs.length-1;
|
||||
// ---------- progress: best stars, spend and briefs cleared per run, under its own key ----------
|
||||
function arLoad(){let j=null;try{j=JSON.parse(localStorage.getItem(AR_KEY)||'{}');}catch(e){}const o={runs:{}};
|
||||
if(j&&j.runs&&typeof j.runs==='object')for(const k of Object.keys(j.runs)){const r=j.runs[k];if((!arRunDef(k)&&!AR_WK_ID.test(k))||!r||typeof r!=='object')continue;
|
||||
o.runs[k]={st:int(r.st,0,3,0),br:int(r.br,0,99,0),sp:r.sp==null||!isFinite(+r.sp)||+r.sp<0?null:Math.round(+r.sp)};if(AR_WK_ID.test(k))o.runs[k].rv=int(r.rv,1,999,1);}
|
||||
return o;}
|
||||
function arStore(p){try{localStorage.setItem(AR_KEY,JSON.stringify(p));}catch(e){}}
|
||||
function arRecord(st,br,sp){const p=arLoad(),run=arRun(),old=p.runs[S.ar.id],r=old&&(!run.wk||(old.rv||1)===run.rev)?old:{st:0,br:0,sp:null};if(run.wk)r.rv=run.rev;
|
||||
if(st>r.st||(st===r.st&&st>0&&(r.sp==null||sp<r.sp))){r.st=st;r.sp=st?sp:r.sp;}r.br=Math.max(r.br,br);p.runs[S.ar.id]=r;arStore(p);}
|
||||
// ---------- money ----------
|
||||
// What a POP or a link costs for the year, as the puzzles count it.
|
||||
const arPopCost=c=>pzPopCost(c)+pzRouterCost(c);
|
||||
const arLinkCost=l=>l.mo*PZ_YEAR;
|
||||
const arSpend=()=>pzSpend()+S.ar.sunk;
|
||||
// Removing what an earlier brief built gives nothing back.
|
||||
const arAge=l=>l.ub==null?(l.br|0):l.ub;
|
||||
function arSink(pops,links){const A=S.ar;for(const c of pops)if(S.pops[c]&&(S.pops[c].br|0)<A.bi)A.sunk+=arPopCost(c);for(const l of links)if(arAge(l)<A.bi)A.sunk+=arLinkCost(l);}
|
||||
// ---------- the graph ----------
|
||||
function arAdj(skip){const nb={};for(const c in S.pops)nb[c]=new Set();for(const l of S.links){if(skip&&skip(l))continue;if(!nb[l.a]||!nb[l.b])continue;nb[l.a].add(l.b);nb[l.b].add(l.a);}return nb;}
|
||||
function arReach(from,nb){const seen=new Set();if(!nb[from])return seen;seen.add(from);const q=[from];while(q.length){const u=q.shift();for(const v of nb[u])if(!seen.has(v)){seen.add(v);q.push(v);}}return seen;}
|
||||
// Sites a cut leaves without a path to HQ.
|
||||
function arDark(u){const nb=arAdj(l=>pzUnit(l)===u),r=arReach(S.ar.hq,nb);return S.pz.cities.filter(c=>S.pops[c]&&!r.has(c));}
|
||||
// The fastest path between two sites, by the links' own latency.
|
||||
function arLat(a,b){if(!S.pops[a]||!S.pops[b])return null;const d={[a]:0},done=new Set();
|
||||
for(;;){let u=null;for(const k in d)if(!done.has(k)&&(u===null||d[k]<d[u]))u=k;if(u===null)return null;if(u===b)return d[u];done.add(u);
|
||||
for(const l of S.links){if(l.a!==u&&l.b!==u)continue;const v=l.a===u?l.b:l.a,x=d[u]+linkLat(l);if(d[v]===undefined||x<d[v])d[v]=x;}}}
|
||||
// A simple cycle through every one of these cities (the networks are small, so a bounded search will do).
|
||||
function arRingOk(cs){const nb=arAdj();if(!cs.every(c=>nb[c]&&nb[c].size>=2))return false;const st=cs[0],on=new Set([st]);let ok=false,n=0;
|
||||
const dfs=(u,d)=>{for(const v of nb[u]){if(ok||++n>50000)return;if(v===st&&d>=3&&cs.every(c=>on.has(c))){ok=true;return;}if(on.has(v))continue;on.add(v);dfs(v,d+1);on.delete(v);}};
|
||||
dfs(st,1);return ok;}
|
||||
// Tubes laid in this brief, against its plan.
|
||||
const arTubes=()=>{const b=arBrief(),u=S.links.filter(l=>(l.br|0)===S.ar.bi).length;return {u,max:b.tubes==null?null:b.tubes,over:b.tubes==null?0:Math.max(0,u-b.tubes)};};
|
||||
// ---------- the brief's checklist ----------
|
||||
function arEval(){const A=S.ar,P=S.pz,nb=arAdj(),r=arReach(A.hq,nb);
|
||||
const got=S.links.some(l=>l.cut)&&UI.arBaseGot?UI.arBaseGot:arGot();
|
||||
const sites=P.cities.map(c=>({c,pop:!!S.pops[c],ok:!!S.pops[c]&&r.has(c),gold:A.gold.includes(c),hq:c===A.hq,dem:c===A.hq?0:arDem(c),got:c===A.hq?0:got[c]||0}));for(const s of sites)s.full=s.hq||s.got>=s.dem*0.999-1e-6;
|
||||
const conn=sites.every(s=>s.ok),lat=A.lat?{a:A.lat[0],b:A.lat[1],cap:A.lat[2],ms:arLat(A.lat[0],A.lat[1])}:null;if(lat)lat.ok=lat.ms!=null&&lat.ms<=lat.cap+1e-9;
|
||||
const moveOut=P.avoid.filter(c=>S.pops[c]),spend=arSpend(),budget=arRun().budget,cheap=spend<=budget+1e-6,miss=sites.filter(s=>!s.ok).map(s=>CITY[s.c].name),rings=A.rings.map(cs=>({cs,ok:arRingOk(cs)})),tubes=arTubes();
|
||||
const why=!conn?tr('architect.not_connected_yet_list',{list:miss.join(', ')}):lat&&!lat.ok?tr('architect.too_slow_for_the_cap'):rings.some(r=>!r.ok)?tr('architect.not_a_ring_yet'):sites.some(s=>!s.full)?tr('architect.too_thin_list',{list:sites.filter(s=>!s.full).map(s=>`${CITY[s.c].name} ${arG(s.got)}/${arG(s.dem)}`).join(', ')}):moveOut.length?tr('architect.move_out_of_city',{city:moveOut.map(c=>CITY[c].name).join(', ')}):'';
|
||||
return {sites,conn,lat,rings,tubes,moveOut,spend,budget,cheap,ready:!why,why,passed:A.passed===pzSig()};}
|
||||
// ---------- the shape: the game names what you drew ----------
|
||||
const AR_SHAPES={braces:['🦺',N_('architect.shape_braces')],tube:['🧪',N_('architect.shape_tube')],line:['➖',N_('architect.shape_line')],star:['✳️',N_('architect.shape_star')],tree:['🌳',N_('architect.shape_tree')],ring:['💍',N_('architect.shape_ring')],lolli:['🍭',N_('architect.shape_lolli')],ladder:['🪜',N_('architect.shape_ladder')],mesh:['🕸️',N_('architect.shape_mesh')],full:['🧶',N_('architect.shape_full')],islands:['🏝️',N_('architect.shape_islands')],spaghetti:['🍝',N_('architect.shape_spaghetti')]};
|
||||
function arShape(){const ns=Object.keys(S.pops),n=ns.length;if(n<2||!S.links.length)return null;const nb=arAdj(),m=new Set(S.links.map(edgeKey)).size,deg=c=>nb[c].size,maxd=Math.max(...ns.map(deg));
|
||||
const dbl=[...new Set(S.links.map(edgeKey))].filter(e=>new Set(S.links.filter(l=>edgeKey(l)===e).map(pzUnit)).size>1).length;
|
||||
let k;if(arReach(ns[0],nb).size<n)k='islands';else if(m===n-1&&dbl===m)k='braces';else if(n===2)k='tube';else if(m===n-1)k=maxd===n-1&&n>=4?'star':maxd<=2?'line':'tree';
|
||||
else if(ns.every(c=>deg(c)===2))k='ring';else if(n>=4&&m===n*(n-1)/2)k='full';
|
||||
else{const core={};for(const c of ns)core[c]=new Set(nb[c]);let cut=true;while(cut){cut=false;for(const c in core)if(core[c].size<=1){for(const v of core[c])core[v]&&core[v].delete(c);delete core[c];cut=true;}}
|
||||
const cs=Object.keys(core),cm=cs.reduce((a,c)=>a+core[c].size,0)/2,d2=cs.filter(c=>core[c].size===2).length;
|
||||
k=cs.length<n&&cs.every(c=>core[c].size===2)?'lolli':cs.length===n&&n>=6&&n%2===0&&cm===3*n/2-2&&d2===4&&cs.every(c=>core[c].size<=3)?'ladder':m>=n*1.8?'spaghetti':'mesh';}
|
||||
return {k,i:AR_SHAPES[k][0],n:tr(AR_SHAPES[k][1])};}
|
||||
// What later briefs do to a city, for the map: [{n: brief number, i: icon}], earliest first.
|
||||
// ---------- starting, briefs and the end ----------
|
||||
const arDem=c=>S.ar.dem[c]||10;
|
||||
// Short Gbps for chips and tags: 40G, 1.2T.
|
||||
const arG=g=>g>=1000?+(g/1000).toFixed(1)+'T':Math.round(g)+'G';
|
||||
function arDemand(){const P=S.pz,A=S.ar;P.src=[A.hq];P.dem=P.cities.filter(c=>c!==A.hq).map(c=>({t:'eye',a:c,b:null,g:arDem(c),ms:0,be:false}));pzDemand();
|
||||
for(const c in S.pops)S.pops[c].bb=P.cities.includes(c)&&c!==A.hq?{d:arDem(c)}:null;}
|
||||
// What each site gets right now, from the last compute().
|
||||
function arGot(){const g=pzGot(),o={};S.pz.dem.forEach((f,i)=>{o[f.a]=g[i].g;});return o;}
|
||||
// Connected sites that do not get all of their traffic.
|
||||
function arShort(dark){const got=arGot();return S.pz.cities.filter(c=>c!==S.ar.hq&&S.pops[c]&&!(dark||[]).includes(c)&&(got[c]||0)<arDem(c)*0.999-1e-6);}
|
||||
// Routers follow the tubes: the cheapest model that takes every tube and port at the POP.
|
||||
const AR_RG=()=>PZ_RG.slice().sort((a,b)=>pzRtCost(a,1)-pzRtCost(b,1));
|
||||
function arRouters(){for(const c in S.pops){const p=S.pops[c];p.routers=1;p.rgen=AR_RG().find(g=>!modelFits(c,g))??(p.rgen||0);}}
|
||||
// The yearly router cost a tube of this size would add at a city (0 when its router already takes it).
|
||||
function arRouterDelta(c,tier){const p=S.pops[c],cur=p?pzRtCost(p.rgen||0,1):0,need=Math.max(tier,...S.links.filter(l=>l.a===c||l.b===c).map(l=>l.tier)),g=AR_RG().find(i=>RG[i].maxLT>=need);return g==null?0:Math.max(0,pzRtCost(g,1)-cur);}
|
||||
const arSnapStr=()=>JSON.stringify({p:S.pops,l:S.links,m:S.pairMet||{},k:S.ar.sunk});
|
||||
function arBegin(run){if(!run)return;mkStop();const b0=run.briefs[0];
|
||||
pzBegin({id:'ar_'+run.id,n:run.n,src:[run.hq],dem:b0.add.map(c=>({t:'eye',a:c,g:1})),via:run.via,budget:0});
|
||||
pzToastsClear();S.pz.n=run.n;S.te={on:true,day:0};S.ar={id:run.id,hq:run.hq,bi:-1,sunk:0,over:0,dem:{},rings:[],gold:[],lat:null,passed:null,start:null};UI.arAll=false;arStop(true);
|
||||
S.pops[run.hq]=pzNewPop(run.hq);arApply(0);}
|
||||
function arApply(i){const A=S.ar,P=S.pz,b=arRun().briefs[i];A.bi=i;
|
||||
for(const c of b.drop||[]){P.cities=P.cities.filter(x=>x!==c);A.gold=A.gold.filter(x=>x!==c);if(!P.avoid.includes(c))P.avoid.push(c);if(A.lat&&A.lat.includes(c))A.lat=null;A.rings=A.rings.filter(r=>!r.includes(c));}
|
||||
for(const c of b.add||[])if(!P.cities.includes(c))P.cities.push(c);
|
||||
for(const c of b.gold||[])if(!A.gold.includes(c))A.gold.push(c);
|
||||
if(b.ring)A.rings.push(b.ring.slice());Object.assign(A.dem,b.dem||{});
|
||||
if(b.lat)A.lat=b.lat.slice();A.passed=null;
|
||||
// Later briefs stay a surprise: their cities do not show until they come (Show all cities shows everything).
|
||||
P.via=(arRun().via||[]).filter(c=>!P.cities.includes(c)&&!P.avoid.includes(c));
|
||||
arDemand();A.start=arSnapStr();UI.pzHist=[];UI.sel=null;UI.arFail=null;
|
||||
compute();pzCam();renderAll();
|
||||
toast(`<b>${tr('architect.brief_n_of_m',{n:i+1,m:arRun().briefs.length})}</b><br>${esc(b.t)}`,'goal');sfx('click');}
|
||||
function arNext(){if(!arOn())return;const e=arEval();if(!e.passed)return;mkStop();if(arLast()){arResults(true);return;}S.ar.over+=e.tubes.over;arApply(S.ar.bi+1);}
|
||||
function arReset(){const o=JSON.parse(S.ar.start);S.pops=o.p;S.links=o.l;S.pairMet=o.m||{};S.ar.sunk=o.k||0;arDemand();UI.sel=null;}
|
||||
// Tubes over plan in the run so far, this brief included.
|
||||
const arOver=()=>S.ar.over+arTubes().over;
|
||||
function arStars(sp){return 1+(arOver()?0:1)+(sp<=arRun().budget+1e-6?1:0);}
|
||||
function arShareText(st,sp){const sh=arShape();return tr('architect.share_line',{what:arRun().n,stars:pzStarStr(st),spend:fmt$(sp),shape:sh?sh.i+' '+sh.n:''});}
|
||||
// ---------- ▶ the chaos monkey review ----------
|
||||
// Every trench and cable is cut in turn, routed by compute() so the traffic visibly moves; a gold site losing HQ stops
|
||||
// the review with the cut still on the map, until the next edit.
|
||||
function arStop(quiet){mkStop();const sh=UI.arShow;if(sh&&sh.t)clearTimeout(sh.t);UI.arShow=null;if(!S||!S.links)return;let any=false;for(const l of S.links)if(l.cut){l.cut=0;any=true;}
|
||||
if(UI.arFail){UI.arFail=null;any=true;}if(any&&!quiet)compute();}
|
||||
function arShowStart(){if(!arOn()||UI.arShow)return;const e=arEval();if(!e.ready){toast(esc(e.why),'bad');sfx('err');return;}
|
||||
arStop(true);UI.sel=null;closeModal();UI.arBaseGot=arGot();UI.arShow={units:[...new Set(S.links.map(pzUnit))],i:-1,t:0,dark:[],short:[]};mkStart(S.ar.hq);arStep();}
|
||||
// One cut, routed: who goes dark, which gold sites with it, and who is still connected but short of room.
|
||||
function arCut(u){const ls=S.links.filter(l=>pzUnit(l)===u);for(const l of ls)l.cut=1;compute();const dark=arDark(u);return {ls,dark,gold:dark.filter(c=>S.ar.gold.includes(c)),short:arShort(dark)};}
|
||||
// The monkey sets off: the tube it last snipped is whole again, the next one stays whole until it gets there.
|
||||
function arStep(now){const sh=UI.arShow;if(!sh||!arOn())return;for(const l of S.links)l.cut=0;sh.i++;sh.hit=false;
|
||||
if(sh.i>=sh.units.length){UI.arShow=null;compute();S.ar.passed=pzSig();renderAll();sfx('star');haptic(15);
|
||||
mkEnd(true);toast(`✅ <b>${tr('architect.review_passed')}</b><br>${arLast()?tr('architect.last_brief_done'):tr('architect.next_brief_waiting')}`,'good');if(arLast())setTimeout(()=>{if(arOn()&&S.ar.passed===pzSig())arResults(true);},900);return;}
|
||||
const u=sh.units[sh.i];compute();renderAll();mkRun(S.links.find(l=>pzUnit(l)===u),AR_RUN/MK_RUN);
|
||||
if(now)arHit();else sh.t=setTimeout(arHit,AR_RUN);}
|
||||
// It has arrived and snips: who goes dark, and does a mission-critical site go with it?
|
||||
function arHit(){const sh=UI.arShow;if(!sh||!arOn())return;sh.hit=true;
|
||||
const u=sh.units[sh.i],{ls,dark,gold,short}=arCut(u),l0=ls[0];sh.dark=dark;sh.short=short;sh.u=u;
|
||||
floater((CITY[l0.a].x+CITY[l0.a].x+wrapDx(CITY[l0.a].x,CITY[l0.b].x))/2,(CITY[l0.a].y+CITY[l0.b].y)/2-26,l0.sub?tr('architect.anchor'):tr('architect.backhoe'),'#FF8A3D');
|
||||
for(const c of dark)floater(CITY[c].x,CITY[c].y-34,gold.includes(c)?'💥 '+CITY[c].name:tr('architect.city_goes_dark',{city:CITY[c].name}),gold.includes(c)?'#FF4D5E':'#9AA3BE');
|
||||
for(const c of short)floater(CITY[c].x,CITY[c].y-34,tr('architect.city_short_g',{city:CITY[c].name,g:arG(arDem(c)-(arGot()[c]||0))}),'#FF4D5E');
|
||||
const bad=gold.length||short.length;if(UI.mk)UI.mk.bad=!!bad;sfx(bad?'err':'click');
|
||||
if(bad){UI.arShow=null;UI.arFail={u,gold,dark,short};renderAll();haptic(30);return;}
|
||||
renderAll();sh.t=setTimeout(arStep,dark.length?AR_HOLD*1.7:AR_HOLD);}
|
||||
// Skip the show: check every cut at once, and stop at the first that breaks a gold site.
|
||||
function arShowSkip(){const sh=UI.arShow;if(!sh)return;clearTimeout(sh.t);for(const l of S.links)l.cut=0;
|
||||
for(let i=sh.hit?sh.i+1:sh.i;i<sh.units.length;i++){const x=arCut(sh.units[i]);for(const l of x.ls)l.cut=0;if(x.gold.length||x.short.length){sh.i=i-1;arStep(true);return;}}
|
||||
sh.i=sh.units.length-1;arStep();}
|
||||
// The kind of a city in a run: its sites, stepping stones and closed cities show; the rest of the world only on request.
|
||||
function arKind(c){const P=S.pz;return P.cities.includes(c)?'goal':P.avoid.includes(c)?'avoid':P.via.includes(c)?'via':S.pops[c]||(UI.arAll&&pzCityOk(c))?'off':null;}
|
||||
23
src/game/60-features/97-puzzle-monkey.js
Normal file
23
src/game/60-features/97-puzzle-monkey.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ---------- the chaos monkey in puzzles: the N-1 star, acted out ----------
|
||||
The third star already asks whether the build survives any single cut (pzEval tries every trench and cable). When a
|
||||
new star lands, and on request, the monkey plays that check on the map: it runs to each trench or cable, snips it,
|
||||
and the cities that lose traffic say so. Only while the map is really being drawn: the stars never wait on it. */
|
||||
const PZ_RUN=450,PZ_HOLD=550; // ms: the run to a tube, then how long its cut shows
|
||||
const pzMkCan=()=>animOn()&&!UI.mapHid&&performance.now()-(UI.drawnAt||-1e9)<2000;
|
||||
function pzMonkey(then){pzMkStop();const units=[...new Set(S.links.map(pzUnit))];if(!units.length){if(then)then();return;}
|
||||
const c=S.pz.src[0]||S.pz.cities[0];UI.pzMk={units,i:-1,t:0,then,bad:0};if(CITY[c])mkStart(c);sfx('alert');pzMkStep();}
|
||||
// Off to the next one: the tube it last snipped is whole again, the next one stays whole until it gets there.
|
||||
function pzMkStep(){const m=UI.pzMk;if(!m||!pzOn())return;for(const l of S.links)l.cut=0;m.i++;if(m.i>=m.units.length){pzMkDone();return;}
|
||||
const u=m.units[m.i];compute();renderAll();mkRun(S.links.find(l=>pzUnit(l)===u),PZ_RUN/MK_RUN);m.t=setTimeout(pzMkHit,PZ_RUN);}
|
||||
function pzMkHit(){const m=UI.pzMk;if(!m||!pzOn())return;const ls=S.links.filter(l=>pzUnit(l)===m.units[m.i]),l0=ls[0];for(const l of ls)l.cut=1;compute();
|
||||
const g=pzGot(),lost=[];S.pz.dem.forEach((f,i)=>{if(!f.be&&!pzFull(f,g[i]))lost.push({c:f.t==='l2'?f.b:f.a,g:Math.max(0,f.g-g[i].g)});});
|
||||
floater((CITY[l0.a].x+CITY[l0.a].x+wrapDx(CITY[l0.a].x,CITY[l0.b].x))/2,(CITY[l0.a].y+CITY[l0.b].y)/2-26,tr('puzzles.monkey_snip'),'#FF8A3D');
|
||||
for(const x of lost)floater(CITY[x.c].x,CITY[x.c].y-34,tr('puzzles.city_loses_g',{city:CITY[x.c].name,g:fmtG(x.g)}),'#FF4D5E');
|
||||
if(UI.mk)UI.mk.bad=lost.length>0;if(lost.length)m.bad++;sfx(lost.length?'err':'click');renderAll();m.t=setTimeout(pzMkStep,lost.length?PZ_HOLD*2:PZ_HOLD);}
|
||||
// The end: a cheer if nothing broke, a tantrum if something did, then whatever was waiting (the stars).
|
||||
function pzMkDone(bad){const m=UI.pzMk;if(!m)return;clearTimeout(m.t);UI.pzMk=null;for(const l of S.links)l.cut=0;compute();
|
||||
mkEnd(!(bad!=null?bad:m.bad),true);renderAll();if(m.then)m.then();}
|
||||
// Skip: straight to the end; the verdict is already known.
|
||||
function pzMkSkip(){if(UI.pzMk)pzMkDone(pzEval().n1?0:1);}
|
||||
// Gone without a word: the build changed under it, or the puzzle closed.
|
||||
function pzMkStop(){const m=UI.pzMk;if(!m)return;clearTimeout(m.t);UI.pzMk=null;for(const l of S.links)l.cut=0;mkStop();}
|
||||
63
src/game/60-features/98-architect-weekly.js
Normal file
63
src/game/60-features/98-architect-weekly.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/* ---------- the published weekly Architect run ----------
|
||||
Every Sunday scripts/weekly-architect.js publishes architect/weekly/<key>.json next to the page: an HQ, a budget and
|
||||
the briefs, as data. Fetched only when Puzzles opens, checked field by field, and played like the handmade runs
|
||||
(AR_RUNS) under the id 'wk-<key>'. A brief's text is written here from what it asks for, in the player's language, so
|
||||
the file can never say one thing and want another. When the file is missing, offline or wrong there is simply no
|
||||
weekly run that week. */
|
||||
const AR_WK_V=1,AR_WK_FIELDS=['v','key','hq','budget','name','joke','briefs','ref','rev'],AR_WK_BRIEF=['add','gold','ring','drop','dem','lat','tubes'];
|
||||
// The labels a file may name (N_: kept whole in the shipped page); their only placeholder is {hq}, a city.
|
||||
const AR_WK_NAMES=[N_('architect_weekly.name_all_roads_lead_to_hq'),N_('architect_weekly.name_the_hq_job'),N_('architect_weekly.name_hq_and_friends')];
|
||||
const AR_WK_JOKES=[N_('architect_weekly.joke_hq_signed_the_lease'),N_('architect_weekly.joke_one_network_a_handful')];
|
||||
const arWkId=key=>'wk-'+key,AR_WK_ID=/^wk-\d{4}-W\d{2}$/;
|
||||
function arWkTxt(o,list){if(!pzObj(o)||!list.includes(o.l))return null;const p=o.p==null?{}:o.p;if(!pzObj(p))return null;
|
||||
const need=[...new Set([...String(EN[o.l]).matchAll(/\{(\w+)\}/g)].map(m=>m[1]))];
|
||||
if(Object.keys(p).length!==need.length||!need.every(k=>k==='hq'&&pzCityOk(p[k])))return null;return {l:o.l,p:Object.assign({},p)};}
|
||||
const arWkSay1=o=>tr(o.l,o.p.hq?{hq:CITY[o.p.hq].name}:{});
|
||||
// What a brief says, built from what it wants.
|
||||
function arWkSay(b){const n=c=>CITY[c].name,t=[];
|
||||
if(b.drop)t.push(tr('architect_weekly.t_drop',{a:n(b.drop[0])}));
|
||||
const ag=b.add&&b.gold&&b.add.length===1&&b.gold.length===1&&b.add[0]===b.gold[0];
|
||||
if(ag)t.push(tr('architect_weekly.t_add_gold',{a:n(b.add[0])}));
|
||||
else if(b.add)t.push(b.add.length>1?tr('architect_weekly.t_add_two',{a:n(b.add[0]),b:n(b.add[1])}):tr('architect_weekly.t_add_one',{a:n(b.add[0])}));
|
||||
if(b.gold&&!ag)t.push(b.gold.length>1?tr('architect_weekly.t_gold_two',{a:n(b.gold[0]),b:n(b.gold[1])}):tr('architect_weekly.t_gold_one',{a:n(b.gold[0])}));
|
||||
for(const c of Object.keys(b.dem||{}))if(!(b.add||[]).includes(c))t.push(tr('architect_weekly.t_grow',{a:n(c),g:arG(b.dem[c])}));
|
||||
if(b.ring)t.push(tr('architect_weekly.t_ring',{list:b.ring.map(n).join(', ')}));
|
||||
if(b.lat)t.push(tr('architect_weekly.t_lat',{a:n(b.lat[0]),b:n(b.lat[1]),ms:+b.lat[2].toFixed(1)}));
|
||||
return t.join(' ');}
|
||||
// The briefs, in order: a site exists from the brief that adds it until one drops it; every brief asks for something.
|
||||
function arWkBriefs(a,hq){if(!Array.isArray(a)||a.length<3||a.length>7)return null;const sites=new Set([hq]),gone=new Set(),out=[];
|
||||
const ids=(x,lo,hi)=>x==null?[]:Array.isArray(x)&&x.length>=lo&&x.length<=hi&&x.every(pzCityOk)&&new Set(x).size===x.length?x.slice():null;
|
||||
for(const b of a){if(!pzObj(b)||Object.keys(b).some(k=>!AR_WK_BRIEF.includes(k)))return null;
|
||||
const drop=ids(b.drop,1,1),add=ids(b.add,1,2),gold=ids(b.gold,1,2),ring=b.ring==null?[]:ids(b.ring,3,4);if(!drop||!add||!gold||!ring)return null;
|
||||
for(const c of drop){if(c===hq||!sites.has(c))return null;sites.delete(c);gone.add(c);}
|
||||
for(const c of add){if(sites.has(c)||gone.has(c))return null;sites.add(c);}
|
||||
if(![...gold,...ring].every(c=>sites.has(c))||gold.includes(hq))return null;
|
||||
const dem={};if(b.dem!=null){if(!pzObj(b.dem))return null;for(const c of Object.keys(b.dem)){const g=b.dem[c];if(!sites.has(c)||c===hq||!Number.isInteger(g)||g<10||g>400)return null;dem[c]=g;}}
|
||||
let lat=null;if(b.lat!=null){const l=b.lat;if(!Array.isArray(l)||l.length!==3||!sites.has(l[0])||!sites.has(l[1])||l[0]===l[1]||typeof l[2]!=='number'||!isFinite(l[2])||l[2]<1||l[2]>300)return null;lat=l.slice();}
|
||||
if(!Number.isInteger(b.tubes)||b.tubes<0||b.tubes>9)return null;
|
||||
if(!add.length&&!gold.length&&!ring.length&&!lat&&!Object.keys(dem).length)return null;
|
||||
const o={tubes:b.tubes};if(add.length)o.add=add;if(gold.length)o.gold=gold;if(ring.length)o.ring=ring;if(drop.length)o.drop=drop;if(Object.keys(dem).length)o.dem=dem;if(lat)o.lat=lat;
|
||||
o.t=arWkSay(o);out.push(o);}
|
||||
return out[0].add?out:null;}
|
||||
// The file, never trusted: a run definition like AR_RUNS's, or null.
|
||||
function arWkValid(j,key){if(!pzObj(j)||Object.keys(j).some(k=>!AR_WK_FIELDS.includes(k))||j.v!==AR_WK_V||j.key!==key||pzWeekStart(key)==null||!pzCityOk(j.hq))return null;
|
||||
if(!Number.isInteger(j.budget)||j.budget<50000||j.budget>2e7)return null;
|
||||
if(j.rev!==undefined&&!(Number.isInteger(j.rev)&&j.rev>=2&&j.rev<=999))return null;if(j.ref!==undefined&&!pzObj(j.ref))return null;
|
||||
const name=arWkTxt(j.name,AR_WK_NAMES),joke=arWkTxt(j.joke,AR_WK_JOKES),briefs=arWkBriefs(j.briefs,j.hq);if(!name||!joke||!briefs)return null;
|
||||
return {id:arWkId(key),key,wk:true,n:arWkSay1(name),j:arWkSay1(joke),hq:j.hq,via:[],budget:j.budget,briefs,rev:j.rev||1};}
|
||||
// The run behind an id, when it is this week's.
|
||||
function arWkRun(id){const w=UI.arWk;return w&&w.def&&w.def.id===id?w.def:null;}
|
||||
// ---------- fetching it: when Puzzles opens, never on page load ----------
|
||||
function arWkEnsure(){const key=pzWeekKey(new Date()),w=UI.arWk;if(w&&w.key===key&&(w.def||Date.now()-w.at<5*60e3))return;
|
||||
const st=UI.arWk={key,def:null,at:Date.now()};let done=false;
|
||||
const fin=def=>{if(done)return;done=true;clearTimeout(to);if(UI.arWk!==st)return;st.def=def;st.at=Date.now();const el=$('arWk');if(el)el.outerHTML=arWkRow();};
|
||||
const ac=window.AbortController?new AbortController():null,to=setTimeout(()=>{if(ac)ac.abort();fin(null);},5000);
|
||||
if(!window.fetch||location.protocol==='file:'){fin(null);return;}
|
||||
try{fetch(`architect/weekly/${key}.json`,ac?{signal:ac.signal}:{}).then(r=>r.ok?r.json():null).then(j=>arWkValid(j,key),()=>null).then(fin,()=>fin(null));}catch(e){fin(null);}}
|
||||
// Its row in the Puzzles menu, above the handmade runs; nothing while there is none.
|
||||
function arWkRow(){const w=UI.arWk,r=w&&w.key===pzWeekKey(new Date())?w.def:null;if(!r)return '<div id="arWk"></div>';
|
||||
const x=arLoad().runs[r.id],ok=x&&(x.rv||1)===r.rev?x:null;
|
||||
return `<div class="scn pzwk" id="arWk"><div class="grow"><div class="eyebrow">🗓️ ${tr('architect_weekly.weekly_run')} · ${arWkNext(new Date())}</div><div class="nm">${esc(r.n)} <span class="pzst">${pzStarStr(ok?ok.st:0)}</span></div><div class="meta">${esc(r.j)}</div><div class="meta">${tr('architect.n_briefs',{n:r.briefs.length})} · 🏠 ${esc(CITY[r.hq].name)} · ${tr('puzzles.budget_x',{x:fmt$(r.budget)})}${ok&&ok.sp!=null?' · '+tr('puzzles.best_x',{x:fmt$(ok.sp)}):''}</div></div>${btn(tr('common.play'),'pzArStart',{id:r.id},ok&&ok.st>=3?'ghost':'pink')}</div>`;}
|
||||
// "New run in 2 d 14 h": when next week's run comes out.
|
||||
function arWkNext(now){const t=pzWeekStart(pzKeyAdd(pzWeekKey(now),1))-now,m=Math.max(1,Math.ceil(t/60e3)),d=Math.floor(m/1440),h=Math.floor(m%1440/60);
|
||||
return d?tr('architect_weekly.next_run_in_d_h',{d,h}):tr('architect_weekly.next_run_in_h_m',{h,m:m%60});}
|
||||
|
|
@ -5,7 +5,9 @@
|
|||
Not That Telecom and Level Tree (whose real-world network lists no sites in PeeringDB at all, but sells in Sydney). Others can sit in
|
||||
an Australian city, like the Pacific carriers backhauling to Sydney (or Glowball Sakura Lager), but reach Australian
|
||||
customers only from overseas. */
|
||||
const AU_SELLERS=['tsy','voc','spl','sgt','drz','cog','ntt','lvl'],sellsAt=(n,c)=>!!n.price&&(n.pops.includes(c)||!!n.premOnly&&n.premOnly.includes(c))&&(!CITY[c].au||AU_SELLERS.includes(n.id));
|
||||
const AU_SELLERS=['tsy','voc','spl','sgt','drz','cog','ntt','lvl'],sellsAt=(n,c)=>!!n.price&&(n.pops.includes(c)||!!n.premOnly&&n.premOnly.includes(c))&&(!CITY[c].au||AU_SELLERS.includes(n.id))&&!noTransitIn(c);
|
||||
// A scenario city where nobody sells transit (Anchors Away: Tallinn's internet is across the water).
|
||||
const noTransitIn=c=>{const x=S&&S.scn&&S.scn.rules&&S.scn.rules.noTransitIn;return Array.isArray(x)&&x.includes(c);};
|
||||
/* China Telecomet's premium crossing into China (CN-Too) is sold where its border routes start: Hong Kong, and Moscow
|
||||
(#195), where it rides the land route east and nothing else of theirs is on offer (premOnly). It costs the same
|
||||
wherever you buy it: the Hong Kong price. */
|
||||
|
|
@ -23,7 +25,7 @@ function ixCap(c){return ixLagF(c)*(S.myIx[c]?myFab(c).g*(myIxLive(c)?1:0):liveC
|
|||
function ixSessions(c){
|
||||
const s=new Set(); if(S.ixp[c]===undefined)return s;
|
||||
for(const id of ixMembers(c)){const n=NET[id];
|
||||
if(S.peers[id+'@'+c]&&!snub(id,c)&&!(isRemote(c)&&noRemote(id))&&!mpDown(id,c))s.add(id);
|
||||
if(S.peers[id+'@'+c]&&!snub(id,c)&&!(isRemote(c)&&noRemote(id)))s.add(id);
|
||||
else if(S.rs[c]&&n.pol==='open'&&ppol()==='open')s.add(id);
|
||||
else if(S.myIx[c]&&(n.pol==='open'||n.pol==='selective'))s.add(id);}
|
||||
return s;
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ const pniBig=id=>{const n=NET[id];return n.type==='t1'||(n.type==='cdn'&&n.pol!=
|
|||
const pniMin=id=>{const n=NET[id];return n.type==='t1'||(n.type==='cdn'&&n.pol!=='open')?1:0;};
|
||||
const pniG1=id=>id==='dtk';
|
||||
// A beer with their peering coordinator at a conference halves the wait. It is how it really works.
|
||||
const PNI_SLOW=0.15,pniLead=id=>{const n=pniBig(id)?(Math.random()<PNI_SLOW?180+Math.floor(Math.random()*186):30):14+Math.floor(Math.random()*29);return S.conf&&S.conf.until>S.day?Math.round(n/2):n;};
|
||||
const PNI_SLOW=0.15,pniLead=id=>{const n=pniBig(id)?(Math.random()<PNI_SLOW?180+Math.floor(Math.random()*186):30):14+Math.floor(Math.random()*29);return leadDays(S.conf&&S.conf.until>S.day?Math.round(n/2):n);};
|
||||
const pniG=p=>p.g1?1:PORT[p.tier].g,pniPN=p=>p.g1?'1G':PORT[p.tier].n,pniOn=p=>!(p.ready>S.day);
|
||||
const pniEta=id=>pniBig(id)?tr('pnis.delivery_about_a_month_sometimes_6'):tr('pnis.delivery_2_to_6_weeks');
|
||||
const PNI_G1_COST=1200,pniWhen=n=>n>=60?tr('pnis.their_team_quotes_m_months',{m:Math.round(n/30)}):tr('pnis.ready_in_about_n_days',{n});
|
||||
function pniWait(p,c){return `<div class="kv"><span>${(p.n||1)>1?p.n+'×':''}${pniPN(p)} PNI</span><b>${tr('common.on_order')}</b></div><div class="meta">${tr('pnis.about_n_days_to_go_nothing',{n:Math.max(0,p.ready-S.day)})}</div><div class="btns">${btn(tr('common.chase_it'),'pniChase',{id:p.id},'ghost sm')}${btn(UI.confirm===p.id?tr('common.really_remove'):tr('pnis.cancel_the_order'),'cancelPni',{id:p.id},'ghost sm')}</div>`;}
|
||||
function pniDay(d){for(const p of S.pni){const nm=esc(NET[p.net].name),city=esc(CITY[p.city].name);
|
||||
if(p.ready===d)toast(tr('pnis.pni_with_net_is_up_in',{net:nm,city,dc:esc(siteName(p.city,'a'))}),'good');
|
||||
if(p.up&&p.up.ready<=d){p.tier=p.up.tier;p.n=p.up.n;if(p.up.g1)p.g1=true;else delete p.g1;delete p.up;toast(tr('pnis.augment_with_net_delivered_in_city',{net:nm,city,port:((p.n||1)>1?p.n+'×':'')+pniPN(p)}),'good');}}}
|
||||
if(p.up&&p.up.ready<=d){p.tier=p.up.tier;p.n=p.up.n;if(p.up.site==='ab'&&p.n>=2&&S.pops[p.city]&&S.pops[p.city].site2)p.site='ab';if(p.up.g1)p.g1=true;else delete p.g1;delete p.up;toast(tr('pnis.augment_with_net_delivered_in_city',{net:nm,city,port:((p.n||1)>1?p.n+'×':'')+pniPN(p)}),'good');}}}
|
||||
// Microsnoft has no capacity on the US east coast. Not for a PNI, not at an exchange, not for anyone.
|
||||
const US_EAST=['ash','nyc','bos','atn','mia'];
|
||||
const MSF_NOPE=[N_('pnis.no_capacity_in_us_east_you'),N_('pnis.us_east_is_sold_out_until'),N_('pnis.their_peering_team_says_us_east'),N_('pnis.a_new_region_is_coming_online')];
|
||||
|
|
|
|||
24
src/game/70-rules/35-pni-orders.js
Normal file
24
src/game/70-rules/35-pni-orders.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* Single and bulk orders share the same checks, prices and provisioning. */
|
||||
function pniQuote(city,net,tier,reserved=0){tier=+tier;const g1=tier===-1;if(g1)tier=0;
|
||||
if(!S||!S.pops[city]||!isNet(net)||!NET[net].pops.includes(city)||!Number.isInteger(tier)||!PORT[tier]||(g1&&!pniG1(net)))return null;
|
||||
const ex=S.pni.find(p=>p.city===city&&p.net===net);
|
||||
if(ex&&(g1||!pniOn(ex)||ex.up||(!(ex.g1&&tier===0)&&tier<=ex.tier)))return null;
|
||||
const cost=g1?PNI_G1_COST:(1500+PORT[tier].setup/2)*(ex&&ex.n||1),slots=ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(tier);
|
||||
let why='';if(!portOk(city,tier))why=tr('actions.your_router_can_t_take_a',{port:PORT[tier].n});
|
||||
else{const r=peerOk(net,'pni',city);if(!r.ok)why=tr('sites_peering_caches.net_declined_the_pni_why',{net:esc(NET[net].name),why:esc(r.why)});
|
||||
else if(!g1&&tier<pniMin(net))why=tr('sites_peering_caches.net_does_not_do_port_pnis',{net:esc(NET[net].name),port:PORT[tier].n});
|
||||
else if(slots>0&&portsUsed(city)+reserved+slots>portsMax(city)+1e-9)why=tr('ports.no_free_router_ports_in_city',{city:esc(CITY[city].name),u:fmtPorts(portsUsed(city)+reserved),m:portsMax(city)});}
|
||||
return {city,net,tier,g1,ex,cost,slots,why};}
|
||||
function pniPlace(q){const {city,net,tier,g1,ex}=q,lead=pniLead(net);
|
||||
if(S.conf&&S.conf.until>S.day)S.stats.beerPni=1;
|
||||
if(ex)ex.up={tier,n:ex.n||1,ready:S.day+lead,g1:false};else S.pni.push({id:uid(),city,net,tier,g1:g1||undefined,ready:S.day+lead});
|
||||
return lead;}
|
||||
function pniBatch(net,tier){tier=+tier;const all=net===null;if(!S||(!all&&!isNet(net))||!Number.isInteger(tier)||(tier===-1?all||!pniG1(net):!PORT[tier]||!portShown(tier)))return null;
|
||||
const shared=[],orders=[],blocked=[],reserved={};let kept=0,cost=0,mo=0,raised=0;
|
||||
// Pending augments and earlier orders in this batch already own their future ports.
|
||||
for(const p of S.pni)if(p.up)reserved[p.city]=(reserved[p.city]||0)+Math.max(0,PORT_SLOT(p.up.tier)*(p.up.n||1)-PORT_SLOT(p.tier)*(p.n||1));
|
||||
for(const n of all?NETS:[NET[net]])for(const city of n.pops){if(!S.pops[city])continue;shared.push(city);
|
||||
// Each network at its own minimum: asking everyone for 10G orders 100G from those that start at 100G.
|
||||
const q=pniQuote(city,n.id,all&&tier>=0?Math.max(tier,pniMin(n.id)):tier,reserved[city]||0);if(!q){kept++;continue;}if(q.why){blocked.push(q);continue;}orders.push(q);if(q.tier>tier&&!q.g1)raised++;cost+=q.cost;reserved[city]=(reserved[city]||0)+q.slots;
|
||||
mo+=pniMo({net:n.id,tier:q.tier,g1:q.g1,n:q.ex&&q.ex.n},0)-(q.ex?pniMo(q.ex,0):0);}
|
||||
return {shared,orders,blocked,kept,cost,mo,raised};}
|
||||
44
src/game/70-rules/38-pni-value.js
Normal file
44
src/game/70-rules/38-pni-value.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* ---------- Is a PNI worth it? (#175, #172) ----------
|
||||
How you reach each network today, and what a PNI at one POP would take over: the traffic your users there send
|
||||
to that network over transit, an exchange or a PNI elsewhere, priced with the real billing functions. Information
|
||||
only: nothing here changes routing or billing. Built once per routing result (R.fl), not per row. */
|
||||
const PNI_HOT=0.8;
|
||||
let PNIX=null;
|
||||
function pniIdx(){if(PNIX&&PNIX.R===R)return PNIX;
|
||||
const ix={},pn={};
|
||||
for(const c in S.ixp){const nm=ixName(c);for(const id of ixSessions(c)){const a=ix[id]||(ix[id]=[]);if(!a.includes(nm))a.push(nm);}}
|
||||
for(const p of S.pni)(pn[p.net]||(pn[p.net]=[])).push(p);
|
||||
return PNIX={R,fl:{},ix,pn};}
|
||||
// One POP's flows by network, added up the first time that POP is asked about.
|
||||
function pniFlows(c){const X=pniIdx();let m=X.fl[c];if(m)return m;m=X.fl[c]={};
|
||||
for(const f of R.fl||[]){if(f.junk||f.c!==c)continue;let o=m[f.n];if(!o)o=m[f.n]={t:0,ix:0,p:0,h:0,u:0,T:{},I:{}};
|
||||
o.u+=f.rem;o.t+=f.gt;o.ix+=f.gi;o.p+=f.gp;o.h+=f.gh;if(f.gt)o.T[f.ti]=(o.T[f.ti]||0)+f.gt;if(f.gi)o.I[f.ii]=(o.I[f.ii]||0)+f.gi;}
|
||||
return m;}
|
||||
// One status, most direct first. c: the POP you are looking at (null: anywhere).
|
||||
function pniStat(id,c){const X=pniIdx(),ps=X.pn[id]||[],h=c?ps.find(p=>p.city===c):null;
|
||||
if(h)return {k:'here',p:h};
|
||||
const el=[...new Set(ps.filter(p=>pniOn(p)).map(p=>p.city))];if(el.length)return {k:'else',cities:el};
|
||||
if(X.ix[id])return {k:'ix',ixs:X.ix[id]};
|
||||
if(R.cone[id])return {k:'cone',by:NET[R.cone[id]]||coneVia(id)};
|
||||
return {k:R.reachable[id]?'t':'none'};}
|
||||
const pniList=a=>a.length>2?tr('pni_list.list_more',{list:a.slice(0,2).join(', '),n:a.length-2}):a.join(', ');
|
||||
const PNI_ICON={here:'🔗',else:'🔗',ix:'🤝',cone:'🧺',t:'💸',none:'🚫'};
|
||||
function pniChip(id,c){const s=pniStat(id,c);let t;
|
||||
if(s.k==='here'){const p=s.p;t=!pniOn(p)?tr('pni_list.chip_pni_here_on_order'):tr('pni_list.chip_pni_here',{port:((p.n||1)>1?p.n+'×':'')+pniPN(p),p:pct(Math.min(1,(R.usePni[p.id]||0)/lagCap(pniG(p),p.n)))});}
|
||||
else if(s.k==='else'){const l=pniList(s.cities.map(x=>CITY[x].name));t=c?tr('pni_list.chip_pni_elsewhere',{list:l}):tr('pni_list.chip_pni_at',{list:l});}
|
||||
else if(s.k==='ix')t=tr('pni_list.chip_peers_at',{list:pniList(s.ixs)});
|
||||
else if(s.k==='cone')t=s.by?tr('pni_list.chip_via_cone',{net:s.by.name}):tr('pni_list.chip_via_a_cone');
|
||||
else t=s.k==='t'?tr('pni_list.chip_via_transit'):tr('pni_list.chip_not_reached');
|
||||
return `<span class="pchip pk-${s.k}">${PNI_ICON[s.k]} ${esc(t)}</span>`;}
|
||||
/* What a new PNI with `id` at `c` would carry and save per month. It takes your users' traffic there that now
|
||||
leaves over transit, an exchange or a PNI elsewhere, or does not leave at all for want of room, up to its port; transit is billed on the 95th percentile,
|
||||
so the saving is the bill now minus the bill with that much less (commits included). */
|
||||
function pniVal(id,c){const o=pniFlows(c)[id]||{t:0,ix:0,p:0,h:0,u:0,T:{},I:{}},want=o.t+o.ix+o.p+o.u;
|
||||
const lo=pniMin(id);let tier=-1;for(let i=lo;i<PORT.length;i++)if(portShown(i)){tier=i;if(PORT[i].g*0.8>=want)break;}
|
||||
if(tier<0)tier=lo;const g=Math.min(want,PORT[tier].g),gt=Math.min(o.t,g);let saved=0;
|
||||
if(gt>0)for(const tid in o.T){const t=S.transit.find(x=>x.id===tid);if(!t)continue;const q=R.p95[tid]??(R.useT[tid]||0),x=gt*o.T[tid]/o.t;saved+=transitMo(t,q)-transitMo(t,Math.max(0,q-x));}
|
||||
const cost=pniMo({net:id,tier,n:1},g);
|
||||
// Then what you drop today for want of room, then a hot exchange port's share.
|
||||
const drop=Math.min(o.u,g-gt);let ixLeft=g-gt-drop,hot=0;for(const x in o.I){if(ixLeft<=0)break;const m=Math.min(ixLeft,o.I[x]);ixLeft-=m;const cp=S.ixp[x]!==undefined?ixCap(x):0;if(cp>0&&(R.useIx[x]||0)>=PNI_HOT*cp)hot+=m;}
|
||||
const val=saved-cost,worth=g>=1&&(val>0||hot>=1||drop>=1);
|
||||
return {...o,want,g,tier,saved,cost,val,hot,drop,worth};}
|
||||
30
src/game/70-rules/40-peering-desk.js
Normal file
30
src/game/70-rules/40-peering-desk.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ---------- The peering desk ----------
|
||||
Every exchange port brings peering requests. Nobody answers them by hand any more: your peering policy does.
|
||||
Open accepts everyone, Selective accepts the networks worth peering with and quietly declines the rest, Closed
|
||||
declines them all. Once a week the NOC log gets one folded line about it. */
|
||||
const PPOL=['open','selective','closed'],ppol=()=>(S&&PPOL.includes(S.ppol))?S.ppol:'open';
|
||||
const PPOL_N={open:N_('peering_desk.open_to_all'),selective:N_('common.selective'),closed:N_('common.closed')};
|
||||
const PPOL_D={open:N_('peering_desk.open_desc'),selective:N_('peering_desk.selective_desc'),closed:N_('peering_desk.closed_desc')};
|
||||
// How often someone asks, against Open: a selective or closed network gets fewer requests.
|
||||
const PDESK_ASK={open:1,selective:0.7,closed:0.5},PDESK_IX=12;
|
||||
const pdeskNew=w=>({w,a:0,d:0,ix:[]});
|
||||
// Who is worth it: a real small network on the exchange, or a newcomer whose PeeringDB is up to date.
|
||||
const pdeskWant=(p,net,fresh)=>p==='open'||(p==='selective'&&(!!net||fresh));
|
||||
function peeringDeskDay(d){const w=Math.floor(d/7);let D=S.pdesk;
|
||||
// A new week: last week's tally becomes one line in the NOC log.
|
||||
if(!D||D.w!==w){if(D&&D.w<w&&(D.a||D.d)){S.pdeskRep={...D,p:ppol()};logNote(esc(pdeskLine(S.pdeskRep)),'',[],{a:'tab',v:'nets'});}D=S.pdesk=pdeskNew(w);}
|
||||
const ixs=Object.keys(S.ixp),p=ppol();
|
||||
if(!ixs.length||Math.random()>=Math.min(0.9,0.15*ixs.length)*PDESK_ASK[p])return;
|
||||
const c=pick(ixs),real=ixMembers(c).filter(id=>{const n=NET[id];return !S.peers[id+'@'+c]&&!merged(id)&&n.type!=='t1'&&n.type!=='cdn'&&n.pol!=='paid'&&n.share<=0.006;});
|
||||
const net=real.length&&Math.random()<0.4?pick(real):null,fresh=Math.random()>=0.6;
|
||||
if(!pdeskWant(p,net,fresh)){D.d++;return;}
|
||||
if(net)S.peers[net+'@'+c]=true;D.a++;if(!D.ix.includes(c)&&D.ix.length<PDESK_IX)D.ix.push(c);}
|
||||
// "Peering desk: 7 new sessions at DE-KICKS and LINX, 3 declined (Selective)."
|
||||
function pdeskLine(x){const pol=tr(PPOL_N[x.p]||PPOL_N.open);if(!x.a)return trn('peering_desk.n_requests_declined',x.d,{pol});
|
||||
const nm=x.ix.slice(0,x.ix.length>4?3:4).map(ixName);if(x.ix.length>4)nm.push(trn('peering_desk.n_more_exchanges',x.ix.length-3));
|
||||
let ix;try{ix=new Intl.ListFormat(LANG,{type:'conjunction'}).format(nm);}catch(e){ix=nm.join(', ');}
|
||||
return x.d?trn('peering_desk.n_new_sessions_at_ix_declined',x.a,{ix,d:x.d,pol}):trn('peering_desk.n_new_sessions_at_ix',x.a,{ix,pol});}
|
||||
// The policy picker, in the Networks tab.
|
||||
function pdeskCard(){const p=ppol(),r=S.pdeskRep;
|
||||
return `<div class="ibx ibxcard"><div class="nm">🤝 ${tr('common.peering_policy')}: ${tr(PPOL_N[p])}</div><div class="seg">${PPOL.map(x=>btn(tr(PPOL_N[x]),'peerPol',{p:x},p===x?'sm':'ghost sm')).join('')}</div>
|
||||
<p class="meta">${tr(PPOL_D[p])}</p>${r&&r.w>=Math.floor(S.day/7)-1&&(r.a||r.d)?`<p class="meta">${esc(pdeskLine(r))}</p>`:''}</div>`;}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/* ---------- The peering inbox ----------
|
||||
Every exchange port brings mail: peering requests from networks nobody has heard of, and sessions that drop
|
||||
because someone's PeeringDB says 50 prefixes and they now send 400 (or a full table). Answer it, or hire an AI. */
|
||||
const PPOL_N={open:N_('peering_inbox.open_to_all'),selective:N_('common.selective'),closed:N_('common.closed')},PPOL_D={open:N_('peering_inbox.everyone_who_asks_gets_a_session'),selective:N_('peering_inbox.fewer_requests_and_you_answer_them'),closed:N_('peering_inbox.nobody_asks_and_no_route_servers')};
|
||||
const AI_MO=Math.round(20e6/12),INBOX_MAX=80,IBX_LEAKS=['nfx','ggl','fbk','amz','msf'];
|
||||
const TINY=['Basement Broadband','Uncle Dave’s WISP','Fibre Fiesta','Raspberry Pi Transit','Vanity ASN Ltd','Moonshot Crypto Hosting','Minecraft Collective','Bob’s Bits','Homelab Heroes','Hackerspace Uplink','Tiny Tower Networks','Pigeon Post IP','Retro BBS Revival','Overkill Home Network','Two Guys and a Rack','Big Dreams Small Prefix','Mesh-y Business','Garden Shed Datacenter','Carrier-Grade NAT Fan Club','LIR in a Box','Yet Another VPN','Grandma’s Fibre Co-op','Seedbox Society','The /24 That Could'];
|
||||
const REQ_SAY=[N_('peering_inbox.hi_we_would_like_to_peer'),N_('peering_inbox.dear_sir_or_madam_please_peer'),N_('peering_inbox.we_noticed_you_are_at_ix'),N_('peering_inbox.hello_please_find_attached_our'),N_('peering_inbox.peering_request_fifth_attempt_is'),N_('peering_inbox.hey_quick_one_can_you_peer'),N_('peering_inbox.greetings_we_are_a_fast_growing'),N_('peering_inbox.please_configure_sessions_with_us_at')];
|
||||
const IBX_AI=[N_('peering_inbox.replied_to_a_peering_request_with'),N_('peering_inbox.signed_you_up_for_a_webinar'),N_('peering_inbox.opened_a_ticket_with_itself_to'),N_('peering_inbox.wrote_a_thousand_word_apology_to'),N_('peering_inbox.updated_your_peeringdb_record_your'),N_('peering_inbox.asked_netchill_s_peering_team_to')];
|
||||
function ibx(){if(!S.inbox||typeof S.inbox!=='object')S.inbox={items:[],down:{},tiny:{},rep:0,bot:false,log:[],seq:0};return S.inbox;}
|
||||
// Reputation nudges selective networks by up to 10% either way: worth caring about, never a wall.
|
||||
// Your peering policy. Open: everyone who asks gets a session and the route servers work. Selective: fewer requests,
|
||||
// you answer them yourself, and no route servers, so you go and ask networks at each exchange. Closed: nobody asks,
|
||||
// and customers hear that you are hard to reach.
|
||||
const PPOL=['open','selective','closed'],ppol=()=>(S&&S.inbox&&PPOL.includes(S.inbox.pol))?S.inbox.pol:'open';
|
||||
const repMul=()=>1-clamp((S.inbox&&S.inbox.rep)||0,-10,5)*0.01;
|
||||
const repName=r=>r>=1?tr('common.responsive'):r>=-2?tr('common.average'):r>=-6?tr('peering_inbox.mostly_ignores_email'):tr('common.black_hole');
|
||||
const ibxOpen=()=>S.inbox?S.inbox.items.length:0,ibxUrgent=()=>S.inbox?S.inbox.items.filter(x=>x.k==='mp').length:0;
|
||||
const mpDown=(id,c)=>{const t=S.inbox&&S.inbox.down[id+'@'+c];return !!t&&t>S.day;};
|
||||
const ibxWho=x=>x.net?NET[x.net].name:x.nm,ibxAsn=x=>x.net?NET[x.net].asn:x.asn;
|
||||
function ibxLog(m,a){const I=ibx();I.log.unshift({d:S.day,m,a:a||{}});I.log.length=Math.min(I.log.length,40);}
|
||||
function inboxDay(d){const I=ibx(),ixs=Object.keys(S.ixp);
|
||||
// new peering requests: more exchange ports, more mail
|
||||
if(ixs.length&&Math.random()<Math.min(0.9,0.15*ixs.length)*({open:1,selective:0.7,closed:0}[ppol()])){const c=pick(ixs),set=ixSessions(c);
|
||||
const real=ixMembers(c).filter(id=>{const n=NET[id];return !set.has(id)&&!merged(id)&&n.type!=='t1'&&n.type!=='cdn'&&n.pol!=='paid'&&n.share<=0.006&&!I.items.some(x=>x.net===id&&x.ix===c);});
|
||||
const it={id:++I.seq,k:'req',ix:c,day:d,stale:Math.random()<0.6,yrs:1+Math.floor(Math.random()*9),say:Math.floor(Math.random()*REQ_SAY.length)};
|
||||
if(real.length&&Math.random()<0.4)it.net=pick(real);else{it.nm=pick(TINY);it.asn=Math.random()<0.05?64512+Math.floor(Math.random()*1000):200000+Math.floor(Math.random()*200000);}
|
||||
I.items.push(it);if(ppol()==='open')ibxAnswer(it.id,'accept',true);}
|
||||
if(ppol()==='closed')I.rep=Math.max(-6,I.rep-0.05);
|
||||
// max-prefix: someone grew past what their PeeringDB says, or leaked a full table
|
||||
const ses=Object.keys(S.peers).filter(k=>{const n=NET[k.split('@')[0]];return n&&n.type!=='cdn'&&n.type!=='t1'&&!mpDown(...k.split('@'));}).map(k=>({key:k,net:k.split('@')[0],ix:k.split('@')[1]}))
|
||||
.concat(Object.keys(I.tiny).map(a=>({key:'t'+a,nm:I.tiny[a].nm,asn:+a,ix:I.tiny[a].ix,stale:I.tiny[a].stale})));
|
||||
if(ses.length&&Math.random()<Math.min(0.15,0.004*ses.length)){const x=pick(ses);if(!I.items.some(y=>y.k==='mp'&&y.key===x.key)){
|
||||
const lim=pick([10,20,50,100,200,500,1000]),leak=Math.random()<0.3,yrs=1+Math.floor(Math.random()*9);
|
||||
I.items.push({id:++I.seq,k:'mp',key:x.key,net:x.net,nm:x.nm,asn:x.asn,ix:x.ix,day:d,lim,got:leak?940000+Math.floor(Math.random()*90000):Math.ceil(lim*(1.15+Math.random()*1.6)),leak,yrs});
|
||||
// A session that blows its limit is down for at most a few weeks: the other side eventually notices too.
|
||||
if(x.net){I.down[x.key]=d+20+Math.floor(Math.random()*20);toast(tr('peering_inbox.max_prefix_limit_hit_who_at',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))}),'bad',[{l:tr('common.inbox'),act:'inbox',args:{}}]);}}}
|
||||
// unanswered mail: requests go stale and people start asking around about you
|
||||
for(const x of I.items){if(x.k==='mp')I.rep-=0.05;else if(d-x.day===14)x.bump=1;}
|
||||
// A max-prefix alert nobody answers resolves itself in the end: the other side raises it, or gives up.
|
||||
I.items=I.items.filter(x=>x.k!=='mp'||(x.net?(I.down[x.key]||0)>d:d-x.day<=30));
|
||||
const old=I.items.filter(x=>x.k==='req'&&d-x.day>30);if(old.length){I.rep-=0.25*old.length;I.items=I.items.filter(x=>!old.includes(x));
|
||||
if(old.some(x=>x.net))toast(tr('peering_inbox.who_asked_a_mailing_list_whether',{who:esc(ibxWho(old.find(x=>x.net))),me:esc(S.name)}),'bad',[{l:tr('common.inbox'),act:'inbox',args:{}}]);}
|
||||
while(I.items.length>INBOX_MAX){const i=I.items.findIndex(x=>x.k==='req');if(i<0)break;I.items.splice(i,1);I.rep-=0.5;}
|
||||
I.rep=clamp(I.rep,-10,5);
|
||||
if(I.bot)inboxBot();}
|
||||
// Answer one item. a: accept | decline | raise | keep. Returns false when the item is gone.
|
||||
function ibxAnswer(id,a,bot){const I=ibx(),i=I.items.findIndex(x=>x.id===id);if(i<0)return false;const x=I.items[i];I.items.splice(i,1);const who=ibxWho(x),ix=ixName(x.ix);
|
||||
if(x.k==='req'){if(a==='accept'){if(x.net){if(S.ixp[x.ix]!==undefined)S.peers[x.net+'@'+x.ix]=true;}else if(Object.keys(I.tiny).length<200)I.tiny[x.asn]={nm:x.nm,ix:x.ix,stale:!!x.stale};I.rep+=0.3;}else I.rep+=0.2;}
|
||||
else if(a==='raise'){delete I.down[x.key];if(x.leak){const n=pick(IBX_LEAKS);S.ev.leak={net:n,until:S.day+4};
|
||||
addInc({type:'leak',ref:n,until:S.day+4,msg:tr('peering_inbox.who_at_ix_was_sending_a',{who,ix,net:NET[n].name}),cost:0});
|
||||
if(!bot)toast(tr('peering_inbox.that_was_a_route_leak_who',{who:esc(who),n:x.got.toLocaleString()}),'bad');I.rep-=1;}
|
||||
else{I.rep+=0.3;if(!bot)toast(tr('peering_inbox.session_with_who_is_back_up',{who:esc(who),n:Math.ceil(x.got*1.5).toLocaleString()}),'good');}}
|
||||
else{const back=S.day+(x.leak?3:10)+Math.floor(Math.random()*(x.leak?8:21));if(x.net)I.down[x.key]=back;I.rep+=x.leak?0.3:0.1;
|
||||
if(!bot)toast(x.leak?tr('peering_inbox.good_call_it_was_a_route',{who:esc(who)}):tr('peering_inbox.the_session_stays_down_who_will',{who:esc(who)}),x.leak?'good':'');}
|
||||
I.rep=clamp(I.rep,-10,5);return true;}
|
||||
// The AI agent clears the inbox every day. It is fast, polite and wrong about a third of the time.
|
||||
function inboxBot(){const I=ibx();let acc=0,dec=0;
|
||||
for(const x of I.items.slice()){const oops=Math.random()<0.3;
|
||||
if(x.k==='req'){const want=!x.stale||!!x.net;const a=(want!==oops)?'accept':'decline';ibxAnswer(x.id,a,true);a==='accept'?acc++:dec++;if(oops&&a==='decline'&&x.net)ibxLog(N_('peering_inbox.declined_who_at_ix_not_a'),{who:ibxWho(x),ix:ixName(x.ix)});}
|
||||
else{const a=(x.leak!==oops)?'keep':'raise';ibxAnswer(x.id,a,true);
|
||||
if(a==='raise'&&x.leak)ibxLog(N_('peering_inbox.raised_the_max_prefix_limit_for'),{who:ibxWho(x),ix:ixName(x.ix),n:Math.ceil(x.got*1.5).toLocaleString()});
|
||||
else if(a==='keep'&&!x.leak)ibxLog(N_('peering_inbox.kept_who_down_at_ix_for'),{who:ibxWho(x),ix:ixName(x.ix)});
|
||||
else ibxLog(a==='raise'?N_('peering_inbox.raised_the_max_prefix_limit_for_7b4b'):N_('peering_inbox.kept_who_down_at_ix_it'),{who:ibxWho(x),ix:ixName(x.ix)});}}
|
||||
if(acc||dec)ibxLog(N_('peering_inbox.answered_your_mail_a_accepted_d'),{a:acc,d:dec});
|
||||
if(Math.random()<0.01){const ks=Object.keys(S.peers);if(ks.length){const k=pick(ks),[id,c]=k.split('@');delete S.peers[k];ibxLog(N_('peering_inbox.tidied_up_a_session_it_decided'),{who:NET[id].name,ix:ixName(c)});}}
|
||||
if(Math.random()<0.08)ibxLog(pick(IBX_AI),{});}
|
||||
function inboxModal(){const I=ibx(),items=I.items.slice().sort((a,b)=>(b.k==='mp')-(a.k==='mp')||b.day-a.day),reqs=items.filter(x=>x.k==='req').length,mps=items.length-reqs;
|
||||
const age=x=>{const n=S.day-x.day;return n?trn('peering_inbox.n_day_ago',n):tr('common.today_4203');};
|
||||
const pdb=x=>x.stale?trn('peering_inbox.peeringdb_last_updated_n_year_ago',x.yrs):tr('peering_inbox.peeringdb_updated_last_month');
|
||||
const card=x=>x.k==='mp'?`<div class="ibx mp"><div class="nm">⚠️ ${tr('peering_inbox.max_prefix_limit_hit_who_at_5c56',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))})}</div>
|
||||
<div class="meta">AS${ibxAsn(x)} · ${age(x)}</div><p class="note">${tr('peering_inbox.configured_lim_prefixes_received_got',{lim:x.lim.toLocaleString(),got:x.got.toLocaleString()})} ${trn('peering_inbox.their_peeringdb_says_lim_last',x.yrs,{lim:x.lim.toLocaleString()})}</p>
|
||||
<div class="btns">${btn(tr('peering_inbox.raise_the_limit'),'inboxAct',{id:x.id,a:'raise'},'sm')}${btn(tr('peering_inbox.keep_it_down'),'inboxAct',{id:x.id,a:'keep'},'ghost sm')}</div></div>`
|
||||
:`<div class="ibx"><div class="nm">${esc(ibxWho(x))} <span class="meta">AS${ibxAsn(x)}</span>${x.bump?` <span class="tag">${tr('common.bumped')}</span>`:''}</div><div class="meta">${esc(ixName(x.ix))} · ${age(x)} · ${pdb(x)}</div>
|
||||
<p class="note">“${esc(tr(REQ_SAY[x.say]||REQ_SAY[0],{ix:ixName(x.ix)}))}”</p><div class="btns">${btn(tr('common.accept'),'inboxAct',{id:x.id,a:'accept'},'sm')}${btn(tr('common.decline'),'inboxAct',{id:x.id,a:'decline'},'ghost sm')}</div></div>`;
|
||||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('common.peering_inbox')}</div><h2 style="font-size:26px">📬 ${trn('peering_inbox.n_unanswered',items.length)}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>
|
||||
<p class="tagline">${tr('peering_inbox.every_exchange_port_brings_mail')}</p>
|
||||
<div class="kv"><span>${tr('common.your_reputation')}</span><b>${repName(I.rep)}</b></div>
|
||||
<div class="kv"><span>${tr('common.peering_policy')}</span><b>${tr(PPOL_N[ppol()])}</b></div><div class="seg">${PPOL.map(p=>btn(tr(PPOL_N[p]),'inboxPol',{p},ppol()===p?'sm':'ghost sm')).join('')}</div><p class="meta">${tr(PPOL_D[ppol()])}</p>
|
||||
<div class="ibx ai">${I.bot?`<div class="nm">🤖 ${tr('peering_inbox.large_peering_model_is_answering')}</div><div class="meta">${tr('peering_inbox.price_year_it_never_sleeps_never',{price:fmt$(20e6)})}</div>
|
||||
${I.log.length?`<pre class="term">${I.log.slice(0,8).map(e=>esc(tr('peering_inbox.day_d',{d:e.d})+': '+tr(e.m,e.a))).join('\n')}</pre>`:''}<div class="btns">${btn(tr('peering_inbox.fire_the_ai'),'inboxBot',{on:0},'ghost sm')}</div>`
|
||||
:`<div class="nm">🤖 ${tr('peering_inbox.large_peering_model')}</div><div class="meta">${tr('peering_inbox.an_ai_agent_that_answers_every',{price:fmt$(20e6)})}</div><div class="btns">${btn(tr('peering_inbox.hire_it_mo_mo',{mo:fmt$(AI_MO)}),'inboxBot',{on:1},'aibtn sm',S.cash<AI_MO)}</div>`}</div>
|
||||
${reqs>1||mps>1?`<div class="btns">${reqs>1?btn(tr('peering_inbox.accept_all_requests'),'inboxAll',{a:'accept'},'sm')+btn(tr('peering_inbox.decline_all_requests'),'inboxAll',{a:'decline'},'ghost sm'):''}${mps>1?btn(tr('peering_inbox.raise_all_max_prefix_limits'),'inboxRaiseAll',{},'sm'):''}</div>`:''}
|
||||
${items.length?items.slice(0,40).map(card).join(''):`<p class="empty">${Object.keys(S.ixp).length?tr('peering_inbox.inbox_zero_enjoy_it_while_it'):tr('peering_inbox.no_mail_yet_buy_an_ix')}</p>`}`);}
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
/* Big networks sometimes refuse to peer in a particular city, for a while. Each (network, city)
|
||||
pair gets a stable verdict per window, derived from a hash, so asking again does not reroll it. */
|
||||
pair gets a stable verdict per window, derived from a hash, so asking again does not reroll it.
|
||||
It is part of the market: without one (Change Freeze, puzzles), nobody refuses or drops a session. */
|
||||
const SNUB_WIN=150,SNUB_P=0.22;
|
||||
const SNUB_IX=[tr('peering_policy.only_peers_over_pnis_in_this'),tr('peering_policy.their_ix_port_here_is_full'),tr('peering_policy.moved_everything_in_this_city_to'),tr('peering_policy.the_peering_coordinator_for_this'),tr('peering_policy.their_policy_here_says_ix_peering')];
|
||||
const SNUB_ALL=[tr('peering_policy.not_accepting_new_peers_in_this'),tr('peering_policy.region_frozen_while_they_renegotiate'),tr('peering_policy.their_routers_in_this_city_are'),tr('peering_policy.already_reach_you_through_your'),tr('peering_policy.their_lawyers_are_reviewing_every'),tr('peering_policy.a_new_vp_wants_to_monetise')];
|
||||
function hstr(t){let h=2166136261;for(let i=0;i<t.length;i++){h^=t.charCodeAt(i);h=Math.imul(h,16777619);}return h>>>0;}
|
||||
function bigPeer(n){return !!n&&n.pol==='selective'&&n.share>=0.03;}
|
||||
function snub(id,c){
|
||||
const n=NET[id];if(!c||!bigPeer(n)||!S||S.myIx[c])return null;
|
||||
const n=NET[id];if(!c||!bigPeer(n)||!S||S.myIx[c]||!rule('market'))return null;
|
||||
const off=hstr(id+c)%SNUB_WIN,ep=Math.floor((S.day+off)/SNUB_WIN),h=hstr(S.asn+'|'+id+'|'+c+'|'+ep);
|
||||
if(h%1000>=SNUB_P*1000)return null;
|
||||
const all=(h>>>10)%5<2,list=all?SNUB_ALL:SNUB_IX;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
const SOLD_WIN=90,SOLD_WHY=[N_('sold_out.a_hyperscaler_bought_every_wave_of'),N_('sold_out.the_carrier_is_out_of_spectrum'),N_('sold_out.the_transponders_for_this_route_are'),N_('sold_out.the_capacity_is_available_in_the'),N_('sold_out.their_capacity_planner_is_on_holiday'),N_('sold_out.the_upgrade_is_planned_for_q3')];
|
||||
const soldP=tier=>Math.min(0.1,0.02+0.012*tier);
|
||||
// Never in the first 90 days: a new network has enough on its plate. Never in the tutorial or a scenario's first quarter either.
|
||||
function soldOut(a,b,tier,via){if(!S||S.day<SOLD_WIN||S.tut)return null;const k=(a<b?a+b:b+a)+'|'+(via||'')+'|'+tier,off=hstr(k)%SOLD_WIN,ep=Math.floor((S.day+off)/SOLD_WIN),h=hstr(S.asn+'|'+k+'|'+ep);
|
||||
function soldOut(a,b,tier,via){if(!S||S.day<SOLD_WIN||S.tut||!rule('market'))return null;const k=(a<b?a+b:b+a)+'|'+(via||'')+'|'+tier,off=hstr(k)%SOLD_WIN,ep=Math.floor((S.day+off)/SOLD_WIN),h=hstr(S.asn+'|'+k+'|'+ep);
|
||||
if(h%1000>=soldP(tier)*1000)return null;return {why:SOLD_WHY[(h>>>10)%SOLD_WHY.length],until:(ep+1)*SOLD_WIN-off};}
|
||||
function snubWhy(sn){const d=Math.max(1,sn.until-S.day);return sn.why+' '+trn('sold_out.they_will_reconsider_in_n_day',d);}
|
||||
// Paid-peering giants drop the fee for networks too big to ignore (freeLv: the customer level that does it).
|
||||
|
|
@ -15,7 +15,8 @@ function peerOk(id,via,city){
|
|||
if(msfNope(id,city))return {ok:false,why:tr(MSF_NOPE[hstr(ixCity(city)+S.day)%MSF_NOPE.length])};
|
||||
if(via==='ix'&&city&&isRemote(city)&&noRemote(id))return {ok:false,remote:true,why:REMOTE_WHY[hstr(id)%REMOTE_WHY.length]};
|
||||
if(n.pol==='open')return {ok:true};
|
||||
if(n.pol==='selective'){const need=Math.round((via==='pni'?n.minPni:n.minIx)*confBoost(id)*repMul());return dem>=need?{ok:true}:{ok:false,why:tr('sold_out.wants_need_gbps_of_traffic_from',{need,dem:dem.toFixed(1)})};}
|
||||
// In the Cogentle Spat, Goggle's peering desk wants eight times the usual traffic first, so cheap Cogentle-only transit really costs you Goggle (playtest).
|
||||
if(n.pol==='selective'){const need=Math.round((via==='pni'?n.minPni:n.minIx)*confBoost(id)*(id==='ggl'&&scnRule('spat')?8:1));return dem>=need?{ok:true}:{ok:false,why:tr('sold_out.wants_need_gbps_of_traffic_from',{need,dem:dem.toFixed(1)})};}
|
||||
if(n.pol==='paid'&&paidFree(n))return via==='pni'?{ok:true,free:true}:{ok:false,why:tr('sold_out.peers_with_you_for_free_now')};
|
||||
if(n.pol==='paid')return via==='pni'?{ok:true,fee:n.paidFee}:{ok:false,why:n.perG?tr('sold_out.sender_pays_a_paid_pni_only',{fee:fmt$(n.paidFee),g:fmt$(n.perG)}):tr('sold_out.paid_peering_only_over_a_pni')};
|
||||
if(n.type!=='t1'){if(via!=='pni')return {ok:false,why:tr('sold_out.only_peers_over_pnis_and_only')};const need=Math.round(60*confBoost(id));return dem>=need||isTier2()?{ok:true}:{ok:false,why:tr('sold_out.wants_you_to_be_a_tier',{need,dem:dem.toFixed(1)})};}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ function isTier2(){return Object.keys(S.pops).length>=5&&Object.keys(S.ixp).leng
|
|||
// Sparkly Seabone joined the Tier 1s in 1.12. Older saves keep the five they were playing for.
|
||||
// Tier 1s added later only count for games started after them, so old saves keep their win (#155).
|
||||
const t1Need=()=>NETS.filter(n=>n.type==='t1'&&(n.id!=='skl'||(S&&S.t1v>=2))&&(n.id!=='att'||(S&&S.t1v>=3)));
|
||||
/* Reach is counted through customer cones (#85): a PNI with a Tier 1 reaches everyone who buys transit from it, and
|
||||
their customers. That only ever adds reach, so the rule is easier for every save, old ones included, and needs no
|
||||
version: what was Tier 1 stays Tier 1. Networks in nobody's cone still need peering of their own. */
|
||||
function isTier1(){return t1Need().every(n=>S.pni.some(p=>p.net===n.id&&pniOn(p)))&&S.transit.length===0&&R.reach>0.999;}
|
||||
// What you are now, not what you once were (#46): buying transit again or losing reach drops the label.
|
||||
function tierLabel(){return S.won&&isTier1()?'Tier 1':isTier2()?'Tier 2':'Tier 3';}
|
||||
function t1Why(){if(S.transit.length)return tr('hot_ports_and_rank.you_buy_transit_again');const miss=t1Need().filter(n=>!S.pni.some(p=>p.net===n.id&&pniOn(p)));if(miss.length)return tr('hot_ports_and_rank.no_pni_with_list',{list:miss.map(n=>n.name).join(', ')});{const lost=NETS.filter(n=>!R.reachable[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id]);if(lost.length)return tr('hot_ports_and_rank.you_cannot_reach_list',{list:lost.slice(0,3).map(n=>n.name).join(', ')+(lost.length>3?' '+tr('hot_ports_and_rank.and_n_more',{n:lost.length-3}):'')});}return tr('hot_ports_and_rank.your_reach_is_p_not_100',{p:reachPct(R.reach)});}
|
||||
function t1Why(){if(S.transit.length)return tr('hot_ports_and_rank.you_buy_transit_again');const miss=t1Need().filter(n=>!S.pni.some(p=>p.net===n.id&&pniOn(p)));if(miss.length)return tr('hot_ports_and_rank.no_pni_with_list',{list:miss.map(n=>n.name).join(', ')});{const lost=NETS.filter(n=>!R.reachable[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id]);if(lost.length)return tr('hot_ports_and_rank.you_cannot_reach_list_outside_cones',{list:lost.slice(0,3).map(n=>n.name).join(', ')+(lost.length>3?' '+tr('hot_ports_and_rank.and_n_more',{n:lost.length-3}):'')});}return tr('hot_ports_and_rank.your_reach_is_p_not_100',{p:reachPct(R.reach)});}
|
||||
|
||||
|
|
|
|||
56
src/game/70-rules/90-backbone-core.js
Normal file
56
src/game/70-rules/90-backbone-core.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* ---------- the backbone's technology: plain IGP, LDP, RSVP-TE, SR-MPLS or SRv6 ----------
|
||||
S.core.lv is the highest level paid for, S.core.run the one running (at most lv: one step down is safer). A POP
|
||||
whose router can't run it stays outside the core: it routes plain IP, TE never steers through it and label
|
||||
switching saves it nothing. Each level costs routers some CPU, from LDP's chatter down to SRv6's almost none. Label
|
||||
switching makes traffic that only passes through a POP cheaper for its router. TE (Auto-TE, RouteScript) needs
|
||||
RSVP-TE or above; RSVP tunnels detour less far than segment routing. Vendors interoperate less the higher you go:
|
||||
a core of mixed vendors running at some router's very top level has interop incidents.
|
||||
Saves from before this, with Auto-TE already bought, keep the old rules (legacy) until they change level. Puzzles,
|
||||
Architect runs and scenarios set TE up themselves and ignore all of this. */
|
||||
const CORE_LV=[N_('core.plain_igp'),N_('core.ldp_mpls'),N_('core.rsvp_te_mpls'),N_('core.sr_mpls'),N_('core.srv6')];
|
||||
const CORE_COST=[0,80000,200000,400000,750000],CORE_REQ=[1,2,3,5,7];
|
||||
const CORE_CPU=[0,.10,.08,.05,.03],CORE_PASS=[1,.6,.6,.6,.6],CORE_TE=[0,0,1.5,2,2],CORE_IOP=[0,.15,.3,.6,1];
|
||||
// Can model g run level L? Every model runs everything up to its top, except noMpls boxes (SRv6 natively, no labels).
|
||||
const rgCore=(g,L)=>{const G=RG[g];return !!G&&L<=G.cr&&!(G.noMpls&&L>=1&&L<=3);};
|
||||
// Do the core rules apply to this game at all?
|
||||
const coreOn=()=>!!(S&&S.core&&!S.core.legacy&&S.mode!=='puzzle'&&!S.pz&&!S.ar&&!S.scn);
|
||||
const coreRun=()=>coreOn()?S.core.run:0;
|
||||
const inCore=c=>{const p=S.pops[c];return !!p&&rgCore(p.rgen||0,coreRun());};
|
||||
// May Auto-TE and RouteScript run? Legacy saves, puzzles and scenarios: as before.
|
||||
const coreTE=()=>!coreOn()||S.core.run>=2;
|
||||
// How far TE may detour, against the shortest path (the old controller: 2×).
|
||||
const coreTeReach=()=>coreOn()?CORE_TE[S.core.run]:2;
|
||||
// Share of a router's capacity left after the core's own protocols take their CPU.
|
||||
const coreCpu=c=>coreOn()&&inCore(c)?1-CORE_CPU[S.core.run]:1;
|
||||
// What traffic passing through (not starting or ending here) costs this POP's router: less once labels switch it.
|
||||
const corePass=c=>coreOn()&&S.core.run>=1&&inCore(c)?CORE_PASS[S.core.run]:1;
|
||||
// Vendors in the core, and whether it runs at the very top of any of its routers: then vendors trip over each other.
|
||||
function coreVendors(){const v=new Set();for(const c in S.pops)if(inCore(c))v.add(RG[S.pops[c].rgen||0].v);return v;}
|
||||
function coreEdge(){if(!coreOn()||S.core.run<1)return false;for(const c in S.pops)if(inCore(c)&&RG[S.pops[c].rgen||0].cr===S.core.run)return true;return false;}
|
||||
// Daily odds of an interop incident: none for one vendor, or below every router's top level.
|
||||
function coreIopRisk(){if(!coreOn()||S.core.run<1||coreVendors().size<2||!coreEdge())return 0;return CORE_IOP[S.core.run]*(S.core.lab?CORE_LAB_F:1);}
|
||||
// POPs left out of the core (their router can't run it), for the panel.
|
||||
const coreOut=()=>coreOn()&&S.core.run>=1?Object.keys(S.pops).filter(c=>!inCore(c)):[];
|
||||
// Links where the vendors meet: both ends in the core, different vendors.
|
||||
const coreIopLinks=live=>live.filter(l=>S.pops[l.a]&&S.pops[l.b]&&inCore(l.a)&&inCore(l.b)&&RG[S.pops[l.a].rgen||0].v!==RG[S.pops[l.b].rgen||0].v);
|
||||
// Vendor names as players see them (Junipurr has no badge, so this is where its name shows).
|
||||
const RG_V={arrrhipster:'Arrrhipster',brocadabra:'Brocadabra',disco:'Disco',edge:'Edge Lord',extremely:'Extremely Networks',junipurr:'Junipurr',knockia:'Knockia',mikrowtik:'Mikrowtik',rusty:'Rusty',universe:'Universe',whitebox:'Whitebox'};
|
||||
// One line for a model: its vendor and the highest backbone it runs (SRv6-only boxes say so).
|
||||
const coreMeta=g=>{const G=RG[g];return tr('core.vendor_v_backbone_up_to_lv',{v:RG_V[G.v],lv:tr(CORE_LV[G.cr])})+(G.noMpls?' · '+tr('core.no_mpls_srv6_only'):'');};
|
||||
/* ---------- what an upgraded backbone brings (only good things) ----------
|
||||
Customers who need it: offers of these appear once the backbone runs their level; a contract already signed keeps
|
||||
paying whatever the backbone runs later. Real carriers sell L3VPNs over MPLS, low-latency planes with flex-algo
|
||||
over segment routing, and slices over SRv6. */
|
||||
Object.assign(BIZ_T,{
|
||||
l3vpn:{l:tr('core.l3vpn_for_an_enterprise'),opts:[1,2,5,10],rate:0,l2:true,sdwan:true,siteRate:1100,km:0,lv:3,core:1,names:['Branch Office Bonanza','Head Office & Sons','Twelve Tills Retail','Regional Bank of Routes','Chain of Command Pharmacies','Franchise Fiesta']},
|
||||
flex:{l:tr('core.flex_algo_low_latency_link'),opts:[5,10,40],rate:0,l2:true,lat:true,km:9,lv:3,core:3,names:['Microsecond Mike Markets','Low-Ping Esports League','Latency Arbitrage Partners','Photon Finish Trading','Lag-Free Ladder Games']},
|
||||
slice:{l:tr('core.network_slice'),opts:[100,200,400],rate:0,l2:true,div:true,km:1.2,lv:3,core:4,names:['Fifth Gen Slices Ltd','Pizza-Slice Mobile','Sliced Bread Telecom','GPU Slice & Dice','Thin Crust Wireless']},
|
||||
});
|
||||
// The backbone's customer types now on offer (twice each, like the other types' weights).
|
||||
function coreProducts(mine){if(!coreOn())return [];const run=S.core.run,out=[];
|
||||
if(run>=1&&mine.length>=3)out.push('l3vpn','l3vpn');if(run>=3&&mine.length>=2)out.push('flex','flex');if(run>=4&&mine.length>=2)out.push('slice','slice');return out;}
|
||||
// Fast reroute (RSVP-TE FRR, TI-LFA): backup paths are ready before a cut, so customers barely notice one.
|
||||
const coreFrr=()=>coreOn()&&S.core.run>=2;
|
||||
// An interop lab: test the vendors against each other before they meet in production.
|
||||
const CORE_LAB=150000,CORE_LAB_F=0.4;
|
||||
const coreLab=()=>!!(S.core&&S.core.lab);
|
||||
29
src/game/70-rules/95-utilities.js
Normal file
29
src/game/70-rules/95-utilities.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* Utilities: plan from live state, then apply a whole batch with one recompute. */
|
||||
function utilityRouteServers(){return S?Object.keys(S.ixp).filter(ix=>isIx(ix)&&!S.myIx[ix]&&!S.rs[ix]):[];}
|
||||
function utilityCacheMoves(city){if(!S||!S.pops[city])return [];const groups=new Map(),moves=[];
|
||||
for(const c of S.caches)if(c.city===city){let g=groups.get(c.net);if(!g){g={a:[],b:[]};groups.set(c.net,g);}g[c.site==='b'?'b':'a'].push(c);}
|
||||
const move=(g,from,n)=>{const to=from==='a'?'b':'a';for(const c of g[from].splice(0,n)){g[to].push(c);moves.push({id:c.id,site:to});}};
|
||||
for(const g of groups.values()){const from=g.a.length>g.b.length?'a':'b',to=from==='a'?'b':'a';
|
||||
move(g,from,Math.floor((g[from].length-g[to].length)/2));}
|
||||
// Spread odd-provider extras too, so the overall site counts also differ by at most one.
|
||||
let diff=0;for(const g of groups.values())diff+=g.a.length-g.b.length;
|
||||
const from=diff>0?'a':'b',to=from==='a'?'b':'a';let left=Math.floor(Math.abs(diff)/2);
|
||||
for(const g of groups.values())if(left&&g[from].length>g[to].length){move(g,from,1);left--;}
|
||||
return moves;}
|
||||
function utilityCaches(city){const p=S&&S.pops[city];if(!p)return null;const sites=p.site2?['a','b']:['a'],add=[],have=new Set();
|
||||
for(const c of S.caches)if(c.city===city)have.add(c.net+'@'+(c.site==='b'?'b':'a'));
|
||||
for(const n of NETS)if(n.cache&&(R.demTo[n.id]||0)>=n.cache.min)for(const site of sites)if(!have.has(n.id+'@'+site))add.push({net:n.id,site});
|
||||
return {add,key:add.map(c=>c.net+'@'+c.site).join(','),mo:add.length*CACHE_MO,free:Math.max(0,portsMax(city)-portsUsed(city))};}
|
||||
function utilityKit(city){const p=S&&S.pops[city];if(!p)return null;
|
||||
const gen=!p.gen,site=!p.site2,router=(p.routers||1)<2,g=p.rgen||0;
|
||||
return {gen,site,router,moves:utilityCacheMoves(city),cost:(gen?GEN_COST:0)+(site?SITE2_COST:0)+(router?routerCost(g,1):0),
|
||||
mo:(gen?GEN_MO:0)+(site?SITE2_MO:0)+(router?routerMo(g):0)};}
|
||||
function utilityPeers(){if(!S)return [];return Object.keys(S.ixp).filter(isIx).map(ix=>{
|
||||
const sessions=ixSessions(ix),requests=[],blocked=[];let existing=0;
|
||||
for(const id of ixMembers(ix)){
|
||||
// Existing but temporarily down sessions must not be repeatedly requested.
|
||||
if(sessions.has(id)||S.peers[id+'@'+ix]){existing++;continue;}
|
||||
const chk=peerOk(id,'ix',ix);if(chk.ok)requests.push(id);else blocked.push({id,why:chk.why});
|
||||
}
|
||||
return {ix,requests,blocked,existing};
|
||||
});}
|
||||
|
|
@ -57,7 +57,7 @@ function teOptimize(){const L=[tr('routescript.suggested_by_the_optimizer_from_l
|
|||
return L.join('\n');}
|
||||
// Ready-made RouteScripts, filled in from the live network. Players load them from the help; the AI button picks them too.
|
||||
const teUps=()=>[...new Set(S.transit.map(t=>t.net))].map(n=>({n,p:Math.min(...S.transit.filter(t=>t.net===n).map(t=>NET[n].price*netMult(NET[n],t.city)))})).sort((a,b)=>a.p-b.p);
|
||||
const teNm=n=>NET[n].name.toLowerCase(),teAtk=()=>!!(S.ev.ddos&&S.ev.ddos.until>S.day);
|
||||
const teNm=n=>NET[n].name.toLowerCase(),teAtk=()=>ddosAll().length>0;
|
||||
const teSad=()=>S.biz.some(b=>!BIZ_T[b.type].l2&&!BIZ_T[b.type].fiber&&!BIZ_T[b.type].event&&sfOf(R,b.city)<0.95);
|
||||
const TE_RECIPES=[
|
||||
{id:'shield',n:N_('common.shields_up'),d:N_('routescript.for_a_ddos_drop_the_junk'),fit:()=>teAtk()?9:0.3,
|
||||
|
|
@ -116,7 +116,7 @@ function teHelpModal(){const rule=(code,what)=>`<dt><code>${code}</code></dt><dd
|
|||
${TE_RECIPES.map(r=>`<div class="terec"><div><b>${tr(r.n)}</b><div class="meta">${tr(r.d)}</div></div>${btn(tr('common.load'),'teRecipe',{id:r.id},'sm')}</div>`).join('')}</div>
|
||||
<div class="btns" style="margin-top:12px">${btn(tr('routescript.back_to_the_editor'),'teBack',{},'big')}</div>`);}
|
||||
let TE_CACHE={src:null,p:null};
|
||||
function teRules(){if(!S||!S.te||!S.te.on||!S.te.script)return null;if(TE_CACHE.src!==S.te.script)TE_CACHE={src:S.te.script,p:teParse(S.te.script)};return TE_CACHE.p.errors.length?null:TE_CACHE.p;}
|
||||
function teRules(){if(!S||!S.te||!S.te.on||!S.te.script||!coreTE())return null;if(TE_CACHE.src!==S.te.script)TE_CACHE={src:S.te.script,p:teParse(S.te.script)};return TE_CACHE.p.errors.length?null:TE_CACHE.p;}
|
||||
function teModal(msg){const src=UI.teDraft!==undefined?UI.teDraft:(S.te.script||TE_EXAMPLE);
|
||||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('routescript.auto_te_controller')}</div><h2 style="font-size:26px">RouteScript</h2></div><button class="x" data-act="teClose" aria-label="${tr('common.close')}">×</button></div>
|
||||
<p class="tagline">${tr('routescript.write_rules_check_them_against_live')}</p>
|
||||
|
|
|
|||
|
|
@ -1,50 +1,64 @@
|
|||
// tr() with one placeholder, remembered: compute() labels every port, PNI and cache on every run.
|
||||
const LABS=new Map();function labOf(s,k,v){const key=s+'|'+v;let o=LABS.get(key);if(o===undefined)LABS.set(key,o=tr(s,{[k]:v}));return o;}
|
||||
// Who carries a network reached only through a cone (kept out of compute(), whose size the JIT is sensitive to).
|
||||
function coneBy(L,id){let by=null;for(const e of L){if(e.k==='p')return e.net;if(!by&&e.k==='ix'&&e.dir)by=ANC[id].find(u=>e.dir.has(u))||null;}return by||1;}
|
||||
function compute(){
|
||||
const day=S.day, R2=emptyR(), pops=Object.keys(S.pops).filter(popUp), NC=CITIES.length;
|
||||
// The graph works on city indices: adj[i] lists [neighbour, edge] in S.links order.
|
||||
const remote=remoteCities(),adj=new Array(NC); pops.concat(remote).forEach(p=>adj[CIDX[p]]=[]);
|
||||
const edges={},TRX=teRules(),live=[];let NE=0;R2.bizDem={};R2.bizSrv={};
|
||||
for(const l of S.links){const ai=CIDX[l.a],bi=CIDX[l.b];if(linkDown(l)||!adj[ai]||!adj[bi])continue;live.push(l);const key=l.a<l.b?l.a+'|'+l.b:l.b+'|'+l.a;let e=edges[key];
|
||||
// The metric belongs to the city pair; links on standby add capacity that fills only after the others (#122).
|
||||
if(!e){const f=MET[pairMet(key)].f;e=edges[key]={id:key,a:l.a,b:l.b,ai,bi,i:NE++,km:l.km,cap:0,scap:0,w:Infinity,lat:Infinity,slat:Infinity,links:[],res:0,ld:0,tr:null,pl:0,f:f*(TRX&&TRX.avoid.has(key)?60:1)};adj[ai].push([bi,e]);adj[bi].push([ai,e]);}
|
||||
const c=capOf(l),lt=linkLat(l);e.cap+=c;e.links.push(l);e.w=Math.min(e.w,(l.km+60)*e.f);if(l.standby){e.scap+=c;e.slat=Math.min(e.slat,lt);}else e.lat=Math.min(e.lat,lt);}
|
||||
// The metric belongs to the city pair (a preset or a custom one); links on standby add capacity that fills only after the others (#122).
|
||||
if(!e){e=edges[key]={id:key,a:l.a,b:l.b,ai,bi,i:NE++,km:l.km,cap:0,scap:0,w:Infinity,lat:Infinity,slat:Infinity,links:[],res:0,ld:0,tr:null,pl:0,f:TRX&&TRX.avoid.has(key)?60:1};adj[ai].push([bi,e]);adj[bi].push([ai,e]);}
|
||||
const c=capOf(l),lt=linkLat(l);e.cap+=c;e.links.push(l);e.w=Math.min(e.w,pairW(key,l.km)*e.f);if(l.standby){e.scap+=c;e.slat=Math.min(e.slat,lt);}else e.lat=Math.min(e.lat,lt);}
|
||||
for(const k in edges){const e=edges[k];if(e.lat===Infinity)e.lat=e.slat;}
|
||||
// Shortest paths from every POP: SPD[pop] the distance to each city index (Infinity: no path), SPP[pop] the edge it arrives by.
|
||||
// ALONE[i]: no other city lies within 1e-6 of POP i (so only its own exits can be at distance 0 from it).
|
||||
const SPD={},SPP={},SDi=[],SPi=[],ALONE=new Uint8Array(NC),wW=e=>e.w,wLat=e=>e.lat+0.05;
|
||||
for(const s of pops){const i=CIDX[s],r=dijkstra(adj,i,wW);SDi[i]=SPD[s]=r.D;SPi[i]=SPP[s]=r.P;ALONE[i]=1;for(let x=0;x<NC;x++)if(x!==i&&r.D[x]<1e-6)ALONE[i]=0;}
|
||||
// COMP[i]: the island city i is on (-1: no POP reaches it). Links run both ways, so reaching is mutual.
|
||||
const COMP=new Int32Array(NC).fill(-1);let NCOMP=0;for(const s of pops){const i=CIDX[s];if(COMP[i]>=0)continue;const D=SDi[i],k=NCOMP++;for(let x=0;x<NC;x++)if(D[x]<Infinity)COMP[x]=k;}
|
||||
const E=[], ev=S.ev;
|
||||
const depeer=ev.depeer>day||scnRule('spat'), leak=ev.leak&&ev.leak.until>day?ev.leak.net:null;
|
||||
// Sender pays (Gangnam Style Peering): no carrier hands traffic to the Korean incumbents for you, only a paid PNI does.
|
||||
const snd=scnRule('sender');
|
||||
for(const t of S.transit){if(!popUp(t.city)||t.down>day||!liveN(t.city,t.site,t.n))continue;
|
||||
// AS-path prepending (#96) moves part of the port to a last-resort exit of its own.
|
||||
const cap=Math.min(liveCap(PORT[t.tier].g,t.city,t.site,t.n)*lagF(t),TRX&&TRX.cap[t.net]!==undefined?TRX.cap[t.net]:Infinity),pf=TRX&&TRX.prep[t.net]?PREPEND_F[TRX.prep[t.net]]:0;
|
||||
const ex={k:'t',net:t.net,prem:premOn(t),pref:t.pref||'normal',carry:!!t.carry,lab:labOf(N_('common.net_transit'),'net',NET[t.net].name),id:t.id,city:t.city,cap:cap*(1-pf),used:0,rank:3,ok:n=>!(depeer&&t.net==='cog'&&n==='ggl')&&n!==leak};
|
||||
const ex={k:'t',net:t.net,prem:premOn(t),pref:t.pref||'normal',lab:labOf(N_('common.net_transit'),'net',NET[t.net].name),id:t.id,city:t.city,cap:cap*(1-pf),used:0,rank:3,ok:n=>!(depeer&&t.net==='cog'&&n==='ggl')&&n!==leak&&!(snd&&NET[n].kr)};
|
||||
E.push(ex);if(pf)E.push({...ex,cap:cap*pf,prep:true});}
|
||||
// `nets`: every network ok() can say yes to, so it need not be asked about the other hundred.
|
||||
for(const c in S.ixp){const ct=ixCity(c);if(!(popUp(ct)||remote.includes(ct))||(S.ev.ixdown&&S.ev.ixdown[c]>day)||!(S.myIx[c]?myIxLive(c):liveN(ct,(S.ixSite||{})[c],(S.ixn||{})[c])))continue;const set=ixSessions(c);R2.sessions+=set.size;
|
||||
E.push({k:'ix',pref:(S.ixPref&&S.ixPref[c])||'normal',lab:labOf(N_('common.ix_peering'),'ix',ixName(c)),id:c,city:ct,cap:ixCap(c),used:0,rank:2,ok:n=>set.has(n),nets:set});}
|
||||
for(const p of S.pni){if(!pniOn(p)||!popUp(p.city)||!liveN(p.city,p.site,p.n))continue;R2.sessions++;E.push({k:'p',pnc:!!NET[p.net].cn,pref:p.pref||'normal',lab:labOf(N_('common.pni_with_net'),'net',NET[p.net].name),id:p.id,city:p.city,cap:liveCap(pniG(p),p.city,p.site,p.n)*lagF(p)*(p.sacrif?0.5:1),used:0,rank:1,ok:n=>n===p.net||!!(NET[n].up&&NET[n].up.includes(p.net)),nets:PNI_NETS[p.net]});}
|
||||
// A peer announces its customers too (#85): the session reaches its cone, after the networks peering directly.
|
||||
let all=set;for(const id of set)if(DOWN[id].length){if(all===set)all=new Set(set);for(const x of DOWN[id])all.add(x);}
|
||||
E.push({k:'ix',pref:(S.ixPref&&S.ixPref[c])||'normal',lab:labOf(N_('common.ix_peering'),'ix',ixName(c)),id:c,city:ct,cap:ixCap(c),used:0,rank:2,ok:n=>all.has(n),nets:all,dir:all===set?null:set});}
|
||||
for(const p of S.pni){if(!pniOn(p)||!popUp(p.city)||!liveN(p.city,p.site,p.n))continue;R2.sessions++;E.push({k:'p',pnc:!!NET[p.net].cn,pref:p.pref||'normal',lab:labOf(N_('common.pni_with_net'),'net',NET[p.net].name),id:p.id,city:p.city,cap:liveCap(pniG(p),p.city,p.site,p.n)*lagF(p)*(p.sacrif?0.5:1),used:0,rank:1,net:p.net,ok:n=>CONE_S[p.net].has(n),nets:CONE[p.net]});}
|
||||
for(const c of S.caches){if(!popUp(c.city)||siteDown(c.city,c.site==='b'?'b':'a'))continue;E.push({k:'c',pref:'normal',lab:labOf(N_('common.name_cache'),'name',NET[c.net].cache.name),id:c.id,city:c.city,cap:CACHE_CAP,used:0,rank:0,ok:n=>n===c.net,nets:[c.net]});}
|
||||
// After an update adds networks, a free courtesy route reaches the new ones you have no other way to (#46).
|
||||
R2.graceNets=0;if(S.grace&&S.grace.until>day){const gs=new Set(S.grace.nets.filter(n=>NET[n]&&!E.some(e=>e.k!=='c'&&e.ok(n)))),hc=popUp(S.home)?S.home:pops.find(popUp);
|
||||
R2.graceNets=gs.size;if(gs.size&&hc)E.push({k:'ix',pref:'normal',lab:tr('compute.courtesy_route_to_new_networks'),id:'~grace',city:hc,cap:1e9,used:0,rank:2,ok:n=>gs.has(n),nets:gs});}
|
||||
{const rp=ev.rpki&&ev.rpki.until>day?new Set(ev.rpki.nets):null;if(rp)for(const e of E){if(e.k==='c')continue;const o=e.ok;e.ok=n=>!rp.has(n)&&o(n);}}
|
||||
// coneOf: does exit e reach network n only through a peer's customer cone (#85)?
|
||||
const coneOf=(e,n)=>e.k==='p'?e.net!==n:!!e.dir&&!e.dir.has(n);
|
||||
// ok() cannot change during one compute, so ask each exit once per network, not once per flow and rank.
|
||||
// okBy[net] lists the exits that reach it in E's order, like E.filter(e=>e.ok(net)).
|
||||
const okBy={};for(const id of NET_IDS)okBy[id]=[];
|
||||
const ekN={};for(const e of E){e.ek=e.k+':'+e.id;ekN[e.ek]=(ekN[e.ek]||0)+1;}
|
||||
// dup: shares its key with another exit (a hand-edited save), so R.egDesc shows whichever pushed last.
|
||||
for(const e of E){e.desc={lab:e.lab,city:e.city,k:e.k};e.dup=ekN[e.ek]>1;e.told=false;e.hp=e.pref==='high'?0:1;e.ci=CIDX[e.city];e.cn=cnCity(e.city);e.vis=0;for(const n of e.nets||NET_IDS){const L=okBy[n];if(L&&L[L.length-1]!==e&&e.ok(n))L.push(e);}}
|
||||
for(const n of NETS){R2.reachable[n.id]=okBy[n.id].some(e=>e.rank>0);if(R2.reachable[n.id])R2.reach+=NSH[n.id];if(okBy[n.id].some(e=>e.rank>0&&e.k!=='t')){R2.nt[n.id]=1;R2.reachNT+=NSH[n.id];}}
|
||||
for(const n of NETS){R2.reachable[n.id]=okBy[n.id].some(e=>e.rank>0);if(R2.reachable[n.id])R2.reach+=NSH[n.id];if(okBy[n.id].some(e=>e.rank>0&&e.k!=='t')){R2.nt[n.id]=1;R2.reachNT+=NSH[n.id];
|
||||
// Reached without transit only through the customers of networks you peer with (#85). R.cone[id]: the peer that
|
||||
// carries it, the first PNI's network or else the nearest upstream that is a member of an exchange you are on.
|
||||
if(!okBy[n.id].some(e=>(e.k==='p'||e.k==='ix')&&!coneOf(e,n.id)))R2.cone[n.id]=coneBy(okBy[n.id],n.id);}}
|
||||
const cacheNets=new Set(S.caches.filter(c=>popUp(c.city)).map(c=>c.net));
|
||||
const viral=(ev.viral>day?1.25:1)*(ev.php&&ev.php>day?0.7:1);
|
||||
// Every flow has the same shape and carries what routing asks about it again and again (nj: its network's index).
|
||||
const NN=NETS.length,flows=[],flow=(c,ci,cn,j,rem,cache,junk,bz=false)=>{const n=NETS[j];flows.push({c,n:n.id,rem,cache,junk,bz,ci,cn,ncn:!!n.cn,nj:j,nr:junk?NN:j});};
|
||||
const NN=NETS.length,flows=[],flow=(c,ci,cn,j,rem,cache,junk,bz=false)=>{const n=NETS[j],f={c,n:n.id,rem,cache,junk,bz,ci,cn,ncn:!!n.cn,nj:j,nr:junk?NN:j,gt:0,gi:0,gp:0,gh:0,ti:null,ii:null};flows.push(f);return f;};
|
||||
// Customer demand per city, added up in S.biz order (what filtering S.biz for each city would give).
|
||||
const bizBw={};for(const b of S.biz){const T=BIZ_T[b.type];if(!T.l2&&!T.fiber&&(!T.event||eventLive(b))){const v=bizBw[b.city];bizBw[b.city]=(v===undefined?0:v)+b.bw;}}
|
||||
// Traffic shares by network index, and their sums, for each share table (and with Russia's throttle).
|
||||
const shArr=new Map(),shSum=new Map(),DEMTO=new Float64Array(NN),loc=scnRule('local'),HAUL=[];R2.haul=[];
|
||||
const shArr=new Map(),shSum=new Map(),DEMTO=new Float64Array(NN),loc=scnRule('local'),scrubRoom={},junkGroups=[],bhCities=new Set(ddosAll().filter(a=>a.bh).map(a=>a.city));R2.haul=[];R2.ddos=[];
|
||||
const VIC={};for(const a of ddosAll())(VIC[a.city]||(VIC[a.city]=[])).push(a);
|
||||
for(const c of Object.keys(S.pops)){
|
||||
const p=S.pops[c],ci=CIDX[c],cn=cnCity(c),SH=cn?NSH_CN:ruCity(c)?NSH_RU:CITY[c].kr&&S.krExit?NSH_KRX:NSH;const eye=(p.bb?p.bb.d:0)*viral*(cn&&ev.golden>day?1.4:1);const biz=bizBw[c]??0;const d0=eye+biz;
|
||||
// Goggle video is throttled in Russia (#70): people there get half of it, so they ask for half. It is not
|
||||
|
|
@ -53,26 +67,17 @@ function compute(){
|
|||
const tt=sm[+ru]||(sm[+ru]=[NETS.reduce((t,n,j)=>t+sa[j]*thr(n.id),0),NETS.reduce((t,n,j)=>t+sa[j],0)]),lf=loc?NETS.reduce((t,n,j)=>t+(R2.reachable[n.id]?sa[j]*thr(n.id):0),0)/(tt[0]||1):1,d=d0*tt[0]/(tt[1]||1)*lf;
|
||||
R2.cityEye[c]=eye;R2.cityDem[c]=d;R2.citySrv[c]=0;R2.demand+=d;
|
||||
for(let j=0;j<NN;j++)DEMTO[j]=(DEMTO[j]||0)+d0*sa[j]*thr(NETS[j].id);
|
||||
if(!popUp(c))continue;
|
||||
// A shaped attack: `rtbh` is the player pulling the plug on the victim IP (junk gone, customer dark too);
|
||||
// `edge` is the crude RouteScript `blackhole ddos` filter (junk gone, 10% of real traffic with it). Flowspec
|
||||
// (a standing licence) and a scrubbing center each knock the flood down before it reaches the sim.
|
||||
const atk=ev.ddos&&ev.ddos.city===c&&ev.ddos.until>day?ev.ddos:null;
|
||||
const rtbh=!!(atk&&atk.bh), edge=!!(atk&&TRX&&TRX.blackhole&&!rtbh);
|
||||
let dd=0;
|
||||
if(atk&&!rtbh){let mult=1;const en=atk.entry||{};
|
||||
if(DDOS_VEC[atk.vec]&&DDOS_VEC[atk.vec].fs){const cap=fsAt(atk.city);if(cap)mult=Math.min(mult,FS_RES[cap]);}
|
||||
if(en.k==='t'){const t=S.transit.find(x=>x.id===en.id);if(t&&t.clean)mult=Math.min(mult,0.1);}
|
||||
if(atk.ixbh&&hasIxAt(atk.city))mult=Math.min(mult,0.5);
|
||||
if(edge)mult=0;
|
||||
// Scrubbing is used when it beats the edge tools; floods for a center in another city are hauled after the circuits below.
|
||||
const sp=edge?null:scrubPlan(atk);
|
||||
if(sp&&scrubIdeal(sp)<atk.gbps*mult){dd=scrubIdeal(sp);for(const x of sp.parts)if(x.city!==c)HAUL.push({c,to:x.city,tier:x.tier,a:x.a,v:d*0.1});}
|
||||
else dd=atk.gbps*mult;
|
||||
if(en.k==='p'){const p=S.pni.find(x=>x.id===en.id);if(p&&p.sacrif)dd=Math.min(dd,liveCap(pniG(p),p.city,p.site,p.n)*0.9);}}
|
||||
const attacks=VIC[c]||[],rtbh=bhCities.has(c),edge=!!(attacks.length&&TRX&&TRX.blackhole&&!rtbh);
|
||||
// The junk heads for the victim over its usual exits, spread like its traffic. How much is left after the edge
|
||||
// tools and scrubbing is only known once hauls to remote centers are routed, so the flows are sized after that.
|
||||
for(const atk of attacks){const m=ddosMitigation(atk,{},rtbh,false),group={m,flows:[]};R2.ddos.push(m);junkGroups.push(group);if(!popUp(c)){m.offline=true;continue;}
|
||||
for(let j=0;j<NN;j++)group.flows.push({f:flow(c,ci,cn,j,0,false,true),share:NSH[NETS[j].id]});}
|
||||
if(!popUp(c))continue;
|
||||
const bh=rtbh||edge;
|
||||
if(dd>0)for(let j=0;j<NN;j++)flow(c,ci,cn,j,dd*NSH[NETS[j].id],false,true);
|
||||
if(edge)R2.teBlack+=atk.gbps*0.15+d*0.1;if(rtbh)R2.teBlack+=atk.gbps+d;
|
||||
if(edge)R2.teBlack+=attacks.reduce((n,a)=>n+a.gbps,0)+d*0.1;if(rtbh)R2.teBlack+=attacks.reduce((n,a)=>n+a.gbps,0)+d;
|
||||
R2.cityBlocked=R2.cityBlocked||{};
|
||||
const mtuH=ev.pmtud&&ev.pmtud.until>day?ev.pmtud:null,kr=CITY[c].kr;
|
||||
for(let j=0;j<NN;j++){const n=NETS[j],a=(loc&&!R2.reachable[n.id]?0:d0)*sa[j]*thr(n.id)*(rtbh?0:edge?0.9:1)*(mtuH&&mtuH.net===n.id?mtuH.f:1)*(kr&&ev.krroute>day&&n.id==='fbk'?0.8:1);if(a<=0)continue;
|
||||
|
|
@ -86,13 +91,17 @@ function compute(){
|
|||
/* While routing, each edge keeps its own room (res) and load (ld). Routers only exist in POPs (HAS): their room,
|
||||
load and served traffic are kept per city index. What crosses each edge (R.ef) is added up by egress, and in
|
||||
arrays by network (then 'junk' and 'l2vpn') and by source city, each key in the order it first got traffic. */
|
||||
const LATP=new Float64Array(NC),FARL=[],NRES=new Float64Array(NC),HAS=new Uint8Array(NC),NLOAD=new Float64Array(NC),NSEEN=new Uint8Array(NC),NORD=[],SRV=new Float64Array(NC);
|
||||
const LATP=new Float64Array(NC),FARL=[],NRES=new Float64Array(NC),HAS=new Uint8Array(NC),NLOAD=new Float64Array(NC),NSEEN=new Uint8Array(NC),NORD=[],SRV=new Float64Array(NC),PASS=new Float64Array(NC).fill(1),OUT=new Uint8Array(NC);
|
||||
for(const k in edges)edges[k].res=edges[k].cap;for(const c of pops){const i=CIDX[c];NRES[i]=nodeCap(c);HAS[i]=1;R2.nodeCap[c]=NRES[i];}
|
||||
// The core (backbone technology): what passing-through traffic costs each router, and which POPs TE must avoid.
|
||||
const CORE=coreOn()&&S.core.run>=1;if(CORE)for(const c of pops){const i=CIDX[c];PASS[i]=corePass(c);OUT[i]=inCore(c)?0:1;}
|
||||
const nodeTake=(i,a)=>{NRES[i]-=a;if(!NSEEN[i]){NSEEN[i]=1;NORD.push(i);}NLOAD[i]=(NLOAD[i]||0)+a;};
|
||||
const NKN=NN+2,ACN=new Float64Array(NE*NKN),SEN=new Uint8Array(NE*NKN),ACD=new Float64Array(NE*NC),SED=new Uint8Array(NE*NC),EL=[];
|
||||
const carry=(l,eg,nr,ci,a)=>{let t=l.tr;if(!t){t=l.tr={g:new Map(),n:[],d:[]};EL.push(l);}t.g.set(eg,(t.g.get(eg)||0)+a);
|
||||
let k=l.i*NKN+nr;if(!SEN[k]){SEN[k]=1;t.n.push(nr);}ACN[k]=(ACN[k]||0)+a;k=l.i*NC+ci;if(!SED[k]){SED[k]=1;t.d.push(ci);}ACD[k]=(ACD[k]||0)+a;};
|
||||
R2.l2route={};R2.l2split={};
|
||||
/* compute() reads only S, except here: scenic circuits remember yesterday's path in R.l2route and R.efg (deliberate
|
||||
hysteresis, so they do not flap). A second call can still move one; the third gives the same answer as the second. */
|
||||
/* Scenic routing (#28). "Busy" is judged without the customer's own traffic, or it flees its own load and
|
||||
flips paths every day. Two paths that are about as quiet share the load, and yesterday's choice is kept
|
||||
unless today's is clearly better. */
|
||||
|
|
@ -135,57 +144,70 @@ function compute(){
|
|||
if((b.reqs||[]).includes('diverse')){const k=b.city+'>'+b.city2;R2.div[b.id]=divMemo[k]??(divMemo[k]=disjointI(b.city,b.city2));}}
|
||||
/* A flood for a scrubbing center elsewhere rides the backbone there, with the victim's own traffic (#117).
|
||||
What the links cannot carry is not scrubbed and lands on the city after all. */
|
||||
for(const H of HAUL){const A=H.c,B=H.to,Ai=CIDX[A],Bi=CIDX[B];let h=0,ms=null;
|
||||
if(popUp(A)&&popUp(B)&&SPD[A]&&SPD[A][Bi]<Infinity){const {path,ni}=walkI(SPP[A],Ai,Bi);let room=Infinity;for(const l of path)room=Math.min(room,l.res);for(const i of ni)if(HAS[i])room=Math.min(room,NRES[i]);
|
||||
const want=H.a+H.v,take=Math.max(0,Math.min(want,room));h=want>0?H.a*take/want:0;ms=path.reduce((x,e)=>x+e.lat,0)*2;
|
||||
const ek='scrub:'+B;R2.egDesc[ek]={lab:labOf(N_('compute.attack_hauled_to_scrubbing_in_city'),'city',CITY[B].name),city:A,k:'l2'};
|
||||
for(const i of ni)if(HAS[i])nodeTake(i,take);for(const l of path){l.res-=take;l.ld+=take;carry(l,ek,NN,Ai,take);}}
|
||||
R2.haul.push({city:A,to:B,tier:H.tier,a:H.a,h,ms});const left=(H.a-h)*0.85;if(left>1e-6)for(let j=0;j<NN;j++)flow(A,Ai,cnCity(A),j,left*NSH[NETS[j].id],false,true);}
|
||||
const TE=!!(S.te&&S.te.on),TR=teRules();R2.teMoved=0;const teCache=new Map(),SPILL=TR&&TR.spill?TR.spill:1;
|
||||
const scrubNear=new Map();
|
||||
for(const m of R2.ddos){const atk=m.attack,A=atk.city,Ai=CIDX[A];
|
||||
m.sp=!m.offline&&m.leak>0?scrubPlan(atk,m.leak,scrubRoom,(x,want)=>{const B=x.city,Bi=CIDX[B];if(A===B)return want;let h=0,ms=null;
|
||||
if(popUp(A)&&popUp(B)&&SPD[A]&&SPD[A][Bi]<Infinity){const {path,ni}=walkI(SPP[A],Ai,Bi);let room=Infinity;for(const l of path)room=Math.min(room,l.res);for(const i of ni)if(HAS[i])room=Math.min(room,NRES[i]);
|
||||
const v=R2.cityDem[A]*0.1*want/Math.max(m.leak,1)/VIC[A].length,total=want+v,take=Math.max(0,Math.min(total,room));h=total>0?want*take/total:0;ms=path.reduce((n,e)=>n+e.lat,0)*2;
|
||||
// Sources sharing a center need separate labels in link breakdowns and map highlights.
|
||||
const ek='scrub:'+A+'>'+B;R2.egDesc[ek]={lab:labOf(N_('compute.attack_hauled_to_scrubbing_in_city'),'city',CITY[B].name),city:A,k:'l2'};
|
||||
for(const i of ni)if(HAS[i])nodeTake(i,take);for(const l of path){l.res-=take;l.ld+=take;carry(l,ek,NN,Ai,take);}}
|
||||
R2.haul.push({city:A,to:B,tier:x.tier||0,a:want,h,ms,attack:atk.id});return h;}):null;
|
||||
if(m.sp){m.leak=m.sp.leak;
|
||||
// The card describes the victim's nearest center.
|
||||
const c=atk.city;let near=scrubNear.get(c);if(near===undefined){near=null;
|
||||
for(const x of S.scrubs)if(popUp(x.city)&&SPD[c]&&SPD[c][CIDX[x.city]]<Infinity){const ms=c===x.city?0:walkI(SPP[c],CIDX[c],CIDX[x.city]).path.reduce((n,e)=>n+e.lat,0);if(!near||ms<near.ms)near={city:x.city,ms};}
|
||||
scrubNear.set(c,near);}m.near=near;}}
|
||||
for(const group of junkGroups)for(const q of group.flows)q.f.rem=group.m.offline?0:group.m.leak*q.share;
|
||||
const TE=!!(S.te&&S.te.on)&&coreTE(),TR=TE?teRules():null,REACH=coreTeReach();R2.teMoved=0;const teCache=new Map(),SPILL=TR&&TR.spill?TR.spill:1;
|
||||
const altPath=(src,dst,base)=>{const key=src*NC+dst,c0=teCache.get(key);
|
||||
if(c0===false)return null;if(c0&&c0.path.every(l=>l.res>1e-3)&&c0.ni.every(i=>!HAS[i]||NRES[i]>1e-3))return c0;
|
||||
const {D,P}=dijkstra(adj,src,wW,(v,e)=>e.res<=1e-3||(HAS[v]&&NRES[v]<=1e-3),dst);
|
||||
if(D[dst]===Infinity||D[dst]>2*base+60){teCache.set(key,false);return null;}
|
||||
const {D,P}=dijkstra(adj,src,wW,(v,e)=>e.res<=1e-3||(HAS[v]&&NRES[v]<=1e-3)||(CORE&&OUT[v]&&v!==dst),dst);
|
||||
if(D[dst]===Infinity||D[dst]>REACH*base+60){teCache.set(key,false);return null;}
|
||||
const Q=walkI(P,src,dst);teCache.set(key,Q);return Q;};
|
||||
const base=e=>e.pref==='low'?4:e.rank;
|
||||
/* A network in a peer's customer cone, reached through that peer (#85): after every network you peer with directly
|
||||
(its AS path is one hop longer) and before transit. */
|
||||
const base=(e,n)=>e.pref==='low'?4:e.rank>0&&e.rank<3&&coneOf(e,n)?CONE_RANK:e.rank;
|
||||
// LOCAL_PREF on an upstream moves it ahead of or behind the other transits, never ahead of peering (#96).
|
||||
const eff=(e,n)=>{let r=base(e);if(TR){if(e.k==='t'&&TR.up[e.net])r=TR.up[e.net]==='prefer'?2.9:3.5;if(e.prep)r=4.4;if(e.k!=='c'&&TR.drain.has(e.city))r=4.6;const o=TR.net[n];if(o){if(o.prefer===e.k)r=0.5;else if(o.avoid===e.k)r=4.5;}}return r;};
|
||||
// A carrier's own port for traffic bound for it or for its customers (25-direct-egress.js): tried before plain transit, but
|
||||
// never over RouteScript, a Prefer-marked port or a port set to backup, which all keep the say they had. Such a port is
|
||||
// also an ordinary transit exit (rank 3), so POPs without one of its own can still use it.
|
||||
const hiAny=E.some(e=>e.k==='t'&&e.pref==='high');
|
||||
const dr=(e,n)=>{if(hiAny||e.k!=='t')return 0;const t=directTier(e.net,n);return t&&eff(e,n)===3?DIRECT_RANK[t][e.carry?0:1]:0;};
|
||||
const RANKS=TR?[0,0.5,1,2,2.9,2.92,2.93,2.94,2.95,3,3.5,4,4.4,4.5,4.6]:[0,1,2,2.92,2.93,2.94,2.95,3,4];
|
||||
const eff=(e,n)=>{let r=base(e,n);if(TR){if(e.k==='t'&&TR.up[e.net])r=TR.up[e.net]==='prefer'?2.9:3.5;if(e.prep)r=4.4;if(e.k!=='c'&&TR.drain.has(e.city))r=4.6;const o=TR.net[n];if(o){if(o.prefer===e.k)r=0.5;else if(o.avoid===e.k)r=4.5;}}return r;};
|
||||
const RANKS=TR?[0,0.5,1,2,CONE_RANK,2.9,3,3.5,4,4.4,4.5,4.6]:[0,1,2,CONE_RANK,3,4];
|
||||
// With `protect customers`, business flows take every rank first; home users get what is left.
|
||||
const PASSES=TR&&TR.protect?[x=>x.bz,x=>!x.bz]:null;
|
||||
// Each network's exits by the rank they route at (RouteScript can move an exit per network), in E's order.
|
||||
// Each list also knows whether it holds a preferred exit (hi) and its exits by city (at), in list order.
|
||||
// usedRank: the ranks that have a list for some network, so a rank nobody sits at costs no pass over the flows.
|
||||
const byRank={},usedRank=new Set();for(const id of NET_IDS){const m=byRank[id]={};for(const e of okBy[id]){const r=TR?eff(e,id):base(e);(m[r]||(m[r]=[])).push(e);usedRank.add(r);
|
||||
const d=dr(e,id);if(d){(m[d]||(m[d]=[])).push(e);usedRank.add(d);}}
|
||||
for(const r in m){const L=m[r];L.hi=L.some(e=>e.hp===0);L.at=new Map();for(const e of L){const h=L.at.get(e.ci);if(h)h.push(e);else L.at.set(e.ci,[e]);}}}
|
||||
// With several islands (POPs no backbone joins), each list is split by island: a flow only scans exits it can reach.
|
||||
const idx=L=>{L.hi=L.some(e=>e.hp===0);L.at=new Map();for(const e of L){const h=L.at.get(e.ci);if(h)h.push(e);else L.at.set(e.ci,[e]);}};
|
||||
// Networks with the same exits at a rank share one list (LIST, by content), so what one flow learns serves them all.
|
||||
const LIST=new Map();for(let i=0;i<E.length;i++)E[i].xi=i;
|
||||
const byRank={},RSET=new Set();for(const id of NET_IDS){const m=byRank[id]={};for(const e of okBy[id]){const r=TR?eff(e,id):base(e,id);RSET.add(r);(m[r]||(m[r]=[])).push(e);}
|
||||
for(const r in m){const L=m[r],key=L.map(e=>e.xi).join(','),o=LIST.get(key);if(o){m[r]=o;continue;}
|
||||
let V=L;if(NCOMP>1){const cs=[];for(const e of L){const k=COMP[e.ci];if(k>=0)(cs[k]||(cs[k]=[])).push(e);}for(const s of cs)if(s)idx(s);V={cs};}else idx(L);LIST.set(key,V);m[r]=V;}}
|
||||
// The flow being routed, and from its POP: distances, arriving edges and the paths walked so far, by city index.
|
||||
let f=null,Dv=null,Pv=null,PP=null,vis=0;const walked=[],G=[],REST=[],NEG=[];
|
||||
// An exit the flow can still try: not visited yet, not full when the flow started, and reachable from the POP.
|
||||
const usable=e=>e.vis!==vis&&e.used<e.cap&&Dv[e.ci]<Infinity,byDist=(a,b)=>a.hp-b.hp||Dv[a.ci]-Dv[b.ci];
|
||||
// An exit the flow can still try: not visited yet, not full when the flow started, reachable, and not on a saturated path.
|
||||
const usable=e=>e.vis!==vis&&e.used<e.cap&&Dv[e.ci]<Infinity&&!gone(e),byDist=(a,b)=>a.hp-b.hp||Dv[a.ci]-Dv[b.ci];
|
||||
// Push up to `want` along one path to exit e; returns what fitted. Capacity only shrinks while routing, so a
|
||||
// path with one full link or node fits nothing for the rest of this pass: mark it, and later tries cost nothing
|
||||
// (most tries are into paths that filled up earlier).
|
||||
const push=(e,P,want,keep=0)=>{if(P.dead)return 0;const path=P.path,ni=P.ni;let amt=want;
|
||||
for(const l of path){const r=l.res;if(r<=1e-6){P.dead=1;return 0;}amt=Math.min(amt,r-l.cap*keep);}
|
||||
for(const i of ni)if(HAS[i]){const r=NRES[i];if(r<=1e-6){P.dead=1;return 0;}amt=Math.min(amt,r);}
|
||||
const last=ni.length-1;
|
||||
for(let k=0;k<=last;k++){const i=ni[k];if(!HAS[i])continue;const r=NRES[i];if(r<=1e-6){P.dead=1;return 0;}const w=k&&k<last?PASS[i]:1;amt=Math.min(amt,r/w);}
|
||||
if(amt<=1e-6)return 0;
|
||||
for(const i of ni)if(HAS[i])nodeTake(i,amt);
|
||||
for(let k=0;k<=last;k++){const i=ni[k];if(HAS[i])nodeTake(i,k&&k<last?amt*PASS[i]:amt);}
|
||||
const ek=e.ek,nr=f.nr,ci=f.ci;if(!e.told||e.dup){R2.egDesc[ek]=e.desc;e.told=true;}
|
||||
for(const l of path){l.res-=amt;l.ld+=amt;carry(l,ek,nr,ci,amt);}
|
||||
e.used+=amt;f.rem-=amt;
|
||||
if(!f.junk){let ok=amt;const cf=f.cn,ce=e.cn,cn=f.ncn;
|
||||
if(cf!==ce||(cf&&!cn)||(!cf&&cn&&e.k==='t')){const prem=(e.k==='t'&&e.prem)||(e.k==='p'&&e.pnc)||path.some(x=>x.links&&x.links.some(y=>y.premium));const loss=prem?0.03:(ev.gfw>day?0.35:0.2);R2.gfwLost+=amt*loss;R2.gfwCross+=amt;ok=amt*(1-loss);}
|
||||
SRV[f.ci]+=ok;R2.served+=ok;if(f.bz)R2.bizSrv[f.c]+=ok;if(e.rank<=2)R2.peered+=ok;if(e.k==='t'){const m=R2.tNet[e.id]||(R2.tNet[e.id]={});m[f.n]=(m[f.n]||0)+ok;
|
||||
SRV[f.ci]+=ok;R2.served+=ok;if(f.bz)R2.bizSrv[f.c]+=ok;if(e.rank<=2)R2.peered+=ok;if(e.k==='t'){const m=R2.tNet[e.id]||(R2.tNet[e.id]={});m[f.n]=(m[f.n]||0)+ok;}
|
||||
// Backhaul to transit: users notice the round trip to the exit. Up to 20 ms (about 1,500 km) is free, then
|
||||
// it gets worse, and past 50 ms broadband and internet services count as bad service (#…).
|
||||
if(path.length){let ms=P.ms;if(ms===undefined){ms=0;for(const l of path)ms+=l.lat;P.ms=ms;}const rtt=2*ms;
|
||||
if(rtt>LAT_OK){LATP[f.ci]+=ok*latLoss(rtt);if(!P.fg){P.fg=0;FARL.push(P,f.ci,e.ci);}P.fg+=ok;}}}R2.egT[e.k]=(R2.egT[e.k]||0)+ok;const ne=NEG[f.nj]||(NEG[f.nj]=R2.netEg[f.n]={c:0,p:0,ix:0,t:0});ne[e.k]+=ok;}
|
||||
// it gets worse, and past 50 ms broadband and internet services count as bad service (#…). Under sender pays,
|
||||
// Korean users notice any exit far away, transit or not, and much sooner.
|
||||
if(path.length&&(e.k==='t'||snd&&CITIES[f.ci].kr)){let ms=P.ms;if(ms===undefined){ms=0;for(const l of path)ms+=l.lat;P.ms=ms;}const rtt=2*ms,kl=snd&&CITIES[f.ci].kr;
|
||||
if(rtt>(kl?KR_LAT_OK:LAT_OK)){LATP[f.ci]+=ok*(kl?krLatLoss(rtt):latLoss(rtt));if(!P.fg){P.fg=0;FARL.push(P,f.ci,e.ci);}P.fg+=ok;}}R2.egT[e.k]=(R2.egT[e.k]||0)+ok;const ne=NEG[f.nj]||(NEG[f.nj]=R2.netEg[f.n]={c:0,p:0,ix:0,t:0});ne[e.k]+=ok;
|
||||
// Where each flow left (the PNI list asks what a PNI here would take over, #175).
|
||||
if(e.k==='t'){f.gt+=ok;f.ti=e.id;}else if(e.k==='ix'){f.gi+=ok;f.ii=e.id;}else if(e.k==='p'){if(e.net===f.n&&e.city===f.c)f.gh+=ok;else f.gp+=ok;}}
|
||||
return amt;
|
||||
};
|
||||
// Shortest path first. With Auto-TE, whatever does not fit spills onto up to two alternate paths
|
||||
|
|
@ -207,33 +229,35 @@ function compute(){
|
|||
// same comparison, so the order is the same either way.
|
||||
const sortD=a=>{const n=a.length;if(n>24){a.sort(byDist);return;}for(let i=1;i<n;i++){const x=a[i];let j=i-1;while(j>=0&&byDist(a[j],x)>0){a[j+1]=a[j];j--;}a[j+1]=x;}};
|
||||
for(const pass of PASSES||[null])for(const rank of RANKS){
|
||||
if(!usedRank.has(rank))continue;
|
||||
// A carrier's own port that is not set to carry only takes the traffic of the POP it sits in.
|
||||
const LOC=rank===DIRECT_RANK[1][1]||rank===DIRECT_RANK[2][1];
|
||||
if(!RSET.has(rank))continue;
|
||||
// Index loops in here: plain for…of allocates an iterator per loop until V8 has optimised compute().
|
||||
for(let fi=0,FN=flows.length;fi<FN;fi++){f=flows[fi];
|
||||
if(f.rem<=1e-6||(rank===0&&!f.cache)||(pass&&!pass(f)))continue;
|
||||
const lst=byRank[f.n][rank];if(!lst)continue;
|
||||
Dv=SDi[f.ci];Pv=SPi[f.ci];PP=walked[f.ci]||(walked[f.ci]=[]);vis++;
|
||||
if(LOC){G.length=0;const here=lst.at.get(f.ci);if(!here)continue;for(let h=0;h<here.length;h++){const e=here[h];if(e.used<e.cap)G.push(e);}if(G.length)sendGroup(G,0,G.length);continue;}
|
||||
let lst=byRank[f.n][rank];if(!lst)continue;if(lst.cs){lst=lst.cs[COMP[f.ci]];if(!lst)continue;}
|
||||
/* Groups are tried nearest first, preferred exits before the rest, in the order a stable sort of the usable
|
||||
exits gives. Exits only fill up once tried, so the usable ones stay the same until then. Nearly every flow
|
||||
fits in its first group: find that one with a scan (nothing is visited yet), and sort only what is left
|
||||
when it does not fit. Most often the group is the POP's own exits: with no preferred exit on the list
|
||||
and no other city at distance 0, the usable ones here are exactly the first group, already in order. */
|
||||
G.length=0;
|
||||
if(!lst.hi&&ALONE[f.ci]){const here=lst.at.get(f.ci);if(here)for(const e of here)if(e.used<e.cap)G.push(e);}
|
||||
if(!lst.hi&&ALONE[f.ci]){const here=lst.at.get(f.ci);if(here)for(const e of here)if(e.used<e.cap&&!gone(e))G.push(e);}
|
||||
if(!G.length){
|
||||
// One scan: the best (preference, distance) so far and, in list order, the exits within 1e-6 of it. The best
|
||||
// distance only goes down, so dropping the ones it leaves behind gives exactly the exits a second scan would.
|
||||
// Exits that are full stay full for this pass: when a quarter of a list is, it is rewritten without them.
|
||||
/* gc[ci]: the first group this list gave a flow from city ci. Exits only fill up during routing, so while all of
|
||||
them still have room no other exit can have become better, and the scan would find the same group (an
|
||||
empty one, no usable exit, stays empty). */
|
||||
const gc=lst.gc||(lst.gc=[]),c=gc[f.ci];
|
||||
if(c!==undefined&&c.every(e=>e.used<e.cap&&!gone(e))){if(!c.length)continue;for(let k=0;k<c.length;k++)G.push(c[k]);}else{
|
||||
let bh=2,bd=Infinity,full=0;
|
||||
for(let li=0,LN=lst.length;li<LN;li++){const e=lst[li];if(e.used>=e.cap){full++;continue;}const d=Dv[e.ci];if(d===Infinity)continue;const h=e.hp;
|
||||
for(let li=0,LN=lst.length;li<LN;li++){const e=lst[li];if(e.used>=e.cap||gone(e)){full++;continue;}const d=Dv[e.ci];if(d===Infinity)continue;const h=e.hp;
|
||||
if(h<bh){bh=h;bd=d;G.length=0;G.push(e);}
|
||||
else if(h===bh){if(d<bd){bd=d;let k=0;for(let gi=0;gi<G.length;gi++){const x=G[gi];if(Dv[x.ci]-d<1e-6)G[k++]=x;}G.length=k;G.push(e);}else if(d-bd<1e-6)G.push(e);}}
|
||||
if(full*4>=lst.length&&full){let k=0;for(let li=0;li<lst.length;li++){const e=lst[li];if(e.used<e.cap)lst[k++]=e;}lst.length=k;}
|
||||
if(bh>1)continue;
|
||||
if(G.length>1)sortD(G);}
|
||||
if(bh>1){gc[f.ci]=[];continue;}
|
||||
if(G.length>1)sortD(G);gc[f.ci]=G.slice();}}
|
||||
sendGroup(G,0,G.length);
|
||||
if(f.rem<=1e-6)continue;
|
||||
REST.length=0;for(let li=0;li<lst.length;li++)if(usable(lst[li]))REST.push(lst[li]);sortD(REST);
|
||||
|
|
@ -261,22 +285,22 @@ function compute(){
|
|||
for(const e of E){if(e.k==='t')R2.useT[e.id]=(R2.useT[e.id]||0)+e.used;else if(e.k==='ix')R2.useIx[e.id]=e.used;else if(e.k==='p')R2.usePni[e.id]=e.used;else R2.useCache[e.id]=e.used;}
|
||||
// money
|
||||
const C=R2.cost,V=R2.rev,pm=S.priceMul;
|
||||
C.pops=Object.values(S.pops).reduce((a,p)=>a+POP_MO+((p.routers||1)-1)*ROUTER_MO+cageMo(p.routers)+(p.routers||1)*RG[p.rgen||0].mo+(p.gen?GEN_MO:0),0);
|
||||
C.pops=Object.entries(S.pops).reduce((a,[c,p])=>a+popMo(c)+((p.routers||1)-1)*ROUTER_MO+cageMo(p.routers)+(p.routers||1)*RG[p.rgen||0].mo+(p.gen?GEN_MO:0),0);
|
||||
C.optical=S.links.filter(l=>l.kind==='df').reduce((a,l)=>a+(l.ready>S.day?0:ampCount(l.km)*AMP_MO*(l.own&&isRdm(l.sys)&&!l.sub?Math.max(1,l.pairs|0):1)+(l.regen|0)*REGEN_MO)+(l.spares?Math.round(150+(l.ch||[]).length*80):0),0);
|
||||
C.links=S.links.reduce((a,l)=>a+(l.mo||0),0);
|
||||
C.nni=(S.nni||[]).reduce((a,x)=>a+NNI[x.tier].mo,0);
|
||||
C.transit=S.transit.reduce((a,t)=>{const q=p95(t,R2.useT[t.id]||0);R2.p95[t.id]=q;return a+transitMo(t,q);},0);
|
||||
const htd=histToday();C.transit=S.transit.reduce((a,t)=>{const q=p95(t,R2.useT[t.id]||0,htd);R2.p95[t.id]=q;return a+transitMo(t,q);},0);
|
||||
C.ix=Object.keys(S.ixp).reduce((a,c)=>a+ixMo(c),0);
|
||||
C.pni=S.pni.reduce((a,p)=>a+pniMo(p,R2.usePni[p.id]||0),0);
|
||||
C.caches=S.caches.length*CACHE_MO;
|
||||
C.loans=(S.loans||[]).reduce((a,l)=>a+(BANKS[l.bank].equity?0:l.model==='transit'?Math.round((C.transit||0)*(l.cut||0.3)):l.pay)+loanFees(l),0);
|
||||
C.extras=(S.cnLic&&S.cnLic.state==='ok'?CN_JV_MO:0)+scrubMo()+Object.keys(S.pops).filter(ruCity).length*RU_BOX_MO+Object.values(S.pops).filter(p=>p.site2).length*SITE2_MO+(S.te?TE_MO:0)+(S.inbox&&S.inbox.bot?AI_MO:0);
|
||||
C.extras=(S.cnLic&&S.cnLic.state==='ok'?CN_JV_MO:0)+scrubMo()+Object.keys(S.pops).filter(ruCity).length*RU_BOX_MO+Object.values(S.pops).filter(p=>p.site2).length*SITE2_MO+(S.te?TE_MO:0)+(S.ops&&S.ops.intern?INTERN_MO:0);
|
||||
V.eyeballs=0;V.business=0;V.ix=0;V.grant=grantOn(R2)?GRANT_MO:0;
|
||||
C.wholesale=0;C.levy=0;const lev=scnRule('levy');for(const c in S.pops){const sf=sfOf(R2,c),v=R2.cityEye[c]*sf*EYE_RATE*(CITY[c].arpu||1);V.eyeballs+=v;if(CITY[c].au){if(lev)C.levy+=v*AU_LEVY;else C.wholesale+=v*AU_WHOLESALE;}}
|
||||
C.wholesale=0;C.levy=0;const lev=scnRule('levy');for(const c in S.pops){const sf=sfOf(R2,c),v=R2.cityEye[c]*sf*EYE_RATE*arpuOf(c);V.eyeballs+=v;if(CITY[c].au){if(lev)C.levy+=v*AU_LEVY;else C.wholesale+=v*AU_WHOLESALE;}}
|
||||
const ids=linkIds();for(const b of S.biz){if(capPend(b))continue;const sf=BIZ_T[b.type].fiber?(fiberOk(b,ids)?1:0):BIZ_T[b.type].l2?clamp((R2.l2[b.id]||0)/b.bw,0,1):sfOf(R2,b.city);V.business+=b.bw*b.rate*Math.min(1,sf/0.95);}
|
||||
for(const c in S.myIx)V.ix+=S.myIx[c].members.length*MYIX_FEE;
|
||||
C.revshare=(S.loans||[]).reduce((a,l)=>a+(BANKS[l.bank].equity||l.bal>0?l.share||0:0),0)*(V.eyeballs+V.business+V.ix);
|
||||
R2.costMo=Object.values(C).reduce((a,b)=>a+b,0);
|
||||
R2.revMo=V.eyeballs+V.business+V.ix+V.grant;
|
||||
R=R2;UI.hotMap=hotByCity();
|
||||
Object.defineProperty(R2,'fl',{value:flows});R=R2;UI.hotMap=hotByCity();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
function p95(t,cur){const h=(t.hist||[]).slice(-29).concat([cur]).sort((a,b)=>a-b);return h[Math.max(0,Math.ceil(.95*h.length)-1)];}
|
||||
// The last 29 days plus today. Once dayTick() has written today into t.hist (S.hist then ends on today too), that
|
||||
// sample is today's own: leave it out, or every recompute later that day counts today twice and drops a day.
|
||||
const histToday=()=>{const H=S.hist,l=H&&H[H.length-1];return !!l&&l.d===S.day;};
|
||||
function p95(t,cur,today=histToday()){const a=t.hist||[],n=Math.max(0,a.length-(today&&a.length?1:0)),h=a.slice(Math.max(0,n-29),n).concat([cur]).sort((a,b)=>a-b);return h[Math.max(0,Math.ceil(.95*h.length)-1)];}
|
||||
function linkDown(l){return l.cut>S.day||(S.ev.runet>S.day&&ruCity(l.a)!==ruCity(l.b))||(S.ev.gulf>S.day&&((CITY[l.a].qa&&(CITY[l.b].gcc||CITY[l.b].uae))||(CITY[l.b].qa&&(CITY[l.a].gcc||CITY[l.a].uae))))||(l.kind==='vxc'&&!!S.ev.fab&&S.ev.fab[l.prov]>S.day)||(l.kind==='df'&&dfCap(l)<=0);}
|
||||
function remoteCities(){return [...new Set(S.links.filter(l=>l.kind==='vxc').flatMap(l=>[l.a,l.b]))].filter(c=>!S.pops[c]);}
|
||||
function nniUsed(c,prov){return S.links.filter(l=>l.kind==='vxc'&&l.prov===prov&&(l.a===c||l.b===c)).reduce((a,l)=>a+VXC[l.vt].g,0)+S.biz.filter(b=>BIZ_T[b.type].nni&&b.prov===prov&&b.city===c).reduce((a,b)=>a+b.bw,0);}
|
||||
// Monthly price of one connection; compute() sums these, the connections overview lists them.
|
||||
function transitMo(t,q){const n=t.n||1;return Math.max(q,PORT[t.tier].g*n*0.2)*transitPerG(NET[t.net],t.city,premOn(t))*S.priceMul+PORT[t.tier].tmo*n+(t.clean?cleanMo(t):0);}
|
||||
function transitMo(t,q){const n=t.n||1;return Math.max(q,PORT[t.tier].g*n*0.2)*transitPerG(NET[t.net],t.city,premOn(t))*S.priceMul+PORT[t.tier].tmo*n+(t.clean?cleanMo(t):0)+krFee(t,q);}
|
||||
// Sender pays (Gangnam Style Peering): on top of the price, every Gbps delivered into Korea (95th percentile).
|
||||
const krFee=(t,q)=>CITY[t.city].kr&&scnRule('sender')?Math.round(q*KR_FEE):0;
|
||||
function pniMo(p,use){if(!pniOn(p))return 0;return (p.g1?Math.round(PORT[0].pni/2):PORT[p.tier].pni)*(p.n||1)+(NET[p.net].pol==='paid'&&!paidFree(NET[p.net])?NET[p.net].paidFee:0)+(NET[p.net].perG?Math.round(NET[p.net].perG*use):0);}
|
||||
function ixMo(c){return S.myIx[c]?Math.round(myFab(c).mo*((S.ixSite||{})[c]==='ab'?1.5:1)):ixPortMo(c,S.ixp[c])*((S.ixn||{})[c]||1)+dkAddonMo(c);}
|
||||
function nniPort(c,prov){return (S.nni||[]).find(x=>x.city===c&&x.prov===prov);}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ const num=(v,d=0)=>{v=+v;return Number.isFinite(v)?v:d;},int=(v,lo,hi,d)=>{v=Mat
|
|||
/* Saves come from localStorage or from imported files, so treat them as untrusted: fill in anything
|
||||
missing, drop references to cities, networks or types that do not exist, and force numbers to be numbers. */
|
||||
function sanitize(s){
|
||||
// A puzzle is never saved; a save that says otherwise is played as a normal game.
|
||||
if(s.mode==='puzzle')s.mode='normal';delete s.pz;
|
||||
const arr=k=>{if(!Array.isArray(s[k]))s[k]=[];},obj=k=>{if(!s[k]||typeof s[k]!=='object'||Array.isArray(s[k]))s[k]={};};
|
||||
['links','nni','transit','pni','caches','biz','offers','inc','usedNames','loans','loanOffers','hist','log'].forEach(arr);
|
||||
['pops','ixp','rs','peers','myIx','done','ev','stats','ixn','ixPref','ixSite','confReg','ach','pairMet'].forEach(obj);
|
||||
|
|
@ -11,31 +13,36 @@ function sanitize(s){
|
|||
s.priceMul=num(s.priceMul,1);s.nextFail=num(s.nextFail,s.day+45);s.nextEvent=num(s.nextEvent,s.day+40);s.lvl=int(s.lvl,1,LEVELS.length,1);s.neg=int(s.neg,0,1e7,0);s.loanStrikes=int(s.loanStrikes,0,1e3,0);
|
||||
for(const k of Object.keys(s.stats)){const v=s.stats[k];if(k==='by'||k==='f'){if(!v||typeof v!=='object')s.stats[k]={};else for(const j of Object.keys(v))v[j]=num(v[j],0);}else if(typeof v!=='boolean')s.stats[k]=num(v,0);}
|
||||
for(const k of ['survived','incidents','peak'])s.stats[k]=num(s.stats[k],0);
|
||||
// The chaos monkey (2.0): saves without one get their first visit scheduled on the next day tick.
|
||||
{const m=s.monkey&&typeof s.monkey==='object'&&!Array.isArray(s.monkey)?s.monkey:{},on=m.on?1:0,o={next:m.next==null?null:int(m.next,0,1e7,s.day+90),on};
|
||||
if(on){o.start=int(m.start,0,s.day,s.day);o.until=int(m.until,o.start,o.start+400,s.day+30);o.snip=int(m.snip,0,1e7,s.day+3);o.n=int(m.n,0,1e4,0);o.hurt=int(m.hurt,0,o.n,0);o.c=isCity(m.c)?m.c:isCity(s.home)?s.home:null;}
|
||||
s.monkey=o;}
|
||||
for(const c of Object.keys(s.pops)){const p=s.pops[c];if(!isCity(c)||!p||typeof p!=='object'){delete s.pops[c];continue;}p.routers=int(p.routers,1,RMAX,1);if(p.rupDay!==undefined)p.rupDay=num(p.rupDay,-1);if(p.rgen!==undefined)p.rgen=int(p.rgen,0,RG.length-1,0);p.down=num(p.down,0);if(p.bb&&typeof p.bb==='object')p.bb.d=num(p.bb.d,0);else p.bb=null;}
|
||||
if(!isCity(s.home))s.home=Object.keys(s.pops)[0]||'fra';
|
||||
opsSanitize(s);
|
||||
const tier=v=>int(v,0,PORT.length-1,0),lag=v=>int(v,1,LAG_MAX,1),sid=v=>String(v==null?uid():v).slice(0,40);
|
||||
s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&!own(CAB,l.cable))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);for(const k of Object.keys(SUB_UPGRADES)){const f='sub'+k;if(l[f]!==undefined){if(l.own&&l.sub&&Number.isFinite(l[f])&&l[f]>=0)l[f]=Math.round(l[f]);else delete l[f];}}if(l.seaPath!==undefined){if(l.own&&l.sub&&Array.isArray(l.seaPath)&&l.seaPath.length>=2&&l.seaPath.length<=2048&&l.seaPath.every(p=>Array.isArray(p)&&p.length===2&&p.every(Number.isFinite)&&Math.abs(p[0])<=180&&Math.abs(p[1])<=90))l.seaPath=l.seaPath.map(p=>p.slice());else delete l.seaPath;}if(l.paid!==undefined){if(l.own&&l.sub&&Number.isFinite(l.paid)&&l.paid>=0)l.paid=Math.round(l.paid);else delete l.paid;}if(l.own&&l.sub&&!own(SEA_DESIGNS,l.seaDesign))l.seaDesign='standard';l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);return l;});
|
||||
s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);if(l.list!==undefined){const L=l.list;if(l.kind==='df'&&L&&typeof L==='object'&&!Array.isArray(L)){const w=int(L.w,0,256,0),p=int(L.p,0,2,0);if(w||p)l.list={w,p};else delete l.list;}else delete l.list;}l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&!own(CAB,l.cable))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);for(const k of Object.keys(SUB_UPGRADES)){const f='sub'+k;if(l[f]!==undefined){if(l.own&&l.sub&&Number.isFinite(l[f])&&l[f]>=0)l[f]=Math.round(l[f]);else delete l[f];}}if(l.seaPath!==undefined){if(l.own&&l.sub&&Array.isArray(l.seaPath)&&l.seaPath.length>=2&&l.seaPath.length<=2048&&l.seaPath.every(p=>Array.isArray(p)&&p.length===2&&p.every(Number.isFinite)&&Math.abs(p[0])<=180&&Math.abs(p[1])<=90))l.seaPath=l.seaPath.map(p=>p.slice());else delete l.seaPath;}if(l.paid!==undefined){if(l.own&&l.sub&&Number.isFinite(l.paid)&&l.paid>=0)l.paid=Math.round(l.paid);else delete l.paid;}if(l.own&&l.sub&&!own(SEA_DESIGNS,l.seaDesign))l.seaDesign='standard';l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);return l;});
|
||||
for(const l of s.links)repairSubUpgradeDates(l,s.day);
|
||||
/* Metrics moved from each link to its city pair (#122). Older saves routed a pair at the lowest metric of its
|
||||
links, with all of them carrying traffic, so the pair keeps that metric and nothing goes on standby. */
|
||||
{const pm=s.pairMet,lo={};for(const l of s.links){if(l.metric!==undefined){const k=edgeKey(l),m=own(MET,l.metric)?l.metric:'normal';if(!lo[k]||MET[m].f<MET[lo[k]].f)lo[k]=m;}if(l.standby!==true)delete l.standby;}
|
||||
for(const l of s.links){const k=edgeKey(l);if(lo[k]&&l.metric===undefined)lo[k]='normal';delete l.metric;}
|
||||
for(const k in lo)pm[k]=lo[k];const ks=new Set(s.links.map(edgeKey));for(const k of Object.keys(pm))if(!ks.has(k)||!own(MET,pm[k])||pm[k]==='normal')delete pm[k];}
|
||||
for(const k in lo)pm[k]=lo[k];const ks=new Set(s.links.map(edgeKey));for(const k of Object.keys(pm)){const v=pm[k];
|
||||
if(v&&typeof v==='object'&&ks.has(k)){const mk=v.k==='w'?'w':'f';pm[k]={k:mk,v:clampM(mk,num(v.v,mk==='w'?60:1))};continue;}
|
||||
if(!ks.has(k)||typeof v!=='string'||!own(MET,v)||v==='normal')delete pm[k];}}
|
||||
const degO=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;
|
||||
s.transit=s.transit.filter(t=>t&&isCity(t.city)&&isNet(t.net)).map(t=>(t.lacp=degO(t.lacp),t.site=['a','b','ab'].includes(t.site)?t.site:'a',t.id=sid(t.id),t.tier=tier(t.tier),t.n=lag(t.n),t.down=num(t.down,0),t.clean=!!t.clean,t.carry===true||delete t.carry,t.premium=premOnlyAt(NET[t.net],t.city)||!!t.premium&&premCity(NET[t.net],t.city),t));
|
||||
s.pni=s.pni.filter(x=>x&&isCity(x.city)&&isNet(x.net)).map(x=>(x.lacp=degO(x.lacp),x.site=['a','b','ab'].includes(x.site)?x.site:'a',x.id=sid(x.id),x.tier=tier(x.tier),x.n=lag(x.n),x.sacrif=!!x.sacrif,x));
|
||||
// PNIs on order (#…): delivery day, a pending augment, and 1G for the one network that sells it
|
||||
for(const x of s.pni){if(x.ready!==undefined)x.ready=num(x.ready,0);if(x.g1)x.g1=x.tier===0&&x.net==='dtk'?true:undefined;else delete x.g1;if(x.up){const u=x.up;x.up=u&&typeof u==='object'?{tier:tier(u.tier),n:lag(u.n),ready:num(u.ready,0),g1:!!u.g1&&x.net==='dtk'&&tier(u.tier)===0}:undefined;if(!x.up)delete x.up;}}
|
||||
for(const x of s.pni){if(x.ready!==undefined)x.ready=num(x.ready,0);if(x.g1)x.g1=x.tier===0&&x.net==='dtk'?true:undefined;else delete x.g1;if(x.up){const u=x.up;x.up=u&&typeof u==='object'?{tier:tier(u.tier),n:lag(u.n),ready:num(u.ready,0),g1:!!u.g1&&x.net==='dtk'&&tier(u.tier)===0,...(u.site==='ab'?{site:'ab'}:{})}:undefined;if(!x.up)delete x.up;}}
|
||||
// Supply chain: a shortage and a price lock, both optional.
|
||||
{const H=s.hw&&typeof s.hw==='object'&&!Array.isArray(s.hw)?s.hw:{},o={};const sh=H.shock,lk=H.lock;
|
||||
if(sh&&typeof sh==='object'&&own(HW_SHOCK,sh.k))o.shock={k:sh.k,until:num(sh.until,0),mul:clamp(num(sh.mul,1),1,2)};
|
||||
if(lk&&typeof lk==='object')o.lock={until:num(lk.until,0),mul:clamp(num(lk.mul,1),1,HW_CAP)};s.hw=o;}
|
||||
{const I=s.inbox&&typeof s.inbox==='object'&&!Array.isArray(s.inbox)?s.inbox:{},o=v=>v&&typeof v==='object'&&!Array.isArray(v)?v:{},str=(v,n)=>String(v==null?'':v).slice(0,n);
|
||||
const items=(Array.isArray(I.items)?I.items:[]).filter(x=>x&&typeof x==='object'&&(x.k==='req'||x.k==='mp')&&typeof x.ix==='string'&&isIx(x.ix)&&(x.net===undefined||isNet(x.net))&&(x.net!==undefined||typeof x.nm==='string')).slice(0,INBOX_MAX).map(x=>({id:int(x.id,0,1e9,0),k:x.k,ix:x.ix,net:x.net,nm:x.net?undefined:str(x.nm,40),asn:x.net?undefined:int(x.asn,1,4294967294,64512),day:num(x.day,0),stale:!!x.stale,yrs:int(x.yrs,1,30,1),say:int(x.say,0,REQ_SAY.length-1,0),bump:x.bump?1:undefined,key:x.k==='mp'?str(x.key,80):undefined,lim:x.k==='mp'?int(x.lim,1,1e7,100):undefined,got:x.k==='mp'?int(x.got,1,1e7,100):undefined,leak:x.k==='mp'?!!x.leak:undefined}));
|
||||
const down={};for(const [k,v] of Object.entries(o(I.down)))if(typeof k==='string'&&k.length<80)down[k]=num(v,0);
|
||||
const tiny={};for(const [k,v] of Object.entries(o(I.tiny)).slice(0,200))if(/^\d{1,10}$/.test(k)&&v&&typeof v==='object'&&isIx(v.ix))tiny[k]={nm:str(v.nm,40),ix:v.ix,stale:!!v.stale};
|
||||
const log=(Array.isArray(I.log)?I.log:[]).filter(e=>e&&typeof e==='object'&&typeof e.m==='string').slice(0,40).map(e=>{const a={};for(const [k,v] of Object.entries(o(e.a)).slice(0,6))a[str(k,12)]=typeof v==='number'?v:str(v,60);return {d:num(e.d,0),m:str(e.m,200),a};});
|
||||
s.inbox={items,down,tiny,rep:clamp(num(I.rep,0),-10,5),bot:!!I.bot,pol:PPOL.includes(I.pol)?I.pol:'open',log,seq:Math.max(int(I.seq,0,1e9,0),...items.map(x=>x.id))};}
|
||||
// 2.0 replaced the peering inbox with the peering desk: keep the policy, drop the mail, max-prefix state and the AI.
|
||||
{const I=s.inbox&&typeof s.inbox==='object'&&!Array.isArray(s.inbox)?s.inbox:{},pol=s.ppol!==undefined?s.ppol:I.pol;s.ppol=PPOL.includes(pol)?pol:'open';delete s.inbox;
|
||||
const wk=(x,rep)=>{if(!x||typeof x!=='object'||Array.isArray(x))return null;const o={w:int(x.w,0,1e7,0),a:int(x.a,0,1e5,0),d:int(x.d,0,1e5,0),ix:[...new Set((Array.isArray(x.ix)?x.ix:[]).filter(isIx))].slice(0,PDESK_IX)};if(rep)o.p=PPOL.includes(x.p)?x.p:'open';return o;};
|
||||
s.pdesk=wk(s.pdesk);s.pdeskRep=wk(s.pdeskRep,1);}
|
||||
{const sp={};if(s.spares&&typeof s.spares==='object')for(const k in s.spares)if(own(OPT,k)){const v=Math.floor(+s.spares[k]);if(v>0)sp[k]=Math.min(999,v);}s.spares=sp;}
|
||||
s.caches=s.caches.filter(x=>x&&isCity(x.city)&&isNet(x.net)&&NET[x.net].cache).map(x=>(x.id=sid(x.id),x.site=x.site==='b'&&s.pops[x.city]&&s.pops[x.city].site2?'b':'a',x));
|
||||
for(const c of Object.keys(s.ixp)){if(!isIx(c))delete s.ixp[c];else s.ixp[c]=tier(s.ixp[c]);}
|
||||
|
|
@ -49,28 +56,48 @@ function sanitize(s){
|
|||
// Sponsorships and capacity conferences (#168): registrations are true or 'sp', the glow and the pending deals are checked.
|
||||
for(const k of Object.keys(s.confReg))s.confReg[k]=s.confReg[k]==='sp'?'sp':!!s.confReg[k];
|
||||
if(s.conf){const c=s.conf;if(typeof c!=='object'||!own(REG,c.reg))s.conf=null;else s.conf={until:num(c.until,0),reg:c.reg,name:String(c.name||'').slice(0,40),sp:!!c.sp};}
|
||||
// The backbone's technology: a save from before it with Auto-TE bought keeps the old rules on RSVP-TE (legacy).
|
||||
{const c=s.core&&typeof s.core==='object'?s.core:null,lv=c?int(c.lv,0,4,0):(s.te?2:0);s.core={lv,run:c?int(c.run,0,lv,lv):lv};if(c?c.legacy===true:!!s.te)s.core.legacy=true;if(c&&c.lab===true)s.core.lab=true;if(c&&c.since!==undefined)s.core.since=num(c.since,0);}
|
||||
s.capDeal=s.capDeal&&typeof s.capDeal==='object'&&own(CAP_ROUTES,s.capDeal.c)?{at:num(s.capDeal.at,0),c:s.capDeal.c}:null;
|
||||
s.inc=s.inc.filter(i=>i&&typeof i.type==='string').map(i=>(i.id=sid(i.id),i.until=num(i.until,s.day),i.cost=num(i.cost,0),i.msg=String(i.msg||'').slice(0,400),i.fix=i.fix==null?undefined:String(i.fix).slice(0,60),i));
|
||||
s.inc=s.inc.filter(i=>i&&typeof i.type==='string').map(i=>(i.type==='maxpfx'&&(i.type='ixloop'),i.id=sid(i.id),i.until=num(i.until,s.day),i.cost=num(i.cost,0),i.msg=String(i.msg||'').slice(0,400),i.fix=i.fix==null?undefined:String(i.fix).slice(0,60),i));
|
||||
s.loans=s.loans.filter(l=>l&&own(BANKS,l.bank));for(const l of s.loans){if(l.model!==undefined&&!['balloon','storm','transit','astro'].includes(l.model))delete l.model;for(const k of ['apr0','cut','share'])if(l[k]!==undefined&&!isFinite(+l[k]))delete l[k];if(!Array.isArray(l.covs))l.covs=[];l.covs=l.covs.filter(c=>own(COVS,c));}s.loanOffers=s.loanOffers.filter(l=>l&&own(BANKS,l.bank));
|
||||
s.usedNames=[...new Set(s.usedNames.filter(x=>typeof x==='string'))];s.log=s.log.filter(e=>e&&typeof e.t==='string').slice(0,LOG_KEEP).map(e=>{const o=e.o&&typeof e.o==='object'&&LOG_OPEN.includes(e.o.a)?(e.o.a==='bank'||e.o.a==='inbox'?{a:e.o.a}:typeof e.o.v==='string'&&e.o.v.length<=64&&(e.o.a!=='city'||isCity(e.o.v))&&(e.o.a!=='tab'||LOG_TABS.includes(e.o.v))?{a:e.o.a,v:e.o.v}:null):null;
|
||||
s.usedNames=[...new Set(s.usedNames.filter(x=>typeof x==='string'))];s.log=s.log.filter(e=>e&&typeof e.t==='string').slice(0,LOG_KEEP).map(e=>{const o=e.o&&typeof e.o==='object'&&e.o.a==='inbox'?{a:'tab',v:'nets'}:e&&e.o&&typeof e.o==='object'&&LOG_OPEN.includes(e.o.a)?(e.o.a==='bank'||e.o.a==='ops'?{a:e.o.a}:typeof e.o.v==='string'&&e.o.v.length<=64&&(e.o.a!=='city'||isCity(e.o.v))&&(e.o.a!=='tab'||LOG_TABS.includes(e.o.v))?{a:e.o.a,v:e.o.v}:null):null;
|
||||
return {id:typeof e.id==='string'&&e.id.length<=40?e.id:uid(),d:num(e.d,0),t:e.t.slice(0,600),h:typeof e.h==='string'?e.h.slice(0,200):'',k:LOG_KINDS.includes(e.k)?e.k:'',at:Number.isFinite(+e.at)?+e.at:0,o,n:int(e.n,1,9999,1)};});
|
||||
// One scrubbing center became a list (#117): older saves carry theirs over.
|
||||
if(!Array.isArray(s.scrubs))s.scrubs=s.scrubAt&&isCity(s.scrubAt)?[{city:s.scrubAt,tier:s.scrubTier}]:[];delete s.scrubAt;delete s.scrubTier;
|
||||
{const seen=new Set();s.scrubs=s.scrubs.filter(x=>x&&typeof x==='object'&&isCity(x.city)&&s.pops[x.city]&&!seen.has(x.city)&&seen.add(x.city)).map(x=>({city:x.city,tier:int(x.tier,0,SCRUB_TIERS.length-1,0)}));}
|
||||
s.scrubMode=s.scrubMode==='ondemand'?'ondemand':'always';
|
||||
if(s.ev&&s.ev.ddos){const a=s.ev.ddos;
|
||||
if(!a||typeof a!=='object'||!isCity(a.city)||!own(DDOS_VEC,a.vec))delete s.ev.ddos;
|
||||
else{a.gbps=num(a.gbps,2);a.until=num(a.until,s.day);a.bh=!!a.bh;a.ixbh=!!a.ixbh;a.start=num(a.start,s.day);
|
||||
if(!a.entry||typeof a.entry!=='object')a.entry={k:'edge',lab:''};else{a.entry.lab=String(a.entry.lab||'').slice(0,60);a.entry.id=a.entry.id==null?undefined:String(a.entry.id).slice(0,40);}}}
|
||||
// Keep the legacy primary attack so old saves and imports remain compatible; additional floods overlap it.
|
||||
const repairAttack=a=>{if(!a||typeof a!=='object'||!isCity(a.city)||!s.pops[a.city]||!own(DDOS_VEC,a.vec))return null;
|
||||
a.id=sid(a.id);a.gbps=Math.max(0,num(a.gbps,2));a.until=num(a.until,s.day);a.bh=!!a.bh;a.ixbh=!!a.ixbh;a.start=Math.max(0,Math.min(s.day,num(a.start,s.day)));a.until=Math.min(a.until,a.start+Math.ceil(7*SPICY_LONG));
|
||||
delete a.entries; // 2.0 betas spread attacks over every ingress port; they arrive on one again
|
||||
if(a.who!==undefined&&!FLOOD_WHO.includes(a.who))delete a.who; // a label from the list, never text from the file
|
||||
a.sla=Array.isArray(a.sla)?a.sla.filter(x=>typeof x==='string').slice(0,s.biz.length):[];
|
||||
if(!a.entry||typeof a.entry!=='object'||!['t','ix','p','edge'].includes(a.entry.k))a.entry={k:'edge',lab:''};else{a.entry.lab=String(a.entry.lab||'').slice(0,60);a.entry.id=a.entry.id==null?undefined:String(a.entry.id).slice(0,40);}return a;};
|
||||
const attacks=[s.ev.ddos,...(Array.isArray(s.ev.ddosMore)?s.ev.ddosMore:[])].map(repairAttack).filter(Boolean).slice(0,14);
|
||||
if(attacks.length)s.ev.ddos=attacks[0];else delete s.ev.ddos;s.ev.ddosMore=attacks.slice(1);
|
||||
s.ddosStarts=(Array.isArray(s.ddosStarts)?s.ddosStarts:attacks.map(a=>a.start)).filter(d=>typeof d==='number'||typeof d==='string').map(Number).filter(d=>Number.isFinite(d)&&d>s.day-7&&d<=s.day).sort((a,b)=>a-b).slice(-14);
|
||||
s.auV=s.auV===1?1:0;if(s.auNews!==true)delete s.auNews;
|
||||
// Badges: S.ach[id] is the day it was earned (any save); S.achP[id] the variant (2.0). A missing variant is the standard one.
|
||||
for(const k of Object.keys(s.ach))s.ach[k]=num(s.ach[k],0);
|
||||
{const p=s.achP&&typeof s.achP==='object'&&!Array.isArray(s.achP)?s.achP:{};s.achP={};for(const k of Object.keys(s.ach))s.achP[k]=typeof p[k]==='string'&&own(BVAR,p[k])?p[k]:'oncall';}
|
||||
if(s.merged){const o={};if(typeof s.merged==='object')for(const m of MERGERS)if(isFinite(s.merged[m.id]))o[m.id]=+s.merged[m.id];s.merged=Object.keys(o).length?o:undefined;}
|
||||
/* The rules (2.0) follow from the mode, as the doors set them, and nothing else: a save without them is the classic
|
||||
game, On-call. Scenarios and the weekly run on On-call; a sandbox keeps only its chaos; a Normal game one of the
|
||||
three Normal presets, unchanged (its validated mods kept). So an edited or imported save cannot stop the clock or print money. */
|
||||
{const r=s.rules&&typeof s.rules==='object'&&!Array.isArray(s.rules)?s.rules:{};
|
||||
const m={mods:r.mods};s.rules=s.scn&&typeof s.scn==='object'?makeRules('oncall',m):s.mode==='sandbox'?makeRules('sandbox',{...m,chaos:r.chaos}):makeRules(NORMAL_PRESETS.includes(r.preset)?r.preset:'oncall',m);}
|
||||
specSanitize(s);
|
||||
if(s.te){if(typeof s.te!=='object')s.te=null;else{s.te.on=!!s.te.on;s.te.script=typeof s.te.script==='string'?s.te.script.slice(0,4000):'';}}
|
||||
return s;}
|
||||
function migrate(s){sanitize(s);
|
||||
// Older saves have one contract per broker sale: fold a carrier's alien waves on one fiber into one contract.
|
||||
{const one=new Map();s.biz=s.biz.filter(b=>{if(b.type!=='wwave')return true;const k=b.link+'|'+b.name,a=one.get(k);if(!a){one.set(k,b);return true;}
|
||||
a.slots=(a.slots||0)+(b.slots||0);a.rate=(a.rate||0)+(b.rate||0);a.since=Math.min(a.since??0,b.since??0);a.mood=Math.min(a.mood??100,b.mood??100);a.folded=true;return false;});
|
||||
for(const a of one.values())if(a.folded){delete a.folded;const l=s.links.find(x=>x.id===a.link);if(l)a.what=wwWhat(l,a.slots);}}if(s.scn&&s.scn.id==='stg'&&s.scn.rules&&typeof s.scn.rules==='object')s.scn.rules.local=true;for(const b of [...s.biz,...s.offers])if(Array.isArray(b.reqs))b.reqs=b.reqs.filter(k=>!REQS[k]||!REQS[k].can||(isCity(b.city)&&(!b.city2||isCity(b.city2))&&REQS[k].can(b,s)));if(s.ltv!==2){for(const l of s.links)if(l.kind==='wave'&&l.tier>=3)l.tier=Math.min(LT.length-1,l.tier+1);s.ltv=2;}if(s.dk){s.dk.m=s.dk.m||{};s.dk.add=s.dk.add||{};s.dk.ret=s.dk.ret||{};s.dk.retUsed=s.dk.retUsed||{};}s.hist=s.hist||[];s.loans=s.loans||[];s.loanOffers=s.loanOffers||[];s.loanStrikes=s.loanStrikes||0;for(const l of s.links||[])if(!l.kind)l.kind='wave';
|
||||
for(const a of one.values())if(a.folded){delete a.folded;const l=s.links.find(x=>x.id===a.link);if(l)a.what=wwWhat(l,a.slots);}}if(s.scn&&s.scn.id==='stg'&&s.scn.rules&&typeof s.scn.rules==='object')s.scn.rules.local=true;if(s.scn&&s.scn.id==='gangnam'&&s.scn.rules&&typeof s.scn.rules==='object')s.scn.rules.sender=true;
|
||||
// A published weekly scenario keeps its file in the save: checked again here; a bad one plays on as the in-browser weekly.
|
||||
if(s.scn&&typeof s.scn==='object'&&s.scn.wk!==undefined){const d=wsValid(s.scn.wk,s.scn.key);if(d){s.scn.wk=d;s.scn.home=d.city;s.scn.run=Number.isInteger(s.scn.run)&&s.scn.run>=0?s.scn.run:0;}else{delete s.scn.wk;delete s.scn.home;delete s.scn.run;}}
|
||||
for(const b of [...s.biz,...s.offers])if(Array.isArray(b.reqs))b.reqs=b.reqs.filter(k=>!REQS[k]||!REQS[k].can||(isCity(b.city)&&(!b.city2||isCity(b.city2))&&REQS[k].can(b,s)));if(s.ltv!==2){for(const l of s.links)if(l.kind==='wave'&&l.tier>=3)l.tier=Math.min(LT.length-1,l.tier+1);s.ltv=2;}if(s.dk){s.dk.m=s.dk.m||{};s.dk.add=s.dk.add||{};s.dk.ret=s.dk.ret||{};s.dk.retUsed=s.dk.retUsed||{};}s.hist=s.hist||[];s.loans=s.loans||[];s.loanOffers=s.loanOffers||[];s.loanStrikes=s.loanStrikes||0;for(const l of s.links||[])if(!l.kind)l.kind='wave';
|
||||
for(const c in s.pops){const p=s.pops[c];if(p.rgen===undefined){let g=0;const need=(i,key)=>{const k=RG.findIndex(r=>r[key]>=i);if(k>g)g=k;};
|
||||
for(const l of s.links||[])if((l.a===c||l.b===c)&&l.kind==='wave')need(l.tier,'maxLT');
|
||||
for(const t of s.transit||[])if(t.city===c)need(t.tier,'maxP');for(const x of s.pni||[])if(x.city===c)need(x.tier,'maxP');if(s.ixp&&s.ixp[c]!==undefined)need(s.ixp[c],'maxP');p.rgen=g;}}for(const b of s.biz||[])if(!b.reqs)b.reqs=BIZ_T[b.type]&&BIZ_T[b.type].div?['diverse']:[];for(const o of s.offers||[])if(!o.reqs)o.reqs=[];if(!s.lvl)s.lvl=1;s.nni=s.nni||[];s.cnLic=s.cnLic||{state:'none'};s.ev=s.ev||{};for(const l of s.links){if(!l.kind)l.kind='wave';if(l.mo===undefined)l.mo=Math.round(waveMo(l.km,l.sub,l.tier)*(l.mult||1));}for(const c in s.pops){if(!s.pops[c].routers)s.pops[c].routers=1;}
|
||||
|
|
|
|||
|
|
@ -37,20 +37,31 @@ function diversityPossible(a,b,state=S){
|
|||
if(!CITY[a]||!CITY[b]||a===b)return false;
|
||||
const rules=state.scn&&state.scn.rules||{},key=JSON.stringify([!!state.won,rules]);
|
||||
if(!diversityMap||diversityMap.key!==key){
|
||||
const links=[],cities=CITIES.filter(c=>!(rules.banCities||[]).includes(c.id)).map(c=>c.id);
|
||||
const add=(a,b,id)=>links.push({a,b,id});
|
||||
for(let i=0;i<cities.length;i++)for(let j=i+1;j<cities.length;j++){
|
||||
const a=cities[i],b=cities[j];
|
||||
if(!isSub(a,b)){add(a,b,'land:'+a+':'+b+':1');add(a,b,'land:'+a+':'+b+':2');}
|
||||
for(const c of cablesFor(a,b))if(!(rules.banPairs||[]).some(p=>p===c.cid+':'+a+'-'+b||p===c.cid+':'+b+'-'+a))add(a,b,'cab:'+c.cid);
|
||||
if(state.won&&seaCab(a,b)&&landing(a)&&landing(b)&&!cnCity(a)&&!cnCity(b))add(a,b,'own:'+a+':'+b);
|
||||
for(const f of FABS)if(f.cities.includes(a)&&f.cities.includes(b))add(a,b,'fab:'+f.id);
|
||||
/* Built once per ruleset, over every city pair, so it runs on the first load of every save: on city indices, with
|
||||
the cables between each pair from a table. A link is the number of its risk: each land trench and your own cable
|
||||
on its own, every segment of one cable (or one fabric) the same; adj[i] lists [neighbour, risk] in the order the
|
||||
links were added, as a graph built from a list of them would. */
|
||||
const cities=CITIES.filter(c=>!(rules.banCities||[]).includes(c.id)).map(c=>c.id),N=cities.length,ix=new Map(cities.map((c,i)=>[c,i]));
|
||||
const cab=new Map();for(const c of CABLE_PAIRS){const k=c.a<c.b?c.a+'|'+c.b:c.b+'|'+c.a;let L=cab.get(k);if(!L)cab.set(k,L=[]);L.push(c);}
|
||||
const LS=cities.map(c=>lands(CITY[c])),land=cities.map(landing),cn=cities.map(cnCity),fab=cities.map(c=>FABS.filter(f=>f.cities.includes(c))),ban=rules.banPairs||[];
|
||||
const adj=cities.map(()=>[]),grp=new Map();let n=0,k=0;const add=(i,j,g)=>{let r;if(g===undefined)r=k++;else{r=grp.get(g);if(r===undefined)grp.set(g,r=k++);}adj[i].push(j,r);adj[j].push(i,r);n++;};
|
||||
for(let i=0;i<N;i++)for(let j=i+1;j<N;j++){
|
||||
const a=cities[i],b=cities[j],cs=cab.get(a<b?a+'|'+b:b+'|'+a),sub=!LS[i].some(x=>LS[j].includes(x));
|
||||
if(!sub){add(i,j);add(i,j);}
|
||||
if(cs)for(const c of cs)if(!ban.some(p=>p===c.cid+':'+a+'-'+b||p===c.cid+':'+b+'-'+a))add(i,j,'cab:'+c.cid);
|
||||
if(state.won&&land[i]&&land[j]&&(sub||cs)&&!cn[i]&&!cn[j])add(i,j);
|
||||
if(fab[i].length&&fab[j].length)for(const f of FABS)if(fab[i].includes(f)&&fab[j].includes(f))add(i,j,'fab:'+f.id);
|
||||
}
|
||||
diversityMap={key,links,answers:{}};
|
||||
diversityMap={key,ix,adj,links:n,answers:{}};
|
||||
}
|
||||
const pair=[a,b].sort().join(':');
|
||||
return diversityMap.answers[pair]??(diversityMap.answers[pair]=disjointRoutes(a,b,diversityMap.links));
|
||||
const pair=[a,b].sort().join(':'),M=diversityMap;
|
||||
return M.answers[pair]??(M.answers[pair]=M.ix.has(a)&&M.ix.has(b)&&disjointOn(M.adj,M.ix.get(a),M.ix.get(b)));
|
||||
}
|
||||
// disjointRoutes() on such a graph: a shortest path by hops, then another one that shares none of its risks.
|
||||
function disjointOn(adj,a,b){const N=adj.length,bfs=skip=>{const prev=new Int32Array(N).fill(-1),pl=new Int32Array(N),q=[a];prev[a]=a;
|
||||
for(let h=0;h<q.length;h++){const u=q[h];if(u===b)break;const L=adj[u];for(let k=0;k<L.length;k+=2){const v=L[k];if(prev[v]<0&&!(skip&&skip.has(L[k+1]))){prev[v]=u;pl[v]=L[k+1];q.push(v);}}}
|
||||
if(prev[b]<0)return null;const used=new Set();for(let v=b;v!==a;v=prev[v])used.add(pl[v]);return used;};
|
||||
const p1=bfs(null);return !!p1&&!!bfs(p1);}
|
||||
// Big networks have thousands of links and customers: callers that ask about all of them (compute(), the daily mood
|
||||
// check, new offers) look links up and add up what is sold in one pass (linkIds(), fiberUse()), not once per item.
|
||||
const linkIds=()=>{const m=new Map();for(const l of S.links)if(!m.has(l.id))m.set(l.id,l);return m;};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ function bizSfOf(r,c){const d=r.bizDem&&r.bizDem[c];return teRules()&&teRules().
|
|||
function bCities(o){return o.sites?o.sites.slice():[o.city,o.city2].filter(Boolean);}
|
||||
function bHas(o){return !!BIZ_T[o.type].cap||bCities(o).every(c=>S.pops[c]);}
|
||||
function eventLive(b){return BIZ_T[b.type].event&&S.day>=b.start&&S.day<b.start+b.dur;}
|
||||
function bRisk(b){return BIZ_T[b.type]?.gaming?`<div class="meta">⚠️ ${tr('customers_and_events.gaming_attracts_attacks')}</div>`:'';}
|
||||
function bTerms(o){const T=BIZ_T[o.type];if(T.cap)return capTerms(o);
|
||||
if(T.event){const live=S.day>=o.start;return tr('customers_and_events.bw_extra_for_d_days_when',{bw:fmtG(o.bw),d:o.dur,when:live?tr('customers_and_events.day_n_of_d',{n:S.day-o.start+1,d:o.dur}):tr('customers_and_events.starting_in_n_d',{n:o.start-S.day}),fee:fmt$(o.fee)});}
|
||||
if(T.sdwan)return tr('customers_and_events.n_sites_list_bw_per_site',{n:o.sites.length,list:o.sites.map(c=>CITY[c].name).join(', '),bw:fmtG(o.bw),price:fmt$(o.bw*o.rate)});
|
||||
|
|
@ -30,15 +31,15 @@ function spawnMega(t,T,nm,mine){
|
|||
if(t==='pairs'){const ls=S.links.filter(l=>l.kind==='df'&&l.own&&l.ready<=S.day&&!S.biz.some(b=>(b.type==='pairs'||b.type==='dfpair')&&b.link===l.id)&&!S.offers.some(o=>o.link===l.id));if(!ls.length)return;const l=pick(ls),n=100+50*Math.floor(Math.random()*7);
|
||||
S.offers.push({id:uid(),city:l.a,city2:l.b,link:l.id,what:tr('customers_and_events.n_fiber_pairs_in_your_a',{n,a:CITY[l.a].name,b:CITY[l.b].name}),name:nm(),type:t,bw:1,rate:Math.round(dfLeaseMo(l.km)*n*0.2),reqs:[],exp:S.day+30,mega:true});}
|
||||
}
|
||||
function spawnSpecial(t){const T=BIZ_T[t],mine=Object.keys(S.pops),lv=S.lvl||1;
|
||||
function spawnSpecial(t){const T=BIZ_T[t],mine=Object.keys(S.pops),lv=lvl();
|
||||
const nm=()=>{const list=T.names.filter(n=>!S.usedNames.includes(n));const n=list.length?pick(list):pick(T.names);useName(n);return n;};
|
||||
if(T.mega){spawnMega(t,T,nm,mine);return;}
|
||||
if(T.event){const city=Math.random()<0.85&&mine.length?pick(mine):pick(OFFC);const bw=pick(T.opts.slice(0,Math.min(T.opts.length,lv+2)));const dur=3+Math.floor(Math.random()*5),start=S.day+12+Math.floor(Math.random()*14);
|
||||
S.offers.push({id:uid(),city,city2:null,name:tr('customers_and_events.name_in_city',{name:nm(),city:CITY[city].name}),type:t,bw,rate:0,reqs:[],start,dur,fee:Math.round(bw*dur*70),exp:start-2});return;}
|
||||
if(T.sdwan){const hub=pick(mine),n=3+Math.floor(Math.random()*4),pool=(Math.random()<0.85?mine:OFFC).filter(c=>c!==hub),sites=[hub];
|
||||
while(sites.length<n&&pool.length)sites.push(pool.splice(Math.floor(Math.random()*pool.length),1)[0]);if(sites.length<3)return;
|
||||
S.offers.push({id:uid(),city:hub,city2:null,sites,name:nm(),type:t,bw:pick(T.opts),rate:700*sites.length,reqs:[],exp:S.day+40});return;}
|
||||
S.offers.push({id:uid(),city:hub,city2:null,sites,name:nm(),type:t,bw:pick(T.opts),rate:(T.siteRate||700)*sites.length,reqs:[],exp:S.day+40});return;}
|
||||
const ready=S.links.filter(l=>l.kind==='df'&&l.ready<=S.day);
|
||||
if(t==='wwave'){const u=fiberUse(),ls=ready.filter(l=>freeCh(l,u)>=1&&!S.offers.some(o=>o.link===l.id));if(!ls.length)return;S.offers.push(fiberOffer(t,pick(ls),nm));return;}
|
||||
if(t==='dfpair'){const u=fiberUse(),ls=ready.filter(l=>pairFree(l,u)&&!S.offers.some(o=>o.link===l.id));if(!ls.length)return;S.offers.push(fiberOffer(t,pick(ls),nm));}
|
||||
if(t==='wwave'){const u=fiberUse(),ls=ready.filter(l=>freeCh(l,u)>=1&&brFree(l)>=1&&!S.offers.some(o=>o.link===l.id));if(!ls.length)return;S.offers.push(fiberOffer(t,pick(ls),nm));return;}
|
||||
if(t==='dfpair'){const u=fiberUse(),ls=ready.filter(l=>pairFree(l,u)&&brFree(l)>=BR_PAIR&&!S.offers.some(o=>o.link===l.id));if(!ls.length)return;S.offers.push(fiberOffer(t,pick(ls),nm));}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,25 @@
|
|||
function cnOk(){return S.cnLic&&S.cnLic.state==='ok';}
|
||||
function regionMult(c){const C=CITY[c];if(!C||C.cn)return 1;if(C.kr)return KR_TRANSIT;if(C.au)return AU_TRANSIT;if(C.tape)return 1.5;return C.reg==='AS'?2.5:C.reg==='AF'?2:C.reg==='OC'?1.8:C.reg==='SA'?1.6:1;}
|
||||
// Few networks in the building means few transit sellers to haggle with: up to 1.8× where almost nobody is present.
|
||||
// Hand-set markets (Korea, Australia, Belgian red tape) keep their own price.
|
||||
const txComp=c=>{const q=CITY_PDB[c];return q?clamp((1000/Math.max(q[1],10))**0.15,1,1.8):1;};
|
||||
// No neutral data center means building your own room: POPs cost more to build and to run.
|
||||
const colo=c=>{const q=CITY_PDB[c];return !q?1:q[0]===0?1.5:q[0]<=2?1.25:1;};
|
||||
const popMo=c=>Math.round(POP_MO*colo(c));
|
||||
function regionMult(c){const C=CITY[c];if(!C||C.cn)return 1;if(C.kr)return KR_TRANSIT;if(C.au)return AU_TRANSIT;if(C.tape)return 1.5;const base=C.reg==='AS'?2.5:C.reg==='AF'?2:C.reg==='OC'?1.8:C.reg==='SA'?1.6:1;return Math.round(base*txComp(c)*10)/10;}
|
||||
// A network's own markup on top of that, where it is far from home (Glowball Sakura Lager in Asia and New Zealand).
|
||||
// What a home pays, against the usual bill.
|
||||
const arpuOf=c=>CITY[c].arpu||(CITY[c].kr&&scnRule('sender')?KR_ARPU:1);
|
||||
const netMult=(n,c)=>regionMult(c)*((n&&n.far&&CITY[c]&&n.far[CITY[c].reg])||1);
|
||||
const uaePair=(a,b)=>!!CITY[a].uae&&!!CITY[b].uae;
|
||||
const rainPair=(a,b)=>!!(CITY[a].rain||CITY[b].rain);
|
||||
const borderPair=(a,b)=>!!CITY[a].cc&&!!CITY[b].cc&&CITY[a].cc!==CITY[b].cc;
|
||||
// Every city has a country (cc), but the border toll is Africa's: elsewhere a wave crosses borders at the plain price.
|
||||
const borderPair=(a,b)=>CITY[a].reg==='AF'&&CITY[b].reg==='AF'&&CITY[a].cc!==CITY[b].cc;
|
||||
// Perth to the east coast: the sea route round the south coast is domestic (AU_WAVE.ew), and the Nullarbor
|
||||
// fiber costs a little more again because the incumbents own it.
|
||||
const NULLARBOR=1.7,nullPair=(a,b)=>!!CITY[a].au&&!!CITY[b].au&&(a==='per')!==(b==='per');
|
||||
const andesPair=(a,b)=>!!CITY[a].andes&&!!CITY[b].andes&&CITY[a].andes!==CITY[b].andes;
|
||||
// A pair an anchor-prone cable serves (the Baltic): the map calls it overland, but the fibre lies on the seabed (Anchors Away).
|
||||
let ANCHOR_P=null;const anchorPair=l=>(ANCHOR_P||(ANCHOR_P=new Set(CABLE_PAIRS.filter(p=>CAB[p.cid]&&CAB[p.cid].anchor).map(p=>edgeKey(p))))).has(edgeKey(l));
|
||||
/* Overland between continents (Europe to the Middle East and Asia) crosses a dozen borders and as many
|
||||
carriers, each taking a cut: in real life it costs ten times the subsea route or more (#40). */
|
||||
const LAND_X=45,landX=(a,b)=>!isSub(a,b)&&CITY[a].reg!==CITY[b].reg;
|
||||
|
|
@ -38,4 +49,4 @@ function waveRoute(a,b,mult,border){const cabs=cablesOk(a,b),sub=isSub(a,b);let
|
|||
function viaSeg(a,b){const cabs=cablesOk(a,b),sub=isSub(a,b);if(!cabs.length)return landMult(a,b)>1?`<p class="note">${landWhy(a,b)}</p>`:'';const wr=waveRoute(a,b,1,false);
|
||||
const opts=(sub?[]:[{v:'land',l:`${tr('common.overland')} <small>${landMult(a,b)>1?landMult(a,b)+'× · ':''}${(kmBetween(a,b)*1.3/200).toFixed(1)} ms</small>`}]).concat(cabs.map(c=>({v:c.cid,l:`${esc(CAB[c.cid].name)} <small>${CAB[c.cid].price}× · ${(c.km*(CAB[c.cid].lat||1)/200).toFixed(1)} ms${CAB[c.cid].age==='old'?' · '+tr('geography_and_latency.old_cuts_often'):''}</small>`})));
|
||||
return `<h4 class="sub4">${tr('common.route')}</h4><div class="seg">${opts.map(o=>btn(o.l,'via',{v:o.v},wr&&wr.via===o.v?'pink':'ghost')).join('')}</div>${wr&&wr.cab?`<p class="note">${esc(CAB[wr.cab].blurb)} ${tr('geography_and_latency.all_your_waves_on_one_cable')}</p>`:''}`;}
|
||||
function bestLat(a,b){const ls=S.links.filter(l=>!linkDown(l));const dist={[a]:0},done=new Set();for(;;){let u=null,ud=Infinity;for(const k in dist)if(!done.has(k)&&dist[k]<ud){u=k;ud=dist[k];}if(u===null)break;if(u===b)return ud;done.add(u);for(const l of ls){if(l.a!==u&&l.b!==u)continue;const v=l.a===u?l.b:l.a,nd=ud+linkLat(l)+0.05;if(nd<(dist[v]??Infinity))dist[v]=nd;}}return Infinity;}
|
||||
function bestLat(a,b,f){const ls=S.links.filter(l=>!linkDown(l)&&(!f||f(l)));const dist={[a]:0},done=new Set();for(;;){let u=null,ud=Infinity;for(const k in dist)if(!done.has(k)&&dist[k]<ud){u=k;ud=dist[k];}if(u===null)break;if(u===b)return ud;done.add(u);for(const l of ls){if(l.a!==u&&l.b!==u)continue;const v=l.a===u?l.b:l.a,nd=ud+linkLat(l)+0.05;if(nd<(dist[v]??Infinity))dist[v]=nd;}}return Infinity;}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const RT={normal:tr('common.follow_metrics'),fast:tr('common.lowest_latency'),scenic:tr('sites_and_service.scenic_quietest_links')};
|
||||
function routeCtl(b){const lt=R.l2lat[b.id];return `<div class="btns"><span class="meta" style="align-self:center">${tr('common.route_4a2e')}</span>${Object.keys(RT).map(m=>btn(RT[m],'setRoute',{id:b.id,m},(b.route||'normal')===m?'pink sm':'ghost sm')).join('')}</div><div class="meta">${tr('sites_and_service.path_latency_lat',{lat:lt!==undefined&&isFinite(lt)?tr('common.ms_ms_one_way',{ms:lt.toFixed(1)}):tr('sites_and_service.no_path_right_now')})}${b.route==='scenic'&&R.l2split&&R.l2split[b.id]?' · '+tr('sites_and_service.split_over_two_equally_quiet_paths'):''}${b.latMax?' · '+tr('sites_and_service.budget_ms_ms',{ms:b.latMax}):''}</div>`;}
|
||||
function nodeCap(c){const p=S.pops[c];if(!p)return Infinity;const eff=(p.routers||1)-(p.rdown>S.day?1:0);return RG[p.rgen||0].cap*Math.max(1,eff)*(p.hot>S.day?(p.site2?0.75:0.5):1)*(p.site2&&(siteDown(c,'a')||siteDown(c,'b'))?0.5:1);}
|
||||
function nodeCap(c){const p=S.pops[c];if(!p)return Infinity;const eff=(p.routers||1)-(p.rdown>S.day?1:0);return RG[p.rgen||0].cap*coreCpu(c)*Math.max(1,eff)*(p.hot>S.day?(p.site2?0.75:0.5):1)*(p.site2&&(siteDown(c,'a')||siteDown(c,'b'))?0.5:1);}
|
||||
// With a second site, one building can be dark (or cut off by a ring cut) while the other carries on.
|
||||
function siteDown(c,s){const p=S.pops[c];if(!p||!p.site2)return false;if(S.inc.some(i=>i.type==='site'&&i.ref===c&&i.site===s&&i.until>S.day))return true;return s==='b'&&p.ringcut>S.day;}
|
||||
// Ports can live in site A, site B, or be split across both ('ab'): a LAG with members in each
|
||||
|
|
@ -15,12 +15,13 @@ function portOk(c,i){const p=S.pops[c];return i<=RG[p?(p.rgen||0):0].maxP;}
|
|||
function waveOk(a,b,i){return [a,b].every(c=>i<=RG[S.pops[c]?(S.pops[c].rgen||0):0].maxLT);}
|
||||
function waveNeed(i){const g=RG.find(r=>r.maxLT>=i);return g?tr('sites_and_service.pn_routers',{pn:g.pn}):'?';}
|
||||
function routerModels(c){const p=S.pops[c],g=p.rgen||0,rt=p.routers||1;
|
||||
return `<div style="margin-top:6px">${RG.map((M,i)=>{if(i===g)return '';const why=modelFits(c,i),lk=M.lvl>lvl();
|
||||
return `<div class="row"><span class="logo" style="--c:${M.badge?'#2C7A7B':'#FF4F9A'}">${M.badge||'R'+(M.cls+1)}</span><div class="grow"><div class="nm">${esc(M.n)} <span class="meta">${M.pn} · ${tr('sites_and_service.n_ports',{n:M.ports})} · ${fmtG(M.cap)} · ${tr('sites_and_service.boots_in_n_min',{n:M.boot})}${M.flaky?' · '+tr('common.crashes_more'):''}</span></div><div class="meta">${esc(M.blurb)}</div>${why?`<div class="why">${esc(why)}</div>`:''}</div>${btn(lk?tr('sites_and_service.level_n',{n:M.lvl}):tr('sites_and_service.swap_cost_mo_mo',{cost:fmt$(swapCost(c,i)),mo:fmt$(M.mo*rt)}),'upRouter',{city:c,g:i},'sm',lk||!!why||S.cash<swapCost(c,i)||p.rupDay===S.day)}</div>`;}).join('')}</div>`;}
|
||||
return `<div style="margin-top:6px">${RG.map((M,i)=>{if(i===g)return '';const why=modelFits(c,i),lk=!techOk('rg',i,M.lvl);
|
||||
return `<div class="row"><span class="logo" style="--c:${M.badge?'#2C7A7B':'#FF4F9A'}">${M.badge||'R'+(M.cls+1)}</span><div class="grow"><div class="nm">${esc(M.n)} <span class="meta">${M.pn} · ${tr('sites_and_service.n_ports',{n:M.ports})} · ${fmtG(M.cap)} · ${tr('sites_and_service.boots_in_n_min',{n:M.boot})}${M.flaky?' · '+tr('common.crashes_more'):''}</span></div><div class="meta">${esc(M.blurb)}</div><div class="meta">${coreMeta(i)}${coreOn()&&coreRun()>0&&!rgCore(i,coreRun())?' · <b style="color:var(--bad)">'+tr('core.can_t_run_your_lv',{lv:tr(CORE_LV[coreRun()])})+'</b>':''}</div>${why?`<div class="why">${esc(why)}</div>`:''}</div>${lk?demoBtn('rg',i,M.lvl,tr('sites_and_service.level_n',{n:M.lvl}),'sm'):btn(tr('sites_and_service.swap_cost_mo_mo',{cost:fmt$(swapCost(c,i)),mo:fmt$(M.mo*rt)}),'upRouter',{city:c,g:i},'sm',!!why||S.cash<swapCost(c,i)||p.rupDay===S.day)}</div>`;}).join('')}</div>`;}
|
||||
function portNote(c){const p=S.pops[c];if(!p)return '';const g=p.rgen||0;return RG[g].maxP<PORT.length-1?`<p class="note" style="margin-top:0">${tr('sites_and_service.your_model_here_tops_out_at',{model:esc(RG[g].n),pn:RG[g].pn})}</p>`:'';}
|
||||
// Service: what you deliver, times how it feels. Traffic backhauled far to transit is slow, and users notice.
|
||||
const latSlow=c=>!!(R&&R.latF&&R.latF[c]<0.97&&R.latFar[c]);
|
||||
function latNote(c){if(!latSlow(c))return '';const f=R.latFar[c];return `<div class="latwarn">🐢 ${tr('sites_and_service.p_of_city_s_traffic_is',{p:pct(Math.min(1,f.share)),city:esc(CITY[c].name),to:esc(CITY[f.to].name),ms:Math.round(f.ms)})}</div>`;}
|
||||
function latNote(c){if(!latSlow(c))return '';const f=R.latFar[c];const v={p:pct(Math.min(1,f.share)),city:esc(CITY[c].name),to:esc(CITY[f.to].name),ms:Math.round(f.ms)};return `<div class="latwarn">🐢 ${CITY[c].kr&&scnRule('sender')?tr('sites_and_service.p_of_city_s_traffic_comes_from_kr',v):tr('sites_and_service.p_of_city_s_traffic_is',v)}</div>`;}
|
||||
const LAT_OK=20,LAT_BAD=50,latLoss=rtt=>rtt<=LAT_OK?0:rtt<=LAT_BAD?0.2*(rtt-LAT_OK)/(LAT_BAD-LAT_OK):0.5;
|
||||
const krLatLoss=rtt=>rtt<=KR_LAT_OK?0:rtt<=KR_LAT_BAD?0.25*(rtt-KR_LAT_OK)/(KR_LAT_BAD-KR_LAT_OK):0.5;
|
||||
function sfOf(r,c){const d=r.cityDem[c]||0;return d<=1e-6?1:clamp(r.citySrv[c]/d,0,1)*((r.latF&&r.latF[c])??1);}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ---------- failures & events ---------- */
|
||||
// A few badges read the incident text: callers whose message mentions a shark, anchor, crocodile or llama pass its English as en.
|
||||
function addInc(o,en=o.msg||''){if(S.loans&&S.loans.some(l=>(l.covs||[]).includes('pizza'))){S.cash-=COVS.pizza.each;S.stats.pizza=(S.stats.pizza||0)+1;}o.id=uid();o.start=S.day;S.inc.push(o);S.stats.incidents++;S.stats.by=S.stats.by||{};S.stats.by[o.type]=(S.stats.by[o.type]||0)+1;if(/shark/i.test(en))S.stats.sharks=(S.stats.sharks||0)+1;const f=S.stats.f=S.stats.f||{};if(/anchor/i.test(en))f.anchor=1;if(/crocodile/i.test(en))f.croc=1;if(/beaver/i.test(en))f.beaver=1;if(/llama/i.test(en))f.llama=1;}
|
||||
function addInc(o,en=o.msg||''){if(S.loans&&S.loans.some(l=>(l.covs||[]).includes('pizza'))){S.cash-=COVS.pizza.each;S.stats.pizza=(S.stats.pizza||0)+1;}o.id=uid();o.start=S.day;S.inc.push(o);S.stats.incidents++;S.stats.by=S.stats.by||{};S.stats.by[o.type]=(S.stats.by[o.type]||0)+1;if(/shark/i.test(en))S.stats.sharks=(S.stats.sharks||0)+1;const f=S.stats.f=S.stats.f||{};if(/anchor/i.test(en))f.anchor=1;if(/crocodile/i.test(en))f.croc=1;if(/beaver/i.test(en))f.beaver=1;if(/llama/i.test(en))f.llama=1;if(S.rules&&S.rules.chaos==='spicy')stretchInc(o);}
|
||||
const HARMLESS=[
|
||||
[tr('common.certificate_expired'),tr('incidents_and_ddos.the_tls_certificate_on_your_noc')],
|
||||
[tr('incidents_and_ddos.it_was_dns'),tr('incidents_and_ddos.someone_deleted_the_dns_record_for')],
|
||||
|
|
@ -24,59 +24,73 @@ const HARMLESS=[
|
|||
function lagsN(){const o=[];for(const t of S.transit)if((t.n||1)>=2&&!(t.down>S.day))o.push({k:'t',id:t.id,o:t,n:t.n,lab:tr('incidents_and_ddos.name_transit_lag_in_city',{name:NET[t.net].name,city:CITY[t.city].name})});
|
||||
for(const p of S.pni)if((p.n||1)>=2)o.push({k:'p',id:p.id,o:p,n:p.n,lab:tr('incidents_and_ddos.pni_lag_with_name_in_city',{name:NET[p.net].name,city:CITY[p.city].name})});
|
||||
for(const x in S.ixp){const n=(S.ixn||{})[x]||1;if(n>=2&&!S.myIx[x])o.push({k:'ix',id:x,n,lab:ixNamesCity(x)?tr('incidents_and_ddos.ix_lag',{ix:ixName(x)}):tr('incidents_and_ddos.ix_lag_in_city',{ix:ixName(x),city:CITY[ixCity(x)].name})});}return o;}
|
||||
// Several attacks can be live at once: the primary slot keeps older saves compatible, the rest overlap it.
|
||||
function ddosAll(s=S,live=true){return [s.ev.ddos,...(s.ev.ddosMore||[])].filter(a=>a&&(!live||a.until>s.day));}
|
||||
const ddosFind=id=>ddosAll().find(a=>id===undefined||a.id===id);
|
||||
function ddosDrop(a){const left=ddosAll(S,false).filter(x=>x!==a);S.ev.ddos=left[0]||null;S.ev.ddosMore=left.slice(1);}
|
||||
function ddosExpire(){for(const a of ddosAll(S,false))if(a.until<=S.day||!S.pops[a.city]){ddosDone(a);ddosDrop(a);}}
|
||||
// An attack is held or lost at its victim: the junk lands there, and other POPs' bad days are not the attacker's doing.
|
||||
// A city with nobody to serve holds only if its tools soak up the flood (or there is nothing to judge but that).
|
||||
const ddosSf=a=>((R.cityDem||{})[a.city]||0)>1e-6||!a.gbps?sfOf(R,a.city):clamp(1-ddosReport(a).leak/a.gbps,0,1);
|
||||
function ddosReport(a){return (R.ddos||[]).find(m=>m.attack===a)||ddosMitigation(a);}
|
||||
// Where the junk comes in: one of the city's live uplinks, or just "the edge" if it has none yet.
|
||||
function ddosEntry(c){const o=[];
|
||||
for(const t of S.transit)if(t.city===c&&!(t.down>S.day))o.push({k:'t',id:t.id,lab:tr('common.net_transit',{net:NET[t.net].name})});
|
||||
for(const x of ixIdsIn(c))if(S.ixp[x]!==undefined)o.push({k:'ix',id:x,lab:tr('common.ix_peering',{ix:ixName(x)})});
|
||||
for(const p of S.pni)if(p.city===c)o.push({k:'p',id:p.id,lab:tr('common.pni_with_net',{net:NET[p.net].name})});
|
||||
return o.length?pick(o):{k:'edge',lab:''};}
|
||||
// Flowspec capability of the router in a city: 0 none, 1 basic, 2 full. The flood is filtered where the
|
||||
// victim POP's own router has the TCAM for it.
|
||||
// Flowspec capability of a POP's router: 0 none, 1 basic, 2 full.
|
||||
const fsAt=c=>{const p=S.pops[c];return p?(RG[p.rgen||0].fs||0):0;};
|
||||
// Scrubbing residual for an attack: clean up to the center's capacity (to 15%), overflow leaks. On-demand
|
||||
// Scrubbing removes attack traffic up to the center's capacity; overflow leaks. On-demand
|
||||
// does nothing for the first couple of days while traffic is being diverted.
|
||||
function scrubEngaged(atk){return hasScrub()&&(S.scrubMode==='always'||(S.day-(atk.start||S.day))>=SCRUB_DELAY);}
|
||||
function scrubEngaged(atk){return hasScrub()&&(S.scrubMode==='always'||(S.day-(atk.start??S.day))>=SCRUB_DELAY);}
|
||||
// Several centers (#117): the flood goes to the nearest working one, and what it cannot take spills to the next.
|
||||
// A center in another city only helps if the backbone can carry the flood there; routing works that out.
|
||||
const scrubFar=c=>{const a=S.ev&&S.ev.ddos;return a&&a.until>S.day&&a.city===c&&(R.haul||[]).find(q=>q.city===c&&q.ms!==null&&q.ms>=SCRUB_FAR_MS)||null;};
|
||||
function scrubPlan(atk){if(!scrubEngaged(atk))return null;const c=atk.city;let g=atk.gbps||0;const parts=[];
|
||||
for(const x of S.scrubs.filter(x=>popUp(x.city)&&(x.city===c||pathExists(c,x.city))).sort((a,b)=>(a.city===c?0:kmBetween(c,a.city))-(b.city===c?0:kmBetween(c,b.city)))){if(g<=0)break;const a=Math.min(g,SCRUB_TIERS[x.tier||0].g);parts.push({city:x.city,tier:x.tier||0,a});g-=a;}
|
||||
const scrubFar=c=>{for(const a of ddosAll())if(a.city===c){const q=(R.haul||[]).find(q=>q.attack===a.id&&q.city===c&&q.ms!==null&&q.ms>=SCRUB_FAR_MS);if(q)return q;}return null;};
|
||||
function scrubPlan(atk,g=atk.gbps||0,room={},take=null){if(!scrubEngaged(atk))return null;const c=atk.city;const parts=[];
|
||||
for(const x of S.scrubs.filter(x=>popUp(x.city)&&(x.city===c||pathExists(c,x.city))).sort((a,b)=>(a.city===c?0:kmBetween(c,a.city))-(b.city===c?0:kmBetween(c,b.city)))){if(g<=0)break;const cap=SCRUB_TIERS[x.tier||0].g,a=Math.min(g,room[x.city]??cap);if(a<=0)continue;const cleaned=take?take(x,a):a;room[x.city]=(room[x.city]??cap)-cleaned;parts.push({city:x.city,tier:x.tier||0,a,cleaned});g-=cleaned;}
|
||||
return parts.length?{parts,leak:g}:null;}
|
||||
// What still lands on the city if every haul gets through: 15% of what is scrubbed, plus whatever no center can take.
|
||||
const scrubIdeal=p=>p?p.parts.reduce((s,x)=>s+x.a*0.15,0)+p.leak:Infinity;
|
||||
// One accounting pipeline for routing and the NOC: upstream -> edge -> scrubbing -> leakage. The junk comes in on one
|
||||
// port of the victim (a.entry) and is filtered by the victim's own router.
|
||||
function ddosMitigation(a,room={},blackhole=a.bh,plan=true){const en=a.entry||{},t=en.k==='t'?S.transit.find(x=>x.id===en.id):null,p=en.k==='p'?S.pni.find(x=>x.id===en.id):null,upstream=!!(t&&t.clean);
|
||||
const reaching=blackhole?0:a.gbps*(upstream?0.1:1);let g=reaching,flowspec=0;
|
||||
if(DDOS_VEC[a.vec]?.fs){g*=FS_RES[fsAt(a.city)];flowspec=reaching-g;}
|
||||
if(a.ixbh&&hasIxAt(a.city))g*=0.5;
|
||||
if(p&&p.sacrif)g=Math.min(g,liveCap(pniG(p),p.city,p.site,p.n)*0.9);
|
||||
if(teRules()?.blackhole&&!blackhole)g=0;
|
||||
const filtered=reaching-g,sp=plan&&g>0?scrubPlan(a,g,room):null;
|
||||
return {attack:a,blackhole,upstream,reaching,flowspec,filtered,sp,leak:sp?sp.leak:g};}
|
||||
// The NOC's live attack view: what is hitting you, what each tool would do about it right now, and the buttons.
|
||||
function ddosPanel(){
|
||||
const a=S&&S.ev&&S.ev.ddos;if(!a||a.until<=S.day||!S.pops[a.city])return '';
|
||||
const V=DDOS_VEC[a.vec]||{n:'?',fs:false},cap=fsAt(a.city),model=RG[(S.pops[a.city].rgen||0)].n,en=a.entry||{};
|
||||
const cleanT=en.k==='t'?S.transit.find(x=>x.id===en.id):null, sacP=en.k==='p'?S.pni.find(x=>x.id===en.id):null;
|
||||
let mult=1;
|
||||
if(V.fs&&cap)mult=Math.min(mult,FS_RES[cap]);
|
||||
if(cleanT&&cleanT.clean)mult=Math.min(mult,0.1);
|
||||
if(a.ixbh&&hasIxAt(a.city))mult=Math.min(mult,0.5);
|
||||
const sp=scrubPlan(a),useS=!!sp&&scrubIdeal(sp)<a.gbps*mult,hl=x=>(R.haul||[]).find(q=>q.city===a.city&&q.to===x.city);
|
||||
let land=a.bh?0:useS?sp.parts.reduce((t,x)=>{const q=x.city===a.city?null:hl(x);return t+x.a*0.15+(q?(q.a-q.h)*0.85:0);},sp.leak):a.gbps*mult;
|
||||
if(sacP&&sacP.sacrif)land=Math.min(land,liveCap(PORT[sacP.tier].g,sacP.city,sacP.site,sacP.n)*0.9);
|
||||
land=Math.round(land);
|
||||
const fsLine=!V.fs?'— '+tr('incidents_and_ddos.flowspec_cannot_catch_an_vec',{vec:esc(V.n)})
|
||||
:cap>=2?'✓ '+tr('incidents_and_ddos.flowspec_on_your_model_is_dropping',{model:esc(model),vec:esc(V.n)})
|
||||
:cap===1?'~ '+tr('incidents_and_ddos.flowspec_on_your_model_trims_vec',{model:esc(model),vec:esc(V.n)})
|
||||
:'— '+tr('incidents_and_ddos.your_model_here_has_no_flowspec',{model:esc(model)});
|
||||
const scrOne=x=>{const T=SCRUB_TIERS[x.tier],q=x.city===a.city?null:hl(x);
|
||||
return q&&q.h<q.a-0.5?'~ '+tr('incidents_and_ddos.your_backbone_can_only_haul_g',{g:fmtG(q.h),city:esc(CITY[x.city].name)})
|
||||
:q&&q.ms!==null?'✓ '+tr('incidents_and_ddos.tier_scrubbing_in_city_is_cleaning',{tier:T.n,city:esc(CITY[x.city].name),ms:Math.round(q.ms)})
|
||||
:'✓ '+tr('incidents_and_ddos.tier_scrubbing_in_city_is_cleaning_a8f6',{tier:T.n,city:esc(CITY[x.city].name)});};
|
||||
function ddosPanel(){return S?ddosAll().filter(a=>S.pops[a.city]).map(ddosOne).join(''):'';}
|
||||
function ddosOne(a){
|
||||
const V=DDOS_VEC[a.vec]||{n:'?',fs:false},en=a.entry||{};
|
||||
const sacP=en.k==='p'?S.pni.find(x=>x.id===en.id):null;
|
||||
const m=ddosReport(a),sp=m.sp,hl=x=>{const qs=(R.haul||[]).filter(q=>q.to===x.city&&q.attack===a.id);return qs.length?{a:qs.reduce((n,q)=>n+q.a,0),h:qs.reduce((n,q)=>n+q.h,0)}:null;};
|
||||
const landLine=m.blackhole?'~ '+tr('incidents_and_ddos.blackholed_the_junk_is_gone_and',{city:esc(CITY[a.city].name)})
|
||||
:m.upstream?'✓ '+tr('incidents_and_ddos.after_upstream_scrubbing_g',{g:fmtG(m.reaching)}):'';
|
||||
const fsLine=!V.fs?'— '+tr('incidents_and_ddos.flowspec_cannot_catch_vec',{vec:esc(V.n)})
|
||||
:m.flowspec<=1e-6?'— '+tr('incidents_and_ddos.no_flowspec_filtering_ingress')
|
||||
:'✓ '+tr('incidents_and_ddos.flowspec_dropping_g',{g:fmtG(m.flowspec)});
|
||||
const used=c=>(R.ddos||[m]).reduce((n,q)=>n+(q.sp?.parts||[]).filter(x=>x.city===c).reduce((t,x)=>t+x.cleaned,0),0);
|
||||
const scrOne=x=>{const T=SCRUB_TIERS[x.tier],q=hl(x),total=used(x.city);
|
||||
return (x.cleaned>1e-6?'✓ ':'~ ')+tr('incidents_and_ddos.scrubbing_in_city_used_capacity',{city:esc(CITY[x.city].name),used:fmtG(total),capacity:T.n})
|
||||
+(total>x.cleaned+1e-6?' · '+tr('incidents_and_ddos.this_attack_g',{g:fmtG(x.cleaned)}):'')
|
||||
+(q&&q.h<q.a-0.5?'<br>~ '+tr('incidents_and_ddos.your_backbone_can_only_haul_g',{g:fmtG(q.h),city:esc(CITY[x.city].name)}):'');};
|
||||
const scrLine=!hasScrub()?'— '+tr('incidents_and_ddos.no_scrubbing_center')
|
||||
:!scrubEngaged(a)?'… '+tr('incidents_and_ddos.on_demand_scrubbing_diverting_live',{n:Math.max(1,SCRUB_DELAY-(S.day-(a.start||S.day)))})
|
||||
:!sp?'— '+tr('incidents_and_ddos.no_scrubbing_center')
|
||||
:sp.parts.map(scrOne).join('<br>')+(sp.leak>0.5?'<br>~ '+tr('incidents_and_ddos.your_scrubbing_centers_are_full_g',{g:fmtG(sp.leak)}):'');
|
||||
const entryLine=cleanT&&cleanT.clean?'✓ '+tr('incidents_and_ddos.net_is_scrubbing_it_upstream_clean',{net:esc(NET[cleanT.net].name)})
|
||||
:sacP&&sacP.sacrif?'✓ '+tr('incidents_and_ddos.contained_on_your_sacrificial_net',{net:esc(NET[sacP.net].name)}):'';
|
||||
:!scrubEngaged(a)?'… '+tr('incidents_and_ddos.on_demand_scrubbing_diverting_live',{n:Math.max(1,SCRUB_DELAY-(S.day-(a.start??S.day)))})
|
||||
:!sp?'— '+(m.leak<=1e-6?tr('incidents_and_ddos.no_scrubbing_needed_after_edge'):tr('incidents_and_ddos.scrubbing_centers_unavailable_or_at'))
|
||||
:sp.parts.map(scrOne).join('<br>');
|
||||
const haulLine=m.near&&m.near.ms>0&&sp?.parts.some(x=>x.cleaned>1e-6)?'✓ '+tr('incidents_and_ddos.scrubbing_traffic_hauled_over_your',{city:esc(CITY[a.city].name),to:esc(CITY[m.near.city].name),ms:m.near.ms.toFixed(1)}):'';
|
||||
const entryLine=sacP&&sacP.sacrif?'✓ '+tr('incidents_and_ddos.contained_on_your_sacrificial_net',{net:esc(NET[sacP.net].name)}):'';
|
||||
let h=`<div class="inc" style="background:#FFE2E6;border:1px solid #FF8A9A">
|
||||
<div class="nm">🚨 ${tr('incidents_and_ddos.live_attack_city',{city:esc(CITY[a.city].name)})}</div>
|
||||
<div class="meta">${tr('incidents_and_ddos.size_vec_entry_n_d_left',{size:fmtG(a.gbps),vec:esc(V.n),entry:a.entry&&a.entry.lab?' · '+esc(a.entry.lab):'',n:a.until-S.day})}</div>
|
||||
<div class="meta"><b>${a.bh?tr('incidents_and_ddos.blackholed_the_junk_is_gone_and',{city:esc(CITY[a.city].name)}):tr('incidents_and_ddos.reaching_your_network_g',{g:fmtG(land)})}</b></div>
|
||||
${landLine?`<div class="meta"><b>${landLine}</b></div>`:''}
|
||||
${m.blackhole?'':`<div class="meta">${fsLine}</div>${entryLine?`<div class="meta">${entryLine}</div>`:''}
|
||||
${m.filtered-m.flowspec>1e-6?`<div class="meta">✓ ${tr('incidents_and_ddos.edge_filters_dropping_g',{g:fmtG(m.filtered-m.flowspec)})}</div>`:''}
|
||||
<div class="meta">${scrLine}</div>
|
||||
<div class="meta">${fsLine}</div>${entryLine?`\n <div class="meta">${entryLine}</div>`:''}
|
||||
<div class="btns">${a.bh?btn(tr('common.stop_blackholing'),'unrtbh',{},'ghost sm'):btn(tr('incidents_and_ddos.blackhole_the_target_rtbh'),'rtbh',{},'red sm')}${hasIxAt(a.city)&&!a.bh?btn(a.ixbh?tr('incidents_and_ddos.ix_blackhole_on'):tr('incidents_and_ddos.ix_blackhole_half_honour_it'),'ixbh',{},a.ixbh?'green sm':'sm'):''}${btn(tr('incidents_and_ddos.hackback_3000tm_20k'),'hackback',{},'sm',S.cash<20000)}</div>
|
||||
${haulLine?`<div class="meta">${haulLine}</div>`:''}
|
||||
<div class="meta">${m.leak>1e-6?'~ '+tr('incidents_and_ddos.g_is_leaking_through',{g:fmtG(m.leak)}):'✓ '+tr('incidents_and_ddos.attack_fully_mitigated')}</div>`}
|
||||
<div class="btns">${m.blackhole?btn(tr('common.stop_blackholing'),'unrtbh',{id:a.id},'ghost sm'):btn(tr('incidents_and_ddos.blackhole_the_target_rtbh'),'rtbh',{id:a.id},'red sm')}${hasIxAt(a.city)&&!m.blackhole?btn(a.ixbh?tr('incidents_and_ddos.ix_blackhole_on'):tr('incidents_and_ddos.ix_blackhole_half_honour_it'),'ixbh',{id:a.id},a.ixbh?'green sm':'sm'):''}${btn(tr('incidents_and_ddos.hackback_3000tm_20k'),'hackback',{id:a.id},'sm',S.cash<20000)}</div>
|
||||
<p class="meta">${tr('incidents_and_ddos.rtbh_is_free_and_instant_but')}</p></div>`;
|
||||
return h;}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
function fireFailure(){
|
||||
// Anchors Away (Baltic): a link on an anchor-prone cable, or on a pair one serves (the map calls those overland).
|
||||
const anchorProne=l=>!!(l.cable&&CAB[l.cable]&&CAB[l.cable].anchor)||anchorPair(l);
|
||||
function fireFailure(only){
|
||||
const opts=[];
|
||||
const live=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l));const fabsUsed=[...new Set(S.links.filter(l=>l.kind==='vxc').map(l=>l.prov))];
|
||||
if(live.length){opts.push(['cut',2+Math.min(6,live.length/2)]);}
|
||||
|
|
@ -7,20 +9,29 @@ function fireFailure(){
|
|||
if(S.transit.some(t=>!(t.down>S.day)))opts.push(['transit',3]);
|
||||
if(Object.keys(S.ixp).length)opts.push(['ixloop',2]);
|
||||
if(S.transit.length&&S.day>60)opts.push(['leak',2]);
|
||||
if(S.day>40&&!scnRule('ddos'))opts.push(['ddos',2]); // Flood Season brings its own
|
||||
// Flood Season brings its own; Change Freeze (calm) has none. Gaming customers put DDoS on its own, busier schedule
|
||||
// (ddosTick) instead of this one, so it is never counted twice. Spicy failures already come 1.8x as often; a slightly
|
||||
// heavier weight makes that twice On-call's DDoS, as BGP at 3 a.m. promises.
|
||||
if(S.day>40&&!scnRule('ddos')&&!ddosOff()&&!gamingCount())opts.push(['ddos',rule('chaos')==='spicy'?2.25:2]);
|
||||
if(fabsUsed.length)opts.push(['fabric',1.5]);
|
||||
const lit=S.links.filter(l=>l.kind==='df'&&dfCap(l)>0&&!linkDown(l));if(lit.length)opts.push(['amp',1.5+lit.length*0.3],['optic',1.5+lit.length*0.3]);
|
||||
// Two vendors' idea of the same protocol: the higher the backbone runs, the more often they disagree.
|
||||
const iop=coreIopRisk()?coreIopLinks(live):[];if(iop.length)opts.push(['interop',3*coreIopRisk()]);
|
||||
opts.push(['funny',4]);
|
||||
if(!opts.length)return;
|
||||
let tot=opts.reduce((a,o)=>a+o[1],0),r=Math.random()*tot,type=opts[0][0];
|
||||
for(const o of opts){r-=o[1];if(r<=0){type=o[0];break;}}
|
||||
if(type==='funny'){const f=['oops','cleaner','harmless','harmless','harmless','ac'];if(live.length)f.push('fatwave','fatwave','mtu','label','loss','loss');if(lagsN().length)f.push('lacp','lacp');if(R.demand>1)f.push('pmtud');if(Object.keys(S.ixp).length)f.push('maxpfx');if(S.transit.length)f.push('prepend');if(S.day>30)f.push('rpki');if(lit.length)f.push('roadmff');type=pick(f);}
|
||||
if(only)type=only;
|
||||
if(type==='funny'){const f=['oops','cleaner','harmless','harmless','harmless','ac'];if(live.length)f.push('fatwave','fatwave','mtu','label','loss','loss');if(lagsN().length)f.push('lacp','lacp');if(R.demand>1)f.push('pmtud');if(S.transit.length)f.push('prepend');if(S.day>30)f.push('rpki');if(lit.length)f.push('roadmff');type=pick(f);}
|
||||
const before=R.served;
|
||||
if(type==='harmless'){const m=pick(HARMLESS);S.stats.incidents++;S.stats.survived++;toast(`<b>${m[0]}</b><br>${m[1]}`,'goal');sfx('alert');return;}
|
||||
if(type==='ring'){const cs=Object.keys(S.pops).filter(c=>S.pops[c].site2),c=pick(cs),pp=S.pops[c],dur=2+Math.floor(Math.random()*3);pp.ringcut=S.day+dur;
|
||||
addInc({type,ref:c,until:pp.ringcut,msg:pick([tr('failures.a_backhoe_cut_the_metro_ring',{city:CITY[c].name}),tr('failures.someone_pulled_the_wrong_cross',{city:CITY[c].name,siteB:siteName(c,'b'),siteA:siteName(c,'a')}),tr('failures.a_tram_line_construction_project_in',{city:CITY[c].name})]),cost:3000,fix:tr('failures.splice_it_tonight')});}
|
||||
else if(type==='ac'){const c=pick(Object.keys(S.pops)),pp=S.pops[c];pp.hot=S.day+2;
|
||||
addInc({type,ref:c,until:pp.hot,msg:CITY[c].lux&&Math.random()<0.7?tr('failures.a_forestry_strike_stopped_the_waste',{dc:siteName(c,'a'),city:CITY[c].name}):pick([tr('failures.the_a_c_at_dc_died',{dc:siteName(c,'a'),city:CITY[c].name}),tr('failures.someone_set_the_data_center',{city:CITY[c].name}),tr('failures.the_cooling_contractor_in_city',{city:CITY[c].name})]),cost:2000,fix:tr('failures.buy_40_desk_fans')});
|
||||
}else if(type==='interop'){
|
||||
const ls=coreIopLinks(live);if(!ls.length)return;const l=pick(ls),dur=1+Math.floor(Math.random()*2),A=CITY[l.a].name,B=CITY[l.b].name,va=RG_V[RG[S.pops[l.a].rgen||0].v],vb=RG_V[RG[S.pops[l.b].rgen||0].v],L=tr(CORE_LV[S.core.run]);l.cut=Math.max(l.cut||0,S.day+dur);
|
||||
addInc({type,ref:l.id,until:l.cut,msg:pick([tr('core.va_and_vb_disagree_about',{va,vb,lv:L,a:A,b:B}),tr('core.a_firmware_update_on_the_va',{va,vb,lv:L,a:A,b:B}),tr('core.both_tacs_say_it_is',{va,vb,a:A,b:B})]),cost:2500,fix:tr('core.open_a_ticket_with_both')});
|
||||
}else if(type==='fatwave'||type==='label'){
|
||||
const l=pick(live),dur=1+Math.floor(Math.random()*2),A=CITY[l.a].name,B=CITY[l.b].name,W=pick(WAVECO);l.cut=Math.max(l.cut||0,S.day+dur);
|
||||
const msg=type==='label'?pick([tr('failures.someone_in_dc_labeled_every_patch',{dc:siteName(l.a,'a'),a:A,b:B}),tr('failures.a_remote_hands_tech_in_a',{a:A,b:B}),tr('failures.a_new_tech_in_a_tidied',{a:A,b:B})])
|
||||
|
|
@ -61,9 +72,6 @@ function fireFailure(){
|
|||
pp.down=Math.max(pp.down||0,S.day+1);
|
||||
const msg=type==='cleaner'?tr('failures.the_cleaner_at_dc_unplugged_your',{dc:siteName(c,'a')}):pick([tr('failures.your_on_call_engineer_typed_clear',{city:C}),tr('failures.an_intern_pushed_an_acl_in',{city:C}),tr('failures.someone_ran_reload_on_the_city',{city:C}),tr('failures.a_config_template_rendered_router_id',{city:C}),tr('failures.someone_committed_a_config_in_city',{city:C}),tr('failures.someone_deployed_to_city_on_a',{city:C}),tr('failures.a_cosmic_ray_flipped_a_bit',{city:C}),tr('failures.an_automation_script_in_city_ran',{city:C})]);
|
||||
addInc({type,ref:c,until:pp.down,msg:msg+(type==='oops'&&(pp.routers||1)>=2?' '+tr('failures.automation_pushed_it_to_every_router'):''),cost:1500,fix:type==='oops'?tr('failures.roll_back_the_config'):tr('failures.hide_the_vacuum')});
|
||||
}else if(type==='maxpfx'){
|
||||
const c=pick(Object.keys(S.ixp));S.ev.ixdown=S.ev.ixdown||{};S.ev.ixdown[c]=Math.max(S.ev.ixdown[c]||0,S.day+1+Math.floor(Math.random()*2));
|
||||
addInc({type,ref:c,until:S.ev.ixdown[c],msg:ixNamesCity(c)?tr('failures.a_member_at_ix_leaked_the',{ix:ixName(c)}):tr('failures.a_member_at_ix_leaked_the_5563',{ix:ixName(c),city:CITY[ixCity(c)].name}),cost:0});
|
||||
}else if(type==='prepend'){
|
||||
const t=pick(S.transit);t.down=Math.max(t.down||0,S.day+2);addInc({type,ref:t.id,until:t.down,msg:tr('failures.net_fat_fingered_a_route_map',{net:NET[t.net].name,n:30+Math.floor(Math.random()*60),city:CITY[t.city].name}),cost:0});
|
||||
}else if(type==='rpki'){
|
||||
|
|
@ -76,8 +84,8 @@ function fireFailure(){
|
|||
const l=pick(lit),A=CITY[l.a].name,B=CITY[l.b].name,o=pick(l.ch),dur=l.spares?1:4;l.chFail={n:1,o,until:S.day+dur};
|
||||
addInc({type,ref:l.id,until:S.day+dur,msg:pick([tr('failures.a_optic_on_a_b_overheated',{optic:OPT[o].n,a:A,b:B}),tr('failures.the_laser_in_a_optic_on',{optic:OPT[o].n,a:A,b:B}),tr('failures.a_optic_on_a_b_started',{optic:OPT[o].n,a:A,b:B})])+(l.spares?' '+tr('failures.swapped_from_your_spares_kit_by'):''),cost:l.spares?0:OPT[o].cost,fix:tr('failures.buy_a_replacement')});
|
||||
}else if(type==='cut'){
|
||||
const mon=Math.floor((S.day%365)/30.42),monsoon=mon>=5&&mon<=8,tw=x=>x.sub&&(x.a==='tpe'||x.b==='tpe'||(x.cable&&CAB[x.cable].anchor)),vn=x=>x.sub&&(x.a==='sgn'||x.b==='sgn'),inl=x=>!x.sub&&(CITY[x.a].india||CITY[x.b].india);
|
||||
const l=pick(live.flatMap(x=>{const w=(x.cable&&CAB[x.cable].age==='old'?3:1)*(x.cable&&CAB[x.cable].fragile?3:1)*(tw(x)?4*(scnRule('anchors')?3:1):1)*(scnRule('sharks')&&x.sub?2:1)*(vn(x)?3:1)*(!x.sub&&andesPair(x.a,x.b)?4:1)*(monsoon&&inl(x)?3:1)*(x.sub&&(x.a==='oos'||x.b==='oos')?3:1);return Array(w).fill(x);})),dur=10+Math.floor(Math.random()*8),trc=l.trench||l.id,hit=S.links.filter(x=>(x.trench||x.id)===trc);hit.forEach(x=>x.cut=Math.max(x.cut||0,S.day+dur));
|
||||
const mon=Math.floor((S.day%365)/30.42),monsoon=mon>=5&&mon<=8,tw=x=>(x.sub&&(x.a==='tpe'||x.b==='tpe'||(x.cable&&CAB[x.cable].anchor)))||(scnRule('anchors')&&anchorProne(x)),vn=x=>x.sub&&(x.a==='sgn'||x.b==='sgn'),inl=x=>!x.sub&&(CITY[x.a].india||CITY[x.b].india);
|
||||
const pool=only&&scnRule('anchors')?live.filter(anchorProne):live;if(!pool.length)return;const l=pick(pool.flatMap(x=>{const w=(x.cable&&CAB[x.cable].age==='old'?3:1)*(x.cable&&CAB[x.cable].fragile?3:1)*(tw(x)?4*(scnRule('anchors')?3:1):1)*(scnRule('sharks')&&x.sub?2:1)*(vn(x)?3:1)*(!x.sub&&andesPair(x.a,x.b)?4:1)*(monsoon&&inl(x)?3:1)*(x.sub&&(x.a==='oos'||x.b==='oos')?3:1);return Array(w).fill(x);})),dur=10+Math.floor(Math.random()*8),trc=l.trench||l.id,hit=S.links.filter(x=>(x.trench||x.id)===trc);hit.forEach(x=>x.cut=Math.max(x.cut||0,S.day+dur));
|
||||
const A=CITY[l.a].name,B=CITY[l.b].name,au=CITY[l.a].au&&CITY[l.b].au,auSummer=mon>=11||mon<=1;
|
||||
const en=l.sub&&(CITY[l.a].au||CITY[l.b].au)&&!(l.cable&&CAB[l.cable].fragile)&&Math.random()<0.35?pick([N_('failures.box_jellyfish_season_at_the_a'),N_('failures.a_great_white_took_an_interest')]):l.cable&&CAB[l.cable].fragile&&Math.random()<0.8?pick([N_('failures.your_a_b_cable_is_cut'),N_('failures.a_b_is_down_same_cable')]):!l.sub&&CITY[l.a].land==='nzs'&&CITY[l.b].land==='nzs'&&Math.random()<0.75?pick([N_('failures.a_kea_pulled_the_rubber_seals'),N_('failures.the_sandflies_drove_your_splicing'),N_('failures.a_farmer_s_post_hole_digger')]):l.cable==='cook'&&Math.random()<0.6?N_('failures.a_ferry_dropped_anchor_in_cook'):!l.sub&&au&&Math.random()<0.75?pick([N_('failures.a_sulphur_crested_cockatoo_chewed'),N_('failures.a_kangaroo_hit_the_fiber_hut'),N_('failures.thieves_dug_up_your_a_b'),N_('failures.a_kilometre_of_copper_went_missing'),N_('failures.a_backhoe_putting_in_a_new'),N_('failures.the_emus_won_again_a_mob'),N_('failures.a_kangaroo_boxed_your_field_tech'),N_('failures.a_drop_bear_fell_on_the'),N_('failures.an_eastern_brown_snake_moved_into'),...((S.day%365)/30.42>=8&&(S.day%365)/30.42<11?[N_('failures.magpie_swooping_season_the_field')]:[]),...(auSummer?[N_('failures.bushfire_season_the_fiber_along_a')]:[]),...(nullPair(l.a,l.b)?[N_('failures.your_a_b_fiber_broke_somewhere')]:[])]):l.sub&&(l.a==='bda'||l.b==='bda')&&Math.random()<0.7?pick([N_('failures.your_a_b_cable_went_quiet'),N_('failures.the_repair_ship_s_compass_spun')]):l.sub&&(l.a==='tbu'||l.b==='tbu')&&Math.random()<0.7?pick([N_('failures.an_undersea_volcano_erupted_next_to'),N_('failures.the_seabed_off_tonga_slid_down')]):vn(l)&&Math.random()<0.8?pick([N_('failures.another_of_vietnam_s_subsea_cables'),N_('failures.your_a_b_cable_broke_in')]):!l.sub&&(l.a==='drw'||l.b==='drw')&&Math.random()<0.7?pick([N_('failures.a_crocodile_took_a_bite_out'),N_('failures.termites_ate_the_duct_on_a')]):tw(l)&&Math.random()<0.8?pick([N_('failures.a_cargo_ship_forgot_to_raise'),N_('failures.another_anchor_another_cut_your_a'),N_('failures.a_fishing_boat_with_an_unusually')]):l.sub&&(l.a==='oos'||l.b==='oos')&&Math.random()<0.8?pick([N_('failures.a_trawler_off_ostend_dragged_its'),N_('failures.a_wind_farm_service_vessel_dropped')]):!l.sub&&(CITY[l.a].ca||CITY[l.b].ca)&&Math.random()<0.4?pick([N_('failures.a_beaver_chewed_through_your_a'),N_('failures.your_a_b_fiber_is_down'),N_('failures.frost_heave_cracked_the_duct_on')]):!l.sub&&andesPair(l.a,l.b)?pick([N_('failures.a_landslide_in_the_andes_buried'),N_('failures.snow_closed_the_mountain_pass_and'),N_('failures.an_earthquake_shook_your_a_b'),N_('failures.a_llama_herd_trampled_the_fiber')]):!l.sub&&(CITY[l.a].india||CITY[l.b].india)?pick([N_('failures.road_widening_near_a_cut_your'),N_('failures.the_monsoon_flooded_a_manhole_on'),N_('failures.a_digger_found_your_a_b')]):l.sub?pick([N_('failures.a_curious_shark_bit_your_subsea'),N_('failures.a_ship_dragged_its_anchor_across'),N_('failures.an_undersea_landslide_snapped_a_b')]):pick([N_('failures.a_backhoe_found_your_fiber_between'),N_('failures.squirrels_chewed_through_a_b_they'),N_('failures.road_works_cut_a_b_nobody')]);
|
||||
addInc({type,ref:trc,until:S.day+dur,msg:tr(en,{a:A,b:B})+(hit.length>1?' '+tr('failures.all_n_links_in_that_trench',{n:hit.length}):''),cost:Math.max(4000,Math.round(hit.reduce((a,x)=>a+x.mo,0)*0.5))},en);
|
||||
|
|
@ -111,30 +119,66 @@ function fireFailure(){
|
|||
else{const paused=pref('pauseIncident')&&autoPause();toast(`<b>${incTitle(type)}</b><br>${esc(last.msg)}${paused?`<br><b>${tr('common.game_paused')}</b>`:''}`,'bad',(last.cost?[{l:`${last.fix||tr('common.rush_repair')} ${fmt$(last.cost)}`,act:'fixInc',args:{id:last.id}}]:[]).concat(paused?[resumeAct()]:[]),incOpen(last));}
|
||||
sfx('alert');
|
||||
}
|
||||
// A DDoS attack: mostly short, modest spikes; now and then a "botnet of toasters" monster into the terabits.
|
||||
// In Flood Season (scenario rule ddos) they come more often, a third are monsters, and they grow over the year.
|
||||
function ddosAttack(){const type='ddos',fl=scnRule('ddos'),grow=fl?1+S.day/180:1;if(S.ev.ddos&&S.ev.ddos.until>S.day)ddosDone(S.ev.ddos);
|
||||
const c=pick(Object.keys(S.pops)),vec=pick(Object.keys(DDOS_VEC)),V=DDOS_VEC[vec];
|
||||
const monster=Math.random()<(fl?0.33:0.15),base=Math.max(R.cityDem[c]||0,4);
|
||||
const gbps=Math.round((monster?800+Math.random()*2600:2+Math.random()*Math.max(18,base*0.9))*grow);
|
||||
const dur=2+Math.floor(Math.random()*4),entry=ddosEntry(c);
|
||||
S.ev.ddos={city:c,vec,gbps,until:S.day+dur,entry,bh:false,start:S.day};
|
||||
const gamingCount=()=>S.biz.reduce((n,b)=>n+(BIZ_T[b.type]?.gaming?1:0),0);
|
||||
const ddosVectors=()=>Object.keys(DDOS_VEC).filter(k=>!DDOS_VEC[k].gaming||gamingCount()>0);
|
||||
// Expected starts per week in normal play; the rolling 14-start limit is a separate ceiling.
|
||||
// Spread gaming exposure over dozens of customers, including the first, rather than switching baselines.
|
||||
const ddosRate=()=>0.5+6.5*(1-Math.exp(-gamingCount()/50*(1+Math.max(1,S.lvl||1)/LEVELS.length)));
|
||||
const ddosPressure=()=>1-Math.exp(-(.01+Math.max(0,(S.lvl||1)-1)/12+gamingCount()/10+(scnRule('ddos')?.2+S.day/365:0)));
|
||||
// Normalize the vector mix so smaller gaming-only floods do not lower the advertised overall mean (Flood Season sizes its own).
|
||||
function ddosSizeMean(){const stage=Math.max(1,S.lvl||1)/LEVELS.length,games=gamingCount();
|
||||
const base=Math.max(10,(R.demand||0)*4/3*stage);
|
||||
// Relative to no gaming: 3x at one customer, 8x at 50, approaching the existing 12x balance.
|
||||
const mean=base*(games?1.2-0.9*Math.pow(4/9,(games-1)/49):0.1),vectors=ddosVectors(),weight=vectors.reduce((n,k)=>n+(DDOS_VEC[k].gaming?1/3:1),0)/vectors.length;
|
||||
return mean/weight;}
|
||||
// Normal rolls: 98% uniform 0.2–2, 2% uniform 8–12. Their mean is 1.278, so spikes do not inflate the balance.
|
||||
const ddosSizeMax=()=>ddosSizeMean()*12/1.278;
|
||||
/* Flood Season (as in 1.36): a third are terabit monsters, the rest ordinary floods sized to the city; all of it grows
|
||||
through the year, and on after it. One draw picks both, so fixed draws give fixed sizes. */
|
||||
function ddosSize(vec,c){const fl=scnRule('ddos'),r=Math.random();
|
||||
if(fl){const games=gamingCount(),grow=(1+S.day/365)*(1+0.2*games/(games+10))*(DDOS_VEC[vec].gaming?1/3:1);
|
||||
const raw=r<1/3?800+2600*r*3:2+(r-1/3)*1.5*Math.max(18,((R.cityDem||{})[c]||0)*0.9);return Math.max(2,Math.floor(raw*grow));}
|
||||
const roll=(r<.98?.2+1.8*r/.98:8+4*(r-.98)/.02)/12,raw=ddosSizeMax()*(DDOS_VEC[vec].gaming?1/3:1)*roll;
|
||||
return Math.max(0.001,Math.floor(raw*1000)/1000);}
|
||||
// Calm (Change Freeze) and no chaos at all mean no attacks, gamers or not.
|
||||
const ddosOff=()=>{const c=rule('chaos');return c==='calm'||c==='none';};
|
||||
// More frequent attacks are opt-in: the spicy chaos setting, or hosting gamers (who attract them in real life).
|
||||
// Outside Flood Season, only gamers move attacks onto ddosTick's daily schedule; spicy alone doubles the usual one.
|
||||
const ddosSpicy=()=>!ddosOff()&&(rule('chaos')==='spicy'||gamingCount()>0);
|
||||
function ddosTick(){if(ddosOff()&&!scnRule('ddos'))return;if(scnRule('ddos')){let next=+S.scn.nextDdos||3,n=0;
|
||||
// Unless spicy, floods take turns as they always did: the next one waits until the last is over.
|
||||
if(!ddosSpicy()&&ddosAll().length)return;
|
||||
while(S.day>=next&&n++<2){ddosAttack(false);next+=floodGap();}S.scn.nextDdos=next<S.day?S.day+floodGap():next;}
|
||||
else if(!ddosOff()&&gamingCount())for(let i=0;i<2;i++)if(Math.random()<ddosRate()/14)ddosAttack(false);}
|
||||
// Size, duration and starts are randomized independently; overlapping floods never replace each other.
|
||||
function ddosAttack(recompute=true){const type='ddos',fl=scnRule('ddos');ddosExpire();
|
||||
S.ddosStarts=(S.ddosStarts||[]).filter(d=>d>S.day-7&&d<=S.day);if(S.ddosStarts.length>=14||!Object.keys(S.pops).length)return;S.ddosStarts.push(S.day);
|
||||
// Flood Season goes for the POPs that serve someone, so empty ones cannot soak up floods for a free win.
|
||||
const all=Object.keys(S.pops),served=fl?all.filter(x=>(R.cityDem||{})[x]>1e-6):[];
|
||||
const c=pick(served.length?served:all),vec=pick(ddosVectors()),V=DDOS_VEC[vec];
|
||||
const gbps=ddosSize(vec,c);
|
||||
const dur=1+Math.floor(Math.random()*(1+6*ddosPressure())),entry=ddosEntry(c);
|
||||
const a={id:uid(),city:c,vec,gbps,until:S.day+dur,entry,bh:false,start:S.day};
|
||||
if(!S.ev.ddos)S.ev.ddos=a;else(S.ev.ddosMore||(S.ev.ddosMore=[])).push(a);
|
||||
const soaked=(V.fs&&fsAt(c))||hasScrub();
|
||||
const how=entry&&entry.lab?tr('failures.in_via_e',{e:entry.lab}):'';
|
||||
const msg=tr('failures.a_size_vec_attack_is_hitting',{size:fmtG(gbps),vec:V.n,city:CITY[c].name,how})+' '+(soaked?tr('failures.your_mitigation_is_eating_most_of'):tr('failures.junk_traffic_is_eating_your_capacity'));
|
||||
if(fl)S.ev.ddos.who=pick(FLOOD_WHO);
|
||||
addInc({type,ref:c,until:S.day+dur,msg:fl?msg+' '+tr('failures.attacker_who',{who:tr(S.ev.ddos.who)}):msg,cost:0});
|
||||
if(fl)a.who=pick(FLOOD_WHO);
|
||||
addInc({type,ref:c,atk:a.id,until:S.day+dur,msg:fl?msg+' '+tr('failures.attacker_who',{who:tr(a.who)}):msg,cost:0});
|
||||
if(soaked){S.stats.survived++;S.stats.ddosHeld=(S.stats.ddosHeld||0)+1;if(gbps>=1000)S.stats.ddosMonster=(S.stats.ddosMonster||0)+1;}
|
||||
compute();
|
||||
toast(`<b>${incTitle('ddos')}: ${esc(CITY[c].name)}</b><br>${esc(msg)}${fl?`<br><i>${esc(tr('failures.attacker_who',{who:tr(S.ev.ddos.who)}))}</i>`:''}`,soaked?'goal':'bad',[{l:tr('common.open_noc'),act:'leftTab',args:{t:'noc'}}],{a:'city',v:c});
|
||||
if(recompute){compute();a.worst=ddosSf(a);}
|
||||
toast(`<b>${incTitle('ddos')}: ${esc(CITY[c].name)}</b><br>${esc(msg)}${fl?`<br><i>${esc(tr('failures.attacker_who',{who:tr(a.who)}))}</i>`:''}`,soaked?'goal':'bad',[{l:tr('common.open_noc'),act:'leftTab',args:{t:'noc'}}],{a:'city',v:c});
|
||||
sfx('alert');}
|
||||
// When an attack is over: was it held? Held means the city under attack got at least 97% of its traffic every day.
|
||||
function ddosDone(a){if(!a||a.done)return;a.done=1;if(a.worst===undefined&&S.pops[a.city])a.worst=sfOf(R,a.city);const ok=(a.worst===undefined?1:a.worst)>=0.97;
|
||||
if(ok){S.stats.ddosOk=(S.stats.ddosOk||0)+1;if(a.gbps>=1000)S.stats.ddosOkBig=(S.stats.ddosOkBig||0)+1;}else S.stats.ddosLost=(S.stats.ddosLost||0)+1;
|
||||
if(scnRule('ddos')){const who=tr(a.who||FLOOD_WHO[0]);toast(ok?tr('failures.flood_held_g_who_gave_up',{g:fmtG(a.gbps),who:who.charAt(0).toUpperCase()+who.slice(1)}):tr('failures.that_one_got_through_g_city',{g:fmtG(a.gbps),city:CITY[a.city]?CITY[a.city].name:tr('common.your_network'),p:pct(a.worst||0),who}),ok?'goal':'bad');}}
|
||||
function ddosDone(a){if(!a||a.done)return;a.done=1;if(a.worst===undefined&&S.pops[a.city])a.worst=ddosSf(a);const ok=(a.worst===undefined?1:a.worst)>=0.97;
|
||||
// In Flood Season a terabit flood counts only when scrubbing or Flowspec took it: spare exits held some by luck (playtest).
|
||||
if(ok){S.stats.ddosOk=(S.stats.ddosOk||0)+1;if(a.gbps>=1000&&(!scnRule('ddos')||hasScrub()||(DDOS_VEC[a.vec]&&DDOS_VEC[a.vec].fs&&fsAt(a.city))))S.stats.ddosOkBig=(S.stats.ddosOkBig||0)+1;}else S.stats.ddosLost=(S.stats.ddosLost||0)+1;
|
||||
if(scnRule('ddos')){const w=tr(FLOOD_WHO.includes(a.who)?a.who:FLOOD_WHO[0]),who=esc(w.charAt(0).toUpperCase()+w.slice(1));toast(ok?tr('failures.flood_held_g_who_gave_up',{g:fmtG(a.gbps),who}):tr('failures.that_one_got_through_g_city',{g:fmtG(a.gbps),city:esc(CITY[a.city]?CITY[a.city].name:tr('common.your_network')),p:pct(a.worst||0),who:esc(w)}),ok?'goal':'bad');}}
|
||||
// Flood Season: 3 to 7 days apart as before, shrinking with age, level and gamers only when attacks are spicy.
|
||||
const floodGap=()=>!ddosSpicy()?3+Math.floor(Math.random()*5):Math.max(0.05,(3+Math.random()*5)/(Math.sqrt(1+S.day/180)*(1+gamingCount()/10+Math.max(0,(S.lvl||1)-1)/12)));
|
||||
const FLOOD_WHO=[N_('failures.a_botnet_of_40_000_smart'),N_('failures.every_unpatched_baby_monitor_in'),N_('failures.a_gaming_clan_that_lost_one'),N_('failures.a_fridge_that_achieved_sentience_and'),N_('failures.a_crypto_bro_shorting_your_stock'),N_('failures.a_teenager_with_a_stolen_credit'),N_('failures.a_rival_isp_s_stress_test'),N_('failures.ten_thousand_smart_light_bulbs'),N_('failures.a_printer_just_one_printer_nobody'),N_('failures.a_botnet_run_from_a_cloud'),N_('failures.somebody_who_did_not_like_your'),N_('failures.the_internet_connected_kettles_of_a')];
|
||||
function incTitle(t){return {ring:tr('failures.metro_ring_cut'),site:tr('common.site_outage'),cut:tr('common.fiber_cut'),crash:tr('common.router_crash'),power:tr('common.power_outage'),transit:tr('common.upstream_outage'),ixloop:tr('common.ix_meltdown'),leak:tr('common.route_leak'),ddos:tr('common.ddos_attack'),fabric:tr('common.fabric_outage'),depeer:tr('common.peering_spat'),fatwave:tr('failures.fat_fingered_wave'),label:tr('failures.patch_panel_mishap'),mtu:tr('common.mtu_mismatch'),krroute:tr('failures.rerouted_via_hong_kong'),ctrlplane:tr('failures.control_plane_meltdown'),lacp:tr('common.lacp_trouble'),loss:tr('common.packet_loss'),pmtud:tr('failures.pmtud_black_hole'),oops:tr('common.oops'),cleaner:tr('common.vacuum_incident'),maxpfx:tr('failures.max_prefix_meltdown'),prepend:tr('common.prepend_ageddon'),rpki:tr('common.rpki_invalid'),amp:tr('common.amplifier_failure'),roadmff:tr('failures.fat_fingered_roadm'),optic:tr('common.dead_optic'),maint:tr('common.maintenance_window_3a92'),ac:tr('common.cooling_failure'),hijack:tr('common.bgp_hijack'),shutdown:tr('common.government_shutdown'),redsea:tr('failures.geopolitical_cable_cut')}[t]||tr('common.incident');}
|
||||
const LINKCUT_TR=['cut','redsea'],LINKCUT_ID=['fatwave','label'],POPDOWN=['crash','power','oops','cleaner','maint','shutdown'],IXDOWN=['ixloop','maxpfx'],TDOWN=['transit','prepend'],LINKEQ=['mtu','amp','roadmff','optic'];
|
||||
function incTitle(t){return {ring:tr('failures.metro_ring_cut'),site:tr('common.site_outage'),cut:tr('common.fiber_cut'),crash:tr('common.router_crash'),power:tr('common.power_outage'),transit:tr('common.upstream_outage'),ixloop:tr('common.ix_meltdown'),leak:tr('common.route_leak'),ddos:tr('common.ddos_attack'),fabric:tr('common.fabric_outage'),depeer:tr('common.peering_spat'),fatwave:tr('failures.fat_fingered_wave'),label:tr('failures.patch_panel_mishap'),interop:tr('core.interop_failure'),mtu:tr('common.mtu_mismatch'),krroute:tr('failures.rerouted_via_hong_kong'),ctrlplane:tr('failures.control_plane_meltdown'),lacp:tr('common.lacp_trouble'),loss:tr('common.packet_loss'),pmtud:tr('failures.pmtud_black_hole'),oops:tr('common.oops'),cleaner:tr('common.vacuum_incident'),prepend:tr('common.prepend_ageddon'),rpki:tr('common.rpki_invalid'),amp:tr('common.amplifier_failure'),roadmff:tr('failures.fat_fingered_roadm'),optic:tr('common.dead_optic'),maint:tr('common.maintenance_window_3a92'),ac:tr('common.cooling_failure'),hijack:tr('common.bgp_hijack'),shutdown:tr('common.government_shutdown'),redsea:tr('failures.geopolitical_cable_cut')}[t]||tr('common.incident');}
|
||||
const LINKCUT_TR=['cut','redsea'],LINKCUT_ID=['fatwave','label','interop'],POPDOWN=['crash','power','oops','cleaner','maint','shutdown'],IXDOWN=['ixloop'],TDOWN=['transit','prepend'],LINKEQ=['mtu','amp','roadmff','optic'];
|
||||
function remainUntil(pred){let u=0;for(const x of S.inc)if(pred(x))u=Math.max(u,x.until);return u;}
|
||||
// Remove an incident, then restore each affected thing to whatever other incidents still hold it down.
|
||||
function clearInc(i){
|
||||
|
|
@ -146,7 +190,7 @@ function clearInc(i){
|
|||
else if(TDOWN.includes(T)){const t=S.transit.find(x=>x.id===i.ref);if(t)t.down=remainUntil(x=>TDOWN.includes(x.type)&&x.ref===i.ref);}
|
||||
else if(T==='rpki'||T==='hijack'){if(!S.inc.some(x=>x.type==='rpki'||x.type==='hijack'))S.ev.rpki=null;}
|
||||
else if(T==='leak'){S.ev.leak=null;}
|
||||
else if(T==='ddos'){const a=S.ev.ddos;if(a&&a.city===i.ref&&(a.start===undefined||a.start===i.start)){ddosDone(a);S.ev.ddos=null;}}
|
||||
else if(T==='ddos'){const a=ddosAll(S,false).find(a=>i.atk?a.id===i.atk:a.city===i.ref&&(a.start===undefined||a.start===i.start));if(a){ddosDone(a);ddosDrop(a);}}
|
||||
else if(T==='fabric'){if(S.ev.fab)S.ev.fab[i.ref]=remainUntil(x=>x.type==='fabric'&&x.ref===i.ref);}
|
||||
else if(T==='mtu'){const l=S.links.find(x=>x.id===i.ref);if(l)l.deg=remainUntil(x=>x.type==='mtu'&&x.ref===i.ref);}
|
||||
else if(T==='loss'){const l=S.links.find(x=>x.id===i.ref);if(l&&!S.inc.some(x=>x.type==='loss'&&x.ref===i.ref))l.loss=null;}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
function fireEvent(){
|
||||
const opts=['viral','price','grant'];
|
||||
if(S.day>50)opts.push('sanction','tariff','hijack','landban','shutdown','redsea','baltic');
|
||||
if(S.day>HW_FREE&&!hwShock())opts.push('hwshock');
|
||||
// Without a market (Change Freeze), no shortages and no trade war on optics.
|
||||
if(!rule('market')&&opts.includes('tariff'))opts.splice(opts.indexOf('tariff'),1);
|
||||
if(S.day>HW_FREE&&!hwShock()&&rule('market'))opts.push('hwshock');
|
||||
if(S.day>90&&S.links.filter(l=>l.kind==='wave'&&!l.sub).length>=3)opts.push('ctrlplane');
|
||||
if(Object.keys(S.pops).some(ruCity))opts.push('runet','runet');
|
||||
if(S.pops.doh&&Object.keys(S.pops).some(c=>CITY[c].gcc||CITY[c].uae)&&!(S.ev.gulf>S.day))opts.push('gulf');
|
||||
|
|
|
|||
53
src/game/85-incidents/40-chaos-monkey.js
Normal file
53
src/game/85-incidents/40-chaos-monkey.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* ---------- the chaos monkey: a visitor that breaks things on purpose ----------
|
||||
Like the real one (Netflix, 2011): something switches off random bits of production so you find out whether the
|
||||
rest copes. Now and then, in On-call and BGP at 3 a.m. only, a monkey moves in for 120 to 240 days and snips a tube
|
||||
every couple of weeks, preferring tubes with no other path round them. Its snips stand in for the usual random
|
||||
failures while it is here, so the visit is a test, not a pile-on. Get through it without a customer noticing and
|
||||
there is a bonus; a banana sends it home early. S.monkey: next (day of the next visit, null until the first tick),
|
||||
on, start, until, snip (day of the next snip), n (snips), hurt (snips customers felt), c (city it last snipped by). */
|
||||
const MK_SNIPS=[N_('chaos_monkey.snip_unplugged'),N_('chaos_monkey.snip_sprayed'),N_('chaos_monkey.snip_to_see')];
|
||||
const mkSpicy=()=>rule('chaos')==='spicy';
|
||||
// Only the real game with real chaos: not Change Freeze (calm), Sandbox, puzzles or scenarios.
|
||||
function mkElig(){return !!S&&S.mode!=='sandbox'&&S.mode!=='puzzle'&&!S.scn&&!S.lost&&['normal','spicy'].includes(rule('chaos'));}
|
||||
const mkOn=()=>!!(S&&S.monkey&&S.monkey.on&&mkElig());
|
||||
const rint=(a,n)=>a+Math.floor(Math.random()*n);
|
||||
// A quarter of a month's revenue to send it home; half a month's as the bonus for outlasting it.
|
||||
const mkBananaCost=()=>Math.round(Math.min(1e6,Math.max(10000,(R.revMo||0)*0.25))/1000)*1000;
|
||||
const mkBonus=()=>Math.round(Math.min(2e6,Math.max(20000,(R.revMo||0)*0.5))/1000)*1000;
|
||||
// Is there another way between this tube's ends once its whole trench is gone? If not, it is a weak spot.
|
||||
function mkWeak(l){const trc=l.trench||l.id,adj={};
|
||||
for(const x of S.links){if(x===l||(x.trench||x.id)===trc||linkDown(x))continue;(adj[x.a]||(adj[x.a]=[])).push(x.b);(adj[x.b]||(adj[x.b]=[])).push(x.a);}
|
||||
const seen=new Set([l.a]),q=[l.a];while(q.length){const c=q.pop();if(c===l.b)return false;for(const n of adj[c]||[])if(!seen.has(n)){seen.add(n);q.push(n);}}return true;}
|
||||
function mkTick(d){const M=S.monkey;if(!M)return;
|
||||
if(!mkElig()){if(M.on)mkLeave('quiet');return;}
|
||||
// The first visit is spread by the ASN, not the dice, so a game's other luck stays exactly as it was.
|
||||
if(M.next==null)M.next=d+(mkSpicy()?180:270)+(S.asn||0)%120;
|
||||
if(!M.on){if(d<M.next)return;if(S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l)).length<3){M.next=d+30;return;}mkArrive(d);return;}
|
||||
if(d>=M.until){mkLeave();return;}
|
||||
if(d>=M.snip){mkSnip();M.snip=d+(mkSpicy()?rint(9,7):rint(14,11));}}
|
||||
function mkArrive(d){const M=S.monkey,cs=Object.keys(S.pops),len=mkSpicy()?rint(180,61):rint(120,121);
|
||||
S.stats.mkMet=(S.stats.mkMet||0)+1;
|
||||
Object.assign(M,{on:1,start:d,until:d+len,snip:d+3,n:0,hurt:0,c:cs.length?pick(cs):S.home});
|
||||
toast(tr('chaos_monkey.arrived',{n:len}),'bad',[{l:tr('chaos_monkey.banana',{cost:fmt$(mkBananaCost())}),act:'mkBanana',args:{}}],{a:'tab',v:'noc'});sfx('alert');track('monkey_arrive');
|
||||
if(typeof mkStart==='function'&&CITY[M.c])mkStart(M.c);}
|
||||
function mkSnip(){const M=S.monkey,live=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l));if(!live.length)return;
|
||||
// Weak spots first: a sample keeps this cheap on big networks.
|
||||
const smp=live.length>40?Array.from({length:40},()=>pick(live)):live,l=pick(smp.flatMap(x=>mkWeak(x)?[x,x,x,x,x]:[x]));
|
||||
const dur=rint(3,4),trc=l.trench||l.id,hit=S.links.filter(x=>(x.trench||x.id)===trc),A=CITY[l.a].name,B=CITY[l.b].name,before=R.served;
|
||||
hit.forEach(x=>x.cut=Math.max(x.cut||0,S.day+dur));M.n++;M.c=l.a;
|
||||
addInc({type:'cut',ref:trc,until:S.day+dur,msg:tr(pick(MK_SNIPS),{a:A,b:B}),cost:Math.max(4000,Math.round(hit.reduce((a,x)=>a+x.mo,0)*0.5))},'');
|
||||
compute();const i=S.inc[S.inc.length-1],imp=Math.max(0,before-R.served);if(i)i.impact=imp;
|
||||
const felt=before>1&&imp>=before*0.03;if(felt)M.hurt++;else S.stats.survived++;
|
||||
toast(felt?`<b>🐒 ${incTitle('cut')}</b><br>${esc(i?i.msg:'')}`:tr('chaos_monkey.rerouted',{a:A,b:B}),felt?'bad':'good',[],i?incOpen(i):null);sfx(felt?'err':'alert');
|
||||
if(typeof mkRun==='function'){if(!UI.mk&&CITY[M.c])mkStart(M.c);mkRun(l,1400,felt);}}
|
||||
// why: 'banana' (bribed), 'quiet' (the rules or the game changed under it), or nothing (its time was up).
|
||||
function mkLeave(why){const M=S.monkey,d=S.day,ok=!why&&M.n>0&&M.hurt===0;M.on=0;M.next=d+(mkSpicy()?rint(220,181):rint(360,361));
|
||||
// The usual failures were paused for the visit; give the NOC a breather before they start again.
|
||||
S.nextFail=Math.max(S.nextFail,d+15);
|
||||
if(why==='banana')toast(tr('chaos_monkey.bribed'),'good');
|
||||
else if(ok){const b=mkBonus();S.cash+=b;S.stats.mkSurv=(S.stats.mkSurv||0)+1;toast(tr('chaos_monkey.survived',{n:M.n,cash:fmt$(b)}),'goal');sfx('coin');track('monkey_survived');}
|
||||
else if(!why)toast(tr('chaos_monkey.went_home',{n:M.n,hurt:M.hurt}),'');
|
||||
if(typeof mkEnd==='function')mkEnd(ok,true);}
|
||||
// The NOC tab's card while it is here.
|
||||
function mkCard(){if(!mkOn())return '';const M=S.monkey,c=mkBananaCost();
|
||||
return `<div class="inc" style="background:#FFF1D6;border:1px solid #FFC56B"><div class="nm">🐒 ${tr('chaos_monkey.loose')}</div><div class="meta">${tr('chaos_monkey.card',{n:Math.max(1,M.until-S.day),s:M.n,hurt:M.hurt})}</div><div class="btns">${btn(tr('chaos_monkey.banana',{cost:fmt$(c)}),'mkBanana',{},'sm',S.cash<c)}</div></div>`;}
|
||||
|
|
@ -1,16 +1,18 @@
|
|||
/* ---------- daily tick ---------- */
|
||||
function dayTick(){
|
||||
if(!S||S.lost)return;
|
||||
if(!S||S.lost||!rule('clock'))return; // no clock (puzzles): no days, no bills, nothing fires
|
||||
S.day++;
|
||||
const d=S.day;
|
||||
dkTick(d);ixPriceWar(d);inboxDay(d);pniDay(d);mergerDay(d);
|
||||
dkTick(d);ixPriceWar(d);peeringDeskDay(d);pniDay(d);mergerDay(d);
|
||||
if(!S.phpDone&&d>45&&Math.random()<1/400)elephant();
|
||||
if(R&&R.teMoved)S.stats.teMax=Math.max(S.stats.teMax||0,R.teMoved);
|
||||
{const t1=!!S.won&&isTier1();if(S.t1Now&&!t1)toast(tr('day_tick.you_are_no_longer_tier_1',{why:t1Why()}),'bad');S.t1Now=t1;}
|
||||
if(S.grace&&S.grace.until===d){toast(tr('day_tick.the_courtesy_route_has_ended_new'),'bad',[{l:tr('common.open_noc'),act:'leftTab',args:{t:'noc'}}]);}
|
||||
{const a=S.ev.ddos;if(a&&a.until>d&&R&&S.pops[a.city])a.worst=Math.min(a.worst===undefined?1:a.worst,sfOf(R,a.city));}
|
||||
if(scnRule('ddos')&&!(S.scn.done||S.scn.failed)&&d>=(+S.scn.nextDdos||3)&&!(S.ev.ddos&&S.ev.ddos.until>d)){ddosAttack();S.scn.nextDdos=d+3+Math.floor(Math.random()*5);}
|
||||
if(R&&R.demand>0)S.stats.clean=R.served/R.demand>=0.995?(S.stats.clean||0)+1:0;
|
||||
for(const a of ddosAll(S,false))if(a.until>=d&&R&&S.pops[a.city])a.worst=Math.min(a.worst===undefined?1:a.worst,ddosSf(a));
|
||||
ddosExpire();
|
||||
ddosTick();
|
||||
// What the Great Firewall drops is not your outage: it alone kept Anchors Away's 99.5% out of reach (playtest).
|
||||
if(R&&R.demand>0)S.stats.clean=(R.served+(R.gfwLost||0))/R.demand>=0.995?(S.stats.clean||0)+1:0;
|
||||
if(S.scn&&S.scn.id==='redsea')S.stats.asiaRun=asiaG()>=RS_G?(S.stats.asiaRun||0)+1:0;
|
||||
if(S.ev.php===d)toast(tr('day_tick.the_internet_is_back_half_of'),'good');
|
||||
for(const k in S.peers){const [id,c]=k.split('@'),sn=snub(id,c);if(!sn)continue;delete S.peers[k];S.stats.depeered=(S.stats.depeered||0)+1;
|
||||
|
|
@ -24,6 +26,7 @@ function dayTick(){
|
|||
if(sf>=0.9){const g=(CITY[c].be&&!(p.boost>d)?0.35:1)*0.025*(scnRule('boom')?1.5:1)*(p.boost>d?2:1)*sf*(0.7+0.6*(R.peerShare||0))*(CITY[c].reg==='AS'&&!CITY[c].cn?1.6:1);p.bb.d+=g*p.bb.d*(1-p.bb.d/P);}
|
||||
else p.bb.d=Math.max(Math.min(3,P),p.bb.d*(1-(0.9-sf)*0.04));}
|
||||
compute();
|
||||
for(const a of ddosAll())a.worst=Math.min(a.worst??1,ddosSf(a));
|
||||
for(const t of S.transit){(t.hist=t.hist||[]).push(R.useT[t.id]||0);if(t.hist.length>30)t.hist.shift();}
|
||||
S.cash+=(R.revMo-R.costMo)/30;
|
||||
S.stats.peak=Math.max(S.stats.peak,R.served);
|
||||
|
|
@ -31,17 +34,17 @@ function dayTick(){
|
|||
{const top=custLevel();if(top>(S.lvl||1)){for(let lv=(S.lvl||1)+1;lv<=top;lv++){track('level_'+lv);toast(tr('day_tick.customer_level_lv_name_new_customers',{lv,name:LEVELS[lv-1].n,unlock:LEVELS[lv-1].unlock})+`<br><i>${esc(LEVELS[lv-1].q)}</i>`,'goal');}S.lvl=top;sfx('coin');}}
|
||||
for(const l of S.links){if(l.kind!=='df')continue;
|
||||
if(l.ready===d){toast(`<b>${l.own?tr('day_tick.your_fiber_is_finished_a_b',{a:CITY[l.a].name,b:CITY[l.b].name}):tr('day_tick.dark_fiber_handed_over_a_b',{a:CITY[l.a].name,b:CITY[l.b].name})}</b><br>${(l.ch||[]).length?tr('day_tick.channels_are_lighting_up_now'):tr('day_tick.it_is_dark_add_optics_to')}`,'goal',[{l:tr('common.open'),act:'selLink',args:{id:l.id}}]);sfx('coin');}
|
||||
if(l.own&&l.ready>d&&Math.random()<0.012){const extra=10+Math.floor(Math.random()*40);setCableReady(l,l.ready+extra);toast(tr('day_tick.construction_delay_n_days_why_a',{n:extra,why:pick(l.sub?SEA_DELAYS.map(x=>tr(x)):[tr('day_tick.archaeologists_found_a_roman'),tr('day_tick.a_protected_hamster_species_lives'),tr('day_tick.the_railway_changed_its_mind_about'),tr('day_tick.the_drilling_crew_hit_a_granite'),tr('day_tick.a_town_council_wants_a_public'),tr('day_tick.somebody_else_s_gas_main_was'),tr('day_tick.the_permit_office_lost_your_permit')]),a:CITY[l.a].name,b:CITY[l.b].name}),'bad');}}
|
||||
if(l.own&&l.ready>d&&Math.random()<0.012){const extra=10+Math.floor(Math.random()*40);setCableReady(l,l.ready+leadDays(extra));toast(tr('day_tick.construction_delay_n_days_why_a',{n:leadDays(extra),why:pick(l.sub?SEA_DELAYS.map(x=>tr(x)):[tr('day_tick.archaeologists_found_a_roman'),tr('day_tick.a_protected_hamster_species_lives'),tr('day_tick.the_railway_changed_its_mind_about'),tr('day_tick.the_drilling_crew_hit_a_granite'),tr('day_tick.a_town_council_wants_a_public'),tr('day_tick.somebody_else_s_gas_main_was'),tr('day_tick.the_permit_office_lost_your_permit')]),a:CITY[l.a].name,b:CITY[l.b].name}),'bad');}}
|
||||
// DDoS protection SLA: if a protected customer's own city is hit and still goes down, you pay out (once per attack).
|
||||
if(S.ev.ddos&&S.ev.ddos.until>d){const a=S.ev.ddos;
|
||||
for(const b of S.biz)if(b.type==='scrub'&&b.city===a.city&&b.slaFor!==a.start&&sfOf(R,b.city)<0.85){
|
||||
b.slaFor=a.start;S.cash-=SLA_PEN;b.mood=Math.max(0,b.mood-18);S.stats.sla=(S.stats.sla||0)+1;
|
||||
for(const a of ddosAll()){
|
||||
for(const b of S.biz)if(b.type==='scrub'&&b.city===a.city&&!(a.sla||[]).includes(b.id)&&(a.id||b.slaFor!==a.start)&&sfOf(R,b.city)<0.85){
|
||||
(a.sla||(a.sla=[])).push(b.id);b.slaFor=a.start;S.cash-=SLA_PEN;b.mood=Math.max(0,b.mood-18);S.stats.sla=(S.stats.sla||0)+1;
|
||||
toast(tr('day_tick.sla_breach_name_the_attack_on',{name:esc(b.name),city:CITY[a.city].name,pen:fmt$(SLA_PEN)}),'bad');sfx('err');}}
|
||||
// businesses mood
|
||||
const ids=linkIds();for(const b of S.biz.slice()){if(eventTick(b,d)||capPendTick(b,d))continue;b.pm=b.mood;const sf=bizSf(b,ids),reachOk=BIZ_T[b.type].l2||BIZ_T[b.type].fiber||R.reach>0.99||scnRule('local'),scrubOk=b.type!=='scrub'||(hasScrub()&&!scrubFar(b.city)),divOk=reqOk(b);
|
||||
const ids=linkIds(),frr=coreFrr()&&S.links.some(l=>l.cut)?.5:1;for(const b of S.biz.slice()){if(eventTick(b,d)||capPendTick(b,d))continue;b.pm=b.mood;const sf=bizSf(b,ids),reachOk=BIZ_T[b.type].l2||BIZ_T[b.type].fiber||R.reach>0.99||scnRule('local'),scrubOk=b.type!=='scrub'||(hasScrub()&&!scrubFar(b.city)),divOk=reqOk(b);
|
||||
if(sf>=0.95&&reachOk&&scrubOk&&divOk)b.mood=Math.min(100,b.mood+2);
|
||||
else if(S.day-(b.since||0)<15){}
|
||||
else{b.mood-=(Math.max(0,0.95-sf)*45+(!reachOk?3:0)+(!scrubOk?4:0)+(!divOk?3:0));
|
||||
else{b.mood-=frr*(Math.max(0,0.95-sf)*45+(!reachOk?3:0)+(!scrubOk?4:0)+(!divOk?3:0));
|
||||
if(b.mood<=0){S.biz=S.biz.filter(x=>x!==b);toast(tr('day_tick.name_cancelled_too_many_outages_and',{name:esc(b.name),city:CITY[b.city].name}),'bad');sfx('err');}
|
||||
else if(b.mood<30&&!b.warned){b.warned=b.warn60=true;const why=bizWhy(b)[0],paused=pref('pauseFurious')&&autoPause();
|
||||
toast(tr('day_tick.name_is_furious_fix_service_in',{name:esc(b.name),city:CITY[b.city].name})+(why?`<br><i>${esc(why)}</i>`:'')+(paused?`<br><b>${tr('common.game_paused')}</b>`:''),'bad',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}].concat(paused?[resumeAct()]:[]));sfx('err');}
|
||||
|
|
@ -53,20 +56,28 @@ function dayTick(){
|
|||
if(cands.length){cands.sort((a,b)=>(a.pol==='open'?0:1)-(b.pol==='open'?0:1)||b.share-a.share);const n=Math.random()<.6?cands[0]:pick(cands);m.members.push(n.id);toast(tr('day_tick.net_joined_ix_another_member_paying',{net:esc(n.name),ix:esc(m.name),fee:fmt$(MYIX_FEE)}),'good');sfx('coin');}
|
||||
m.next=d+8+Math.floor(Math.random()*10);}}
|
||||
loanTick(d);
|
||||
if(S.mode==='sandbox'&&S.cash<1e8)S.cash=1e9;
|
||||
if(rule('money')==='infinite'&&S.cash<1e8)S.cash=1e9;
|
||||
// offers
|
||||
S.offers=S.offers.filter(o=>o.exp>d);
|
||||
brTick();
|
||||
if(S.offers.length<5&&Math.random()<(0.05+0.01*(S.lvl||1))*(ppol()==='closed'?0.6:1)*(confSpOn()?SP_OFFERS:1))spawnOffer();
|
||||
// failures & events
|
||||
let dirty=false;
|
||||
if(d>=S.nextFail){dirty=true;fireFailure();const size=S.links.length+Object.keys(S.pops).length;S.nextFail=d+Math.round((Math.max(22,50-size*1.5)+Math.floor(Math.random()*25))*(scnRule('chaos')?0.5:1));}
|
||||
if(d>=S.nextEvent){dirty=true;fireEvent();S.nextEvent=d+45+Math.floor(Math.random()*45);}
|
||||
// Chaos (the rules) scales how often: calm waits about three times as long, spicy comes almost twice as often, none never.
|
||||
let dirty=false;const cm=chaosMul();
|
||||
// A visiting chaos monkey does the breaking instead (its snips replace these while it is here).
|
||||
mkTick(d);
|
||||
if(cm&&d>=S.nextFail&&!mkOn()){dirty=true;fireFailure();const size=S.links.length+Object.keys(S.pops).length;S.nextFail=d+Math.round((Math.max(22,50-size*1.5)+Math.floor(Math.random()*25))*(scnRule('chaos')?0.5:1)/cm);}
|
||||
// Anchors Away: on top of the usual failures, ships drag anchors over each Baltic seabed link (about three cuts a link-year).
|
||||
if(cm&&d>45&&scnRule('anchors')){const n=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l)&&anchorProne(l)).length;if(n&&Math.random()<Math.min(5,+S.scn.rules.anchors||1)*n/365){dirty=true;fireFailure('cut');}}
|
||||
if(cm&&d>=S.nextEvent){dirty=true;fireEvent();S.nextEvent=d+Math.round((45+Math.floor(Math.random()*45))/cm);}
|
||||
if(dirty)compute();
|
||||
opsDay(d);
|
||||
// payday floaters
|
||||
if(d%30===0){for(const c in S.pops){let v=(R.cityEye[c]*sfOf(R,c)*EYE_RATE)+S.biz.filter(b=>b.city===c).reduce((a,b)=>a+b.bw*b.rate,0);v=v-R.cityEye[c]*sfOf(R,c)*EYE_RATE*(1-(CITY[c].arpu||1));if(v>500)floater(CITY[c].x,CITY[c].y-30,'+'+fmt$(v),'#16A866');}sfx('coin');}
|
||||
if(d%30===0){for(const c in S.pops){let v=(R.cityEye[c]*sfOf(R,c)*EYE_RATE)+S.biz.filter(b=>b.city===c).reduce((a,b)=>a+b.bw*b.rate,0);v=v-R.cityEye[c]*sfOf(R,c)*EYE_RATE*(1-arpuOf(c));if(v>500)floater(CITY[c].x,CITY[c].y-30,'+'+fmt$(v),'#16A866');}sfx('coin');}
|
||||
checkGoals();
|
||||
scnTick(d);
|
||||
confTick(d);
|
||||
specDay(d);
|
||||
// money trouble
|
||||
if(S.cash<0){S.neg++;if(S.neg===1)toast(tr('day_tick.you_are_in_the_red_cancel'),'bad');}
|
||||
else S.neg=0;
|
||||
|
|
@ -75,15 +86,21 @@ function dayTick(){
|
|||
if(d%10===0)save();
|
||||
}
|
||||
function spawnOffer(){
|
||||
const mine=spMine(Object.keys(S.pops)),lv=S.lvl||1;
|
||||
const mine=spMine(Object.keys(S.pops)),lv=lvl();
|
||||
const types=['dia','dia','game','host'];if(mine.length>=2)types.push('l2vpn','l2vpn');if(S.day>60)types.push('scrub');
|
||||
if(lv>=2)types.push('isp','stream','edu','host','hft','bulk','event','event');if(mine.length>=3&&lv>=2)types.push('sdwan','sdwan');
|
||||
if(S.links.some(l=>l.kind==='df'&&l.ready<=S.day))types.push('wwave','wwave');if(S.links.some(l=>l.kind==='df'&&l.own&&l.ready<=S.day))types.push('dfpair');if(lv>=3)types.push('gpu','gpu','onramp','onramp');if(lv>=4)types.push('ai','ai','hyper','hyper');
|
||||
if(lv>=3&&MEGA.some(m=>mine.includes(m.c)))types.push('ingest');if(lv>=4&&MEGA.some(m=>mine.includes(m.c)))types.push('aiwan','aiwan','mtrain');if(lv>=4&&S.links.some(l=>l.kind==='df'&&l.own&&l.ready<=S.day))types.push('pairs');
|
||||
if(lv>=5)types.push('esport');if(lv>=6&&mine.length>=2)types.push('sov','sov');if(lv>=8)types.push('cgame','cgame');if(lv>=9)types.push('metav','metav');if(lv>=11&&MEGA.some(m=>mine.includes(m.c)))types.push('agi');if(lv>=13&&mine.length>=2)types.push('mars');
|
||||
const br=mine.filter(c=>CITY[c].br);if(br.length)types.push('provedor','provedor','provedor');
|
||||
// Countries with thousands of ASNs (Brazil's provedores, US regionals) are full of small ISPs shopping for transit.
|
||||
const dense=mine.filter(c=>(CITY_PDB[c]||[])[2]>=2000);if(lv>=2&&dense.length)types.push('isp');
|
||||
const fabC=mine.filter(c=>FABS.some(f=>f.cities.includes(c)));if(lv>=2&&fabC.length){types.push('fabip','fabip');if(mine.length>=2)types.push('fabl2');}
|
||||
// What your network can already serve calls too, at a lower weight and the smallest size (#187).
|
||||
const sp=spots(),spT=[...new Set(sp.map(s=>s.t))],bq=charter()==='boutique';for(const x of spT){types.push(x);if(x==='hft'&&bq)types.push(x,x);}if(bq&&lv>=2)types.push('hft','hft');
|
||||
types.push(...coreProducts(mine));
|
||||
const t=pick(types),T=BIZ_T[t];
|
||||
if(T.lv>lv&&spT.includes(t)){spawnSpot(t,pick(sp.filter(s=>s.t===t)));return;}
|
||||
if(T.event||T.sdwan||T.fiber||T.mega){spawnSpecial(t);return;}
|
||||
if(T.nni){const city=pick(fabC),prov=pick(FABS.filter(f=>f.cities.includes(city))).id,bw=pick(T.opts),others=mine.filter(c=>c!==city),city2=T.l2&&others.length?pick(others):null;if(T.l2&&!city2)return;
|
||||
const base=pick(BIZ_N.filter(n=>!S.usedNames.includes(n)).concat(BIZ_N)).replace(/ (Inc\.|Co\.|Ltd)$/,'');const name=tr('day_tick.name_via_fab',{name:base,fab:FAB[prov].name});useName(base);
|
||||
|
|
@ -96,8 +113,9 @@ function spawnOffer(){
|
|||
let name=list.length?pick(list):(T.names?pick(T.names):'Startup #'+Math.floor(Math.random()*999));
|
||||
useName(name);
|
||||
if(t==='provedor')city=pick(br);
|
||||
if(t==='isp'&&dense.length&&Math.random()<0.5)city=pick(dense);
|
||||
if(t==='hft'){const fin=['nyc','chi','lon','fra','tok','sin','hkg','ams','ash'],mf=mine.filter(c=>fin.includes(c));city=mf.length?pick(mf):pick(mine);city2=pick(fin.filter(c=>c!==city));}
|
||||
let rate=T.l2?Math.round((150+kmBetween(city,city2)*0.08)*T.km):T.rate;
|
||||
let rate=T.l2?Math.round((150+kmBetween(city,city2)*0.08)*T.km*(T.lat?latPay():1)):T.rate;
|
||||
if(CITY[city].au&&!T.l2&&!T.fiber&&!T.event){rate=Math.round(rate*AU_ARPU);bw=Math.min(bw,pick(T.opts.slice(0,2)));}
|
||||
if(T.div&&!reqCan('diverse',{city,city2}))return;
|
||||
const reqs=T.div?['diverse']:T.lat?['lat']:[];if((t==='hyper'||t==='ai'||t==='gpu')&&Math.random()<0.4)reqs.push('metro');const pool=Object.keys(REQS).filter(k=>!reqs.includes(k)&&!REQS[k].only&&(!REQS[k].l2||T.l2)&&(!REQS[k].ip||!T.l2)&&reqCan(k,{city,city2}));
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ const RARITY={c:{n:tr('common.common'),col:'#16A866'},r:{n:tr('common.rare'),col
|
|||
const st=()=>S.stats||{};
|
||||
const BADGES=[
|
||||
{id:'hello',i:'👋',t:tr('common.hello_neighbour'),d:tr('badges.bring_up_your_first_peering_session'),r:'c',ok:()=>R.sessions>=1},
|
||||
{id:'backhoe',i:'🚜',t:tr('badges.met_the_backhoe'),d:tr('badges.have_a_fiber_cut'),r:'c',ok:()=>(st().by||{}).cut>=1},
|
||||
// Keeps its old id so badges already earned (in saves and the hall of fame) carry over.
|
||||
{id:'backhoe',i:'🐒',t:tr('badges.met_the_chaos_monkey'),d:tr('badges.get_a_visit_from_the_chaos_monkey'),r:'c',ok:()=>(st().mkMet||0)>=1},
|
||||
{id:'debt',i:'🏦',t:tr('badges.in_debt_we_trust'),d:tr('badges.take_out_a_loan'),r:'c',ok:()=>(st().loans||0)>=1||(S.loans||[]).length>0},
|
||||
{id:'twins',i:'👯',t:tr('common.twins'),d:tr('badges.run_two_routers_in_one_pop'),r:'c',ok:()=>Object.values(S.pops).some(p=>(p.routers||1)>=2)},
|
||||
{id:'shark',i:'🦈',t:tr('common.shark_week'),d:tr('badges.get_a_subsea_cable_bitten_by'),r:'r',ok:()=>(st().sharks||0)>=1},
|
||||
|
|
@ -26,6 +27,8 @@ const BADGES=[
|
|||
{id:'giants',i:'🏭',t:tr('badges.friend_of_giants'),d:tr('badges.hold_deals_at_3_different_ai'),r:'e',ok:()=>new Set(S.biz.filter(b=>BIZ_T[b.type]&&BIZ_T[b.type].mega).flatMap(b=>bCities(b))).size>=3},
|
||||
{id:'landlord',i:'🧵',t:tr('common.trench_landlord'),d:tr('badges.lease_hundreds_of_fiber_pairs_to'),r:'e',ok:()=>S.biz.some(b=>b.type==='pairs')},
|
||||
{id:'t1',i:'👑',t:tr('common.tier_1'),d:tr('badges.go_transit_free'),r:'e',ok:()=>!!S.won},
|
||||
{id:'sol',i:'⚡',t:tr('specialist.speed_of_light'),d:tr('specialist.win_as_a_low_latency_boutique'),r:'e',ok:()=>!!S.solWon},
|
||||
{id:'seat',i:'🚢',t:tr('specialist.part_owner_of_the_sea'),d:tr('specialist.take_a_seat_on_a_consortium'),r:'r',ok:()=>S.links.some(l=>l.seat)},
|
||||
{id:'bait',i:'🎣',t:tr('common.shark_bait'),d:tr('badges.get_bitten_by_sharks_3_times'),r:'l',ok:()=>(st().sharks||0)>=3},
|
||||
{id:'nines',i:'💎',t:tr('common.five_nines'),d:tr('badges.serve_99_5_of_demand_every'),r:'l',ok:()=>(st().clean||0)>=365},
|
||||
{id:'fifty',i:'🗺️',t:tr('badges.everywhere_at_once'),d:tr('badges.have_pops_in_50_cities'),r:'l',ok:()=>Object.keys(S.pops).length>=50},
|
||||
|
|
@ -66,20 +69,43 @@ const BADGES=[
|
|||
{id:'toaster',i:'🍞',t:tr('common.toaster_wrangler'),d:tr('badges.weather_a_ddos_with_your_defences'),r:'c',ok:()=>(st().ddosHeld||0)>=1},
|
||||
{id:'cleanpipe',i:'🚿',t:tr('common.clean_pipes'),d:tr('badges.turn_on_a_transit_clean_pipe'),r:'r',ok:()=>S.transit.some(t=>t.clean)},
|
||||
{id:'lamb',i:'🐐',t:tr('common.sacrificial_lamb'),d:tr('badges.run_a_sacrificial_pni_choke_point'),r:'r',ok:()=>S.pni.some(p=>p.sacrif)},
|
||||
{id:'monkey',i:'🛡️',t:tr('badges.monkey_proof'),d:tr('badges.outlast_a_chaos_monkey_visit'),r:'e',ok:()=>(st().mkSurv||0)>=1},
|
||||
{id:'flood',i:'🌊',t:tr('badges.held_the_flood'),d:tr('badges.weather_a_multi_terabit_ddos'),r:'e',ok:()=>(st().ddosMonster||0)>=1},
|
||||
{id:'skynot',i:'🤖',t:tr('common.skynot_smiles'),d:tr('badges.land_a_hackback_3000tm_that_actually'),r:'e',secret:true,ok:()=>(st().hackWin||0)>=1},
|
||||
{id:'label',i:'🏷️',t:tr('core.label_switcher'),d:tr('core.run_an_mpls_backbone'),r:'c',ok:()=>coreOn()&&S.core.run>=1},
|
||||
{id:'bleed',i:'🩸',t:tr('core.bleeding_edge'),d:tr('core.run_an_srv6_backbone'),r:'r',ok:()=>coreOn()&&S.core.run>=4},
|
||||
{id:'mono',i:'🏪',t:tr('core.single_vendor_shop'),d:tr('core.run_sr_mpls_or_srv6_on'),r:'e',ok:()=>coreOn()&&S.core.run>=3&&Object.keys(S.pops).length>=8&&!coreOut().length&&coreVendors().size===1},
|
||||
{id:'zoo',i:'🦓',t:tr('core.vendor_zoo'),d:tr('core.run_an_mpls_backbone_with_4'),r:'r',ok:()=>coreOn()&&S.core.run>=1&&coreVendors().size>=4},
|
||||
{id:'zero',i:'🕳️',t:tr('badges.zero_peers_given'),d:tr('badges.reach_tier_2_with_every_single'),r:'l',secret:true,ok:()=>isTier2()&&!Object.keys(S.peers).length&&!S.pni.length},
|
||||
];
|
||||
function hof(){try{return JSON.parse(localStorage.getItem('sot-badges')||'{}')||{};}catch(e){return {};}}
|
||||
function checkBadges(){S.ach=S.ach||{};if(S.mode==='sandbox')return;let h=null;
|
||||
for(const b of BADGES){if(S.ach[b.id]!==undefined)continue;let ok=false;try{ok=b.ok();}catch(e){}
|
||||
if(!ok)continue;S.ach[b.id]=S.day;const R0=RARITY[b.r];
|
||||
if(!h)h=hof();if(!h[b.id])h[b.id]={d:new Date().toISOString().slice(0,10),n:S.name};
|
||||
toast(`<b>${b.i} ${tr('badges.badge_unlocked_name',{name:esc(b.t)})}</b><br><span style="color:${R0.col};font-weight:900">${R0.n}</span> · ${esc(b.d)}`,'goal',[],{a:'tab',v:'goals'});sfx('coin');track('badge_'+b.id);}
|
||||
/* Badge variants by ruleset (2.0): On-call earns the standard badge, Change Freeze a frosted one and BGP at 3 a.m. a
|
||||
fiery one; Sandbox and the puzzles earn none (puzzles have stars). Earning a badge again under a harder preset
|
||||
upgrades its look, here and in the hall of fame. S.ach[id] stays the day it was earned; S.achP[id] is its variant. */
|
||||
const BVAR={freeze:{k:'freeze',lv:1,i:'🧊',n:N_('badges.variant_freeze_dried'),col:'#5BC0EB'},oncall:{k:'oncall',lv:2,i:'⭐',n:N_('badges.variant_on_call'),col:'#FFD23F'},bgp:{k:'bgp',lv:3,i:'🔥',n:N_('badges.variant_forged_at_3_a_m'),col:'#FF5A1F'}};
|
||||
const BVAR_IDS=['freeze','oncall','bgp'],bvar=k=>own(BVAR,k)?BVAR[k]:BVAR.oncall;
|
||||
// The preset this save plays under ('oncall' for every save from before rulesets), and the variant it earns (null: none).
|
||||
const rulePre=()=>(typeof rulePreset==='function'?rulePreset():(S&&S.rules&&S.rules.preset))||'oncall';
|
||||
function badgeVar(){if(!S||S.mode==='sandbox')return null;const p=rulePre();return p==='sandbox'||p==='puzzle'?null:own(BVAR,p)?p:'oncall';}
|
||||
// The hall of fame is this device's localStorage, so it is checked like a save: unknown variants count as standard.
|
||||
function hof(){let h;try{h=JSON.parse(localStorage.getItem('sot-badges')||'{}');}catch(e){h=null;}if(!h||typeof h!=='object'||Array.isArray(h))return {};
|
||||
for(const k of Object.keys(h)){const x=h[k];if(!x||typeof x!=='object'){delete h[k];continue;}const vs=x.vs&&typeof x.vs==='object'&&!Array.isArray(x.vs)?x.vs:{};
|
||||
x.vs={};for(const v of BVAR_IDS)if(typeof vs[v]==='string')x.vs[v]=vs[v];if(!Object.keys(x.vs).length)x.vs.oncall=typeof x.d==='string'?x.d:'';
|
||||
x.v=BVAR_IDS.filter(v=>x.vs[v]!==undefined).pop();}
|
||||
return h;}
|
||||
function checkBadges(){S.ach=S.ach||{};S.achP=S.achP||{};const v=badgeVar();if(!v)return;let h=null;const V=BVAR[v];
|
||||
for(const b of BADGES){const had=S.ach[b.id]!==undefined;if(had&&bvar(S.achP[b.id]).lv>=V.lv)continue;let ok=false;try{ok=b.ok();}catch(e){}
|
||||
if(!ok)continue;if(!had)S.ach[b.id]=S.day;S.achP[b.id]=v;const R0=RARITY[b.r];
|
||||
// "Upgraded" is about this device's collection: the hall of fame already held the badge, only in a lower variant.
|
||||
if(!h)h=hof();const today=new Date().toISOString().slice(0,10),up=!!h[b.id]&&bvar(h[b.id].v).lv<V.lv,x=h[b.id]||(h[b.id]={d:today,n:S.name,vs:{}});if(x.vs[v]===undefined)x.vs[v]=today;if(bvar(x.v).lv<V.lv||!x.v)x.v=v;
|
||||
toast(`<b>${b.i} ${up?tr('badges.badge_upgraded_name',{name:esc(b.t)}):tr('badges.badge_unlocked_name',{name:esc(b.t)})}</b><br><span style="color:${R0.col};font-weight:900">${R0.n}</span>${v==='oncall'?'':` · <span class="bvt v-${v}">${V.i} ${tr(V.n)}</span>`} · ${esc(b.d)}`,'goal',[],{a:'tab',v:'goals'});sfx('coin');track('badge_'+b.id+(v==='oncall'?'':'_'+v));}
|
||||
if(h)try{localStorage.setItem('sot-badges',JSON.stringify(h));}catch(e){}}
|
||||
function badgeGrid(){const h=hof(),got=BADGES.filter(b=>S.ach&&S.ach[b.id]!==undefined).length;
|
||||
return `<h3 style="font-size:15px;margin:14px 0 6px">${tr('common.badges')} <span class="meta">${tr('badges.got_total_this_game_ever_ever',{got,total:BADGES.length,ever:Object.keys(h).filter(k=>BADGES.some(b=>b.id===k)).length})}</span></h3><div class="badges">${BADGES.map(b=>{const on=S.ach&&S.ach[b.id]!==undefined,ever=!!h[b.id],R0=RARITY[b.r],hide=b.secret&&!on&&!ever;
|
||||
return `<div class="bdg ${on?'on':ever?'ever':''}" style="--rc:${R0.col}" title="${esc(hide?tr('badges.a_secret_badge'):b.t+': '+b.d)}"><span class="bi">${hide?'❔':b.i}</span><span class="bt">${esc(hide?'???':b.t)}</span><span class="br">${R0.n}${ever&&!on?' · '+tr('common.earned_before'):''}</span>${hide?'':`<span class="bd">${esc(b.d)}</span>`}</div>`;}).join('')}</div>`;}
|
||||
// How many badges this device has ever earned in each variant: the collection.
|
||||
function badgeShelf(h){const o={freeze:0,oncall:0,bgp:0};for(const b of BADGES){const x=h[b.id];if(x)for(const v of BVAR_IDS)if(x.vs[v]!==undefined)o[v]++;}return o;}
|
||||
function badgeGrid(){const h=hof(),got=BADGES.filter(b=>S.ach&&S.ach[b.id]!==undefined).length,sh=badgeShelf(h),V=badgeVar();
|
||||
return `<h3 style="font-size:15px;margin:14px 0 6px">${tr('common.badges')} <span class="meta">${tr('badges.got_total_this_game_ever_ever',{got,total:BADGES.length,ever:Object.keys(h).filter(k=>BADGES.some(b=>b.id===k)).length})}</span></h3>
|
||||
<div class="bshelf">${BVAR_IDS.map(v=>`<span class="bsh v-${v}${V===v?' cur':''}">${BVAR[v].i} ${esc(tr(BVAR[v].n))} <b>${sh[v]}/${BADGES.length}</b></span>`).join('')}</div>${V&&V!=='oncall'?`<p class="meta" style="margin:0 0 6px">${V==='bgp'?tr('badges.this_game_earns_fiery_badges'):tr('badges.this_game_earns_frosted_badges')}</p>`:''}
|
||||
<div class="badges">${BADGES.map(b=>{const on=S.ach&&S.ach[b.id]!==undefined,ever=!!h[b.id],R0=RARITY[b.r],hide=b.secret&&!on&&!ever,vk=on?bvar(S.achP&&S.achP[b.id]).k:ever?h[b.id].v:'',vn=vk&&vk!=='oncall'?' · '+BVAR[vk].i+' '+tr(BVAR[vk].n):'';
|
||||
return `<div class="bdg ${on?'on':ever?'ever':''}${vk?' v-'+vk:''}" style="--rc:${R0.col}" title="${esc(hide?tr('badges.a_secret_badge'):b.t+': '+b.d+vn)}"><span class="bi">${hide?'❔':b.i}</span><span class="bt">${esc(hide?'???':b.t)}</span><span class="br">${R0.n}${ever&&!on?' · '+tr('common.earned_before'):''}</span>${vk&&vk!=='oncall'?`<span class="bv">${BVAR[vk].i} ${esc(tr(BVAR[vk].n))}</span>`:''}${hide?'':`<span class="bd">${esc(b.d)}</span>`}</div>`;}).join('')}</div>`;}
|
||||
function checkGoals(){checkBadges();
|
||||
for(const g of GOALS){if(S.done[g.id]!==undefined)continue;let ok=false;try{ok=g.ok();}catch(e){}
|
||||
if(ok){S.done[g.id]=S.day;if(g.r&&S.mode!=='sandbox'){S.cash+=g.r;}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
/* ================= ACTIONS ================= */
|
||||
function spend(c){if(S.cash<c){toast(tr('interface.not_enough_cash_wait_for_revenue'),'bad');sfx('err');return false;}S.cash-=c;sfx('build');return true;}
|
||||
const ACT={
|
||||
speed:({v})=>{v=+v;if(![0,0.5,1,2,4,8].includes(v))return;if(v)UI.lastSpeed=v;UI.speed=v;renderHUD();},
|
||||
linkCheck:({id})=>{const l=S.links.find(x=>x.id===id);if(!l||linkDown(l))return;linkCheckModal(l);},
|
||||
speed:({v})=>{v=+v;if(pzOn())return;if(![0,0.5,1,2,4,8].includes(v)||(S&&!rule('clock')&&v))return;if(v)UI.lastSpeed=v;UI.speed=v;renderHUD();},
|
||||
help:()=>showHelp(),
|
||||
dash:()=>{if(!S)return;const d=$('dash');d.hidden=!d.hidden;if(!d.hidden)renderDash();},
|
||||
dash:()=>{if(!S||pzOn())return;const d=$('dash');d.hidden=!d.hidden;if(!d.hidden)renderDash();},
|
||||
dashClose:()=>{$('dash').hidden=true;},
|
||||
dashTab:({k})=>{if(!DTABS.includes(k))return;UI.dtab=k;renderDash();const d=$('dash');if(d)d.scrollTop=0;},
|
||||
dashSort:({k})=>{if(!['name','asn','type','traffic','cost','lost'].includes(k))return;if(UI.dashSort===k)UI.dashDir=-(UI.dashDir||-1);else{UI.dashSort=k;UI.dashDir=k==='name'||k==='type'||k==='asn'?1:-1;}renderDash();},
|
||||
bank:()=>{if(!S)return;UI.confirm=null;$('dash').hidden=true;const b=$('bankBox');b.hidden=false;UI._bh=null;renderBank();},
|
||||
bank:()=>{if(!S||pzOn())return;UI.confirm=null;$('dash').hidden=true;const b=$('bankBox');b.hidden=false;UI._bh=null;renderBank();},
|
||||
bankClose:()=>{UI.confirm=null;$('bankBox').hidden=true;},
|
||||
takeLoan:({id})=>{const o=S.loanOffers.find(x=>x.id===id);if(!o)return;S.stats.loans=(S.stats.loans||0)+1;const B=BANKS[o.bank];let got=o.amount,note='';
|
||||
if(B.crypto){const f=0.55+Math.random()*0.8;got=Math.round(o.amount*f);note=' '+(f>=1?tr('interface.tubecoin_moved_up_p_on_the',{p:Math.round(Math.abs(f-1)*100)}):tr('interface.tubecoin_moved_down_p_on_the',{p:Math.round(Math.abs(f-1)*100)}));}
|
||||
|
|
@ -29,12 +30,12 @@ const ACT={
|
|||
tab:({t})=>{UI.tab=t;UI.confirm=null;renderPanel();},
|
||||
leftTab:({t})=>{UI.left=t;UI.leftOpen=true;renderLeft();},
|
||||
netFocus:({id})=>{if(!NET[id])return;$('dash').hidden=true;UI.netFocus=id;UI.nf='all';UI.left='nets';UI.leftOpen=true;UI.sel=null;renderPanel();renderLeft();const b=$('leftBody');if(b)b.scrollTop=0;},
|
||||
netFilter:({f})=>{UI.nf=f==='out'?'out':'all';UI.netFocus=null;$('dash').hidden=true;UI.left='nets';UI.leftOpen=true;UI.sel=null;renderPanel();renderLeft();const b=$('leftBody');if(b)b.scrollTop=0;},
|
||||
netFilter:({f})=>{UI.nf=f==='out'?'out':'all';listReset('nets');UI.netFocus=null;$('dash').hidden=true;UI.left='nets';UI.leftOpen=true;UI.sel=null;renderPanel();renderLeft();const b=$('leftBody');if(b)b.scrollTop=0;},
|
||||
meetGo:({city})=>{if(!isCity(city))return;$('dash').hidden=true;ACT.focusCity({city});if(S.pops[city]){UI.tab='peer';renderPanel();}},
|
||||
toggleLeft:()=>{UI.leftOpen=!UI.leftOpen;renderLeft();},
|
||||
phoneTab:({t})=>{if(!['goals','deals','noc','nets'].includes(t))return;haptic(8);if(UI.leftOpen&&UI.left===t&&!UI.sel){UI.leftOpen=false;}else{UI.left=t;UI.leftOpen=true;UI.sel=null;renderPanel();}$('left').classList.remove('full');renderLeft();},
|
||||
phonePlay:()=>{haptic(10);if(UI.speed){UI.lastSpeed=UI.speed;UI.speed=0;}else UI.speed=UI.lastSpeed||1;renderHUD();},
|
||||
phoneSpeed:()=>{haptic(8);const cur=UI.speed||UI.lastSpeed||1,i=SPEEDS.indexOf(cur),n=SPEEDS[(i+1)%SPEEDS.length];UI.speed=n;UI.lastSpeed=n;renderHUD();},
|
||||
phoneTab:({t})=>{if(!['goals','deals','noc','nets'].includes(t))return;if($('modal').classList.contains('link-check'))closeModal();haptic(8);if(UI.leftOpen&&UI.left===t&&!UI.sel){UI.leftOpen=false;}else{UI.left=t;UI.leftOpen=true;UI.sel=null;renderPanel();}$('left').classList.remove('full');renderLeft();},
|
||||
phonePlay:()=>{if(pzOn())return;if(S&&!rule('clock'))return;haptic(10);if(UI.speed){UI.lastSpeed=UI.speed;UI.speed=0;}else UI.speed=UI.lastSpeed||1;renderHUD();},
|
||||
phoneSpeed:()=>{if(pzOn())return;if(S&&!rule('clock'))return;haptic(8);const cur=UI.speed||UI.lastSpeed||1,i=SPEEDS.indexOf(cur),n=SPEEDS[(i+1)%SPEEDS.length];UI.speed=n;UI.lastSpeed=n;renderHUD();},
|
||||
install:()=>{if(installEvt){installEvt.prompt();installEvt.userChoice.finally(()=>{installEvt=null;});return;}
|
||||
openModal(pitchHtml(false));},
|
||||
pitchSkip:()=>{const p=UI.pendGame;UI.pendGame=null;UI.pitched=true;if(p)beginGame(...p);else closeModal();},
|
||||
|
|
@ -42,7 +43,7 @@ const ACT={
|
|||
if(o.a==='city'&&isCity(o.v)){ACT.focusCity({city:o.v});return;}
|
||||
if(o.a==='link'){if(S.links.some(l=>l.id===o.v)){ACT.selLink({id:o.v});return;}toast(tr('interface.that_link_is_gone_it_was'),'');return;}
|
||||
if(o.a==='cust'){if(S.biz.some(b=>b.id===o.v)){ACT.custGo({id:o.v});return;}toast(tr('interface.that_customer_is_gone_the_contract'),'');return;}
|
||||
if(o.a==='bank'){ACT.bank({});return;}if(o.a==='inbox'){ACT.inbox({});return;}if(o.a==='tab'&&LOG_TABS.includes(o.v))ACT.leftTab({t:o.v});},
|
||||
if(o.a==='bank'){ACT.bank({});return;}if(o.a==='ops'){ACT.opsOpen();return;}if(o.a==='tab'&&LOG_TABS.includes(o.v))ACT.leftTab({t:o.v});},
|
||||
logAll:()=>{UI.logAll=!UI.logAll;renderLeft();},
|
||||
focusCity:({city})=>{selectCity(city);const C=CITY[city];cam.x=C.x;cam.y=C.y;cam.z=Math.max(cam.z,1.2);if(innerWidth<760)UI.leftOpen=false;renderLeft();},
|
||||
selLink:({id})=>selectLink(id),
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue