IPv4 address space: scarce, bought, leased, leased out; IPv6 is free (#150)
A rule (ip4), on in On-call and BGP at 3 a.m., off in the gentler presets, sandbox and puzzles; scenarios only when they opt in. You start with a /21 from the registry, sized so the early game never notices (a gameplay-rules F1 test plays six start cities for 50 days). Business customers need a block by kind and size; broadband homes take what is left and the rest go behind CGNAT, which costs a box per home and annoys some customers. An offer that does not fit cannot be signed and says why, and a customer that cannot grow at renewal stays its size. The bank's Address space section buys and sells blocks on a transfer market with a gentle trend, leases blocks in, and leases spare blocks out for monthly income, in real CIDR sizes (/24 to /16), at most 256 blocks (what a save keeps). Old saves get what they already use, plus room, so nothing changes on load. The dashboard's AS box now lists the blocks you announce.
This commit is contained in:
parent
2cd6b71198
commit
eac0604300
34 changed files with 957 additions and 32 deletions
|
|
@ -46,7 +46,7 @@ These are what the game promises, held up by `tests/gameplay-rules.test.js` (one
|
|||
| --- | --- | --- |
|
||||
| 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: Best Effort never harsher than Change Freeze, Change Freeze never harsher than On-call, BGP at 3 a.m. never gentler (chaos, lead times, market; and a seeded year of incidents). Only Best Effort mends sea cuts without ships, skips conferences, rescues instead of game over, has patient customers and instant PNIs. | 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, cable ships (`sea`), conferences (`confs`), going broke (`broke`), customer patience (`moods`), PNI delivery (`pnis`), and the day's toasts (quiet notifications). A quiet ruleset gives a quiet year. | Rules are presets of flags, not separate code. |
|
||||
| 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, cable ships (`sea`), conferences (`confs`), going broke (`broke`), customer patience (`moods`), PNI delivery (`pnis`), scarce IPv4 and CGNAT (`ip4`, On-call and BGP at 3 a.m. only; scenarios opt in), and the day's toasts (quiet notifications). 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. |
|
||||
| M6 | A Normal game picks its charter once, when it starts (sandbox, puzzles and scenarios never do). A charter changes what you set out to do, never what things cost: the Cable broker gets glass (fiber, line systems, optics, own subsea cables and the routers to light them) from day one at the prices everyone pays at the top level, and everything else by level. | Same prices and rules for every charter (#300). |
|
||||
|
|
@ -64,7 +64,7 @@ These are what the game promises, held up by `tests/gameplay-rules.test.js` (one
|
|||
|
||||
| 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. |
|
||||
| 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. Its first IPv4 block covers the start: no home behind CGNAT, no IPv4 bill and no IPv4 warning before day 50, even signing every offer that fits. | 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. |
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ All notable changes to this project are documented here. The project follows
|
|||
- Dark mode: pick Light, Dark or Auto (follows your device) under Settings › Theme. The panels, the NOC dashboard and the map all go dark, with a night-time sea and land, and the setting is kept on your device (#80).
|
||||
- Your intern can standardize your routers on a model you choose: pick it in Keep routers ahead, and every POP on a smaller model is swapped to it, the busiest first, within the monthly budget. Every setting in the Standing orders sheet is now a list to pick from instead of a button to tap through.
|
||||
- Set a build standard for your whole network: routers, a second building and a generator at every POP, LAGs, exchange ports and PNIs, line systems, optics and wave sizes, all in one sheet. New POPs get the POP part the day they open, the sheet shows what is below the standard and what fixing it costs, one tap brings everything up, and the new "Keep to the build standard" order has your intern do it a few jobs a day with money to spare. Find it in the menu, the Standing orders sheet and every POP's router section.
|
||||
- IPv4 is scarce now: business customers need public address blocks, and the homes that do not fit share addresses behind CGNAT. A new network starts with a /21 from its registry, enough for its first months; buy, lease or sell blocks from /24 to /16 on the transfer market in the bank's new Address space section, or lease spare ones out for a monthly income. An offer you have no addresses for says so and waits, a customer that wants to grow at renewal stays at its size until you have the addresses, CGNAT costs a little and annoys some gamers, and you pick how many homes share an address. IPv6 stays free for everyone. This is part of On-call and BGP at 3 a.m.; the gentler rules, Sandbox, puzzles and scenarios keep IPv4 plentiful, and saved games get the addresses they already use plus room to grow (#150).
|
||||
|
||||
## [3.0.0] — 2026-11-06
|
||||
|
||||
|
|
|
|||
|
|
@ -185,5 +185,8 @@
|
|||
return { a, b, c };
|
||||
};
|
||||
const acts = () => Object.keys(ACT);
|
||||
window.__fz = { acts, direct, lists, start, state, screen, press, close, poke, day, routing, parts, sKeys, sDigest, sParts, check, errs, modalOpen };
|
||||
// Scarce IPv4 off (#150, rule ip4), the same rules object with its keys in the same order on both pages: the driver calls
|
||||
// it only while the base has no such rule, so the pages play the same game until it lands.
|
||||
const noIp4 = () => { if (S && S.rules) { const { ip4, mods, ...r } = S.rules; S.rules = { ...r, ip4: false, mods }; } };
|
||||
window.__fz = { acts, direct, lists, start, state, screen, press, close, poke, day, routing, parts, sKeys, sDigest, sParts, check, errs, modalOpen, noIp4 };
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ function playGame(pages, seed, opts = {}) {
|
|||
preset: kind === 'sandbox' ? r.pick(['none', 'calm', 'normal', 'spicy']) : r.pick(PRESETS),
|
||||
id: kind === 'scenario' ? r.pick(L.scn) : kind === 'puzzle' ? r.pick(L.pz) : kind === 'architect' ? r.pick(L.ar) : undefined };
|
||||
const [s0, s1] = both('start', st);
|
||||
// A base without scarce IPv4 (#150) plays the classic game: both pages switch the rule off. Once it is on main, both play it.
|
||||
if (!base.call('acts').includes('ip4Buy')) both('noIp4');
|
||||
same('start', s0, s1);
|
||||
note('start ' + JSON.stringify(st));
|
||||
// A normal game signs its charter first: a popup on newer pages (which seeded pages skip), a card on older ones. Both
|
||||
|
|
|
|||
|
|
@ -2640,6 +2640,54 @@
|
|||
"interface.tubecoin_moved_down_p_on_the":"TubeCoin ist auf dem Weg zu deinem Konto um {p} % gefallen.",
|
||||
"interface.tubecoin_moved_up_p_on_the":"TubeCoin ist auf dem Weg zu deinem Konto um {p} % gestiegen.",
|
||||
"interface.you_bought_out_bank_they_flew":"<b>Du hast {bank} ausbezahlt.</b><br>Sie sind weitergeflogen, um ein anderes Startup zu finden.",
|
||||
"ip4.block_size":"Blockgröße",
|
||||
"ip4.blocks":"Deine Blöcke",
|
||||
"ip4.bought":"Einen {p}-Block ({n} Adressen) für {price} gekauft.",
|
||||
"ip4.bought_on":"Gekauft {date}",
|
||||
"ip4.business":"Von Geschäftskunden genutzt",
|
||||
"ip4.buy":"Kaufen {price}",
|
||||
"ip4.cgnat_boxes":"CGNAT-Boxen",
|
||||
"ip4.cgnat_note":"Mehr Haushalte pro Adresse macht Platz für Kunden, aber Spiele und Portweiterleitungen leiden: {p} der Rechnung eines CGNAT-Haushalts gehen als Erstattung zurück.",
|
||||
"ip4.cgnat_ratio":"CGNAT: Haushalte pro Adresse",
|
||||
"ip4.costs_row":"IPv4-Mieten und CGNAT",
|
||||
"ip4.free":"Frei für neue Kunden (Haushalte kommen zuerst hinter CGNAT)",
|
||||
"ip4.from_rir":"Von der RIR",
|
||||
"ip4.give_back":"Zurückgeben",
|
||||
"ip4.held":"Die RIR überträgt diesen Block erst ab {date} wieder.",
|
||||
"ip4.homes":"Breitband-Haushalte",
|
||||
"ip4.homes_cgnat":"{n}, davon {p} hinter CGNAT",
|
||||
"ip4.in_use":"Deine Kunden brauchen diese Adressen: steck mehr Haushalte hinter CGNAT oder hol dir erst einen weiteren Block.",
|
||||
"ip4.lease":"Mieten {price}/Monat",
|
||||
"ip4.lease_out":"Vermieten +{price}/Monat",
|
||||
"ip4.leased_in":"Einen {p}-Block ({n} Adressen) für {price}/Monat gemietet.",
|
||||
"ip4.leased_in_mo":"Gemietet · {price}/Monat",
|
||||
"ip4.leased_out":"Dein {p}-Block ist vermietet: +{price}/Monat.",
|
||||
"ip4.leased_out_mo":"Vermietet · +{price}/Monat",
|
||||
"ip4.leases_in":"Gemietete Blöcke",
|
||||
"ip4.leases_out":"Vermietete Blöcke",
|
||||
"ip4.market":"Transfermarkt",
|
||||
"ip4.market_note":"IPv4 kostet etwa {px} pro Adresse (große Blöcke etwas weniger), zur Miete {lin} pro Adresse und Monat, und vermietet bringt es nach dem Anteil des Brokers {lout}. Ein Verkauf bringt {p} des Preises, und ein Block darf erst zwei Jahre nach seinem letzten Transfer wieder übertragen werden.",
|
||||
"ip4.movable_from":"wieder übertragbar ab {date}",
|
||||
"ip4.n_addresses":{"one":"{n} Adresse","other":"{n} Adressen"},
|
||||
"ip4.n_homes_per_address":{"one":"{n} Haushalt pro Adresse","other":"{n} Haushalte pro Adresse"},
|
||||
"ip4.no_grow":"{name} ({city}) wollte auf {bw} wachsen, aber du hattest keine freien IPv4-Adressen dafür.",
|
||||
"ip4.no_space":"{name} braucht einen IPv4-Block {p} ({n} Adressen), und nur {free} sind frei. Kauf oder miete einen Block oder steck mehr Haushalte hinter CGNAT.",
|
||||
"ip4.note":"IPv6 ist kostenlos und unendlich. IPv4 ist seit Jahren aus: Geschäftskunden brauchen öffentliche Blöcke davon, und Haushalte, die nicht mehr reinpassen, teilen sich Adressen hinter CGNAT (IPv6-Traffic läuft an der Box vorbei).",
|
||||
"ip4.off":"Nach den Regeln dieses Spiels gibt es IPv4 reichlich.",
|
||||
"ip4.offer_needs":"Braucht einen IPv4-Block {p} ({n} Adressen); nur {free} frei.",
|
||||
"ip4.preset_plenty":"IPv4 gibt es reichlich für alle.",
|
||||
"ip4.preset_scarce":"IPv4 ist knapp: kaufen, mieten oder hinter CGNAT teilen.",
|
||||
"ip4.really_sell":"Wirklich für {price} verkaufen?",
|
||||
"ip4.refunds":"Erstattungen an genervte Gamer",
|
||||
"ip4.section":"Adressraum",
|
||||
"ip4.sell":"Verkaufen {price}",
|
||||
"ip4.sold":"Dein {p}-Block ist für {price} verkauft.",
|
||||
"ip4.squeezed":"Kein Platz mehr: {p} der Haushalte passen nicht mal bei {r} Haushalten pro Adresse rein. Ihre Verbindungen brechen ab und sie wollen Geld zurück: kauf oder miete einen Block.",
|
||||
"ip4.take_back":"Zurückholen",
|
||||
"ip4.toast_cgnat":"<b>Dein IPv4 ist voll.</b> {p} deiner Haushalte teilen sich jetzt Adressen hinter CGNAT, und ein paar Gamer haben schon geschrieben.",
|
||||
"ip4.toast_out":"<b>IPv4 ist aus.</b> Selbst bei {r} Haushalten pro Adresse passt nicht jeder hinter CGNAT: kauf oder miete einen Block bei der Bank.",
|
||||
"ip4.too_many":"Du hast {n} IPv4-Blöcke, mehr kann ein Netz nicht führen. Verkauf kleine Blöcke oder gib sie zurück, um Platz für einen größeren zu schaffen.",
|
||||
"ip4.yours":"Deine IPv4-Adressen",
|
||||
"ix_downgrade.pni_downgraded":"Das PNI mit {net} in {city} ist jetzt {port}.",
|
||||
"ix_downgrade.port_downgraded_at_ix":"Der Port bei {ix} ist jetzt {port}.",
|
||||
"ix_downgrade.transit_downgraded":"{net}-Transit in {city} ist jetzt {port}.",
|
||||
|
|
|
|||
|
|
@ -2638,6 +2638,54 @@
|
|||
"interface.tubecoin_moved_down_p_on_the":"TubeCoin bajó un {p} % de camino a tu cuenta.",
|
||||
"interface.tubecoin_moved_up_p_on_the":"TubeCoin subió un {p} % de camino a tu cuenta.",
|
||||
"interface.you_bought_out_bank_they_flew":"<b>Compraste {bank}.</b><br>Se fueron volando a buscar otra startup.",
|
||||
"ip4.block_size":"Tamaño del bloque",
|
||||
"ip4.blocks":"Tus bloques",
|
||||
"ip4.bought":"Has comprado un {p} ({n} direcciones) por {price}.",
|
||||
"ip4.bought_on":"Comprado el {date}",
|
||||
"ip4.business":"Usadas por clientes empresariales",
|
||||
"ip4.buy":"Comprar {price}",
|
||||
"ip4.cgnat_boxes":"Equipos CGNAT",
|
||||
"ip4.cgnat_note":"Más hogares por dirección liberan espacio para clientes, pero los juegos y el port forwarding sufren: el {p} de la factura de un hogar con CGNAT se devuelve en reembolsos.",
|
||||
"ip4.cgnat_ratio":"CGNAT: hogares por dirección",
|
||||
"ip4.costs_row":"Alquiler de IPv4 y CGNAT",
|
||||
"ip4.free":"Libres para nuevos clientes (los hogares pasan antes a CGNAT)",
|
||||
"ip4.from_rir":"Del RIR",
|
||||
"ip4.give_back":"Devolver",
|
||||
"ip4.held":"El RIR no volverá a transferir ese bloque antes del {date}.",
|
||||
"ip4.homes":"Hogares con banda ancha",
|
||||
"ip4.homes_cgnat":"{n}, {p} detrás de CGNAT",
|
||||
"ip4.in_use":"Tus clientes necesitan esas direcciones: pon más hogares detrás de CGNAT o consigue antes otro bloque.",
|
||||
"ip4.lease":"Alquilar {price}/mes",
|
||||
"ip4.lease_out":"Ceder en alquiler +{price}/mes",
|
||||
"ip4.leased_in":"Has alquilado un {p} ({n} direcciones) por {price}/mes.",
|
||||
"ip4.leased_in_mo":"Alquilado · {price}/mes",
|
||||
"ip4.leased_out":"Tu {p} está cedido en alquiler: +{price}/mes.",
|
||||
"ip4.leased_out_mo":"Cedido en alquiler · +{price}/mes",
|
||||
"ip4.leases_in":"Bloques alquilados",
|
||||
"ip4.leases_out":"Bloques cedidos en alquiler",
|
||||
"ip4.market":"Mercado de transferencias",
|
||||
"ip4.market_note":"IPv4 se vende a unos {px} por dirección (los bloques grandes, algo menos), se alquila a {lin} por dirección al mes y, cedido en alquiler, rinde {lout} tras la comisión del bróker. Una venta paga el {p} del precio, y un bloque solo puede volver a transferirse dos años después de su último traspaso.",
|
||||
"ip4.movable_from":"transferible desde el {date}",
|
||||
"ip4.n_addresses":{"one":"{n} dirección","other":"{n} direcciones"},
|
||||
"ip4.n_homes_per_address":{"one":"{n} hogar por dirección","other":"{n} hogares por dirección"},
|
||||
"ip4.no_grow":"{name} ({city}) quería crecer a {bw}, pero no tenías direcciones IPv4 libres para ello.",
|
||||
"ip4.no_space":"{name} necesita un {p} de IPv4 ({n} direcciones) y solo hay {free} libres. Compra o alquila un bloque, o pon más hogares detrás de CGNAT.",
|
||||
"ip4.note":"IPv6 es gratis e infinito. IPv4 se agotó hace años: los clientes empresariales necesitan bloques públicos, y los hogares que no caben comparten direcciones detrás de CGNAT (el tráfico IPv6 rodea la caja).",
|
||||
"ip4.off":"Con las reglas de esta partida sobra IPv4.",
|
||||
"ip4.offer_needs":"Necesita un {p} de IPv4 ({n} direcciones); solo hay {free} libres.",
|
||||
"ip4.preset_plenty":"IPv4 de sobra para todos.",
|
||||
"ip4.preset_scarce":"IPv4 escasea: cómpralo, alquílalo o compártelo detrás de CGNAT.",
|
||||
"ip4.really_sell":"¿Vender de verdad por {price}?",
|
||||
"ip4.refunds":"Reembolsos a gamers enfadados",
|
||||
"ip4.section":"Espacio de direcciones",
|
||||
"ip4.sell":"Vender {price}",
|
||||
"ip4.sold":"Has vendido tu {p} por {price}.",
|
||||
"ip4.squeezed":"Sin espacio: el {p} de los hogares no cabe ni con {r} hogares por dirección. Sus conexiones fallan y piden reembolsos: compra o alquila un bloque.",
|
||||
"ip4.take_back":"Recuperar",
|
||||
"ip4.toast_cgnat":"<b>Tu IPv4 está lleno.</b> El {p} de tus hogares comparte ahora direcciones detrás de CGNAT, y algunos gamers ya han escrito.",
|
||||
"ip4.toast_out":"<b>Sin IPv4.</b> Ni con {r} hogares por dirección cabe todo el mundo en el CGNAT: compra o alquila un bloque en el banco.",
|
||||
"ip4.too_many":"Tienes {n} bloques IPv4, el máximo que puede llevar una red. Vende o devuelve bloques pequeños para hacer sitio a uno más grande.",
|
||||
"ip4.yours":"Tus direcciones IPv4",
|
||||
"ix_downgrade.pni_downgraded":"El PNI con {net} en {city} ahora es {port}.",
|
||||
"ix_downgrade.port_downgraded_at_ix":"El puerto en {ix} es ahora de {port}.",
|
||||
"ix_downgrade.transit_downgraded":"El tránsito de {net} en {city} ahora es {port}.",
|
||||
|
|
|
|||
|
|
@ -2638,6 +2638,54 @@
|
|||
"interface.tubecoin_moved_down_p_on_the":"Le TubeCoin a perdu {p} % en route vers ton compte.",
|
||||
"interface.tubecoin_moved_up_p_on_the":"Le TubeCoin a pris {p} % en route vers ton compte.",
|
||||
"interface.you_bought_out_bank_they_flew":"<b>Tu as racheté la part de {bank}.</b><br>Ils se sont envolés à la recherche d’une autre startup.",
|
||||
"ip4.block_size":"Taille du bloc",
|
||||
"ip4.blocks":"Tes blocs",
|
||||
"ip4.bought":"Tu as acheté un {p} ({n} adresses) pour {price}.",
|
||||
"ip4.bought_on":"Acheté le {date}",
|
||||
"ip4.business":"Utilisées par les clients pros",
|
||||
"ip4.buy":"Acheter {price}",
|
||||
"ip4.cgnat_boxes":"Boîtiers CGNAT",
|
||||
"ip4.cgnat_note":"Plus de foyers par adresse libère de la place pour les clients, mais les jeux et la redirection de ports en pâtissent : {p} de la facture d’un foyer derrière le CGNAT repart en remboursements.",
|
||||
"ip4.cgnat_ratio":"CGNAT : foyers par adresse",
|
||||
"ip4.costs_row":"Locations IPv4 et CGNAT",
|
||||
"ip4.free":"Libres pour de nouveaux clients (les foyers passent d’abord derrière le CGNAT)",
|
||||
"ip4.from_rir":"Attribué par le RIR",
|
||||
"ip4.give_back":"Le rendre",
|
||||
"ip4.held":"Le RIR ne transférera pas ce bloc avant le {date}.",
|
||||
"ip4.homes":"Foyers en haut débit",
|
||||
"ip4.homes_cgnat":"{n}, dont {p} derrière le CGNAT",
|
||||
"ip4.in_use":"Tes clients ont besoin de ces adresses : mets plus de foyers derrière le CGNAT ou trouve d’abord un autre bloc.",
|
||||
"ip4.lease":"Louer {price}/mois",
|
||||
"ip4.lease_out":"Mettre en location +{price}/mois",
|
||||
"ip4.leased_in":"Tu as loué un {p} ({n} adresses) pour {price}/mois.",
|
||||
"ip4.leased_in_mo":"Loué · {price}/mois",
|
||||
"ip4.leased_out":"Ton {p} est en location : +{price}/mois.",
|
||||
"ip4.leased_out_mo":"Mis en location · +{price}/mois",
|
||||
"ip4.leases_in":"Blocs loués",
|
||||
"ip4.leases_out":"Blocs mis en location",
|
||||
"ip4.market":"Marché des transferts",
|
||||
"ip4.market_note":"L’IPv4 se vend environ {px} l’adresse (un peu moins pour les gros blocs), se loue {lin} l’adresse par mois et, mis en location, rapporte {lout} après la part du courtier. Une vente rapporte {p} du prix, et un bloc ne peut être transféré à nouveau que deux ans après son dernier transfert.",
|
||||
"ip4.movable_from":"transférable à partir du {date}",
|
||||
"ip4.n_addresses":{"one":"{n} adresse","other":"{n} adresses"},
|
||||
"ip4.n_homes_per_address":{"one":"{n} foyer par adresse","other":"{n} foyers par adresse"},
|
||||
"ip4.no_grow":"{name} ({city}) voulait passer à {bw}, mais tu n’avais pas d’adresses IPv4 libres pour ça.",
|
||||
"ip4.no_space":"{name} a besoin d’un {p} d’IPv4 ({n} adresses), et seulement {free} sont libres. Achète ou loue un bloc, ou mets plus de foyers derrière le CGNAT.",
|
||||
"ip4.note":"L’IPv6 est gratuit et sans fin. L’IPv4 est épuisé depuis des années : les clients pros ont besoin de blocs publics, et les foyers qui ne rentrent plus partagent des adresses derrière le CGNAT (le trafic IPv6 contourne la boîte).",
|
||||
"ip4.off":"Avec les règles de cette partie, l’IPv4 ne manque pas.",
|
||||
"ip4.offer_needs":"Il lui faut un {p} d’IPv4 ({n} adresses) ; seulement {free} libres.",
|
||||
"ip4.preset_plenty":"De l’IPv4 à volonté pour tout le monde.",
|
||||
"ip4.preset_scarce":"L’IPv4 est rare : achète-le, loue-le ou partage-le derrière le CGNAT.",
|
||||
"ip4.really_sell":"Vraiment vendre pour {price} ?",
|
||||
"ip4.refunds":"Remboursements aux gamers grincheux",
|
||||
"ip4.section":"Espace d’adressage",
|
||||
"ip4.sell":"Vendre {price}",
|
||||
"ip4.sold":"Ton {p} est vendu pour {price}.",
|
||||
"ip4.squeezed":"Plus de place : {p} des foyers ne rentrent pas, même à {r} foyers par adresse. Leurs connexions lâchent et ils veulent être remboursés : achète ou loue un bloc.",
|
||||
"ip4.take_back":"Le reprendre",
|
||||
"ip4.toast_cgnat":"<b>Ton IPv4 est plein.</b> {p} de tes foyers partagent maintenant des adresses derrière le CGNAT, et quelques gamers ont déjà écrit.",
|
||||
"ip4.toast_out":"<b>Plus d’IPv4.</b> Même à {r} foyers par adresse, le CGNAT ne suffit pas pour tout le monde : achète ou loue un bloc à la banque.",
|
||||
"ip4.too_many":"Tu as {n} blocs IPv4, le maximum qu’un réseau peut garder. Vends ou rends de petits blocs pour faire de la place à un plus grand.",
|
||||
"ip4.yours":"Tes adresses IPv4",
|
||||
"ix_downgrade.pni_downgraded":"Le PNI avec {net} à {city} est maintenant en {port}.",
|
||||
"ix_downgrade.port_downgraded_at_ix":"Le port chez {ix} est maintenant en {port}.",
|
||||
"ix_downgrade.transit_downgraded":"Le transit {net} à {city} est maintenant en {port}.",
|
||||
|
|
|
|||
|
|
@ -2638,6 +2638,54 @@
|
|||
"interface.tubecoin_moved_down_p_on_the":"TubeCoin è sceso del {p}% mentre arrivava sul tuo conto.",
|
||||
"interface.tubecoin_moved_up_p_on_the":"TubeCoin è salito del {p}% mentre arrivava sul tuo conto.",
|
||||
"interface.you_bought_out_bank_they_flew":"<b>Hai liquidato {bank}.</b><br>Sono volati via in cerca di un’altra startup.",
|
||||
"ip4.block_size":"Dimensione del blocco",
|
||||
"ip4.blocks":"I tuoi blocchi",
|
||||
"ip4.bought":"Comprato un {p} ({n} indirizzi) per {price}.",
|
||||
"ip4.bought_on":"Comprato il {date}",
|
||||
"ip4.business":"Usati dai clienti business",
|
||||
"ip4.buy":"Compra {price}",
|
||||
"ip4.cgnat_boxes":"Apparati CGNAT",
|
||||
"ip4.cgnat_note":"Più case per indirizzo liberano spazio per i clienti, ma giochi e port forwarding ne soffrono: il {p} della bolletta di una casa dietro il CGNAT torna indietro in rimborsi.",
|
||||
"ip4.cgnat_ratio":"CGNAT: case per indirizzo",
|
||||
"ip4.costs_row":"Affitti IPv4 e CGNAT",
|
||||
"ip4.free":"Liberi per nuovi clienti (prima le case passano dietro il CGNAT)",
|
||||
"ip4.from_rir":"Dal RIR",
|
||||
"ip4.give_back":"Restituiscilo",
|
||||
"ip4.held":"Il RIR non trasferisce di nuovo quel blocco prima del {date}.",
|
||||
"ip4.homes":"Case in banda larga",
|
||||
"ip4.homes_cgnat":"{n}, il {p} dietro il CGNAT",
|
||||
"ip4.in_use":"I tuoi clienti hanno bisogno di quegli indirizzi: metti più case dietro il CGNAT o prendi prima un altro blocco.",
|
||||
"ip4.lease":"Affitta {price}/mese",
|
||||
"ip4.lease_out":"Dai in affitto +{price}/mese",
|
||||
"ip4.leased_in":"Preso in affitto un {p} ({n} indirizzi) per {price}/mese.",
|
||||
"ip4.leased_in_mo":"In affitto · {price}/mese",
|
||||
"ip4.leased_out":"Il tuo {p} è dato in affitto: +{price}/mese.",
|
||||
"ip4.leased_out_mo":"Dato in affitto · +{price}/mese",
|
||||
"ip4.leases_in":"Blocchi presi in affitto",
|
||||
"ip4.leases_out":"Blocchi dati in affitto",
|
||||
"ip4.market":"Mercato dei trasferimenti",
|
||||
"ip4.market_note":"IPv4 costa circa {px} a indirizzo (i blocchi grandi un po' meno), in affitto {lin} a indirizzo al mese, e dato in affitto rende {lout} dopo la quota del broker. Una vendita paga il {p} del prezzo, e un blocco si può trasferire di nuovo solo due anni dopo l'ultimo trasferimento.",
|
||||
"ip4.movable_from":"trasferibile dal {date}",
|
||||
"ip4.n_addresses":{"one":"{n} indirizzo","other":"{n} indirizzi"},
|
||||
"ip4.n_homes_per_address":{"one":"{n} casa per indirizzo","other":"{n} case per indirizzo"},
|
||||
"ip4.no_grow":"{name} ({city}) voleva crescere a {bw}, ma non avevi indirizzi IPv4 liberi per farlo.",
|
||||
"ip4.no_space":"{name} ha bisogno di un {p} di IPv4 ({n} indirizzi), e ne restano liberi solo {free}. Compra o affitta un blocco, o metti più case dietro il CGNAT.",
|
||||
"ip4.note":"IPv6 è gratis e infinito. IPv4 è finito anni fa: i clienti business hanno bisogno di blocchi pubblici, e le case che non ci stanno condividono gli indirizzi dietro il CGNAT (il traffico IPv6 gli passa accanto).",
|
||||
"ip4.off":"Con le regole di questa partita l'IPv4 abbonda.",
|
||||
"ip4.offer_needs":"Serve un {p} di IPv4 ({n} indirizzi); solo {free} liberi.",
|
||||
"ip4.preset_plenty":"IPv4 in abbondanza per tutti.",
|
||||
"ip4.preset_scarce":"IPv4 scarseggia: compralo, affittalo o condividilo dietro il CGNAT.",
|
||||
"ip4.really_sell":"Vendere davvero per {price}?",
|
||||
"ip4.refunds":"Rimborsi ai gamer arrabbiati",
|
||||
"ip4.section":"Spazio di indirizzi",
|
||||
"ip4.sell":"Vendi {price}",
|
||||
"ip4.sold":"Venduto il tuo {p} per {price}.",
|
||||
"ip4.squeezed":"Spazio esaurito: il {p} delle case non ci sta nemmeno con {r} case per indirizzo. Le connessioni saltano e vogliono un rimborso: compra o affitta un blocco.",
|
||||
"ip4.take_back":"Riprendilo",
|
||||
"ip4.toast_cgnat":"<b>Il tuo IPv4 è pieno.</b> Il {p} delle tue case ora condivide gli indirizzi dietro il CGNAT, e qualche gamer ha già scritto.",
|
||||
"ip4.toast_out":"<b>IPv4 esaurito.</b> Nemmeno con {r} case per indirizzo il CGNAT basta per tutti: compra o affitta un blocco in banca.",
|
||||
"ip4.too_many":"Hai {n} blocchi IPv4, il massimo che una rete può tenere. Vendi o restituisci qualche blocco piccolo per fare posto a uno più grande.",
|
||||
"ip4.yours":"I tuoi indirizzi IPv4",
|
||||
"ix_downgrade.pni_downgraded":"Il PNI con {net} a {city} ora è {port}.",
|
||||
"ix_downgrade.port_downgraded_at_ix":"La porta su {ix} ora è da {port}.",
|
||||
"ix_downgrade.transit_downgraded":"Il transito {net} a {city} ora è {port}.",
|
||||
|
|
|
|||
|
|
@ -2638,6 +2638,54 @@
|
|||
"interface.tubecoin_moved_down_p_on_the":"A TubeCoin caiu {p}% no caminho até sua conta.",
|
||||
"interface.tubecoin_moved_up_p_on_the":"A TubeCoin subiu {p}% no caminho até sua conta.",
|
||||
"interface.you_bought_out_bank_they_flew":"<b>Você comprou a parte de {bank}.</b><br>Eles voaram em busca de outra startup.",
|
||||
"ip4.block_size":"Tamanho do bloco",
|
||||
"ip4.blocks":"Seus blocos",
|
||||
"ip4.bought":"Você comprou um {p} ({n} endereços) por {price}.",
|
||||
"ip4.bought_on":"Comprado em {date}",
|
||||
"ip4.business":"Usados por clientes empresariais",
|
||||
"ip4.buy":"Comprar {price}",
|
||||
"ip4.cgnat_boxes":"Caixas de CGNAT",
|
||||
"ip4.cgnat_note":"Mais casas por endereço liberam espaço para clientes, mas jogos e redirecionamento de portas sofrem: {p} da conta de uma casa atrás do CGNAT volta como reembolso.",
|
||||
"ip4.cgnat_ratio":"CGNAT: casas por endereço",
|
||||
"ip4.costs_row":"Aluguel de IPv4 e CGNAT",
|
||||
"ip4.free":"Livres para novos clientes (as casas vão antes para trás do CGNAT)",
|
||||
"ip4.from_rir":"Do RIR",
|
||||
"ip4.give_back":"Devolver",
|
||||
"ip4.held":"O RIR não transfere esse bloco de novo antes de {date}.",
|
||||
"ip4.homes":"Casas com banda larga",
|
||||
"ip4.homes_cgnat":"{n}, {p} atrás do CGNAT",
|
||||
"ip4.in_use":"Seus clientes precisam desses endereços: coloque mais casas atrás do CGNAT ou arrume outro bloco antes.",
|
||||
"ip4.lease":"Alugar {price}/mês",
|
||||
"ip4.lease_out":"Alugar para terceiros +{price}/mês",
|
||||
"ip4.leased_in":"Você alugou um {p} ({n} endereços) por {price}/mês.",
|
||||
"ip4.leased_in_mo":"Alugado · {price}/mês",
|
||||
"ip4.leased_out":"Seu {p} está alugado: +{price}/mês.",
|
||||
"ip4.leased_out_mo":"Alugado para terceiros · +{price}/mês",
|
||||
"ip4.leases_in":"Blocos alugados",
|
||||
"ip4.leases_out":"Blocos alugados para terceiros",
|
||||
"ip4.market":"Mercado de transferências",
|
||||
"ip4.market_note":"IPv4 sai por cerca de {px} o endereço (blocos grandes, um pouco menos), aluga-se por {lin} o endereço por mês e, alugado para terceiros, rende {lout} depois da comissão do broker. Uma venda paga {p} do preço, e um bloco só pode ser transferido de novo dois anos depois da última transferência.",
|
||||
"ip4.movable_from":"transferível a partir de {date}",
|
||||
"ip4.n_addresses":{"one":"{n} endereço","other":"{n} endereços"},
|
||||
"ip4.n_homes_per_address":{"one":"{n} casa por endereço","other":"{n} casas por endereço"},
|
||||
"ip4.no_grow":"{name} ({city}) queria crescer para {bw}, mas você não tinha endereços IPv4 livres para isso.",
|
||||
"ip4.no_space":"{name} precisa de um {p} de IPv4 ({n} endereços), e só {free} estão livres. Compre ou alugue um bloco, ou coloque mais casas atrás do CGNAT.",
|
||||
"ip4.note":"IPv6 é grátis e infinito. IPv4 acabou há anos: clientes empresariais precisam de blocos públicos, e as casas que não cabem compartilham endereços atrás do CGNAT (o tráfego IPv6 passa por fora da caixa).",
|
||||
"ip4.off":"Nas regras deste jogo, IPv4 não falta.",
|
||||
"ip4.offer_needs":"Precisa de um {p} de IPv4 ({n} endereços); só {free} livres.",
|
||||
"ip4.preset_plenty":"IPv4 de sobra para todo mundo.",
|
||||
"ip4.preset_scarce":"IPv4 é escasso: compre, alugue ou compartilhe atrás do CGNAT.",
|
||||
"ip4.really_sell":"Vender mesmo por {price}?",
|
||||
"ip4.refunds":"Reembolsos para gamers irritados",
|
||||
"ip4.section":"Espaço de endereços",
|
||||
"ip4.sell":"Vender {price}",
|
||||
"ip4.sold":"Seu {p} foi vendido por {price}.",
|
||||
"ip4.squeezed":"Sem espaço: {p} das casas não cabem nem com {r} casas por endereço. As conexões caem e elas querem reembolso: compre ou alugue um bloco.",
|
||||
"ip4.take_back":"Pegar de volta",
|
||||
"ip4.toast_cgnat":"<b>Seu IPv4 está cheio.</b> {p} das suas casas agora compartilham endereços atrás do CGNAT, e alguns gamers já reclamaram.",
|
||||
"ip4.toast_out":"<b>Acabou o IPv4.</b> Nem com {r} casas por endereço o CGNAT comporta todo mundo: compre ou alugue um bloco no banco.",
|
||||
"ip4.too_many":"Você tem {n} blocos IPv4, o máximo que uma rede pode manter. Venda ou devolva blocos pequenos para abrir espaço para um maior.",
|
||||
"ip4.yours":"Seus endereços IPv4",
|
||||
"ix_downgrade.pni_downgraded":"O PNI com {net} em {city} agora é {port}.",
|
||||
"ix_downgrade.port_downgraded_at_ix":"A porta em {ix} agora é de {port}.",
|
||||
"ix_downgrade.transit_downgraded":"O trânsito de {net} em {city} agora é {port}.",
|
||||
|
|
|
|||
|
|
@ -86,6 +86,9 @@ const API_DOMAINS={
|
|||
pieSpatId:{table:'PIE_SPAT_DEF',kind:'key'},
|
||||
pieSpatChoice:{kind:'enum',values:[0,1]},
|
||||
countryCode:{kind:'enum',values:()=>[...new Set(CITIES.map(c=>c.cc))].sort()},
|
||||
// Address space: an IPv4 prefix length the market sells, and the CGNAT ratios.
|
||||
ip4Len:{kind:'enum',values:()=>Array.from({length:IP4_MAX-IP4_MIN+1},(_,i)=>IP4_MIN+i)},
|
||||
ip4Ratio:{kind:'enum',values:()=>IP4_NAT.slice()},
|
||||
scnId:{table:'SCN',kind:'id'},
|
||||
// A traceroute target in the modal's own terms.
|
||||
};
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ const API_CMD={
|
|||
doc:'Set how many channels of one optic model a dark-fiber span carries, in one change. Added optics come from the spares shelf when you have them (regen cards still cost their share); removed ones go back to the shelf.'},
|
||||
/* ---------- customers ---------- */
|
||||
accept:{args:[['id','entityId']],
|
||||
doc:'Sign a pending offer. Rejected without a POP in every city it needs, without free channels for a wave sale, or after an event\'s start date. Extra waves for a carrier you already serve grow that contract.'},
|
||||
doc:'Sign a pending offer. Rejected without a POP in every city it needs, without the IPv4 addresses it needs (rule ip4: see the bank\'s Address space), without free channels for a wave sale, or after an event\'s start date. Extra waves for a carrier you already serve grow that contract.'},
|
||||
decline:{args:[['id','entityId']],
|
||||
doc:'Throw an offer away.'},
|
||||
salesHire:{args:[['id','salesPersona']],
|
||||
|
|
@ -282,6 +282,23 @@ const API_CMD={
|
|||
repayLoan:{args:[['id','entityId']],confirm:'double',
|
||||
quote:a=>{const l=S.loans.find(x=>x.id===a.id);return l?{setup:repayCost(l,BANKS[l.bank])}:{};},
|
||||
doc:'Repay a loan early, or buy an equity investor out.'},
|
||||
/* ---------- address space (IPv4, rule ip4: On-call and BGP at 3 a.m.) ---------- */
|
||||
ip4Buy:{args:[['len','ip4Len']],watch:['ip4'],
|
||||
quote:a=>({setup:ip4Cost(Number(a.len)),blocked:[ip4On()?'':tr('ip4.off'),ip4On()&&ip4Full()?tr('ip4.too_many',{n:IP4_BLK}):''].filter(Boolean)}),
|
||||
doc:'Buy an IPv4 block of this prefix length (24 = 256 addresses up to 16 = 65,536) on the transfer market at today\'s price. It can be sold again two years after this transfer. A network holds at most 256 blocks, bought, leased in and from the registry together.'},
|
||||
ip4Lease:{args:[['len','ip4Len']],watch:['ip4'],
|
||||
quote:a=>({setup:0,monthly:ip4InMo(Number(a.len)),blocked:[ip4On()?'':tr('ip4.off'),ip4On()&&ip4Full()?tr('ip4.too_many',{n:IP4_BLK}):''].filter(Boolean)}),
|
||||
doc:'Lease an IPv4 block of this prefix length by the month, at today\'s rate (fixed for the lease). Hand it back with ip4Return. Refused at 256 blocks, like ip4Buy.'},
|
||||
ip4Sell:{args:[['id','entityId']],confirm:'double',watch:['ip4'],
|
||||
doc:'Sell an owned block (not leased out) for 92% of the market price. Refused within two years of its last transfer, or when the customers signed would no longer fit with every home behind CGNAT.'},
|
||||
ip4Out:{args:[['id','entityId']],watch:['ip4'],
|
||||
doc:'Lease an owned block out through a broker for a monthly income, while your own customers still fit without it.'},
|
||||
ip4Back:{args:[['id','entityId']],watch:['ip4'],
|
||||
doc:'End the lease of a block you leased out; its addresses are yours to use again.'},
|
||||
ip4Return:{args:[['id','entityId']],watch:['ip4'],
|
||||
doc:'Hand a leased-in block back, ending its monthly fee, when your customers still fit without it.'},
|
||||
ip4Nat:{args:[['v','ip4Ratio']],watch:['ip4'],
|
||||
doc:'Set how many broadband homes share one IPv4 address behind CGNAT (8, 16, 32 or 64). More frees space for business customers but more gamers ask for refunds; fewer is refused when the customers signed would not fit.'},
|
||||
/* ---------- security, China, incidents ---------- */
|
||||
buildScrub:{args:[['city','cityId'],['tier','scrubTier',false]],watch:['scrubs'],
|
||||
quote:a=>{const T=SCRUB_TIERS[a.tier||0];return {setup:T?T.cost:undefined,monthly:T?T.mo:undefined};},
|
||||
|
|
@ -453,6 +470,8 @@ const API_CMD={
|
|||
|
||||
const API_VIEW={
|
||||
pieOpen:{args:[],doc:'Open Pie Control, the rocket company\'s panel.'},
|
||||
ip4Open:{args:[],doc:'Open the bank at its Address space section: your IPv4 blocks, who uses them, CGNAT and the transfer market.'},
|
||||
ip4Pick:{args:[['v','ip4Len']],doc:'Pick the block size the Address space market quotes (a prefix length, 24 to 16).'},
|
||||
pieGovOpen:{args:[],doc:'Open the bank at its Government money section: the rocket company\'s fund auctions, the Pitcairn grant and the Ex-Im Pie Bank (it used to be Pie Control\'s Gov tab).'},
|
||||
pieTab:{args:[['t','pieTab']],doc:'Switch the Pie Control tab: traffic, co (the company, its books and the Founder\'s posts), fly (launches) or dish.'},
|
||||
pieCity:{args:[['v','cityId']],doc:'Pick the POP the Dishes tab works on.'},
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const API_STATE_DOC={
|
|||
cash:{type:'number',doc:'Cash on hand. Goes negative into the red; -100k is bankruptcy.'},
|
||||
priceMul:{type:'number',doc:'Multiplier on transit prices (weekly modifier).'},
|
||||
mode:{type:'string',doc:'normal | sandbox | scenario | puzzle.'},
|
||||
rules:{type:'map',doc:'The rules this network locked in at its door: preset (soft, freeze, oncall, bgp, sandbox or puzzle), the chaos dial, lead times, the market, and the Best Effort extras (sea, confs, broke, moods, pnis), which are only written where they differ from the classic game. They stay for the network\'s whole life.'},
|
||||
rules:{type:'map',doc:'The rules this network locked in at its door: preset (soft, freeze, oncall, bgp, sandbox or puzzle), the chaos dial, lead times, the market, and the later rules (sea, confs, broke, moods, pnis, and ip4 for scarce IPv4, off outside On-call and BGP at 3 a.m.), which are only written where they differ from the classic game. They stay for the network\'s whole life.'},
|
||||
charter:{type:'string',doc:'The charter a normal game signed when it started: global | boutique | broker. chartSet is false until one is signed.'},
|
||||
baronWon:{type:'number',doc:'The day a broker won Glass Baron, or 0.'},
|
||||
chartSet:{type:'boolean',doc:'The charter has been picked; false while the choice is still open.'},
|
||||
|
|
@ -61,6 +61,7 @@ const API_STATE_DOC={
|
|||
ops:{type:'map',doc:'The NOC intern: who is hired, each standing order\'s on/off switch and settings (network work only: deals belong to the sales desk, slAuto), the monthly budget and what it spent, per-POP exceptions, the new-POP template and the weekly log.'},
|
||||
core:{type:'map',doc:'Your backbone technology: lv bought, the level it runs at, the interop lab.'},
|
||||
ddosAuto:{type:'map',doc:'The NOC\'s auto-mitigation switches: rtbh and scrub.'},
|
||||
ip4:{type:'map',doc:'IPv4 address space (rule ip4): b, the blocks, at most 256 (len: prefix length 16-24, k: rir from the registry, buy bought, in leased in; d: the day it last moved, out: leased out, mo: the monthly fee or income), nat: homes per address behind CGNAT, w: which warnings were shown. What customers use is derived from their kind and size.'},
|
||||
popStd:{type:'map',doc:'The build standard, or null for none. g router model (an RG index), rt routers, then only the targets that are set: site2, gen (true), lag (2 or 4 members), split, ix (true), pni (2 or 3 cities per network), sys (roadm, cl), opt (fast), wv (an LT index). New POPs get g, rt, site2 and gen at once; the std standing order and bstdApply bring the rest up.'},
|
||||
mp:{type:'map',doc:'Multiplayer, only in a self-hosted copy with a session server: the session code, your player id, the AS number and seed the session gave you, its rules preset, your colour, its title and the last save number the server holds; null in every other game.'},
|
||||
demo:{type:'map',doc:'Vendor demo units on order, by "kind:id" → ready day.'},
|
||||
|
|
|
|||
|
|
@ -6,17 +6,18 @@
|
|||
// sea: cable ships sail out to subsea cuts, or (timer) a cut mends on its own clock. confs: conference season.
|
||||
// broke: deep in the red ends the game, or (rescue) a state loan keeps it going. moods: patient customers sour half as fast.
|
||||
// pnis: PNIs and their augments wait for the other network's team, or (instant) are up the moment they are ordered.
|
||||
const RULE_DEF={clock:true,chaos:'normal',lead:'real',market:true,money:'normal',gates:'ladder',sea:'ships',confs:true,broke:'lose',moods:'normal',pnis:'wait',mods:[]};
|
||||
const RULE_LATE=['sea','confs','broke','moods','pnis'];
|
||||
const RULE_OK={clock:[true,false],chaos:['none','calm','normal','spicy'],lead:['real','quick'],market:[true,false],money:['normal','infinite'],gates:['ladder','open'],sea:['ships','timer'],confs:[true,false],broke:['lose','rescue'],moods:['normal','patient'],pnis:['wait','instant']};
|
||||
// ip4: IPv4 is scarce (#150, 33-address-space.js): customers need addresses, homes share them behind CGNAT.
|
||||
const RULE_DEF={clock:true,chaos:'normal',lead:'real',market:true,money:'normal',gates:'ladder',sea:'ships',confs:true,broke:'lose',moods:'normal',pnis:'wait',ip4:true,mods:[]};
|
||||
const RULE_LATE=['sea','confs','broke','moods','pnis','ip4'];
|
||||
const RULE_OK={clock:[true,false],chaos:['none','calm','normal','spicy'],lead:['real','quick'],market:[true,false],money:['normal','infinite'],gates:['ladder','open'],sea:['ships','timer'],confs:[true,false],broke:['lose','rescue'],moods:['normal','patient'],pnis:['wait','instant'],ip4:[true,false]};
|
||||
// i: icon, n: name, d: the one-line joke, x: what is different, in small print.
|
||||
const PRESETS={
|
||||
soft:{i:'☕',n:tr('rules.best_effort'),d:tr('rules.no_sla_no_pager_no_promises'),x:tr('rules.rare_outages_no_ddos_pnis_at_once'),clock:true,chaos:'calm',lead:'quick',market:false,money:'normal',gates:'ladder',sea:'timer',confs:false,broke:'rescue',moods:'patient',pnis:'instant'},
|
||||
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'},
|
||||
soft:{i:'☕',n:tr('rules.best_effort'),d:tr('rules.no_sla_no_pager_no_promises'),x:tr('rules.rare_outages_no_ddos_pnis_at_once'),clock:true,chaos:'calm',lead:'quick',market:false,money:'normal',gates:'ladder',sea:'timer',confs:false,broke:'rescue',moods:'patient',pnis:'instant',ip4:false},
|
||||
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',ip4:false},
|
||||
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'},
|
||||
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',ip4:false},
|
||||
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',ip4:false},
|
||||
};
|
||||
const NORMAL_PRESETS=['soft','freeze','oncall','bgp'];
|
||||
// How often things break, against the classic game. Spicy outages also last half as long again.
|
||||
|
|
|
|||
89
src/game/60-features/33-address-space.js
Normal file
89
src/game/60-features/33-address-space.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/* ---------- Address space (#150): IPv6 is free for everyone, IPv4 ran out years ago ----------
|
||||
The network holds IPv4 blocks in real CIDR sizes (/24 to /16): its first allocation from the RIR, blocks bought on
|
||||
the transfer market and blocks leased in by the month. Owned blocks can be leased out (a broker finds the tenant) or
|
||||
sold, once two years have passed since they last moved (the RIRs' holding period, which also stops flipping).
|
||||
Business customers on IP service take a public block each, sized by kind and port (a /29 for a small DIA port, a /23
|
||||
for a big hosting company); broadband homes take what is left, and the homes that do not fit share addresses behind
|
||||
CGNAT at the player's ratio. CGNAT costs a little per Gbps it carries (IPv6 goes around the box) and some gamers want
|
||||
their money back. An offer that needs more than is free, with every home already behind CGNAT, cannot be signed, and a
|
||||
customer renewing bigger stays at its size when the bigger block is not free (clGrow).
|
||||
Nothing is stored per customer: what each one needs follows from its kind and size, so growing customers and old saves
|
||||
need no new fields. On in On-call and BGP at 3 a.m. (rule ip4), off in the gentler presets, sandbox and puzzles;
|
||||
scenarios only when they opt in (S.scn.rules.ip4). No random draws: the market price is a function of the day.
|
||||
The first allocation is a /21: one transit's worth of broadband levels off at about 1,300 homes in every start city,
|
||||
so the first months fit with room for a few customers (gameplay rule F1). */
|
||||
// IP4_BLK: the most blocks a network holds; buying and leasing stop there, and a save keeps that many.
|
||||
const IP4_START=21,IP4_MIN=16,IP4_MAX=24,IP4_HOLD=730,IP4_NAT=[8,16,32,64],IP4_NAT0=16,IP4_BLK=256;
|
||||
// Public addresses per Gbps of busy-hour broadband (a home each), and the part of it CGNAT still carries: the rest is IPv6.
|
||||
const IP4_BB=10,IP4_V4=0.55,IP4_CGN=2;
|
||||
// The market: dollars per address, flat for half a year, then +3% a year on a slow four-year swing. Leases are by the
|
||||
// month (a broker keeps a cut of what yours earn), sales pay 92% of the price after the broker's fee.
|
||||
const IP4_PX=38,IP4_FREE=180,IP4_YR=0.03,IP4_IN=0.5,IP4_OUT=0.4,IP4_SELL=0.92;
|
||||
// Of the bill of a home behind CGNAT, the share that comes back as refunds (gamers, mostly): more homes per address, more
|
||||
// grumbling. Homes squeezed past the ratio (port exhaustion) are worse.
|
||||
const IP4_ANNOY={8:0.01,16:0.015,32:0.025,64:0.04},IP4_SQZ=0.15;
|
||||
// Per kind of customer: addresses per Gbps of port, and the smallest block it takes. Circuits, waves and fiber carry no
|
||||
// addresses of yours; downstream ISPs and universities bring their own (universities sit on legacy /16s); orbit
|
||||
// terminals sit behind the satellite operator's own CGNAT.
|
||||
const IP4_BIZ={cgame:[0.5,256],dia:[2,8],fabip:[2,8],game:[2,16],gpu:[0.5,64],host:[4,64],metav:[0.25,256],scrub:[2,8],stream:[1,32]};
|
||||
const ip4Sz=len=>2**(32-len),ip4LenOk=len=>Number.isInteger(len)&&len>=IP4_MIN&&len<=IP4_MAX;
|
||||
const ip4Cidr=n=>'/'+(32-Math.ceil(Math.log2(Math.max(1,n)))),ip4N=n=>Math.round(n).toLocaleString();
|
||||
function ip4On(){return !!S&&!!S.ip4&&rule('ip4')===true&&(S.scn?scnRule('ip4'):S.mode==='normal');}
|
||||
function ip4Need(b){const k=b&&IP4_BIZ[b.type];if(!k||!(b.bw>0))return 0;return Math.min(4096,2**Math.ceil(Math.log2(Math.max(k[1],b.bw*k[0]))));}
|
||||
/* Who uses what. T: usable addresses (owned and leased in, without what is leased out); B: business customers; H: homes;
|
||||
cg: homes behind CGNAT; over: the share of homes that do not fit even at the ratio; free: what a new customer can have
|
||||
with every home behind CGNAT. */
|
||||
function ip4Use(s=S){const I=s.ip4,r=I.nat;let own=0,inn=0,out=0,B=0,H=0;
|
||||
for(const b of I.b){const n=ip4Sz(b.len);if(b.k==='in')inn+=n;else if(b.out)out+=n;else own+=n;}
|
||||
for(const b of s.biz)B+=ip4Need(b);
|
||||
for(const c in s.pops){const p=s.pops[c];if(p.bb)H+=p.bb.d*IP4_BB;}
|
||||
H=Math.ceil(H);const T=own+inn,A=Math.max(0,T-B),min=Math.ceil(H/r);let cg=0,over=0;
|
||||
if(A<H){if(A>=min)cg=Math.min(H,Math.ceil((H-A)*r/(r-1)));else{cg=H;over=min?1-A/min:0;}}
|
||||
return {T,own,inn,out,B,H,cg,over,free:T-B-min,r};}
|
||||
const ip4Fits=o=>!ip4On()||ip4Need(o)<=Math.max(0,ip4Use().free);
|
||||
// A customer renewing at bw: does the bigger block it needs fit what is free?
|
||||
const ip4GrowOk=(b,bw)=>!ip4On()||ip4Need({type:b.type,bw})-ip4Need(b)<=Math.max(0,ip4Use().free);
|
||||
const ip4Full=()=>S.ip4.b.length>=IP4_BLK;
|
||||
// What you announce, as the AS box shows it: your blocks by prefix length, without the ones leased out to others.
|
||||
const ip4Pfx=()=>{const c={};for(const b of S.ip4.b)if(!b.out)c[b.len]=(c[b.len]||0)+1;return Object.keys(c).sort((a,b)=>a-b).map(l=>`${c[l]} × /${l}`).join(', ');};
|
||||
// Would giving this block up (selling, leasing it out, handing it back) still leave room for everyone?
|
||||
const ip4Spare=b=>ip4Use().free>=ip4Sz(b.len);
|
||||
const ip4Held=b=>b.k!=='in'&&S.day-b.d<IP4_HOLD;
|
||||
function ip4Px(d=S.day){if(!rule('market')||d<=IP4_FREE)return IP4_PX;const y=(d-IP4_FREE)/365;return IP4_PX*(1+IP4_YR*y)*(1+0.12*Math.sin(2*Math.PI*y/4));}
|
||||
// Bigger blocks are a little cheaper per address, as on the real market.
|
||||
const ip4Cost=len=>Math.round(ip4Sz(len)*ip4Px()*(1-0.015*(IP4_MAX-len))/100)*100;
|
||||
const ip4Value=len=>Math.round(ip4Cost(len)*IP4_SELL/100)*100;
|
||||
const ip4InMo=len=>Math.round(ip4Sz(len)*IP4_IN*ip4Px()/IP4_PX),ip4OutMo=len=>Math.round(ip4Sz(len)*IP4_OUT*ip4Px()/IP4_PX);
|
||||
// The month's IPv4 bill: leases in and out, CGNAT boxes, refunds (eye: what broadband earns a month).
|
||||
function ip4Bill(eye){const u=ip4Use();let lin=0,lout=0;for(const b of S.ip4.b){if(b.k==='in')lin+=b.mo||0;else if(b.out)lout+=b.mo||0;}
|
||||
const cgS=u.H?u.cg/u.H:0;return {u,lin,lout,box:u.cg/IP4_BB*IP4_V4*IP4_CGN,refund:eye*(cgS*IP4_ANNOY[u.r]+u.over*IP4_SQZ)};}
|
||||
// computeMoney: only what is there, so a network with nothing to pay keeps its money rows as they were.
|
||||
function ip4Money(C,V){if(!ip4On())return;const b=ip4Bill(V.eyeballs||0),c=Math.round(b.lin+b.box+b.refund);if(c>0)C.ip4=c;if(b.lout>0)V.ip4=b.lout;}
|
||||
/* A new network gets its /21 from the RIR. An older save gets what it already uses registered to it and a quarter more to
|
||||
grow into (about a month for a big, fast-growing network), rounded up to /24s in real CIDR blocks (a /21 at the
|
||||
least), so nothing changes on load; those blocks move like any other two years on.
|
||||
Their ids are fixed (rir0, rir1…), not uid(): a new game draws no id, so every id after it stays as it was. */
|
||||
function ip4Grant(s){const d=s.day||0,b=[],add=len=>b.push({id:'rir'+b.length,len,k:'rir',d});let need=0;
|
||||
for(const x of s.biz||[])need+=ip4Need(x);
|
||||
for(const c in s.pops||{}){const p=s.pops[c];if(p&&p.bb&&p.bb.d>0)need+=p.bb.d*IP4_BB;}
|
||||
need=Math.max(ip4Sz(IP4_START),Math.ceil(need*1.25/256)*256);
|
||||
while(need>=ip4Sz(IP4_MIN)&&b.length<200){add(IP4_MIN);need-=ip4Sz(IP4_MIN);}
|
||||
for(let len=IP4_MIN+1;len<=IP4_MAX;len++)if(need>=ip4Sz(len)){add(len);need-=ip4Sz(len);}
|
||||
return {b,nat:IP4_NAT0,w:0};}
|
||||
const ip4New=()=>ip4Grant({});
|
||||
function ip4Fix(s){const I=s.ip4&&typeof s.ip4==='object'&&!Array.isArray(s.ip4)?s.ip4:null;if(!I){s.ip4=ip4Grant(s);return;}
|
||||
const day=Math.max(0,num(s.day,0)),mo=v=>Math.round(Math.min(1e8,Math.max(0,num(v,0))));
|
||||
const b=(Array.isArray(I.b)?I.b:[]).filter(x=>x&&typeof x==='object'&&ip4LenOk(x.len)&&['rir','buy','in'].includes(x.k)).slice(0,IP4_BLK).map(x=>{
|
||||
const o={id:typeof x.id==='string'&&x.id&&x.id.length<=40?x.id:uid(),len:x.len,k:x.k,d:int(x.d,0,day,0)};
|
||||
if(x.k==='in')o.mo=mo(x.mo);else if(x.out===true){o.out=true;o.mo=mo(x.mo);}return o;});
|
||||
s.ip4={b,nat:IP4_NAT.includes(I.nat)?I.nat:IP4_NAT0,w:int(I.w,0,3,0)};}
|
||||
/* Once a day: say so when homes go behind CGNAT (a percent of them at least), and when even CGNAT cannot fit them all
|
||||
(w: what was said). Each rearms only with room to spare again, so homes hovering at the limit hear it once. */
|
||||
function ip4Day(d){if(!ip4On())return;const I=S.ip4,u=ip4Use(),A=u.T-u.B,go=[{l:tr('ip4.section'),act:'ip4Open'}];
|
||||
if(u.cg>=Math.max(1,u.H*0.01)){if(!(I.w&1)){I.w|=1;toast(tr('ip4.toast_cgnat',{p:pct(u.cg/u.H)}),'',go);}}else if(A>=u.H*1.05)I.w&=~1;
|
||||
if(u.over>0){if(!(I.w&2)){I.w|=2;toast(tr('ip4.toast_out',{r:u.r}),'bad',go);sfx('err');}}else if(A>=Math.ceil(u.H/u.r)*1.1)I.w&=~2;}
|
||||
// Renewals that wanted a bigger block than is free (clGrow, [customer, bandwidth]): they stay as they are, and hear why.
|
||||
function ip4News(l=[]){for(const [b,bw] of l.slice(0,3))toast(tr('ip4.no_grow',{name:esc(b.name),city:esc(clWhere(b)),bw:fmtG(bw)}),'',[{l:tr('ip4.section'),act:'ip4Open'}]);}
|
||||
// The line under an offer that cannot be signed for want of addresses.
|
||||
function ip4Why(o){if(ip4Fits(o))return '';const n=ip4Need(o);
|
||||
return `<div class="why">${tr('ip4.offer_needs',{p:ip4Cidr(n),n:ip4N(n),free:ip4N(Math.max(0,ip4Use().free))})} ${btn(tr('ip4.section'),'ip4Open',{},'ghost sm')}</div>`;}
|
||||
|
|
@ -65,13 +65,13 @@ function salesDay(d){const L=S.sales;if(!L)return;
|
|||
// With a rocket company, every other game is with the Founder, and in orbit (pieGolf, 99-pie-sales.js).
|
||||
const SALES_GOLF=['metav','cgame','gpu','stream','isp','edu','host','dia'];
|
||||
function salesGolf(d){if(pieGolf(d))return;const mine=Object.keys(S.pops).filter(c=>popUp(c)&&bizCity(c));if(!mine.length)return;
|
||||
const t=SALES_GOLF.find(x=>(BIZ_T[x].lv||1)<=lvl());if(!t)return;const T=BIZ_T[t],city=mine.sort((a,b)=>CITY[b].P-CITY[a].P||(a<b?-1:1))[0];
|
||||
const t=SALES_GOLF.find(x=>(BIZ_T[x].lv||1)<=lvl()&&ip4Fits({type:x,bw:BIZ_T[x].opts[BIZ_T[x].opts.length-1]}));if(!t)return;const T=BIZ_T[t],city=mine.sort((a,b)=>CITY[b].P-CITY[a].P||(a<b?-1:1))[0];
|
||||
const list=(T.names||BIZ_N).filter(n=>!S.usedNames.includes(n));const name=list.length?list[Math.floor(slR('golfn|'+d)*list.length)]:(T.names||BIZ_N)[0];useName(name);
|
||||
const o={id:uid(),city,city2:null,name,type:t,bw:T.opts[T.opts.length-1],rate:Math.round((CITY[city].au?T.rate*AU_ARPU:T.rate)*mkt()*0.7),reqs:[],exp:d+40};
|
||||
const k=salesPromise(o);if(k)o.reqs.push(k);const b=offerCustomer(o);b.by='ceo';b.mk=mkt();S.biz.push(clSign(b));
|
||||
toast(tr('sales.ceo_golf',{name:esc(name),city:esc(CITY[city].name),bw:fmtG(o.bw),price:fmt$(o.bw*o.rate)})+(k?' '+tr('sales.ceo_promised',{req:esc(typeof REQS[k].l==='function'?REQS[k].l(o):REQS[k].l)}):''),'goal',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}]);sfx('coin');}
|
||||
// Declining an offer the CEO likes: about one in three, he already shook hands on it.
|
||||
function salesOverride(o){if(slP()!=='ceo'||!o||!bHas(o)||BIZ_T[o.type].event||slR('veto|'+slKey(o))>=0.33)return false;
|
||||
function salesOverride(o){if(slP()!=='ceo'||!o||!bHas(o)||BIZ_T[o.type].event||!ip4Fits(o)||slR('veto|'+slKey(o))>=0.33)return false;
|
||||
const b=offerCustomer(o);if(o.mk)b.mk=o.mk;b.by='ceo';S.offers=S.offers.filter(x=>x!==o);S.biz.push(clSign(b));toast(tr('sales.ceo_override',{name:esc(o.name)}),'');return true;}
|
||||
// Saves: who is at the desk, the VP on the way, the CEO's calendar; who brought each offer and signed each customer.
|
||||
function salesFix(s){const L=s.sales&&typeof s.sales==='object'&&!Array.isArray(s.sales)?s.sales:{},n=v=>Number.isInteger(v)&&v>=0&&v<1e7?v:null;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ function slAutoDay(d){if(!slAutoOn())return;const A=S.slAuto,p=slP(),w=Math.floo
|
|||
const won=o=>{if(S.offers.includes(o))return false;W.n++;W.rev+=Math.round(bizMo(o));dirty=true;return true;};
|
||||
opsQuiet(()=>{for(const o of S.offers.slice()){if(!S.offers.includes(o))continue;const T=BIZ_T[o.type];if(!T||!(o.exp>d))continue;const v=T.event?(o.fee||0):bizMo(o);
|
||||
if(A.min&&v<A.min){const b0=S.biz.length;ACT.decline({id:o.id});W.x++;if(S.biz.length>b0){W.y++;W.rev+=Math.round(bizMo(o));dirty=true;}continue;}
|
||||
if(!A.on)continue;
|
||||
if(!A.on||!ip4Fits(o))continue;
|
||||
if(T.orbit){const k=slSkyOk(o,used);if(!k||(p==='shark'&&S.cash<bizMo(o)))continue;ACT.accept({id:o.id});if(won(o))used.set(k,(used.get(k)||0)+o.bw);continue;}
|
||||
if(!bCities(o).every(popUp))continue;
|
||||
if(p==='shark'){if(S.cash<bizMo(o)||(T.event&&!(o.start>d)))continue;ACT.accept({id:o.id});won(o);continue;}
|
||||
|
|
|
|||
|
|
@ -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:4,auV:1,calV:1,pieV:1,pie:null,ops:opsNew(),slAuto:slAutoNew(),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:{},
|
||||
ltv:2,t1v:4,auV:1,calV:1,pieV:1,pie:null,ip4:ip4New(),ops:opsNew(),slAuto:slAutoNew(),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:[],fleet:{},ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',ddosAuto:{rtbh:false,scrub:true},capDeal:null,core:{lv:0,run:0},popStd:null,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},mp:null};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -374,10 +374,11 @@ function computeMoney(R2,PX=null){
|
|||
C.wholesale=0;C.levy=0;const lev=scnRule('levy');for(const c in S.pops){const sf=sfOf(R2,c)*(R2.bbF[c]??1),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)||BIZ_T[b.type].orbit)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)*(R2.tgtF[b.id]??1);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;
|
||||
ip4Money(C,V);
|
||||
if(PX)pieMoney(PX,R2,V);
|
||||
// The UK grant for Pitcairn, its satellite tier once orbit is known; the Rural Digital Pie Fund (99-pie-subsidies.js).
|
||||
{const on=grantOn(R2),sky=!on&&!!PX&&grantSky(R2);V.grant=on?GRANT_MO:sky?GRANT_SKY_MO:0;if(PX)V.gov=pieGovMo();if(PX)R2.pie.gov={rdf:V.gov||0,sky:sky?GRANT_SKY_MO:0};}
|
||||
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+(V.orbit||0));
|
||||
R2.costMo=Object.values(C).reduce((a,b)=>a+b,0);
|
||||
R2.revMo=V.eyeballs+V.business+V.ix+V.grant+(V.gov||0)+(V.orbit||0);
|
||||
R2.revMo=V.eyeballs+V.business+V.ix+V.grant+(V.gov||0)+(V.orbit||0)+(V.ip4||0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ function sanitize(s){
|
|||
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);mpSanitize(s);
|
||||
pieSanitize(s);pieIncFix(s);
|
||||
ip4Fix(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);
|
||||
|
|
|
|||
|
|
@ -58,14 +58,16 @@ function clRenew(b,rate){b.rate=Math.max(0,Math.round(rate));b.mk=mkt();delete b
|
|||
function clGone(b,why){S.biz=S.biz.filter(x=>x!==b);clNote('lost',why);}
|
||||
const clWhere=b=>bCities(b).map(c=>CITY[c].name).join(' ⇄ ');
|
||||
|
||||
// Growing: the next size up their type sells, or twice the bandwidth past the top one. Fiber grows by renewing.
|
||||
function clGrow(b){const T=BIZ_T[b.type];if(T.fiber)return false;const up=(T.opts||[]).find(x=>x>b.bw);b.bw=up||b.bw*2;return true;}
|
||||
// Growing: the next size up their type sells, or twice the bandwidth past the top one. Fiber grows by renewing. Not
|
||||
// when the bigger IPv4 block it needs is not free (#150): out.v4 lists them for the day's news.
|
||||
function clGrow(b,out){const T=BIZ_T[b.type];if(T.fiber)return false;const bw=(T.opts||[]).find(x=>x>b.bw)||b.bw*2;
|
||||
if(!ip4GrowOk(b,bw)){if(out)out.v4.push([b,bw]);return false;}b.bw=bw;return true;}
|
||||
// Leaving, or one of the not-your-fault turns that keeps them. Returns what the log says.
|
||||
function clLeave(b,d,out){const T=BIZ_T[b.type],v={name:esc(b.name),city:esc(clWhere(b))};
|
||||
if(b.mood<50){clGone(b,'sad');out.lost.push(tr('lifecycle.left_unhappy',v));return;}
|
||||
const C=S.cl;if(d-C.odd>=CL_ODD_GAP&&clR(b,'odd')<0.25){C.odd=d;clGone(b,'odd');out.lost.push(tr('lifecycle.left_odd',{...v,why:tr(clPick(CL_ODD,b,'oddline'))}));return;}
|
||||
const ks=Object.keys(CL_WHY).filter(k=>CL_WHY[k].ok(b.type)),k=clPick(ks,b,'why');
|
||||
if(k==='acq'&&clR(b,'acqbig')<0.3&&clGrow(b)){clRenew(b,clFair(b));clNote('grew');out.ok.push(tr('lifecycle.acquired_stays_bigger',{...v,bw:fmtG(b.bw)}));return;}
|
||||
if(k==='acq'&&clR(b,'acqbig')<0.3&&clGrow(b,out)){clRenew(b,clFair(b));clNote('grew');out.ok.push(tr('lifecycle.acquired_stays_bigger',{...v,bw:fmtG(b.bw)}));return;}
|
||||
if(k==='moved'){const reg=CITY[b.city].reg,to=Object.keys(S.pops).filter(c=>c!==b.city&&CITY[c].reg===reg&&bizCity(c)).sort();
|
||||
const c2=to.length&&clR(b,'stay')<0.5?clPick(to,b,'to'):null;
|
||||
if(c2){const from=CITY[b.city].name;b.city=c2;clRenew(b,clFair(b));clNote('ren');out.ok.push(tr('lifecycle.moved_stays',{name:v.name,from:esc(from),to:esc(CITY[c2].name)}));return;}}
|
||||
|
|
@ -75,7 +77,7 @@ function clLeave(b,d,out){const T=BIZ_T[b.type],v={name:esc(b.name),city:esc(clW
|
|||
/* A day of contracts, after the moods. 30 days before a term ends a customer with competitors around may ask for a
|
||||
discount (at most three open at a time); at the end, the rest renew, grow or leave. An unanswered haggle renews at
|
||||
the asked price. */
|
||||
function clDay(d){if(!S.cl)S.cl={odd:-1e9,mo:[]};const out={ren:0,grew:0,ok:[],lost:[],hag:[]};let open=S.biz.reduce((a,b)=>a+(b.hag?1:0),0);
|
||||
function clDay(d){if(!S.cl)S.cl={odd:-1e9,mo:[]};const out={ren:0,grew:0,ok:[],lost:[],hag:[],v4:[]};let open=S.biz.reduce((a,b)=>a+(b.hag?1:0),0);
|
||||
const pat=rule('moods')==='patient'?0.5:1;
|
||||
for(const b of S.biz.slice()){if(!b.te||!clOn(b))continue;
|
||||
if(b.hag){if(d>=b.hag.until){clRenew(b,b.hag.rate);clNote('ren');out.ren++;}continue;}
|
||||
|
|
@ -86,7 +88,7 @@ function clDay(d){if(!S.cl)S.cl={odd:-1e9,mo:[]};const out={ren:0,grew:0,ok:[],l
|
|||
continue;}
|
||||
const cf=Math.min(1,clComp(b)/6),u=(100-b.mood)/100,leave=(0.04+0.08*cf+0.35*u*u)*pat*salesLeaveMul(b);
|
||||
if(clR(b,'leave')<leave){clLeave(b,d,out);continue;}
|
||||
const g=clR(b,'grow');if((b.mood>=80&&g<0.3)||(b.mood>=60&&g<0.12)){if(clGrow(b)){clRenew(b,clFair(b));clNote('grew');out.grew++;out.ok.push(tr('lifecycle.renewed_and_grew',{name:esc(b.name),city:esc(clWhere(b)),bw:fmtG(b.bw)}));continue;}}
|
||||
const g=clR(b,'grow');if((b.mood>=80&&g<0.3)||(b.mood>=60&&g<0.12)){if(clGrow(b,out)){clRenew(b,clFair(b));clNote('grew');out.grew++;out.ok.push(tr('lifecycle.renewed_and_grew',{name:esc(b.name),city:esc(clWhere(b)),bw:fmtG(b.bw)}));continue;}}
|
||||
clRenew(b,clFair(b));clNote('ren');out.ren++;}
|
||||
clNews(out);clReferral(d);}
|
||||
// What the day says: haggles one by one (they want an answer), the rest in a few lines so a big network is not a wall of toasts.
|
||||
|
|
@ -94,7 +96,7 @@ function clNews(out){
|
|||
for(const b of out.hag){const was=bizMo(b),now=BIZ_T[b.type].fiber?b.hag.rate:b.bw*b.hag.rate;
|
||||
toast(tr('lifecycle.haggle',{name:esc(b.name),city:esc(clWhere(b)),price:fmt$(now),p:pct(1-now/Math.max(1,was)),n:b.hag.until-S.day}),'',[{l:tr('common.deals'),act:'leftTab',args:{t:'deals'}}],{a:'cust',v:b.id});}
|
||||
const few=(list,kind)=>{for(const t of list.slice(0,3))toast(t,kind);if(list.length>3)toast(trn('lifecycle.n_more',list.length-3),kind);};
|
||||
few(out.ok,'good');few(out.lost,'');
|
||||
few(out.ok,'good');ip4News(out.v4);few(out.lost,'');
|
||||
if(out.ren)toast(trn('lifecycle.n_renewed',out.ren,{p:mktTxt()}),'');}
|
||||
const mktTxt=()=>{const m=mkt();return Math.abs(m-1)<0.005?tr('lifecycle.market_as_start'):m<1?tr('lifecycle.market_below',{p:pct(1-m)}):tr('lifecycle.market_above',{p:pct(m-1)});};
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ function dayPost(d){
|
|||
scnTick(d);
|
||||
confTick(d);
|
||||
specDay(d);
|
||||
ip4Day(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;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Object.assign(ACT,{
|
|||
if(!w&&!p){toast(tr('customers.nothing_spare_to_sell_on_this'),'bad');sfx('err');return;}const L=l.list||(l.list={w:0,p:0});L.w+=w;L.p+=p;
|
||||
toast(tr('broker.listed',{a:CITY[l.a].name,b:CITY[l.b].name}),'good');sfx('click');after();},
|
||||
unlistFiber:({id})=>{const l=S.links.find(x=>x.id===id);if(!l||!l.list)return;delete l.list;sfx('click');after();},
|
||||
accept:({id,auto=false})=>{const o=S.offers.find(x=>x.id===id);if(!o)return;const customer=auto?autoOffer(o):offerCustomer(o);if(!customer)return;if(!bHas(o)){toast(tr('customers.you_need_a_pop_in_every'),'bad');return;}
|
||||
accept:({id,auto=false})=>{const o=S.offers.find(x=>x.id===id);if(!o)return;if(!ip4Fits(o)){const n=ip4Need(o);toast(tr('ip4.no_space',{name:esc(o.name),p:ip4Cidr(n),n:ip4N(n),free:ip4N(Math.max(0,ip4Use().free))}),'bad',[{l:tr('ip4.section'),act:'ip4Open'}]);sfx('err');return;}const customer=auto?autoOffer(o):offerCustomer(o);if(!customer)return;if(!bHas(o)){toast(tr('customers.you_need_a_pop_in_every'),'bad');return;}
|
||||
if(o.type==='wwave'){const l=S.links.find(x=>x.id===o.link);if(!l||chMax(l)-(l.ch||[]).length-soldSlots(l)<o.slots){toast(tr('customers.not_enough_free_channels_on_that'),'bad');return;}}
|
||||
if(BIZ_T[o.type].event&&S.day>=o.start){toast(tr('customers.too_late_the_event_has_already'),'bad');return;}
|
||||
// A carrier renting more alien waves on a fiber it already rents grows its contract, like a real order for extra waves,
|
||||
|
|
|
|||
29
src/game/90-actions/54-address-space.js
Normal file
29
src/game/90-actions/54-address-space.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* Address space (#150, 33-address-space.js): buy, lease in, lease out, sell, hand back, and the CGNAT ratio. Every block
|
||||
change keeps room for the customers already signed, with every home behind CGNAT. */
|
||||
const ip4Re=()=>{after();renderBank();};
|
||||
function ip4Can(){if(ip4On())return true;toast(tr('ip4.off'),'bad');sfx('err');return false;}
|
||||
const ip4Blk=id=>S.ip4.b.find(b=>b.id===id);
|
||||
function ip4Busy(){toast(tr('ip4.in_use'),'bad');sfx('err');}
|
||||
// No more blocks than a save keeps (IP4_BLK): a new one is refused with the way out.
|
||||
function ip4Room(){if(!ip4Full())return true;toast(tr('ip4.too_many',{n:IP4_BLK}),'bad');sfx('err');return false;}
|
||||
Object.assign(ACT,{
|
||||
ip4Open:()=>{if(!S||pzOn()||!ip4On())return;if(!$('modal').hidden)closeModal();ACT.bank();const g=$('bankIp4');if(g&&g.scrollIntoView)g.scrollIntoView({block:'start'});},
|
||||
// The size the market rows quote (a dropdown: v is the prefix length).
|
||||
ip4Pick:({v})=>{const len=Number(v);if(ip4LenOk(len))UI.ip4Len=len;renderBank();},
|
||||
ip4Buy:({len})=>{if(!ip4Can())return;len=Number(len);if(!ip4LenOk(len)||!ip4Room())return;const c=ip4Cost(len);if(!spend(c))return;
|
||||
S.ip4.b.push({id:uid(),len,k:'buy',d:S.day});toast(tr('ip4.bought',{p:'/'+len,n:ip4N(ip4Sz(len)),price:fmt$(c)}),'good');sfx('coin');ip4Re();},
|
||||
ip4Lease:({len})=>{if(!ip4Can())return;len=Number(len);if(!ip4LenOk(len)||!ip4Room())return;const mo=ip4InMo(len);
|
||||
S.ip4.b.push({id:uid(),len,k:'in',d:S.day,mo});toast(tr('ip4.leased_in',{p:'/'+len,n:ip4N(ip4Sz(len)),price:fmt$(mo)}),'good');sfx('click');ip4Re();},
|
||||
ip4Sell:({id})=>{if(!ip4Can())return;const b=ip4Blk(id);if(!b||b.k==='in'||b.out)return;
|
||||
if(ip4Held(b)){toast(tr('ip4.held',{date:dateStr(b.d+IP4_HOLD)}),'bad');sfx('err');return;}if(!ip4Spare(b)){ip4Busy();return;}
|
||||
if(UI.confirm!==id){UI.confirm=id;renderBank();return;}UI.confirm=null;const v=ip4Value(b.len);S.ip4.b=S.ip4.b.filter(x=>x!==b);S.cash+=v;
|
||||
toast(tr('ip4.sold',{p:'/'+b.len,price:fmt$(v)}),'good');sfx('coin');ip4Re();},
|
||||
ip4Out:({id})=>{if(!ip4Can())return;const b=ip4Blk(id);if(!b||b.k==='in'||b.out)return;if(!ip4Spare(b)){ip4Busy();return;}
|
||||
b.out=true;b.mo=ip4OutMo(b.len);toast(tr('ip4.leased_out',{p:'/'+b.len,price:fmt$(b.mo)}),'good');sfx('coin');ip4Re();},
|
||||
ip4Back:({id})=>{if(!ip4Can())return;const b=ip4Blk(id);if(!b||!b.out)return;delete b.out;delete b.mo;sfx('click');ip4Re();},
|
||||
ip4Return:({id})=>{if(!ip4Can())return;const b=ip4Blk(id);if(!b||b.k!=='in')return;if(!ip4Spare(b)){ip4Busy();return;}
|
||||
S.ip4.b=S.ip4.b.filter(x=>x!==b);sfx('click');ip4Re();},
|
||||
// Fewer homes per address needs more addresses: refused when the customers already signed would not fit.
|
||||
ip4Nat:({v})=>{if(!ip4Can())return;const r=Number(v);if(!IP4_NAT.includes(r)||r===S.ip4.nat)return;const u=ip4Use();
|
||||
if(r<S.ip4.nat&&u.T-u.B<Math.ceil(u.H/r)){ip4Busy();UI._bh=null;renderBank();return;}S.ip4.nat=r;sfx('click');ip4Re();},
|
||||
});
|
||||
|
|
@ -47,7 +47,7 @@ function renderLeft(){checkLayer();
|
|||
{const lv=S.lvl||1,nx=LEVELS[lv];h+=`<div class="inc" style="background:var(--tint-y,#FFF6CF)"><div class="nm">${tr('hud_and_panels.customer_level_lv_name',{lv,name:LEVELS[lv-1].n})}</div><div class="meta">${nx?tr('hud_and_panels.next_req_unlocks_what',{req:nx.req,what:lc1(nx.unlock)}):tr('common.every_customer_type_is_unlocked_go')}</div></div>`;}
|
||||
if(!S.offers.length)h+=`<p class="empty">${tr('hud_and_panels.no_open_offers_right_now_businesses')}</p>`;
|
||||
for(const o of S.offers.slice().sort((a,b)=>a.exp-b.exp)){const has=bHas(o);
|
||||
h+=`<div class="row"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${esc(BIZ_T[o.type].l)} · ${CITY[o.city].name}${o.city2?' ⇄ '+CITY[o.city2].name:''} · <b>${bTerms(o)}</b> · ${tr('ui.n_d_left',{n:o.exp-S.day})}${(o.reqs||[]).length?` · ${trn('hud_and_panels.n_special_requirement',o.reqs.length)}`:''}</div>${o.refN?`<div class="meta">${tr('lifecycle.referred_by',{name:esc(o.refN)})}</div>`:''}${spotWhy(o)}${bRisk(o)}${reqList(o)}
|
||||
h+=`<div class="row"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${esc(BIZ_T[o.type].l)} · ${CITY[o.city].name}${o.city2?' ⇄ '+CITY[o.city2].name:''} · <b>${bTerms(o)}</b> · ${tr('ui.n_d_left',{n:o.exp-S.day})}${(o.reqs||[]).length?` · ${trn('hud_and_panels.n_special_requirement',o.reqs.length)}`:''}</div>${o.refN?`<div class="meta">${tr('lifecycle.referred_by',{name:esc(o.refN)})}</div>`:''}${spotWhy(o)}${ip4Why(o)}${bRisk(o)}${reqList(o)}
|
||||
<div class="btns">${has?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):btn(tr('common.go_there'),'focusCity',{city:bCities(o).find(c=>!S.pops[c])},'ghost sm')}${btn(tr('common.decline'),'decline',{id:o.id},'ghost sm')}</div>${has?'':`<div class="why">${tr('hud_and_panels.needs_a_pop_in_cities',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}</div>`}</div></div>`;}
|
||||
}else if(UI.left==='noc'){
|
||||
h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('hud_and_panels.open_noc_dashboard'),'dash',{},'pink')}${pieNocBtn()}${btn(`⚙️ ${tr('routing.routing_and_ddos')}${S.te&&!coreTE()?'<span class="cnt red dot" aria-hidden="true"></span>':''}`,'routingOpen',{},'')}</div>`;
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ function dfPanel(l){
|
|||
}
|
||||
function offersHere(c){
|
||||
const os=S.offers.filter(o=>bCities(o).includes(c));if(!os.length)return '';
|
||||
return `<section><h3>${tr('common.offers_here')}</h3>${os.map(o=>`<div class="row${o.id===UI.offerAt?' on':''}"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${esc(BIZ_T[o.type].l)}${o.city2?` ${CITY[o.city].name} ⇄ ${CITY[o.city2].name}`:''} · ${bTerms(o)} · ${tr('ui.n_d_left',{n:o.exp-S.day})}</div>${spotWhy(o)}${R.reach<0.99&&!BIZ_T[o.type].l2?`<div class="why">${tr('link_panels.they_need_the_full_internet_your',{pct:pct(R.reach)})}</div>`:''}${o.type==='scrub'&&!hasScrub()?`<div class="why">${tr('link_panels.needs_your_own_scrubbing_center')}</div>`:''}${bRisk(o)}${reqList(o)}${bHas(o)?'':`<div class="why">${tr('link_panels.needs_a_pop_in_cities_too',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}</div>`}</div>${bHas(o)?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('common.no'),'decline',{id:o.id},'ghost sm')}</div>`).join('')}</section>`;
|
||||
return `<section><h3>${tr('common.offers_here')}</h3>${os.map(o=>`<div class="row${o.id===UI.offerAt?' on':''}"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${esc(BIZ_T[o.type].l)}${o.city2?` ${CITY[o.city].name} ⇄ ${CITY[o.city2].name}`:''} · ${bTerms(o)} · ${tr('ui.n_d_left',{n:o.exp-S.day})}</div>${spotWhy(o)}${R.reach<0.99&&!BIZ_T[o.type].l2?`<div class="why">${tr('link_panels.they_need_the_full_internet_your',{pct:pct(R.reach)})}</div>`:''}${o.type==='scrub'&&!hasScrub()?`<div class="why">${tr('link_panels.needs_your_own_scrubbing_center')}</div>`:''}${ip4Why(o)}${bRisk(o)}${reqList(o)}${bHas(o)?'':`<div class="why">${tr('link_panels.needs_a_pop_in_cities_too',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}</div>`}</div>${bHas(o)?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('common.no'),'decline',{id:o.id},'ghost sm')}</div>`).join('')}</section>`;
|
||||
}
|
||||
function linkPanel(id){
|
||||
const l=S.links.find(x=>x.id===id);if(!l){UI.sel=null;return '';}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ function renderDash(){checkLayer();
|
|||
<div class="dgrid">${tile(tr('common.traffic_now'),fmtG(R.served),tr('dashboard.of_g_wanted',{g:fmtG(R.demand)}))}${tile(tr('common.peak'),fmtG(S.stats.peak))}${tile(tr('dashboard.delivered_30_days'),(up*100).toFixed(1)+'%',up>=0.999?tr('dashboard.five_nines_ish'):up>=0.99?tr('dashboard.two_nines_and_change'):tr('dashboard.customers_are_upset'))}${tile(tr('common.peering_ratio'),pct(R.peerShare||0),tr('dashboard.caches_pnis_and_ix'))}${tile(tr('dashboard.monthly_p_l'),`<span style="color:${net>=0?'var(--eye)':'var(--bad)'}">${net>=0?'+':''}${fmt$(net)}</span>`,tr('dashboard.in_in_out_out',{in:fmt$(R.revMo),out:fmt$(R.costMo)}))}${tile(tr('common.incidents'),S.stats.incidents,tr('dashboard.n_shrugged_off',{n:S.stats.survived}))}</div>
|
||||
<div class="dcols"><div class="panel2"><h3>${tr('dashboard.traffic_by_way_out')}</h3>${svgChart(rows,['c','p','ix','t','l2'],[{k:'dem',col:'var(--text)',dash:true}],v=>fmtCap(Math.round(v)),'traffic')}${chartLegend('traffic',k=>k==='dem'?'':' '+pct((R.egT[k]||0)/tot))}</div>
|
||||
<div class="panel2"><h3>${tr('dashboard.money_per_month')}</h3>${svgChart(rows,[],[{k:'rev',col:'#16A866'},{k:'cost',col:'#FF4D5E'}],v=>fmt$(v),'money')}${chartLegend('money')}
|
||||
<h3 style="margin-top:8px">${tr('dashboard.where_the_money_goes')}</h3>${Object.entries(R.cost).filter(([k,v])=>v>0).sort((a,b)=>b[1]-a[1]).map(([k,v])=>`<div class="kv"><span>${{pops:tr('dashboard.pops_and_routers'),links:tr('dashboard.waves_and_fiber'),transit:tr('common.transit'),ix:tr('common.ix_ports'),pni:tr('common.pnis'),caches:tr('common.cache_power'),nni:tr('common.fabric_ports'),optical:tr('dashboard.amp_huts_and_spares'),loans:tr('common.loan_repayments'),revshare:tr('dashboard.investor_revenue_share'),extras:tr('dashboard.licenses_and_scrubbing'),wholesale:tr('dashboard.nearly_broadband_network_wholesale'),levy:tr('dashboard.regional_broadband_levy'),pie:tr('pie.costs_row')}[k]||k}</span><b>${tr('common.price_mo',{price:fmt$(v)})}</b></div>`).join('')}</div></div>`;
|
||||
<h3 style="margin-top:8px">${tr('dashboard.where_the_money_goes')}</h3>${Object.entries(R.cost).filter(([k,v])=>v>0).sort((a,b)=>b[1]-a[1]).map(([k,v])=>`<div class="kv"><span>${{pops:tr('dashboard.pops_and_routers'),links:tr('dashboard.waves_and_fiber'),transit:tr('common.transit'),ix:tr('common.ix_ports'),pni:tr('common.pnis'),caches:tr('common.cache_power'),nni:tr('common.fabric_ports'),optical:tr('dashboard.amp_huts_and_spares'),loans:tr('common.loan_repayments'),revshare:tr('dashboard.investor_revenue_share'),extras:tr('dashboard.licenses_and_scrubbing'),wholesale:tr('dashboard.nearly_broadband_network_wholesale'),levy:tr('dashboard.regional_broadband_levy'),pie:tr('pie.costs_row'),ip4:tr('ip4.costs_row')}[k]||k}</span><b>${tr('common.price_mo',{price:fmt$(v)})}</b></div>`).join('')}</div></div>`;
|
||||
const tT=(R.egT.t||0)||1;
|
||||
const offMix=(UI.chartOff&&UI.chartOff.mix)||{},filt=Object.keys(offMix).length>0;
|
||||
// The legend above the table picks which ways in count; "lost" still looks at everything the network gets.
|
||||
|
|
@ -28,7 +28,7 @@ function renderDash(){checkLayer();
|
|||
const rs=Object.keys(S.pops).map(c=>({c,u:(R.nodeLoad[c]||0)/(R.nodeCap[c]||1)})).sort((a,b)=>b.u-a.u).slice(0,6);
|
||||
if(DT==='infra')h+=`<div class="dcols" style="margin-top:12px"><div class="panel2"><h3>${tr('common.busiest_links')}</h3>${ls.length?ls.map(({l,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[l.a].name} ⇄ ${CITY[l.b].name} <span class="meta">${capName(l)} · ${linkLat(l).toFixed(1)} ms</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b>${btn(tr('common.open'),'dashLink',{id:l.id},'ghost sm')}</div>`).join(''):'<p class="empty">'+tr('common.no_links_yet')+'</p>'}</div>
|
||||
<div class="panel2"><h3>${tr('common.router_load')}</h3>${rs.map(({c,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[c].name} <span class="meta">${(S.pops[c].routers||1)} × ${esc(RG[S.pops[c].rgen||0].n)}</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b></div>`).join('')}
|
||||
<h3 style="margin-top:10px">${tr('common.your_as')}</h3><div class="kv"><span>${tr('common.as_number')}</span><b>AS${S.asn}</b></div><div class="kv"><span>${tr('common.prefixes')}</span><b>${Math.max(1,Math.ceil(Object.keys(S.pops).length/3))} × /22 IPv4, 1 × /32 IPv6</b></div><div class="kv"><span>${tr('common.bgp_sessions')}</span><b>${R.sessions}</b></div><div class="kv"><span>${tr('common.upstreams')}</span><b>${new Set(S.transit.map(t=>t.net)).size}</b></div><div class="kv"><span>${tr('common.reach')}</span><b>${pct(R.reach)}</b></div><div class="kv"><span>${tr('common.customers')}</span><b>${tr('dashboard.n_businesses',{n:S.biz.length})}</b></div></div></div>`;
|
||||
<h3 style="margin-top:10px">${tr('common.your_as')}</h3><div class="kv"><span>${tr('common.as_number')}</span><b>AS${S.asn}</b></div><div class="kv"><span>${tr('common.prefixes')}</span><b>${(ip4On()&&ip4Pfx())||Math.max(1,Math.ceil(Object.keys(S.pops).length/3))+' × /22'} IPv4, 1 × /32 IPv6</b></div><div class="kv"><span>${tr('common.bgp_sessions')}</span><b>${R.sessions}</b></div><div class="kv"><span>${tr('common.upstreams')}</span><b>${new Set(S.transit.map(t=>t.net)).size}</b></div><div class="kv"><span>${tr('common.reach')}</span><b>${pct(R.reach)}</b></div><div class="kv"><span>${tr('common.customers')}</span><b>${tr('dashboard.n_businesses',{n:S.biz.length})}</b></div></div></div>`;
|
||||
if(DT==='pops')h+=popsSection();
|
||||
if(DT==='lease')h+=leaseTab();
|
||||
if(h!==UI._dh){UI._dh=h;morph($('dashCard'),h);}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,6 @@ function renderBank(){
|
|||
${B.equity?`<div class="meta">${tr('bank.taking_pct_of_your_revenue_every',{pct:pct(l.share)})}</div>`:`<div class="kv"><span>${tr('common.still_owed')}</span><b>${fmt$(l.bal)}</b></div><div class="bar me"><i style="width:${Math.min(100,(1-l.bal/l.amount)*100)}%"></i></div><div class="meta">${loanLine(l)}</div>`}
|
||||
${covList(l)}${l.breach>=1?`<div class="why">${trn('bank.condition_broken_for_n_day',l.breach)} ${l.breach<10?tr('bank.penalty_in_n_days',{n:10-l.breach}):tr('bank.penalties_are_running')}</div>`:''}
|
||||
<div class="btns" style="margin-top:6px">${btn(UI.confirm===l.id?tr('bank.really_pay_price',{price:fmt$(cost)}):B.equity?tr('bank.buy_them_out_price',{price:fmt$(cost)}):tr('bank.repay_early_price_incl_2_fee',{price:fmt$(cost)}),'repayLoan',{id:l.id},UI.confirm===l.id?'red sm':'sm',S.cash<cost)}</div></div></div>`;}
|
||||
h+=pieGovBank();
|
||||
h+=pieGovBank()+ip4Bank();
|
||||
if(h!==UI._bh){UI._bh=h;$('bankCard').innerHTML=h;}
|
||||
}
|
||||
|
|
|
|||
22
src/game/94-dashboard/72-address-space.js
Normal file
22
src/game/94-dashboard/72-address-space.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* The bank's Address space section (#150, 33-address-space.js): what you hold and who uses it, the CGNAT ratio, your
|
||||
blocks, and the transfer market. Phones: the boxes are full width, the dropdowns stack and every button row wraps. */
|
||||
const ip4Pc=x=>(x*100).toFixed(1).replace(/\.0$/,'')+'%';
|
||||
function ip4Bank(){if(!S||!ip4On())return '';const I=S.ip4,B=ip4Bill((R.rev&&R.rev.eyeballs)||0),u=B.u,len=ip4LenOk(UI.ip4Len)?UI.ip4Len:IP4_MAX,px=ip4Px(),full=ip4Full();
|
||||
const kv=(l,v,bad)=>`<div class="kv"><span>${l}</span><b${bad?' style="color:var(--bad)"':''}>${v}</b></div>`,mo=v=>tr('common.price_mo',{price:fmt$(v)});
|
||||
let h=`<section class="bank-gov bank-ip4"><h3 id="bankIp4" style="font-size:18px;margin-top:14px">🔢 ${tr('ip4.section')}</h3><p class="meta">${tr('ip4.note')}</p>`;
|
||||
h+=`<div class="ops-o">${kv(tr('ip4.yours'),ip4N(u.T))}${kv(tr('ip4.business'),ip4N(u.B))}${kv(tr('ip4.homes'),u.cg?tr('ip4.homes_cgnat',{n:ip4N(u.H),p:pct(u.cg/u.H)}):ip4N(u.H))}${kv(tr('ip4.free'),ip4N(Math.max(0,u.free)),u.free<=0)}`;
|
||||
if(u.over>0)h+=`<div class="why">${tr('ip4.squeezed',{p:pct(u.over),r:u.r})}</div>`;
|
||||
if(B.lin>0)h+=kv(tr('ip4.leases_in'),mo(B.lin));if(B.box>=1)h+=kv(tr('ip4.cgnat_boxes'),mo(B.box));if(B.refund>=1)h+=kv(tr('ip4.refunds'),mo(B.refund));if(B.lout>0)h+=kv(tr('ip4.leases_out'),'+'+mo(B.lout));
|
||||
h+=`<label class="ops-sel" style="margin-top:6px"><span>${tr('ip4.cgnat_ratio')}</span><select data-chg="ip4Nat">${IP4_NAT.map(r=>`<option value="${r}"${r===I.nat?' selected':''}>${trn('ip4.n_homes_per_address',r)}</option>`).join('')}</select></label>
|
||||
<p class="meta">${tr('ip4.cgnat_note',{p:ip4Pc(IP4_ANNOY[I.nat])})}</p></div>`;
|
||||
h+=`<div class="ops-o"><div class="nm">${tr('ip4.blocks')}</div>`;
|
||||
for(const b of I.b){const n=ip4Sz(b.len),spare=u.free>=n,held=ip4Held(b),sure=UI.confirm===b.id;
|
||||
const what=b.k==='in'?tr('ip4.leased_in_mo',{price:fmt$(b.mo||0)}):b.out?tr('ip4.leased_out_mo',{price:fmt$(b.mo||0)}):b.k==='buy'?tr('ip4.bought_on',{date:dateStr(b.d)}):tr('ip4.from_rir');
|
||||
const btns=b.k==='in'?btn(tr('ip4.give_back'),'ip4Return',{id:b.id},'ghost sm',!spare):b.out?btn(tr('ip4.take_back'),'ip4Back',{id:b.id},'ghost sm')
|
||||
:btn(tr('ip4.lease_out',{price:fmt$(ip4OutMo(b.len))}),'ip4Out',{id:b.id},'sm',!spare)+btn(sure?tr('ip4.really_sell',{price:fmt$(ip4Value(b.len))}):tr('ip4.sell',{price:fmt$(ip4Value(b.len))}),'ip4Sell',{id:b.id},sure?'red sm':'ghost sm',held||!spare);
|
||||
// Greyed for want of room: say so (a disabled button never gets to show ip4Busy's toast).
|
||||
h+=`<div class="row"><div class="grow"><div class="nm">/${b.len} · ${trn('ip4.n_addresses',n,{n:ip4N(n)})}</div><div class="meta">${what}${held&&!b.out?' · '+tr('ip4.movable_from',{date:dateStr(b.d+IP4_HOLD)}):''}</div>${!spare&&!b.out?`<div class="why">${tr('ip4.in_use')}</div>`:''}<div class="btns">${btns}</div></div></div>`;}
|
||||
h+=`</div><div class="ops-o"><div class="nm">${tr('ip4.market')}</div><p class="meta">${tr('ip4.market_note',{px:fmt$(px),lin:'$'+(IP4_IN*px/IP4_PX).toFixed(2),lout:'$'+(IP4_OUT*px/IP4_PX).toFixed(2),p:pct(IP4_SELL)})}</p>
|
||||
<label class="ops-sel"><span>${tr('ip4.block_size')}</span><select data-chg="ip4Pick">${Array.from({length:IP4_MAX-IP4_MIN+1},(_,i)=>IP4_MAX-i).map(l=>`<option value="${l}"${l===len?' selected':''}>/${l} · ${trn('ip4.n_addresses',ip4Sz(l),{n:ip4N(ip4Sz(l))})}</option>`).join('')}</select></label>
|
||||
${full?`<div class="why">${tr('ip4.too_many',{n:IP4_BLK})}</div>`:''}<div class="btns">${btn(tr('ip4.buy',{price:fmt$(ip4Cost(len))}),'ip4Buy',{len},'pink sm',full||S.cash<ip4Cost(len))}${btn(tr('ip4.lease',{price:fmt$(ip4InMo(len))}),'ip4Lease',{len},'sm',full)}</div></div></section>`;
|
||||
return h;}
|
||||
|
|
@ -43,7 +43,7 @@ function whatsNew(returning,force){
|
|||
const DOORS=[['puzzle','🧩',tr('title.puzzles'),tr('title.one_network_one_knot_no_clock')],['sandbox','🏖️',tr('common.sandbox'),tr('title.a_billion_dollars_and_every_toy')],['normal','📟',tr('common.normal'),tr('title.the_real_game_climb_from_tier')],['scn','🏆',tr('title.scenarios_amp_weekly'),tr('title.hand_built_crises_and_one_world')]];
|
||||
const doorAct={puzzle:'puzzleDoor',sandbox:'modeSet',normal:'modeSet',scn:'scenarios'};
|
||||
// The chosen preset in one line: its joke, then what actually changes.
|
||||
const presetWhat=k=>`${esc(PRESETS[k].d)} <span class="meta">${esc(PRESETS[k].x)}</span>`;
|
||||
const presetWhat=k=>`${esc(PRESETS[k].d)} <span class="meta">${esc(PRESETS[k].x)} ${PRESETS[k].ip4===false?tr('ip4.preset_plenty'):tr('ip4.preset_scarce')}</span>`;
|
||||
// The Normal presets, one toggle each: on the title screen, and for a multiplayer session (48-multiplayer.js).
|
||||
const presetBtns=pr=>`<label class="f">${tr('title.how_much_trouble')}</label><div class="presets">${NORMAL_PRESETS.map(k=>{const P=PRESETS[k];return `<button class="preset${k===pr?' on':''}" data-preset="${k}" data-act="presetSet" data-args='{"p":"${k}"}' aria-pressed="${k===pr}"><i aria-hidden="true">${P.i}</i><b>${P.n}</b></button>`;}).join('')}</div><p class="note" id="presetWhat">${presetWhat(pr)}</p>`;
|
||||
function doorsHtml(){const m=UI.mode==='sandbox'?'sandbox':'normal',pr=own(PRESETS,UI.preset)&&NORMAL_PRESETS.includes(UI.preset)?UI.preset:'oncall',ch=own(CHAOS,UI.sbChaos)?UI.sbChaos:'none';
|
||||
|
|
|
|||
|
|
@ -2639,6 +2639,54 @@
|
|||
"interface.tubecoin_moved_down_p_on_the":"TubeCoin moved down {p}% on the way to your account.",
|
||||
"interface.tubecoin_moved_up_p_on_the":"TubeCoin moved up {p}% on the way to your account.",
|
||||
"interface.you_bought_out_bank_they_flew":"<b>You bought out {bank}.</b><br>They flew off to find another startup.",
|
||||
"ip4.block_size":"Block size",
|
||||
"ip4.blocks":"Your blocks",
|
||||
"ip4.bought":"Bought a {p} ({n} addresses) for {price}.",
|
||||
"ip4.bought_on":"Bought {date}",
|
||||
"ip4.business":"Used by business customers",
|
||||
"ip4.buy":"Buy {price}",
|
||||
"ip4.cgnat_boxes":"CGNAT boxes",
|
||||
"ip4.cgnat_note":"More homes per address frees space for customers, but games and port forwarding suffer: {p} of a CGNAT home's bill comes back as refunds.",
|
||||
"ip4.cgnat_ratio":"CGNAT: homes sharing one address",
|
||||
"ip4.costs_row":"IPv4 leases and CGNAT",
|
||||
"ip4.free":"Free for new customers (homes move behind CGNAT first)",
|
||||
"ip4.from_rir":"From the RIR",
|
||||
"ip4.give_back":"Give it back",
|
||||
"ip4.held":"The RIR won't transfer that block again before {date}.",
|
||||
"ip4.homes":"Broadband homes",
|
||||
"ip4.homes_cgnat":"{n}, {p} behind CGNAT",
|
||||
"ip4.in_use":"Your customers need those addresses: put more homes behind CGNAT or get another block first.",
|
||||
"ip4.lease":"Lease {price}/mo",
|
||||
"ip4.lease_out":"Lease out +{price}/mo",
|
||||
"ip4.leased_in":"Leased a {p} ({n} addresses) for {price}/mo.",
|
||||
"ip4.leased_in_mo":"Leased in · {price}/mo",
|
||||
"ip4.leased_out":"Your {p} is leased out: +{price}/mo.",
|
||||
"ip4.leased_out_mo":"Leased out · +{price}/mo",
|
||||
"ip4.leases_in":"Blocks leased in",
|
||||
"ip4.leases_out":"Blocks leased out",
|
||||
"ip4.market":"Transfer market",
|
||||
"ip4.market_note":"IPv4 sells for about {px} an address (big blocks a little less), leases for {lin} an address a month, and earns {lout} leased out after the broker's cut. A sale pays {p} of the price, and a block can only move again two years after its last transfer.",
|
||||
"ip4.movable_from":"can move again from {date}",
|
||||
"ip4.n_addresses":{"one":"{n} address","other":"{n} addresses"},
|
||||
"ip4.n_homes_per_address":{"one":"{n} home per address","other":"{n} homes per address"},
|
||||
"ip4.no_grow":"{name} ({city}) wanted to grow to {bw}, but you had no IPv4 addresses free for it.",
|
||||
"ip4.no_space":"{name} needs a {p} of IPv4 ({n} addresses), and only {free} are free. Buy or lease a block, or put more homes behind CGNAT.",
|
||||
"ip4.note":"IPv6 is free and endless. IPv4 ran out years ago: business customers need public blocks of it, and homes that don't fit share addresses behind CGNAT (IPv6 traffic goes around the box).",
|
||||
"ip4.off":"IPv4 is plentiful under this game's rules.",
|
||||
"ip4.offer_needs":"Needs a {p} of IPv4 ({n} addresses); only {free} free.",
|
||||
"ip4.preset_plenty":"Plenty of IPv4 for everyone.",
|
||||
"ip4.preset_scarce":"IPv4 is scarce: buy it, lease it or share it behind CGNAT.",
|
||||
"ip4.really_sell":"Really sell for {price}?",
|
||||
"ip4.refunds":"Refunds to grumpy gamers",
|
||||
"ip4.section":"Address space",
|
||||
"ip4.sell":"Sell {price}",
|
||||
"ip4.sold":"Sold your {p} for {price}.",
|
||||
"ip4.squeezed":"Out of space: {p} of homes don't fit even at {r} homes per address. Their connections break and they want refunds: buy or lease a block.",
|
||||
"ip4.take_back":"Take it back",
|
||||
"ip4.toast_cgnat":"<b>Your IPv4 is full.</b> {p} of your homes now share addresses behind CGNAT, and a few gamers have already written in.",
|
||||
"ip4.toast_out":"<b>Out of IPv4.</b> Even at {r} homes per address, CGNAT can't fit everyone: buy or lease a block at the bank.",
|
||||
"ip4.too_many":"You hold {n} IPv4 blocks, the most one network can keep track of. Sell or give back small ones to make room for a bigger block.",
|
||||
"ip4.yours":"Your IPv4 addresses",
|
||||
"ix_downgrade.pni_downgraded":"The PNI with {net} in {city} is now {port}.",
|
||||
"ix_downgrade.port_downgraded_at_ix":"Port at {ix} is now {port}.",
|
||||
"ix_downgrade.transit_downgraded":"{net} transit in {city} is now {port}.",
|
||||
|
|
|
|||
442
tests/address-space.test.js
Normal file
442
tests/address-space.test.js
Normal file
|
|
@ -0,0 +1,442 @@
|
|||
// IPv4 address space (#150, src/game/60-features/33-address-space.js): business customers need public blocks, broadband
|
||||
// homes share addresses behind CGNAT when they do not fit, blocks are bought, sold, leased in and leased out, and the
|
||||
// whole thing is a rule (ip4): On-call and BGP at 3 a.m. only, scenarios when they opt in.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { load } = require('./harness');
|
||||
const { lit } = require('../scripts/lib/js-literal');
|
||||
|
||||
// Frankfurt on On-call, plenty of cash, nothing breaking, level 9 so every kind of customer can turn up.
|
||||
const BASE = "ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.rules=makeRules('oncall');S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=9;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.offers=[];S.biz=[];" +
|
||||
"ACT.launchBB({city:'fra'});S.pops.fra.rgen=3;ACT.buyTransit({city:'fra',net:'lvl',tier:3});compute()";
|
||||
function game(t, opts) {
|
||||
const h = load(opts);
|
||||
t.after(() => h.dom.window.close());
|
||||
h.ev(BASE);
|
||||
return h;
|
||||
}
|
||||
const J = (ev, x) => JSON.parse(ev(`JSON.stringify(${x})`));
|
||||
const homes = (ev, g) => ev(`S.pops.fra.bb.d=${g};compute()`);
|
||||
const biz = (ev, b) => ev(`S.biz.push(${lit({ id: b.id || 'b' + Math.random().toString(36).slice(2), city: 'fra', city2: null, reqs: [], name: 'X', type: 'host', bw: 10, rate: 60, mood: 100, since: 0, ...b })});compute()`);
|
||||
|
||||
test('what each customer needs: a block by kind and size, nothing for circuits, fiber, downstream ISPs or orbit', (t) => {
|
||||
const { ev, errors } = game(t);
|
||||
const need = (type, bw) => ev(`ip4Need({type:${lit(type)},bw:${bw}})`);
|
||||
assert.equal(need('dia', 1), 8, 'a small DIA port gets a /29');
|
||||
assert.equal(need('dia', 10), 32);
|
||||
assert.equal(need('game', 5), 16);
|
||||
assert.equal(need('host', 10), 64);
|
||||
assert.equal(need('host', 80), 512, 'a big hosting company a /23');
|
||||
assert.equal(need('cgame', 3200), 2048);
|
||||
assert.equal(need('metav', 6400), 2048);
|
||||
assert.equal(need('host', 1e6), 4096, 'capped at a /20');
|
||||
for (const k of ['l2vpn', 'hyper', 'wwave', 'dfpair', 'isp', 'edu', 'provedor', 'event', 'pizza', 'flywifi']) assert.equal(need(k, 100), 0, k);
|
||||
assert.equal(ev('ip4Cidr(8)'), '/29');
|
||||
assert.equal(ev('ip4Cidr(512)'), '/23');
|
||||
// Every IPv4 kind is a real kind of customer that pays by the Gbps.
|
||||
assert.deepEqual(J(ev, 'Object.keys(IP4_BIZ).filter(k=>!BIZ_T[k]||!(BIZ_T[k].rate>0)||BIZ_T[k].l2||BIZ_T[k].fiber||BIZ_T[k].orbit)'), []);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('consumption: business first, homes take the rest, and the ones that do not fit go behind CGNAT', (t) => {
|
||||
const { ev, errors } = game(t);
|
||||
// A new network: one /21 from the RIR, held two years before it can move.
|
||||
assert.deepEqual(J(ev, 'S.ip4.b.map(b=>[b.len,b.k,b.d])'), [[21, 'rir', 0]]);
|
||||
assert.equal(ev('S.ip4.nat'), 16);
|
||||
homes(ev, 50);
|
||||
let u = J(ev, 'ip4Use()');
|
||||
assert.deepEqual([u.T, u.B, u.H, u.cg, u.over, u.free], [2048, 0, 500, 0, 0, 2048 - 32], '500 homes all public; a new customer could push them all behind CGNAT');
|
||||
assert.equal(ev('R.cost.ip4'), undefined, 'nothing to pay while everyone has an address');
|
||||
biz(ev, { type: 'host', bw: 80 }); // a /23
|
||||
homes(ev, 150);
|
||||
u = J(ev, 'ip4Use()');
|
||||
// 1,536 left for 1,500 homes: all public. 1,600 homes: (1600-1536)*16/15 rounded up go behind CGNAT.
|
||||
assert.deepEqual([u.B, u.cg], [512, 0]);
|
||||
homes(ev, 160);
|
||||
u = J(ev, 'ip4Use()');
|
||||
assert.equal(u.cg, Math.ceil((1600 - 1536) * 16 / 15));
|
||||
assert.ok(u.H - u.cg + Math.ceil(u.cg / 16) <= 1536, 'public homes plus the CGNAT pool fit the space');
|
||||
const c = J(ev, 'ip4Bill(R.rev.eyeballs)');
|
||||
assert.ok(c.box > 0 && c.refund > 0, 'CGNAT boxes and refunds cost money');
|
||||
assert.equal(ev('R.cost.ip4'), Math.round(c.box + c.refund));
|
||||
assert.ok(Math.abs(c.refund - ev('R.rev.eyeballs') * (u.cg / u.H) * 0.015) < 1e-6, 'refunds: 1.5% of the CGNAT share of what homes pay at 1:16');
|
||||
// A wider ratio frees addresses and annoys more gamers.
|
||||
const free16 = u.free;
|
||||
ev("ACT.ip4Nat({v:'64'})");
|
||||
assert.equal(ev('S.ip4.nat'), 64);
|
||||
assert.ok(J(ev, 'ip4Use()').free > free16);
|
||||
assert.ok(J(ev, 'ip4Bill(R.rev.eyeballs)').refund > c.refund);
|
||||
ev("ACT.ip4Nat({v:'16'})");
|
||||
// Business customers squeeze the homes: past the ratio, homes are squeezed out (port exhaustion) and it shows.
|
||||
biz(ev, { type: 'host', bw: 80, id: 'h2' });
|
||||
biz(ev, { type: 'host', bw: 1e6, id: 'h3' });
|
||||
u = J(ev, 'ip4Use()');
|
||||
assert.equal(u.cg, u.H);
|
||||
assert.ok(u.over > 0 && u.free < 0);
|
||||
assert.ok(J(ev, 'ip4Bill(R.rev.eyeballs)').refund >= ev('R.rev.eyeballs*ip4Use().over') * 0.15, 'squeezed homes want real money back');
|
||||
// Narrowing the ratio is refused when the signed customers would not fit.
|
||||
ev("ACT.ip4Nat({v:'8'})");
|
||||
assert.equal(ev('S.ip4.nat'), 16);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('an offer that needs more IPv4 than is free cannot be signed, and says why; a block fixes it', (t) => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
homes(ev, 50);
|
||||
ev(`S.offers.push({id:'big',city:'fra',name:'Pixel Palace',type:'cgame',bw:3200,rate:45,reqs:[],exp:S.day+30},{id:'small',city:'fra',name:'Tiny DIA',type:'dia',bw:1,rate:600,reqs:[],exp:S.day+30})`);
|
||||
assert.equal(ev("ip4Fits(S.offers[0])"), false, 'a /21 does not fit the starting /21 with homes on it');
|
||||
assert.equal(ev("ip4Fits(S.offers[1])"), true);
|
||||
// The deals list and the city panel say why, with a way to the address space.
|
||||
ev("UI.left='deals';UI.leftOpen=true;renderLeft();selectCity('fra');UI.tab='cust';renderPanel()");
|
||||
const left = dom.window.document.getElementById('leftBody').textContent;
|
||||
assert.match(left, /Needs a \/21 of IPv4 \(2,048 addresses\); only 2,016 free\./);
|
||||
assert.ok(dom.window.document.querySelector('#leftBody [data-act="ip4Open"]'), 'a button to the address space');
|
||||
ev("ACT.accept({id:'big'})");
|
||||
assert.equal(ev("S.offers.some(o=>o.id==='big')"), true, 'not signed');
|
||||
assert.equal(ev('S.biz.length'), 0);
|
||||
assert.match(dom.window.document.getElementById('toasts').textContent, /Pixel Palace needs a \/21 of IPv4/);
|
||||
ev("ACT.accept({id:'small'})");
|
||||
assert.equal(ev('S.biz.length'), 1, 'a small one fits');
|
||||
// Buy a /21 and the big one signs.
|
||||
const cash = ev('S.cash');
|
||||
ev("ACT.ip4Buy({len:21})");
|
||||
assert.equal(ev('S.cash'), cash - ev('ip4Cost(21)'));
|
||||
assert.equal(ev('ip4Cost(21)'), Math.round(2048 * 38 * (1 - 0.015 * 3) / 100) * 100, 'about $38 an address, a little less for a bigger block');
|
||||
ev("ACT.accept({id:'big'})");
|
||||
assert.equal(ev('S.biz.length'), 2);
|
||||
assert.equal(J(ev, 'ip4Use()').B, 8 + 2048);
|
||||
// The bank opens at the section.
|
||||
ev("ACT.ip4Open()");
|
||||
assert.equal(dom.window.document.getElementById('bankBox').hidden, false);
|
||||
assert.ok(dom.window.document.getElementById('bankIp4'));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the sales desk and the CEO do not sign what does not fit', (t) => {
|
||||
const { ev, errors } = game(t);
|
||||
homes(ev, 50);
|
||||
ev("ACT.salesHire({id:'shark'});closeModal();S.slAuto.on=true");
|
||||
ev("S.offers.push({id:'big',city:'fra',name:'Big One',type:'metav',bw:6400,rate:35,reqs:[],exp:S.day+30})");
|
||||
ev('slAutoDay(S.day)');
|
||||
assert.equal(ev("S.offers.some(o=>o.id==='big')"), true, 'the shark leaves it');
|
||||
ev("ACT.salesFire({});ACT.salesFire({});closeModal();ACT.salesHire({id:'ceo'});closeModal()");
|
||||
assert.equal(ev("salesOverride(S.offers.find(o=>o.id==='big'))"), false, 'no handshake on addresses you do not have');
|
||||
assert.equal(ev("(()=>{const t=SALES_GOLF.find(x=>(BIZ_T[x].lv||1)<=lvl()&&ip4Fits({type:x,bw:BIZ_T[x].opts[BIZ_T[x].opts.length-1]}));return t;})()"), 'gpu', 'the golf deal is the biggest that fits (a /23 for an AI data center, not a /21 for cloud gaming)');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('buying, leasing in, leasing out and selling move the right money', (t) => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
homes(ev, 20);
|
||||
const rev0 = ev('R.revMo'), cost0 = ev('R.costMo');
|
||||
ev("ACT.ip4Lease({len:22})");
|
||||
const lin = ev("S.ip4.b.find(b=>b.k==='in').mo");
|
||||
assert.equal(lin, 512, 'a /22 leases for $0.50 an address a month');
|
||||
assert.equal(ev('R.costMo'), cost0 + lin);
|
||||
assert.equal(ev('ip4Use().T'), 3072);
|
||||
ev("ACT.ip4Buy({len:24})");
|
||||
const bought = ev("S.ip4.b.find(b=>b.k==='buy').id");
|
||||
ev(`ACT.ip4Out({id:${lit(bought)}})`);
|
||||
assert.equal(ev(`S.ip4.b.find(b=>b.id===${lit(bought)}).mo`), Math.round(256 * 0.4));
|
||||
assert.equal(ev('R.revMo'), rev0 + Math.round(256 * 0.4), 'leased out: income every month');
|
||||
assert.equal(ev('R.rev.ip4'), Math.round(256 * 0.4));
|
||||
// A leased-out block cannot be sold; take it back first. A fresh block cannot move for two years.
|
||||
ev(`ACT.ip4Sell({id:${lit(bought)}})`);
|
||||
assert.equal(ev(`S.ip4.b.some(b=>b.id===${lit(bought)})`), true);
|
||||
ev(`ACT.ip4Back({id:${lit(bought)}})`);
|
||||
assert.equal(ev('R.rev.ip4'), undefined);
|
||||
ev(`ACT.ip4Sell({id:${lit(bought)}})`);
|
||||
assert.match(dom.window.document.getElementById('toasts').textContent, /won't transfer that block again/);
|
||||
ev('S.day+=730');
|
||||
const cash = ev('S.cash');
|
||||
ev(`ACT.ip4Sell({id:${lit(bought)}})`);
|
||||
assert.equal(ev(`S.ip4.b.some(b=>b.id===${lit(bought)})`), true, 'the first click only asks');
|
||||
ev(`ACT.ip4Sell({id:${lit(bought)}})`);
|
||||
assert.equal(ev(`S.ip4.b.some(b=>b.id===${lit(bought)})`), false);
|
||||
assert.equal(ev('S.cash'), cash + ev('ip4Value(24)'));
|
||||
assert.ok(ev('ip4Value(24)') < ev('ip4Cost(24)'), 'the broker keeps a cut');
|
||||
// Hand the leased block back: the fee stops.
|
||||
ev("ACT.ip4Return({id:S.ip4.b.find(b=>b.k==='in').id})");
|
||||
assert.equal(ev("S.ip4.b.some(b=>b.k==='in')"), false);
|
||||
assert.equal(ev('R.cost.ip4'), undefined);
|
||||
// Space in use cannot be given away: with customers on every address, leasing out or selling the /21 is refused.
|
||||
biz(ev, { type: 'host', bw: 80 });
|
||||
biz(ev, { type: 'host', bw: 40, id: 'h2' });
|
||||
const rir = ev("S.ip4.b.find(b=>b.k==='rir').id");
|
||||
ev(`ACT.ip4Out({id:${lit(rir)}})`);
|
||||
assert.equal(ev(`!!S.ip4.b.find(b=>b.id===${lit(rir)}).out`), false);
|
||||
assert.match(dom.window.document.getElementById('toasts').textContent, /Your customers need those addresses/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a list of blocks stops where a save keeps them: buying and leasing past it is refused, and a full save loads whole', (t) => {
|
||||
const { ev, dom, errors } = load({ agent: true });
|
||||
t.after(() => dom.window.close());
|
||||
ev(BASE);
|
||||
homes(ev, 20);
|
||||
// The market's default size, clicked over and over (or an agent in a loop): bought and leased /24s.
|
||||
ev('for(let i=0;i<150;i++)ACT.ip4Buy({len:24});for(let i=0;i<150;i++)ACT.ip4Lease({len:24})');
|
||||
assert.equal(ev('S.ip4.b.length'), ev('IP4_BLK'), 'stops at the most a save keeps');
|
||||
assert.equal(ev('IP4_BLK'), 256);
|
||||
assert.match(dom.window.document.getElementById('toasts').textContent, /You hold 256 IPv4 blocks/);
|
||||
const cash = ev('S.cash'), T = ev('ip4Use().T'), mo = ev('R.cost.ip4');
|
||||
ev('ACT.ip4Buy({len:16});ACT.ip4Lease({len:16})');
|
||||
assert.deepEqual([ev('S.ip4.b.length'), ev('S.cash'), ev('ip4Use().T')], [256, cash, T], 'refused: no money spent, nothing added');
|
||||
// The bank says so and greys the market out; an agent's quote says why.
|
||||
ev('ACT.ip4Open()');
|
||||
const sec = dom.window.document.querySelector('#bankCard .bank-ip4');
|
||||
assert.match(sec.textContent, /the most one network can keep track of/);
|
||||
assert.equal(sec.querySelector('[data-act="ip4Buy"]').disabled, true);
|
||||
assert.equal(sec.querySelector('[data-act="ip4Lease"]').disabled, true);
|
||||
assert.match(J(ev, 'API_CMD.ip4Buy.quote({len:24}).blocked')[0], /256 IPv4 blocks/);
|
||||
assert.match(J(ev, 'API_CMD.ip4Lease.quote({len:24}).blocked')[0], /256 IPv4 blocks/);
|
||||
// Saved and loaded: every block, every lease, the same space and bill.
|
||||
const before = ev('JSON.stringify(S.ip4)');
|
||||
ev('S=migrate(JSON.parse(JSON.stringify(S)));compute()');
|
||||
assert.equal(ev('JSON.stringify(S.ip4)'), before);
|
||||
assert.deepEqual([ev('ip4Use().T'), ev('R.cost.ip4')], [T, mo]);
|
||||
// Handing one back makes room for a bigger block.
|
||||
ev("ACT.ip4Return({id:S.ip4.b.find(b=>b.k==='in').id});ACT.ip4Buy({len:16})");
|
||||
assert.deepEqual([ev('S.ip4.b.length'), ev('S.ip4.b[255].len')], [256, 16]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a customer renewing bigger stays at its size when the bigger block is not free, and says why', (t) => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
homes(ev, 0);
|
||||
// Eight 40G hosts (a /24 each) fill the /21; the ninth is refused at the door.
|
||||
for (let i = 0; i < 9; i++) ev(`S.offers.push({id:'o${i}',city:'fra',name:'Host ${i}',type:'host',bw:40,rate:60,reqs:[],exp:S.day+30});ACT.accept({id:'o${i}'})`);
|
||||
assert.equal(ev('S.biz.length'), 8);
|
||||
assert.equal(J(ev, 'ip4Use()').free, 0);
|
||||
// The next term of host 0 on a day its own rolls say: stay, and grow (to 80G, a /23).
|
||||
const renew = () => J(ev, `(()=>{const b=S.biz[0];for(const x of S.biz)if(x!==b)x.te=1e6;
|
||||
for(let k=Math.max(S.day,b.te)+1;k<S.day+20000;k++){b.te=k;b.mood=100;
|
||||
if(clR(b,'grow')<0.3&&clR(b,'leave')>=(0.04+0.08*Math.min(1,clComp(b)/6))*salesLeaveMul(b)){S.day=k;document.getElementById('toasts').innerHTML='';clDay(k);compute();
|
||||
return {bw:b.bw,te:b.te,in:S.biz.includes(b),free:ip4Use().free,toasts:document.getElementById('toasts').textContent};}}return null;})()`);
|
||||
let r = renew();
|
||||
assert.ok(r, 'a growing renewal turns up');
|
||||
assert.deepEqual([r.bw, r.in, r.free], [40, true, 0], 'renewed at the size it has: nobody runs on addresses you do not have');
|
||||
assert.ok(r.te > ev('S.day'), 'a new term');
|
||||
assert.match(r.toasts, /Host 0 \(Frankfurt\) wanted to grow to 80(\.0)? Gbps, but you had no IPv4 addresses free for it\./);
|
||||
assert.match(r.toasts, /renewed/);
|
||||
// The acquisition that would stay bigger goes through the same door.
|
||||
assert.equal(ev('(()=>{const out={v4:[]};return clGrow(S.biz[0],out)===false&&out.v4.length===1&&S.biz[0].bw===40;})()'), true);
|
||||
// A block bought, the next growing renewal grows.
|
||||
ev('ACT.ip4Buy({len:24})');
|
||||
r = renew();
|
||||
assert.deepEqual([r.bw, r.free], [80, 0]);
|
||||
assert.match(r.toasts, /renewed and grew to 80(\.0)? Gbps/);
|
||||
// Without the rule, growth is as it always was.
|
||||
ev("S.rules=makeRules('freeze');compute()");
|
||||
r = renew();
|
||||
assert.equal(r.bw, 160);
|
||||
assert.doesNotMatch(r.toasts, /IPv4/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the address space says what its numbers mean: free counts homes behind CGNAT, blocks in use say why they stay', (t) => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
ev('S.day=800');
|
||||
homes(ev, 50);
|
||||
ev('ACT.ip4Open()');
|
||||
const sec = () => dom.window.document.querySelector('#bankCard .bank-ip4');
|
||||
assert.match(sec().textContent, /Free for new customers \(homes move behind CGNAT first\)2,016/);
|
||||
// The /21 is out of its holding period, but 500 homes use it: greyed out, and the row says why.
|
||||
let row = sec().querySelector('[data-act="ip4Out"]').closest('.row');
|
||||
assert.equal(row.querySelector('[data-act="ip4Out"]').disabled, true);
|
||||
assert.equal(row.querySelector('[data-act="ip4Sell"]').disabled, true);
|
||||
assert.match(row.querySelector('.why').textContent, /Your customers need those addresses/);
|
||||
// A leased-in /24 the customers need too: Give it back is greyed, with the reason.
|
||||
ev("ACT.ip4Lease({len:24})");
|
||||
biz(ev, { type: 'host', bw: 80, id: 'h1' });
|
||||
biz(ev, { type: 'host', bw: 80, id: 'h2' });
|
||||
biz(ev, { type: 'host', bw: 80, id: 'h3' });
|
||||
biz(ev, { type: 'host', bw: 80, id: 'h4' });
|
||||
assert.equal(J(ev, 'ip4Use()').free, 224, 'fewer free than the /24 holds');
|
||||
ev('UI._bh=null;renderBank()');
|
||||
row = sec().querySelector('[data-act="ip4Return"]').closest('.row');
|
||||
assert.equal(row.querySelector('[data-act="ip4Return"]').disabled, true);
|
||||
assert.match(row.querySelector('.why').textContent, /Your customers need those addresses/);
|
||||
// With room to spare, no reason is shown and the buttons work.
|
||||
ev("S.biz=[];compute();ACT.ip4Buy({len:24});UI._bh=null;renderBank()");
|
||||
row = [...sec().querySelectorAll('[data-act="ip4Out"]')].pop().closest('.row');
|
||||
assert.equal(row.querySelector('[data-act="ip4Out"]').disabled, false);
|
||||
assert.equal(row.querySelector('.why'), null);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the AS box on the dashboard lists the blocks you announce, not a made-up count', (t) => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
const asBox = () => { ev("ACT.dash({});ACT.dashTab({k:'infra'})"); const k = [...dom.window.document.querySelectorAll('.kv')].map(e => e.textContent).find(x => /IPv6/.test(x)); ev('ACT.dashClose()'); return k; };
|
||||
assert.match(asBox(), /1 × \/21 IPv4, 1 × \/32 IPv6/, 'the starting allocation');
|
||||
ev("ACT.ip4Lease({len:22});ACT.ip4Buy({len:24})");
|
||||
assert.match(asBox(), /1 × \/21, 1 × \/22, 1 × \/24 IPv4/, 'bought and leased-in blocks are announced too');
|
||||
ev("S.rules=makeRules('freeze');compute()");
|
||||
assert.match(asBox(), /1 × \/22 IPv4/, 'without the rule it stays as it always was');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the market price drifts gently with the day, and holds still without the market rule', (t) => {
|
||||
const { ev, errors } = game(t);
|
||||
assert.equal(ev('ip4Px(0)'), 38);
|
||||
assert.equal(ev('ip4Px(180)'), 38, 'flat for half a year');
|
||||
const px = [400, 900, 1500, 2200].map((d) => ev(`ip4Px(${d})`));
|
||||
assert.ok(px.every((p) => p > 30 && p < 50), 'realistic: $30 to $50 an address: ' + px);
|
||||
assert.ok(Math.abs(ev('ip4Px(546)') - ev('ip4Px(545)')) < 0.1, 'a gentle trend, not a jump');
|
||||
assert.ok(ev('ip4Cost(16)') / 65536 < ev('ip4Cost(24)') / 256, 'bigger blocks a little cheaper per address');
|
||||
ev("S.rules=makeRules('oncall',{market:false})");
|
||||
assert.equal(ev('ip4Px(1500)'), 38);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the day says it once when homes go behind CGNAT, and when even CGNAT cannot fit them', (t) => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
const said = () => dom.window.document.getElementById('toasts').textContent;
|
||||
// A handful of homes over the edge (under a percent of them) is not news yet.
|
||||
homes(ev, 205.3);
|
||||
ev('ip4Day(S.day)');
|
||||
const few = J(ev, 'ip4Use()');
|
||||
assert.ok(few.cg > 0 && few.cg < few.H / 100, JSON.stringify(few));
|
||||
assert.equal(ev('S.ip4.w'), 0);
|
||||
assert.doesNotMatch(said(), /IPv4/);
|
||||
homes(ev, 250);
|
||||
ev('ip4Day(S.day)');
|
||||
assert.match(said(), /Your IPv4 is full\.\s*19% of your homes now share addresses behind CGNAT/);
|
||||
assert.equal(ev('S.ip4.w'), 1);
|
||||
ev("document.getElementById('toasts').innerHTML='';ip4Day(S.day)");
|
||||
assert.equal(said(), '', 'only once');
|
||||
// Homes hovering at the limit hear it once: dipping just under does not rearm it, real room again does.
|
||||
homes(ev, 204);
|
||||
ev('ip4Day(S.day)');
|
||||
assert.deepEqual([J(ev, 'ip4Use()').cg, ev('S.ip4.w')], [0, 1]);
|
||||
homes(ev, 250);
|
||||
ev('ip4Day(S.day)');
|
||||
assert.equal(said(), '', 'not again while hovering');
|
||||
homes(ev, 150);
|
||||
ev('ip4Day(S.day)');
|
||||
assert.equal(ev('S.ip4.w'), 0, 'room to spare: it rearms');
|
||||
homes(ev, 250);
|
||||
ev('ip4Day(S.day)');
|
||||
assert.match(said(), /Your IPv4 is full/);
|
||||
ev("document.getElementById('toasts').innerHTML=''");
|
||||
biz(ev, { type: 'host', bw: 1e6 });
|
||||
ev('ip4Day(S.day)');
|
||||
assert.match(dom.window.document.getElementById('toasts').textContent, /Out of IPv4/);
|
||||
assert.equal(ev('S.ip4.w'), 3);
|
||||
ev("S.biz=[];S.pops.fra.bb.d=10;compute();ip4Day(S.day)");
|
||||
assert.equal(ev('S.ip4.w'), 0, 'fixed: the warnings rearm');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('rule off means no effect: gentler presets, sandbox, puzzles and scenarios unless they opt in', (t) => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
assert.deepEqual(J(ev, "['soft','freeze','oncall','bgp','sandbox','puzzle'].map(p=>makeRules(p).ip4)"), [false, false, null, null, false, false], 'On-call and BGP keep the default (on), written nowhere');
|
||||
assert.equal(ev('RULE_DEF.ip4'), true);
|
||||
ev("S.rules=makeRules('freeze');S.pops.fra.bb.d=500;compute()");
|
||||
assert.equal(ev('ip4On()'), false);
|
||||
ev("S.offers.push({id:'big',city:'fra',name:'Big One',type:'metav',bw:6400,rate:35,reqs:[],exp:S.day+30})");
|
||||
assert.equal(ev("ip4Why(S.offers[0])"), '');
|
||||
ev("ACT.accept({id:'big'})");
|
||||
assert.equal(ev('S.biz.length'), 1, 'signed: IPv4 is plentiful here');
|
||||
assert.equal(ev('R.cost.ip4'), undefined);
|
||||
ev("ACT.ip4Buy({len:24})");
|
||||
assert.equal(ev('S.ip4.b.length'), 1, 'the market is closed');
|
||||
ev("ACT.bank()");
|
||||
assert.equal(dom.window.document.getElementById('bankIp4'), null, 'no address space in the bank');
|
||||
ev("ACT.bankClose()");
|
||||
// Sandbox and scenarios.
|
||||
ev("beginGame('Box','fra',{mode:'sandbox'});if(UI.pendGame)ACT.pitchSkip()");
|
||||
assert.equal(ev('ip4On()'), false, 'sandbox');
|
||||
ev("beginGame('S','fra',{mode:'normal',preset:'oncall',scn:SCN.find(x=>x.city==='fra')||SCN[0]});if(UI.pendGame)ACT.pitchSkip()");
|
||||
assert.equal(ev("S.mode"), 'scenario');
|
||||
assert.equal(ev('ip4On()'), false, 'scenarios run On-call but stay as they were');
|
||||
ev('S.scn.rules.ip4=true');
|
||||
assert.equal(ev('ip4On()'), true, 'unless they opt in');
|
||||
ev("beginGame('B','fra',{mode:'normal',preset:'bgp'});if(UI.pendGame)ACT.pitchSkip()");
|
||||
assert.equal(ev('ip4On()'), true, 'BGP at 3 a.m.');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('old saves: what they already use is registered to them, so nothing changes on load', (t) => {
|
||||
const { ev, errors } = game(t);
|
||||
homes(ev, 300);
|
||||
biz(ev, { type: 'host', bw: 80 });
|
||||
biz(ev, { type: 'dia', bw: 10, id: 'd1' });
|
||||
biz(ev, { type: 'l2vpn', bw: 10, id: 'l1' });
|
||||
// The same network without the rule, for its money.
|
||||
ev("window.__r=S.rules;S.rules=makeRules('freeze');compute();window.__m=[R.revMo,R.costMo];S.rules=__r");
|
||||
ev('S.day=400;delete S.ip4;S=migrate(JSON.parse(JSON.stringify(S)));compute()');
|
||||
const u = J(ev, 'ip4Use()');
|
||||
assert.equal(u.cg, 0, 'no home behind CGNAT');
|
||||
const want = (u.B + u.H) * 1.25;
|
||||
assert.ok(u.T >= want && u.T - want < 256, 'what they use and a quarter more to grow into, rounded up to whole /24s: ' + JSON.stringify(u));
|
||||
assert.ok(J(ev, 'S.ip4.b').every((b) => b.k === 'rir' && b.d === 400 && b.len >= 16 && b.len <= 24));
|
||||
assert.deepEqual([ev('R.revMo'), ev('R.costMo')], J(ev, '__m'), 'the same money as before the feature');
|
||||
// A tiny old save still gets the /21 a new one starts with.
|
||||
ev("S.biz=[];S.pops.fra.bb.d=1;delete S.ip4;S=sanitize(JSON.parse(JSON.stringify(S)))");
|
||||
assert.deepEqual(J(ev, 'S.ip4.b.map(b=>b.len)'), [21]);
|
||||
// A big old network: whole /16s.
|
||||
ev("S.pops.fra.bb.d=20000;delete S.ip4;S=sanitize(JSON.parse(JSON.stringify(S)))");
|
||||
const big = J(ev, 'ip4Use()');
|
||||
assert.ok(big.T >= 200000 && big.cg === 0 && J(ev, 'S.ip4.b.filter(b=>b.len===16).length') === 3);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the big network loads with its usage granted: routing and money as before', (t) => {
|
||||
const { ev, dom, errors } = load({ seed: 3 });
|
||||
t.after(() => dom.window.close());
|
||||
const SAVE = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8');
|
||||
ev(`S=migrate(JSON.parse(${lit(SAVE)}));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();compute()`);
|
||||
const on = ev('ip4On()');
|
||||
const digest = 'JSON.stringify([R.served,R.revMo,R.costMo,R.cost,R.rev])';
|
||||
const a = ev(digest);
|
||||
ev("window.__r=S.rules;S.rules=Object.assign({},S.rules,{ip4:false});compute()");
|
||||
assert.equal(ev(digest), a, 'the grant covers it all (rule ' + (on ? 'on' : 'off') + ')');
|
||||
assert.equal(J(ev, 'S.ip4.b.length') > 0, true);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('saves: garbage is repaired, and the state round-trips', (t) => {
|
||||
const { ev, errors } = game(t);
|
||||
ev("ACT.ip4Lease({len:23});ACT.ip4Nat({v:'32'})");
|
||||
const before = ev('JSON.stringify(S.ip4)');
|
||||
ev('S=sanitize(JSON.parse(JSON.stringify(S)))');
|
||||
assert.equal(ev('JSON.stringify(S.ip4)'), before);
|
||||
ev(`S.ip4={b:[{id:'a',len:12,k:'rir',d:0},{id:'b',len:24,k:'stolen',d:0},{id:'c',len:24,k:'buy',d:-5,out:'yes',mo:5},{id:'d',len:23,k:'in',d:1e9,mo:-3},null,{id:'e',len:24,k:'rir',d:0,out:true,mo:'x'}],nat:7,w:99};S=sanitize(JSON.parse(JSON.stringify(S)))`);
|
||||
assert.deepEqual(J(ev, 'S.ip4'), { b: [{ id: 'c', len: 24, k: 'buy', d: 0 }, { id: 'd', len: 23, k: 'in', d: ev('S.day'), mo: 0 }, { id: 'e', len: 24, k: 'rir', d: 0, out: true, mo: 0 }], nat: 16, w: 3 });
|
||||
ev("S.ip4='nope';S=sanitize(JSON.parse(JSON.stringify(S)))");
|
||||
assert.ok(J(ev, 'S.ip4.b.length') >= 1, 'a broken field is granted afresh');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the address space works on a phone: one column, wrapping buttons, the dropdowns stacked', (t) => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
ev("window.innerWidth=360;window.innerHeight=740;S.pops.fra.bb.d=250;compute();ACT.ip4Lease({len:24});ACT.ip4Open()");
|
||||
const sec = dom.window.document.querySelector('#bankCard .bank-ip4');
|
||||
assert.ok(sec, 'the section is in the bank');
|
||||
assert.equal(sec.querySelectorAll('select').length, 2, 'the CGNAT ratio and the block size');
|
||||
for (const s of sec.querySelectorAll('select')) assert.ok(s.closest('.ops-sel'), 'each dropdown in a stacking label');
|
||||
for (const b of sec.querySelectorAll('button')) assert.ok(b.closest('.btns'), 'every button in a wrapping row: ' + b.textContent);
|
||||
assert.match(sec.textContent, /2,500, \d+% behind CGNAT/);
|
||||
// The dropdown picks the size the buttons quote.
|
||||
ev("ACT.ip4Pick({v:'18'})");
|
||||
assert.ok(dom.window.document.querySelector('#bankCard [data-act="ip4Buy"]').dataset.args.includes('"len":18'));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('no raw labels in the address space, in every language', (t) => {
|
||||
for (const lang of ['en', 'de', 'es', 'fr', 'it', 'pt']) {
|
||||
const { ev, dom, errors } = load(lang === 'en' ? {} : { lang });
|
||||
ev(BASE);
|
||||
ev("S.pops.fra.bb.d=300;compute();ACT.ip4Lease({len:24});ACT.ip4Buy({len:24});S.ip4.b[2].out=true;S.ip4.b[2].mo=99;S.biz.push({id:'z',city:'fra',city2:null,reqs:[],name:'Z',type:'host',bw:1e6,rate:1,mood:100,since:0});compute();ip4Day(S.day);ACT.ip4Open()");
|
||||
ev("S.offers.push({id:'o',city:'fra',name:'O',type:'host',bw:80,rate:60,reqs:[],exp:S.day+30});UI.left='deals';renderLeft()");
|
||||
ev("for(let i=S.ip4.b.length;i<IP4_BLK;i++)S.ip4.b.push({id:'f'+i,len:24,k:'buy',d:0,out:true,mo:1});ip4News([[S.biz[0],80]]);UI._bh=null;renderBank()");
|
||||
assert.ok(dom.window.document.querySelectorAll('#bankCard .bank-ip4 .why').length > 2, lang + ': the full list and the blocks in use say why');
|
||||
const txt = dom.window.document.getElementById('bankCard').textContent + dom.window.document.getElementById('leftBody').textContent + dom.window.document.getElementById('toasts').textContent;
|
||||
assert.doesNotMatch(txt, /\bip4\.[a-z_]+|\{[a-z]+\}|undefined|NaN/, lang);
|
||||
assert.deepEqual(errors, [], lang);
|
||||
dom.window.close();
|
||||
}
|
||||
});
|
||||
|
|
@ -256,7 +256,8 @@ test('M3: every subsystem that can annoy the player reads a rule', () => {
|
|||
const reads = [['dayPost', 'chaosMul()'], ['fireEvent', "rule('market')"], ['ddosTick', 'ddosOff()'],
|
||||
['soldOut', "rule('market')"], ['hwMul', "rule('market')"], ['leadDays', "rule('lead')"], ['pniLead', 'leadDays'],
|
||||
['dfBuildDays', 'leadDays'], ['dayPre', "rule('clock')"], ['snub', "rule('market')"], ['fireFailure', 'shipsOn()'],
|
||||
['upcomingConfs', 'confsOn()'], ['pniLead', 'pniNow()'], ['dayPost', "rule('broke')"], ['dayPost', "rule('moods')"], ['toast', 'quietOn()']];
|
||||
['upcomingConfs', 'confsOn()'], ['pniLead', 'pniNow()'], ['dayPost', "rule('broke')"], ['dayPost', "rule('moods')"], ['toast', 'quietOn()'],
|
||||
['ip4On', "rule('ip4')"], ['ip4Fits', 'ip4On()'], ['ip4Money', 'ip4On()'], ['ip4Day', 'ip4On()']];
|
||||
fail('M3', reads.filter(([f, r]) => !ev(`typeof ${f}==='function'&&${f}.toString().includes(${lit(r)})`)).map(([f, r]) => `${f}() does not read ${r}`), 'gate it on the ruleset (src/game/40-progress/30-rules.js)');
|
||||
// and in play: no chaos and no market means a quiet year
|
||||
const g = load();
|
||||
|
|
@ -372,6 +373,23 @@ test('F1: new players get a gentle start: nothing breaks for 45 days, no sold-ou
|
|||
assert.deepEqual(g.errors, []);
|
||||
});
|
||||
|
||||
test('F1: the first IPv4 block covers the start: no CGNAT, no IPv4 bill and no IPv4 warning before day 50', () => {
|
||||
// The F2 reference build, signing every offer that fits, in the F2 cities and the fastest-growing big homes (Asia).
|
||||
const bad = [];
|
||||
for (const city of ['fra', 'nyc', 'sin', 'jnb', 'tok', 'del']) {
|
||||
const g = load();
|
||||
g.ev(`beginGame('Ref','${city}',{mode:'normal',preset:'oncall'});if(UI.pendGame)ACT.pitchSkip()`);
|
||||
g.ev(`(()=>{const c='${city}',n=NETS.filter(n=>sellsAt(n,c)).sort((a,b)=>a.price*netMult(a,c)-b.price*netMult(b,c))[0];
|
||||
ACT.launchBB({city:c});ACT.buyTransit({city:c,net:n.id,tier:1});if(ixName(c)){ACT.buyIx({city:c,tier:1,signed:true});ACT.rs({city:c});}})()`);
|
||||
assert.equal(g.ev('ip4On()'), true, 'On-call has scarce IPv4');
|
||||
const hit = g.ev(`(()=>{for(let d=0;d<50;d++){for(const o of S.offers.slice())if(bHas(o)&&ip4Fits(o))ACT.accept({id:o.id});dayTick();
|
||||
const u=ip4Use();if(u.cg>0||S.ip4.w||R.cost.ip4)return 'day '+S.day+': '+u.cg+' of '+u.H+' homes behind CGNAT, bill '+(R.cost.ip4||0);}return '';})()`);
|
||||
if (hit) bad.push(`${city}: ${hit}`);
|
||||
assert.deepEqual(g.errors, []);
|
||||
}
|
||||
fail('F1', bad, 'size the first allocation (IP4_START, src/game/60-features/33-address-space.js) so the start fits');
|
||||
});
|
||||
|
||||
test('F2: a simple build in a start city makes money within three months on On-call', () => {
|
||||
// Reference build: launch broadband, the cheapest 100G transit in town, and a port with a route server where there is an exchange.
|
||||
const bad = [];
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ test('a dry run prices every command that has a price, and changes nothing', ()
|
|||
fixInc: { id: 'none' }, confGo: { key: T('catalog', { name: 'conferences' })[0].key }, confSponsor: { key: T('catalog', { name: 'conferences' })[0].key },
|
||||
opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df }, seaRush: { id: df },
|
||||
utilityKit: { city: 'fra' }, utilityCaches: { city: 'fra' }, teDeploy: { script: 'spill at 85%' }, upLinkX: {},
|
||||
pieRd: { k: 'reuse' }, pieAnt: { id: 'none' },
|
||||
pieRd: { k: 'reuse' }, pieAnt: { id: 'none' }, ip4Buy: { len: 24 }, ip4Lease: { len: 22 },
|
||||
};
|
||||
const missing = quoted.filter((n) => !sample[n] && T('schema', { section: 'commands' })[n].args.some((a) => a.required));
|
||||
assert.deepEqual(missing, [], 'every priced command with arguments has a sample here');
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ test('the shark: bigger deals at a quarter more, oversold promises, no nerds, a
|
|||
test('the CEO: golf deals at 30% off, the odd declined offer signed anyway, opinions; all from hashes, not Math.random', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(start);
|
||||
// Room for every deal he signs (#150: nobody signs what the network has no IPv4 addresses for), so this counts handshakes.
|
||||
ev("S.ip4.b.push({id:'room',len:16,k:'buy',d:0})");
|
||||
ev("ACT.salesHire({id:'ceo'})");
|
||||
ev('window.__r=0;window.__r0=Math.random;Math.random=()=>{__r++;return __r0();};');
|
||||
const n0 = ev('S.biz.length');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue