A build standard for the whole network, kept by the intern

One sheet sets the target state for every POP, port and fiber: router
model and count, a second building, a generator, LAG members (split over
both buildings), an exchange port wherever there is one, PNIs spread
over the cities that pay, the line system, the fastest optics that reach
and wave sizes. S.popStd keeps its name; an old {g,rt} standard loads
with the same meaning.

One read-only plan prices every job with the game's own cost helpers,
POPs busiest first, then ports, then fiber hottest first. The sheet's
summary, the MCP quote, "Bring everything up now" and the new "Keep to
the build standard" order all use it, so the quote is what the click
spends. The order works a few jobs a shift through the budget and the
cash floor: a second router before a swap on a busy POP, no generator
under a nogen covenant, no De-Kicks, a line system swap only where the
fiber is quiet or a parallel link carries it, one a shift. New POPs get
the POP part of the standard, and the template's kit no longer pays for
it twice. opsMoNow counts generators and second buildings.
This commit is contained in:
jvanvik 2026-11-07 00:41:42 +01:00
parent 647e302f1c
commit 2b48a6ad65
27 changed files with 1153 additions and 61 deletions

View file

@ -8,6 +8,7 @@ All notable changes to this project are documented here. The project follows
- Your intern can upgrade optical transport: a new standing order moves full, busy fiber to a bigger line system, or trades its smallest channels for bigger optics. Pick a line system, and every fiber on a smaller one is moved up to it. A line system swap takes the fiber down for a day, so the intern only does it where the traffic gets around it and no customer rides it, one a night.
- 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.
## [3.0.0] — 2026-11-06

View file

@ -397,6 +397,48 @@
"broker.win_text":"{name} (AS{asn}) hat in {days} Tagen eigene Kabel auf {n} Kontinente verlegt und verkauft anderen Carriern Kapazität für {mo} im Monat. Die Ozeane sind jetzt dein Graben.",
"broker.won_on_date":"Gewonnen am {date}: Deine eigenen Kabel überspannen die Ozeane, und Carrier zahlen dir für ihre Nutzung.",
"broker.your_glass_gear_is_already_yours":"Als Kabelmakler gehören dir jede Fiber, jedes Leitungssystem, jede Optik, jedes Seekabel und die Router, um sie zu beleuchten, schon jetzt, egal was das Level sagt.",
"bstd.all_up":"Alles entspricht dem Standard.",
"bstd.any_model":"beliebiges Modell",
"bstd.applied":{"one":"Ein Job für den Build-Standard erledigt, {cost}.","other":"{n} Jobs für den Build-Standard erledigt, {cost}."},
"bstd.applied_none":"Für den Build-Standard ließ sich gerade nichts machen.",
"bstd.apply_nothing":"Nichts unter dem Standard",
"bstd.apply_now":"Jetzt alles hochziehen · {cost}",
"bstd.apply_wait":"Nichts zu tun, bis diese Glasfasern frei sind",
"bstd.at_every_pop":"An jedem POP",
"bstd.at_least_n":"Mindestens {n}",
"bstd.below":"Heute unter dem Standard",
"bstd.both_buildings":"Über beide Gebäude",
"bstd.cost_mo":"Laufende Kosten",
"bstd.cost_now":"Um jetzt alles hochzuziehen",
"bstd.edit":"Build-Standard bearbeiten",
"bstd.every_exchange":"Wo es einen IX gibt",
"bstd.fastest":"Die schnellste, die reicht",
"bstd.fiber_note":"Ein Line-System-Tausch legt die Glasfaser einen Tag dunkel: nur wenn sie ruhig ist oder ein paralleler Link ihre Last trägt.",
"bstd.from_level":"(Level {lv})",
"bstd.g_fiber":"Glasfaser und Waves",
"bstd.g_port":"Ports und Peering",
"bstd.generator":"Generator",
"bstd.held":{"one":"Eine Glasfaser behält vorerst ihr Line System, bis sie ruhig ist oder ein paralleler Link ihre Last für den Tag trägt, an dem sie dunkel ist. Bis dahin bekommt sie die schnellste Optik, die ihr Line System nimmt.","other":"{n} Glasfasern behalten vorerst ihr Line System, bis sie ruhig sind oder ein paralleler Link ihre Last für den Tag trägt, an dem sie dunkel sind. Bis dahin bekommen sie die schnellste Optik, die ihr Line System nimmt."},
"bstd.hire_note":"Stell in Ops einen NOC-Praktikanten ein, dann hält er jeden POP, Port und jede Glasfaser auf dem Standard: ein paar Jobs pro Tag, die meistbelasteten zuerst, im Monatsbudget und nur mit Geld übrig.",
"bstd.in_n_cities":"In mindestens {n} Städten",
"bstd.intern_keeps":"{name} hält das Netz auf Standard",
"bstd.keep":"So lassen",
"bstd.l_ix":"IX-Port",
"bstd.l_lag":"LAG-Member",
"bstd.l_model":"Router-Modell",
"bstd.l_pni":"PNIs pro Netz",
"bstd.l_site2":"Zweites Gebäude",
"bstd.l_split":"LAGs aufteilen",
"bstd.left":{"one":"Noch eine Sache liegt darunter und wartet auf Geld, eine ruhige Glasfaser oder eine Erweiterung.","other":"Noch {n} Sachen liegen darunter und warten auf Geld, eine ruhige Glasfaser oder eine Erweiterung."},
"bstd.n_more_targets":{"one":"{n} weiteres Ziel","other":"{n} weitere Ziele"},
"bstd.new_pops_note":"Ein neuer POP bekommt das sofort, solange er noch leer ist: kein Wartungsfenster. Reicht das Geld nicht, bekommt er, was passt. Ein noch gesperrtes Modell heißt: das beste freigeschaltete darunter.",
"bstd.none_set":"Noch kein Standard: Jedes Ziel steht auf „So lassen“.",
"bstd.now_line":"Standard: {list}",
"bstd.or_better":"{x} oder besser",
"bstd.port_note":"LAGs und Aufteilung gelten für Transit-, IX- und PNI-Ports. Ein neues PNI-Member ist eine Erweiterung und kommt erst Wochen später.",
"bstd.second_building":"zweites Gebäude",
"bstd.tagline":"Ein Design fürs ganze Netz: was jeder POP, Port und jede Glasfaser haben soll. Neue POPs bekommen den POP-Teil am Tag der Eröffnung; dein Praktikant oder der Button unten zieht den Rest nach.",
"bstd.title":"Build-Standard",
"businesses.a_free_pni_with_voda_phony":"Ein kostenloser PNI mit Voda-Phony. Hardware: Absolute-Unit-3.2T-Router, 3.2T-Ports und 12.8T-Waves.",
"businesses.agi_lab_allegedly":"AGI-Labor (angeblich)",
"businesses.agi_labs_allegedly_wanting_ai_wans":"AGI-Labore (angeblich), die KI-WANs mit 12,8 bis 25,6 Tbps wollen, und kostenlose PNIs mit Du-opoly und Ooh-redoo. Hardware: Mikrowtik-CCR-3.2T-Router.",
@ -3237,6 +3279,7 @@
"ops.l_routers":{"one":"hat Router in {where} aufgerüstet","other":"hat Router an {n} Orten aufgerüstet ({where})"},
"ops.l_rs":{"one":"hat sich einem Route Server angeschlossen","other":"hat sich {n} Route Servern angeschlossen"},
"ops.l_snag":{"one":"ist bei {where} hängen geblieben und hat den Auftrag pausiert, bis du draufschaust","other":"ist bei {n} Aufträgen hängen geblieben ({where}) und hat sie pausiert, bis du draufschaust"},
"ops.l_std":{"one":"hat {where} auf den Build-Standard gebracht","other":"hat {n} Jobs für den Build-Standard erledigt ({where})"},
"ops.l_transit":{"one":"hat Transit in {where} aufgestockt","other":"hat {n}-mal Transit aufgestockt ({where})"},
"ops.locked":"Das NOC stellt ab Kundenlevel {lv} Praktikanten ein.",
"ops.model_next":"Nächste Generation, wenn ausgelastet",
@ -3270,6 +3313,8 @@
"ops.o_repair_d":"Für jeden Ausfall mit Eil-Reparatur zahlen, solange das Budget reicht.",
"ops.o_routers":"Router voraus halten",
"ops.o_routers_desc":"Einen Router dazustellen oder auf die nächste Generation tauschen, wo ein zweiter Router den Traffic trägt, sobald Last oder Ports eine Grenze überschreiten. Wähl ein Modell, und jeder POP mit einem kleineren wird darauf getauscht, der am meisten ausgelastete zuerst, im Rahmen des Budgets.",
"ops.o_std":"Build-Standard einhalten",
"ops.o_std_d":"POPs, Ports und Glasfaser auf deinen Build-Standard bringen, die meistbelasteten zuerst, ein paar Jobs pro Schicht. Vor einem Tausch kommt ein zweiter Router rein, und ein Line System wechselt nur auf einer ruhigen Glasfaser.",
"ops.o_transit":"Transit-Reserve halten",
"ops.o_transit_d":"Transit an jedem POP über einem Vielfachen seiner 30-Tage-Spitze halten: ein LAG-Member dazu oder eine Portgröße hoch.",
"ops.ops":"Ops",
@ -3302,6 +3347,7 @@
"ops.template":"Neuer POP aus der Vorlage",
"ops.template_note":"Wähle, was {name} einrichtet, wenn du eine Stadt aus der Vorlage eröffnest. Den Rest übernehmen die Daueraufträge.",
"ops.tpl_bb":"Breitband",
"ops.tpl_bstd":"Build-Standard",
"ops.tpl_done":"{name} hat {city} eröffnet: {list}.",
"ops.tpl_ix":"IX-Port",
"ops.tpl_just_pop":"nur den POP",
@ -3800,12 +3846,12 @@
"pnis.us_east_is_sold_out_until":"US East ist bis auf Weiteres ausverkauft. „Bis auf Weiteres“ ist auch ausverkauft.",
"pop_std.city_gets_the_standard_cost":"{city} bekommt den Standard: {n} × {model} für {cost}.",
"pop_std.clear":"Entfernen",
"pop_std.includes_the_build_standard":"Inklusive deines Build-Standards: {list}, {cost} + {mo}/Monat. Reicht das Geld nicht, bekommt der POP, was passt.",
"pop_std.includes_the_standard_n_model":"Inklusive deiner Standard-Router: {n} × {model}, {cost} + {mo}/Monat. Reicht das Geld nicht, bekommt der POP, was passt.",
"pop_std.make_this_the_standard":"Zum Standard machen",
"pop_std.new_pops_now_start_with":"Neue POPs starten jetzt mit {n} × {model}.",
"pop_std.new_pops_now_start_with_list":"Neue POPs starten jetzt mit {list}.",
"pop_std.none":"Keiner",
"pop_std.not_all_of_the_standard":"Nicht genug Geld oder Level für den ganzen Standard in {city}: Er bekam, was passte.",
"pop_std.standard_for_new_pops":"Standard für neue POPs",
"pops_transit_ix.40_off_for_6_months":"40 % Rabatt für 6 Monate",
"pops_transit_ix.40_off_ix_for_6_months":"<b>40 % Rabatt auf {ix} für 6 Monate.</b><br>Dein Account Manager ist erleichtert. Das Kleingedruckte liest du später.",
"pops_transit_ix.after_consulting_with_management_the":"<b>„Nach Rücksprache mit dem Management …“</b><br>Der Preis ist gestiegen. Das Management wurde konsultiert.",

View file

@ -395,6 +395,48 @@
"broker.win_text":"{name} (AS{asn}) tendió sus propios cables hasta {n} continentes y vende {mo} al mes de capacidad a otros operadores, en {days} días. Los océanos son ahora tu zanja.",
"broker.won_on_date":"Ganado el {date}: tus propios cables cruzan los océanos y los operadores te pagan por usarlos.",
"broker.your_glass_gear_is_already_yours":"Como bróker de cables, toda la fibra, los sistemas de línea, los ópticos, los cables submarinos y los routers para iluminarlos ya son tuyos, diga lo que diga el nivel.",
"bstd.all_up":"Todo cumple el estándar.",
"bstd.any_model":"cualquier modelo",
"bstd.applied":{"one":"Un trabajo hecho para el estándar de red, {cost}.","other":"{n} trabajos hechos para el estándar de red, {cost}."},
"bstd.applied_none":"Ahora mismo no se pudo hacer nada para el estándar de red.",
"bstd.apply_nothing":"Nada por debajo del estándar",
"bstd.apply_now":"Ponerlo todo al día ahora · {cost}",
"bstd.apply_wait":"Nada que hacer hasta que esas fibras estén libres",
"bstd.at_every_pop":"En cada POP",
"bstd.at_least_n":"Al menos {n}",
"bstd.below":"Por debajo del estándar hoy",
"bstd.both_buildings":"Repartidos en los dos edificios",
"bstd.cost_mo":"Costes mensuales",
"bstd.cost_now":"Para ponerlo todo al día ahora",
"bstd.edit":"Editar el estándar de red",
"bstd.every_exchange":"Donde haya un IX",
"bstd.fastest":"La más rápida que llegue",
"bstd.fiber_note":"Cambiar el sistema de línea deja la fibra apagada un día: solo si va tranquila o un enlace paralelo lleva su carga.",
"bstd.from_level":"(nivel {lv})",
"bstd.g_fiber":"Fibra y ondas",
"bstd.g_port":"Puertos y peering",
"bstd.generator":"generador",
"bstd.held":{"one":"Una fibra mantiene por ahora su sistema de línea, hasta que vaya tranquila o un enlace paralelo pueda llevar su carga el día que quede apagada. Mientras tanto recibe la óptica más rápida que admite su sistema de línea.","other":"{n} fibras mantienen por ahora su sistema de línea, hasta que vayan tranquilas o un enlace paralelo pueda llevar su carga el día que queden apagadas. Mientras tanto reciben la óptica más rápida que admite su sistema de línea."},
"bstd.hire_note":"Contrata a un becario del NOC en Ops y mantendrá cada POP, puerto y fibra en el estándar: unos pocos trabajos al día, los más cargados primero, dentro de un presupuesto mensual y solo con dinero de sobra.",
"bstd.in_n_cities":"En al menos {n} ciudades",
"bstd.intern_keeps":"{name} mantiene la red en el estándar",
"bstd.keep":"Dejar como está",
"bstd.l_ix":"Puerto en un IX",
"bstd.l_lag":"Miembros de LAG",
"bstd.l_model":"Modelo de router",
"bstd.l_pni":"PNI por red",
"bstd.l_site2":"Segundo edificio",
"bstd.l_split":"Repartir los LAG",
"bstd.left":{"one":"Queda una cosa por debajo, esperando dinero, una fibra tranquila o que llegue una ampliación.","other":"Quedan {n} cosas por debajo, esperando dinero, una fibra tranquila o que llegue una ampliación."},
"bstd.n_more_targets":{"one":"{n} objetivo más","other":"{n} objetivos más"},
"bstd.new_pops_note":"Un POP nuevo recibe esto enseguida, mientras sigue vacío: sin ventana de mantenimiento. Si falta dinero, recibe lo que alcance. Un modelo aún bloqueado significa el mejor desbloqueado por debajo.",
"bstd.none_set":"Aún no hay estándar: todos los objetivos dicen Dejar como está.",
"bstd.now_line":"Estándar: {list}",
"bstd.or_better":"{x} o mejor",
"bstd.port_note":"Los LAG y el reparto valen para los puertos de tránsito, IX y PNI. Un miembro nuevo de PNI es una ampliación y llega semanas después.",
"bstd.second_building":"segundo edificio",
"bstd.tagline":"Un solo diseño para toda la red: lo que debe tener cada POP, puerto y fibra. Los POP nuevos reciben la parte del POP el día que abren; tu becario, o el botón de abajo, pone el resto al día.",
"bstd.title":"Estándar de red",
"businesses.a_free_pni_with_voda_phony":"Un PNI gratis con Voda-Phony. Equipo: routers Absolute Unit 3.2T, puertos de 3.2T y ondas de 12.8T.",
"businesses.agi_lab_allegedly":"Laboratorio de AGI (supuestamente)",
"businesses.agi_labs_allegedly_wanting_ai_wans":"Laboratorios de AGI (supuestamente) que quieren WAN de IA de 12.8 a 25.6 Tbps, y PNIs gratis con Du-opoly y Ooh-redoo. Equipo: routers Mikrowtik CCR 3.2T.",
@ -3235,6 +3277,7 @@
"ops.l_routers":{"one":"mejoró los routers en {where}","other":"mejoró los routers en {n} sitios ({where})"},
"ops.l_rs":{"one":"se unió a un route server","other":"se unió a {n} route servers"},
"ops.l_snag":{"one":"se atascó con {where} y la pausó hasta que le eches un vistazo","other":"se atascó con {n} órdenes ({where}) y las pausó hasta que les eches un vistazo"},
"ops.l_std":{"one":"puso {where} al nivel del estándar de red","other":"hizo {n} trabajos para el estándar de red ({where})"},
"ops.l_transit":{"one":"amplió el tránsito en {where}","other":"amplió el tránsito {n} veces ({where})"},
"ops.locked":"El NOC contrata becarios a partir del nivel de clientes {lv}.",
"ops.model_next":"Siguiente generación, si va lleno",
@ -3268,6 +3311,8 @@
"ops.o_repair_d":"Pagar la reparación urgente de cada caída que la tenga, mientras dure el presupuesto.",
"ops.o_routers":"Routers por delante",
"ops.o_routers_desc":"Añadir un router, o pasar a la siguiente generación donde un segundo router lleve el tráfico, cuando la carga o los puertos pasen de un nivel. Elige un modelo y cada POP con uno más pequeño se cambia a ese, primero el más cargado, dentro del presupuesto.",
"ops.o_std":"Mantener el estándar de red",
"ops.o_std_d":"Poner los POP, los puertos y la fibra al nivel de tu estándar de red, los más cargados primero, unos pocos trabajos por turno. Antes de un cambio entra un segundo router, y el sistema de línea solo cambia en una fibra tranquila.",
"ops.o_transit":"Margen de tránsito",
"ops.o_transit_d":"Mantener el tránsito de cada POP por encima de un múltiplo de su pico de 30 días: un miembro LAG más o un tamaño de puerto mayor.",
"ops.ops":"Ops",
@ -3300,6 +3345,7 @@
"ops.template":"POP nuevo desde plantilla",
"ops.template_note":"Elige lo que monta {name} cuando abres una ciudad desde la plantilla. Las órdenes permanentes se encargan del resto.",
"ops.tpl_bb":"Banda ancha",
"ops.tpl_bstd":"estándar de red",
"ops.tpl_done":"{name} abrió {city}: {list}.",
"ops.tpl_ix":"Puerto IX",
"ops.tpl_just_pop":"solo el POP",
@ -3798,12 +3844,12 @@
"pnis.us_east_is_sold_out_until":"US East está agotado hasta nuevo aviso. El nuevo aviso también está agotado.",
"pop_std.city_gets_the_standard_cost":"{city} recibe el estándar: {n} × {model} por {cost}.",
"pop_std.clear":"Quitar",
"pop_std.includes_the_build_standard":"Incluye tu estándar de red: {list}, {cost} + {mo}/mes. Si falta dinero, el POP recibe lo que alcance.",
"pop_std.includes_the_standard_n_model":"Incluye tus routers estándar: {n} × {model}, {cost} + {mo}/mes. Si falta dinero, el POP recibe lo que alcance.",
"pop_std.make_this_the_standard":"Convertir en estándar",
"pop_std.new_pops_now_start_with":"Los nuevos POP empiezan ahora con {n} × {model}.",
"pop_std.new_pops_now_start_with_list":"Los nuevos POP empiezan ahora con {list}.",
"pop_std.none":"Ninguno",
"pop_std.not_all_of_the_standard":"No hay dinero o nivel para todo el estándar en {city}: recibió lo que cupo.",
"pop_std.standard_for_new_pops":"Estándar para nuevos POP",
"pops_transit_ix.40_off_for_6_months":"40 % de descuento durante 6 meses",
"pops_transit_ix.40_off_ix_for_6_months":"<b>40 % de descuento en {ix} durante 6 meses.</b><br>Tu gestor de cuenta está aliviado. Lee la letra pequeña más tarde.",
"pops_transit_ix.after_consulting_with_management_the":"<b>«Tras consultar con la dirección…»</b><br>El precio subió. Se consultó a la dirección.",

View file

@ -395,6 +395,48 @@
"broker.win_text":"{name} (AS{asn}) a posé ses propres câbles jusqu’à {n} continents et vend {mo} de capacité par mois à d’autres opérateurs, en {days} jours. Les océans sont ta tranchée maintenant.",
"broker.won_on_date":"Gagné le {date} : tes propres câbles traversent les océans, et les opérateurs te paient pour s’en servir.",
"broker.your_glass_gear_is_already_yours":"En courtier en câbles, toute la fibre, les systèmes de ligne, les optiques, les câbles sous-marins et les routeurs pour les allumer sont déjà à toi, quoi que dise le niveau.",
"bstd.all_up":"Tout est au standard.",
"bstd.any_model":"n’importe quel modèle",
"bstd.applied":{"one":"Un chantier fait pour le standard réseau, {cost}.","other":"{n} chantiers faits pour le standard réseau, {cost}."},
"bstd.applied_none":"Rien n’a pu être fait pour le standard réseau pour l’instant.",
"bstd.apply_nothing":"Rien sous le standard",
"bstd.apply_now":"Tout mettre à niveau maintenant · {cost}",
"bstd.apply_wait":"Rien à faire tant que ces fibres ne sont pas libres",
"bstd.at_every_pop":"Dans chaque POP",
"bstd.at_least_n":"Au moins {n}",
"bstd.below":"Sous le standard aujourd’hui",
"bstd.both_buildings":"Répartis sur les deux bâtiments",
"bstd.cost_mo":"Coûts mensuels",
"bstd.cost_now":"Pour tout mettre à niveau maintenant",
"bstd.edit":"Modifier le standard réseau",
"bstd.every_exchange":"Partout où il y a un IX",
"bstd.fastest":"La plus rapide qui porte",
"bstd.fiber_note":"Changer le système de ligne éteint la fibre pendant un jour : seulement si elle est calme ou qu’un lien parallèle porte sa charge.",
"bstd.from_level":"(niveau {lv})",
"bstd.g_fiber":"Fibre et longueurs d’onde",
"bstd.g_port":"Ports et peering",
"bstd.generator":"groupe électrogène",
"bstd.held":{"one":"Une fibre garde son système de ligne pour l’instant, jusqu’à ce qu’elle soit calme ou qu’un lien parallèle puisse porter sa charge le jour où elle est éteinte. D’ici là, elle reçoit l’optique la plus rapide que son système de ligne accepte.","other":"{n} fibres gardent leur système de ligne pour l’instant, jusqu’à ce qu’elles soient calmes ou qu’un lien parallèle puisse porter leur charge le jour où elles sont éteintes. D’ici là, elles reçoivent l’optique la plus rapide que leur système de ligne accepte."},
"bstd.hire_note":"Recrute un stagiaire NOC dans Ops et il garde chaque POP, port et fibre au standard : quelques chantiers par jour, les plus chargés d’abord, dans un budget mensuel et seulement avec de l’argent en trop.",
"bstd.in_n_cities":"Dans au moins {n} villes",
"bstd.intern_keeps":"{name} garde le réseau au standard",
"bstd.keep":"Laisser tel quel",
"bstd.l_ix":"Port IX",
"bstd.l_lag":"Membres de LAG",
"bstd.l_model":"Modèle de routeur",
"bstd.l_pni":"PNI par réseau",
"bstd.l_site2":"Second bâtiment",
"bstd.l_split":"Répartir les LAG",
"bstd.left":{"one":"Encore un élément en dessous : il attend de l’argent, une fibre calme ou une extension.","other":"Encore {n} éléments en dessous : ils attendent de l’argent, une fibre calme ou une extension."},
"bstd.n_more_targets":{"one":"{n} autre objectif","other":"{n} autres objectifs"},
"bstd.new_pops_note":"Un nouveau POP reçoit tout ça d’un coup, tant qu’il est vide : pas de fenêtre de maintenance. Si l’argent manque, il reçoit ce qui rentre. Un modèle pas encore débloqué veut dire le meilleur débloqué en dessous.",
"bstd.none_set":"Pas encore de standard : chaque objectif est sur Laisser tel quel.",
"bstd.now_line":"Standard : {list}",
"bstd.or_better":"{x} ou mieux",
"bstd.port_note":"LAG et répartition valent pour les ports de transit, IX et PNI. Un nouveau membre de PNI est une extension et arrive des semaines plus tard.",
"bstd.second_building":"second bâtiment",
"bstd.tagline":"Un seul design pour tout le réseau : ce que chaque POP, port et fibre doit avoir. Les nouveaux POP reçoivent la partie POP le jour de leur ouverture ; ton stagiaire, ou le bouton plus bas, met le reste à niveau.",
"bstd.title":"Standard réseau",
"businesses.a_free_pni_with_voda_phony":"Un PNI gratuit avec Voda-Phony. Matos : routeurs Absolute Unit 3.2T, ports 3.2T et longueurs d’onde 12.8T.",
"businesses.agi_lab_allegedly":"Labo d’AGI (soi-disant)",
"businesses.agi_labs_allegedly_wanting_ai_wans":"Des labos d’AGI (soi-disant) qui veulent des WAN IA de 12,8 à 25,6 Tbps, et des PNI gratuits avec Du-opoly et Ooh-redoo. Matos : routeurs Mikrowtik CCR 3.2T.",
@ -3235,6 +3277,7 @@
"ops.l_routers":{"one":"a mis à niveau les routeurs à {where}","other":"a mis à niveau les routeurs à {n} endroits ({where})"},
"ops.l_rs":{"one":"a rejoint un route server","other":"a rejoint {n} route servers"},
"ops.l_snag":{"one":"a calé sur {where} et l'a mis en pause en attendant que tu jettes un œil","other":"a calé sur {n} ordres ({where}) et les a mis en pause en attendant que tu jettes un œil"},
"ops.l_std":{"one":"a mis {where} au standard réseau","other":"a fait {n} chantiers pour le standard réseau ({where})"},
"ops.l_transit":{"one":"a renforcé le transit à {where}","other":"a renforcé le transit {n} fois ({where})"},
"ops.locked":"Le NOC recrute des stagiaires à partir du niveau clients {lv}.",
"ops.model_next":"Génération suivante, si chargé",
@ -3268,6 +3311,8 @@
"ops.o_repair_d":"Payer la réparation express de chaque panne qui en a une, tant que le budget suit.",
"ops.o_routers":"Garder les routeurs en avance",
"ops.o_routers_desc":"Ajouter un routeur, ou passer à la génération suivante là où un second routeur porte le trafic, quand la charge ou les ports dépassent un seuil. Choisissez un modèle, et chaque POP équipé d’un plus petit passe à celui-ci, le plus chargé d’abord, dans la limite du budget.",
"ops.o_std":"Tenir le standard réseau",
"ops.o_std_d":"Mettre POP, ports et fibre au niveau de ton standard réseau, les plus chargés d’abord, quelques chantiers par service. Un second routeur arrive avant un échange, et le système de ligne ne change que sur une fibre calme.",
"ops.o_transit":"Garder de la marge de transit",
"ops.o_transit_d":"Garder le transit de chaque POP au-dessus d'un multiple de son pic sur 30 jours : un membre LAG de plus, ou une taille de port au-dessus.",
"ops.ops":"Ops",
@ -3300,6 +3345,7 @@
"ops.template":"Nouveau POP depuis le modèle",
"ops.template_note":"Choisis ce que {name} installe quand tu ouvres une ville depuis le modèle. Les ordres permanents s'occupent du reste.",
"ops.tpl_bb":"Haut débit",
"ops.tpl_bstd":"standard réseau",
"ops.tpl_done":"{name} a ouvert {city} : {list}.",
"ops.tpl_ix":"Port IX",
"ops.tpl_just_pop":"juste le POP",
@ -3798,12 +3844,12 @@
"pnis.us_east_is_sold_out_until":"US East est complet jusqu’à nouvel ordre. Le nouvel ordre est complet aussi.",
"pop_std.city_gets_the_standard_cost":"{city} reçoit le standard : {n} × {model} pour {cost}.",
"pop_std.clear":"Effacer",
"pop_std.includes_the_build_standard":"Inclut ton standard réseau : {list}, {cost} + {mo}/mois. Si l’argent manque, le POP reçoit ce qui rentre.",
"pop_std.includes_the_standard_n_model":"Inclut tes routeurs standard : {n} × {model}, {cost} + {mo}/mois. Si l’argent manque, le POP reçoit ce qui rentre.",
"pop_std.make_this_the_standard":"En faire le standard",
"pop_std.new_pops_now_start_with":"Les nouveaux POP démarrent désormais avec {n} × {model}.",
"pop_std.new_pops_now_start_with_list":"Les nouveaux POP démarrent désormais avec {list}.",
"pop_std.none":"Aucun",
"pop_std.not_all_of_the_standard":"Pas assez d'argent ou de niveau pour tout le standard à {city} : il a reçu ce qui passait.",
"pop_std.standard_for_new_pops":"Standard des nouveaux POP",
"pops_transit_ix.40_off_for_6_months":"40 % de remise pendant 6 mois",
"pops_transit_ix.40_off_ix_for_6_months":"<b>40 % de remise sur {ix} pendant 6 mois.</b><br>Ton account manager est soulagé. Lis les petites lignes plus tard.",
"pops_transit_ix.after_consulting_with_management_the":"<b>« Après consultation de la direction… »</b><br>Le prix a augmenté. La direction a été consultée.",

View file

@ -395,6 +395,48 @@
"broker.win_text":"{name} (AS{asn}) ha posato i propri cavi fino a {n} continenti e vende {mo} al mese di capacità ad altri operatori, in {days} giorni. Gli oceani ora sono la tua trincea.",
"broker.won_on_date":"Vinto il {date}: i tuoi cavi attraversano gli oceani e gli operatori ti pagano per usarli.",
"broker.your_glass_gear_is_already_yours":"Da broker di cavi, ogni fibra, sistema di linea, ottica, cavo sottomarino e i router per accenderli sono già tuoi, qualunque cosa dica il livello.",
"bstd.all_up":"Tutto è a standard.",
"bstd.any_model":"qualsiasi modello",
"bstd.applied":{"one":"Un lavoro fatto per lo standard di rete, {cost}.","other":"{n} lavori fatti per lo standard di rete, {cost}."},
"bstd.applied_none":"Per ora non si è potuto fare niente per lo standard di rete.",
"bstd.apply_nothing":"Niente sotto lo standard",
"bstd.apply_now":"Porta tutto a standard ora · {cost}",
"bstd.apply_wait":"Niente da fare finché quelle fibre non sono libere",
"bstd.at_every_pop":"In ogni POP",
"bstd.at_least_n":"Almeno {n}",
"bstd.below":"Sotto lo standard oggi",
"bstd.both_buildings":"Su entrambi gli edifici",
"bstd.cost_mo":"Costi mensili",
"bstd.cost_now":"Per portare tutto a standard ora",
"bstd.edit":"Modifica lo standard di rete",
"bstd.every_exchange":"Ovunque ci sia un IX",
"bstd.fastest":"La più veloce che arriva",
"bstd.fiber_note":"Cambiare il sistema di linea spegne la fibra per un giorno: solo se è tranquilla o se un link parallelo ne regge il carico.",
"bstd.from_level":"(livello {lv})",
"bstd.g_fiber":"Fibra e wave",
"bstd.g_port":"Porte e peering",
"bstd.generator":"generatore",
"bstd.held":{"one":"Una fibra tiene per ora il suo sistema di linea, finché non è tranquilla o un link parallelo può reggerne il carico il giorno in cui resta spenta. Nel frattempo riceve l’ottica più veloce che il suo sistema di linea accetta.","other":"{n} fibre tengono per ora il loro sistema di linea, finché non sono tranquille o un link parallelo può reggerne il carico il giorno in cui restano spente. Nel frattempo ricevono l’ottica più veloce che il loro sistema di linea accetta."},
"bstd.hire_note":"Assumi uno stagista NOC in Ops e terrà ogni POP, porta e fibra a standard: qualche lavoro al giorno, i più carichi prima, dentro un budget mensile e solo con soldi in avanzo.",
"bstd.in_n_cities":"In almeno {n} città",
"bstd.intern_keeps":"{name} tiene la rete a standard",
"bstd.keep":"Lascia com’è",
"bstd.l_ix":"Porta IX",
"bstd.l_lag":"Membri LAG",
"bstd.l_model":"Modello di router",
"bstd.l_pni":"PNI per rete",
"bstd.l_site2":"Secondo edificio",
"bstd.l_split":"Dividi i LAG",
"bstd.left":{"one":"Resta una cosa sotto lo standard: aspetta soldi, una fibra tranquilla o un ampliamento.","other":"Restano {n} cose sotto lo standard: aspettano soldi, una fibra tranquilla o un ampliamento."},
"bstd.n_more_targets":{"one":"{n} altro obiettivo","other":"altri {n} obiettivi"},
"bstd.new_pops_note":"Un POP nuovo riceve tutto subito, finché è vuoto: niente finestra di manutenzione. Se mancano i soldi, riceve quello che ci sta. Un modello non ancora sbloccato vuol dire il migliore sbloccato sotto di lui.",
"bstd.none_set":"Ancora nessuno standard: ogni obiettivo è su Lascia com’è.",
"bstd.now_line":"Standard: {list}",
"bstd.or_better":"{x} o meglio",
"bstd.port_note":"LAG e divisione valgono per le porte di transit, IX e PNI. Un nuovo membro di PNI è un ampliamento e arriva settimane dopo.",
"bstd.second_building":"secondo edificio",
"bstd.tagline":"Un solo design per tutta la rete: cosa deve avere ogni POP, porta e fibra. I POP nuovi ricevono la parte POP il giorno in cui aprono; il tuo stagista, o il pulsante qui sotto, porta il resto a standard.",
"bstd.title":"Standard di rete",
"businesses.a_free_pni_with_voda_phony":"Un PNI gratuito con Voda-Phony. Gear: router Absolute Unit 3.2T, porte 3.2T e wave 12.8T.",
"businesses.agi_lab_allegedly":"Laboratorio AGI (a sentir loro)",
"businesses.agi_labs_allegedly_wanting_ai_wans":"Laboratori AGI (a sentir loro) che vogliono AI WAN da 12.8 a 25.6 Tbps, e PNI gratuiti con Du-opoly e Ooh-redoo. Gear: router Mikrowtik CCR 3.2T.",
@ -3235,6 +3277,7 @@
"ops.l_routers":{"one":"ha potenziato i router a {where}","other":"ha potenziato i router in {n} posti ({where})"},
"ops.l_rs":{"one":"si è unito a un route server","other":"si è unito a {n} route server"},
"ops.l_snag":{"one":"si è bloccato su {where} e l'ha messo in pausa finché non dai un'occhiata","other":"si è bloccato su {n} ordini ({where}) e li ha messi in pausa finché non dai un'occhiata"},
"ops.l_std":{"one":"ha portato {where} allo standard di rete","other":"ha fatto {n} lavori per lo standard di rete ({where})"},
"ops.l_transit":{"one":"ha aumentato il transit a {where}","other":"ha aumentato il transit {n} volte ({where})"},
"ops.locked":"Il NOC assume stagisti dal livello clienti {lv}.",
"ops.model_next":"Generazione successiva, se carico",
@ -3268,6 +3311,8 @@
"ops.o_repair_d":"Paga la riparazione urgente di ogni guasto che ce l'ha, finché il budget regge.",
"ops.o_routers":"Router sempre avanti",
"ops.o_routers_desc":"Aggiungi un router, o passa alla generazione successiva dove un secondo router regge il traffico, quando carico o porte superano una soglia. Scegli un modello e ogni POP con uno più piccolo passa a quello, prima il più carico, nei limiti del budget.",
"ops.o_std":"Tieni lo standard di rete",
"ops.o_std_d":"Porta POP, porte e fibra al tuo standard di rete, i più carichi prima, qualche lavoro a turno. Prima di uno scambio arriva un secondo router, e il sistema di linea cambia solo su una fibra tranquilla.",
"ops.o_transit":"Margine di transit",
"ops.o_transit_d":"Tieni il transit di ogni POP sopra un multiplo del suo picco a 30 giorni: un membro LAG in più, o una porta più grande.",
"ops.ops":"Ops",
@ -3300,6 +3345,7 @@
"ops.template":"Nuovo POP da modello",
"ops.template_note":"Scegli cosa monta {name} quando apri una città dal modello. Al resto pensano gli ordini permanenti.",
"ops.tpl_bb":"Banda larga",
"ops.tpl_bstd":"standard di rete",
"ops.tpl_done":"{name} ha aperto {city}: {list}.",
"ops.tpl_ix":"Porta IX",
"ops.tpl_just_pop":"solo il POP",
@ -3798,12 +3844,12 @@
"pnis.us_east_is_sold_out_until":"US East è esaurito fino a nuovo avviso. Anche il nuovo avviso è esaurito.",
"pop_std.city_gets_the_standard_cost":"{city} riceve lo standard: {n} × {model} per {cost}.",
"pop_std.clear":"Rimuovi",
"pop_std.includes_the_build_standard":"Include il tuo standard di rete: {list}, {cost} + {mo}/mese. Se mancano i soldi, il POP riceve quello che ci sta.",
"pop_std.includes_the_standard_n_model":"Include i tuoi router standard: {n} × {model}, {cost} + {mo}/mese. Se mancano i soldi, il POP riceve quello che ci sta.",
"pop_std.make_this_the_standard":"Rendilo lo standard",
"pop_std.new_pops_now_start_with":"I nuovi POP ora partono con {n} × {model}.",
"pop_std.new_pops_now_start_with_list":"I nuovi POP ora partono con {list}.",
"pop_std.none":"Nessuno",
"pop_std.not_all_of_the_standard":"Non bastano soldi o livello per tutto lo standard a {city}: ha avuto quello che si poteva.",
"pop_std.standard_for_new_pops":"Standard per i nuovi POP",
"pops_transit_ix.40_off_for_6_months":"40% di sconto per 6 mesi",
"pops_transit_ix.40_off_ix_for_6_months":"<b>40% di sconto su {ix} per 6 mesi.</b><br>Il tuo account manager tira un sospiro di sollievo. Le clausole in piccolo leggile dopo.",
"pops_transit_ix.after_consulting_with_management_the":"<b>“Dopo un confronto con il management…”</b><br>Il prezzo è salito. Il management è stato consultato.",

View file

@ -395,6 +395,48 @@
"broker.win_text":"{name} (AS{asn}) lançou os próprios cabos até {n} continentes e vende {mo} por mês de capacidade a outras operadoras, em {days} dias. Os oceanos agora são a sua vala.",
"broker.won_on_date":"Vencido em {date}: seus próprios cabos cruzam os oceanos e as operadoras pagam para usá-los.",
"broker.your_glass_gear_is_already_yours":"Como corretor de cabos, toda fibra, sistema de linha, óptico, cabo submarino e os roteadores para acendê-los já são seus, diga o nível o que disser.",
"bstd.all_up":"Tudo está no padrão.",
"bstd.any_model":"qualquer modelo",
"bstd.applied":{"one":"Um trabalho feito para o padrão de rede, {cost}.","other":"{n} trabalhos feitos para o padrão de rede, {cost}."},
"bstd.applied_none":"Nada pôde ser feito para o padrão de rede agora.",
"bstd.apply_nothing":"Nada abaixo do padrão",
"bstd.apply_now":"Colocar tudo no padrão agora · {cost}",
"bstd.apply_wait":"Nada a fazer até essas fibras ficarem livres",
"bstd.at_every_pop":"Em cada POP",
"bstd.at_least_n":"Pelo menos {n}",
"bstd.below":"Abaixo do padrão hoje",
"bstd.both_buildings":"Nos dois prédios",
"bstd.cost_mo":"Custos mensais",
"bstd.cost_now":"Para colocar tudo no padrão agora",
"bstd.edit":"Editar o padrão de rede",
"bstd.every_exchange":"Onde houver um IX",
"bstd.fastest":"A mais rápida que alcança",
"bstd.fiber_note":"Trocar o sistema de linha apaga a fibra por um dia: só quando ela está tranquila ou um link paralelo leva a carga.",
"bstd.from_level":"(nível {lv})",
"bstd.g_fiber":"Fibra e waves",
"bstd.g_port":"Portas e peering",
"bstd.generator":"gerador",
"bstd.held":{"one":"Uma fibra mantém por enquanto o seu sistema de linha, até ficar tranquila ou um link paralelo poder levar a carga dela no dia em que ela fica apagada. Até lá, ela recebe a óptica mais rápida que o seu sistema de linha aceita.","other":"{n} fibras mantêm por enquanto o seu sistema de linha, até ficarem tranquilas ou um link paralelo poder levar a carga delas no dia em que ficam apagadas. Até lá, elas recebem a óptica mais rápida que o seu sistema de linha aceita."},
"bstd.hire_note":"Contrate um estagiário de NOC em Ops e ele mantém cada POP, porta e fibra no padrão: alguns trabalhos por dia, os mais carregados primeiro, dentro de um orçamento mensal e só com dinheiro sobrando.",
"bstd.in_n_cities":"Em pelo menos {n} cidades",
"bstd.intern_keeps":"{name} mantém a rede no padrão",
"bstd.keep":"Deixar como está",
"bstd.l_ix":"Porta no IX",
"bstd.l_lag":"Membros de LAG",
"bstd.l_model":"Modelo de roteador",
"bstd.l_pni":"PNIs por rede",
"bstd.l_site2":"Segundo prédio",
"bstd.l_split":"Dividir LAGs",
"bstd.left":{"one":"Ainda falta uma coisa abaixo do padrão, esperando dinheiro, uma fibra tranquila ou uma ampliação.","other":"Ainda faltam {n} coisas abaixo do padrão, esperando dinheiro, uma fibra tranquila ou uma ampliação."},
"bstd.n_more_targets":{"one":"mais {n} meta","other":"mais {n} metas"},
"bstd.new_pops_note":"Um POP novo recebe isso na hora, enquanto ainda está vazio: sem janela de manutenção. Se faltar dinheiro, recebe o que couber. Um modelo ainda bloqueado significa o melhor desbloqueado abaixo dele.",
"bstd.none_set":"Ainda sem padrão: toda meta está em Deixar como está.",
"bstd.now_line":"Padrão: {list}",
"bstd.or_better":"{x} ou melhor",
"bstd.port_note":"LAGs e divisão valem para portas de trânsito, IX e PNI. Um novo membro de PNI é uma ampliação e chega semanas depois.",
"bstd.second_building":"segundo prédio",
"bstd.tagline":"Um só design para a rede toda: o que cada POP, porta e fibra deve ter. POPs novos recebem a parte do POP no dia em que abrem; seu estagiário, ou o botão abaixo, coloca o resto no padrão.",
"bstd.title":"Padrão de rede",
"businesses.a_free_pni_with_voda_phony":"Um PNI grátis com a Voda-Phony. Gear: routers Absolute Unit 3.2T, portas 3.2T e waves de 12.8T.",
"businesses.agi_lab_allegedly":"Laboratório de AGI (supostamente)",
"businesses.agi_labs_allegedly_wanting_ai_wans":"Laboratórios de AGI (supostamente) querendo AI WANs de 12.8 a 25.6 Tbps, e PNIs grátis com a Du-opoly e a Ooh-redoo. Gear: routers Mikrowtik CCR 3.2T.",
@ -3235,6 +3277,7 @@
"ops.l_routers":{"one":"melhorou os roteadores em {where}","other":"melhorou os roteadores em {n} lugares ({where})"},
"ops.l_rs":{"one":"entrou em um route server","other":"entrou em {n} route servers"},
"ops.l_snag":{"one":"travou em {where} e pausou a ordem até você dar uma olhada","other":"travou em {n} ordens ({where}) e pausou-as até você dar uma olhada"},
"ops.l_std":{"one":"colocou {where} no padrão de rede","other":"fez {n} trabalhos para o padrão de rede ({where})"},
"ops.l_transit":{"one":"reforçou o trânsito em {where}","other":"reforçou o trânsito {n} vezes ({where})"},
"ops.locked":"O NOC contrata estagiários a partir do nível de clientes {lv}.",
"ops.model_next":"Próxima geração, quando lotado",
@ -3268,6 +3311,8 @@
"ops.o_repair_d":"Pagar o reparo urgente de cada queda que tenha um, enquanto o orçamento durar.",
"ops.o_routers":"Roteadores à frente",
"ops.o_routers_desc":"Adicionar um roteador, ou trocar para a próxima geração onde um segundo roteador segura o tráfego, quando a carga ou as portas passarem de um nível. Escolha um modelo e cada POP com um menor é trocado para ele, o mais carregado primeiro, dentro do orçamento.",
"ops.o_std":"Manter o padrão de rede",
"ops.o_std_d":"Colocar POPs, portas e fibra no seu padrão de rede, os mais carregados primeiro, alguns trabalhos por turno. Antes de uma troca entra um segundo roteador, e o sistema de linha só muda numa fibra tranquila.",
"ops.o_transit":"Folga de trânsito",
"ops.o_transit_d":"Manter o trânsito de cada POP acima de um múltiplo do seu pico de 30 dias: mais um membro LAG, ou um tamanho de porta acima.",
"ops.ops":"Ops",
@ -3300,6 +3345,7 @@
"ops.template":"Novo POP por modelo",
"ops.template_note":"Escolha o que {name} monta quando você abre uma cidade pelo modelo. As ordens permanentes cuidam do resto.",
"ops.tpl_bb":"Banda larga",
"ops.tpl_bstd":"padrão de rede",
"ops.tpl_done":"{name} abriu {city}: {list}.",
"ops.tpl_ix":"Porta de IX",
"ops.tpl_just_pop":"só o POP",
@ -3798,12 +3844,12 @@
"pnis.us_east_is_sold_out_until":"US East está esgotado até segunda ordem. A segunda ordem também esgotou.",
"pop_std.city_gets_the_standard_cost":"{city} recebe o padrão: {n} × {model} por {cost}.",
"pop_std.clear":"Limpar",
"pop_std.includes_the_build_standard":"Inclui seu padrão de rede: {list}, {cost} + {mo}/mês. Se faltar dinheiro, o POP recebe o que couber.",
"pop_std.includes_the_standard_n_model":"Inclui seus roteadores padrão: {n} × {model}, {cost} + {mo}/mês. Se faltar dinheiro, o POP recebe o que couber.",
"pop_std.make_this_the_standard":"Tornar este o padrão",
"pop_std.new_pops_now_start_with":"Novos POPs agora começam com {n} × {model}.",
"pop_std.new_pops_now_start_with_list":"Novos POPs agora começam com {list}.",
"pop_std.none":"Nenhum",
"pop_std.not_all_of_the_standard":"Sem dinheiro ou nível para todo o padrão em {city}: recebeu o que coube.",
"pop_std.standard_for_new_pops":"Padrão para novos POPs",
"pops_transit_ix.40_off_for_6_months":"40% de desconto por 6 meses",
"pops_transit_ix.40_off_ix_for_6_months":"<b>40% de desconto no {ix} por 6 meses.</b><br>Seu account manager respirou aliviado. Leia as letras miúdas depois.",
"pops_transit_ix.after_consulting_with_management_the":"<b>“Depois de consultar a diretoria…”</b><br>O preço subiu. A diretoria foi consultada.",

View file

@ -38,6 +38,8 @@ const API_DOMAINS={
opsKey:{table:'OPSK',kind:'key'},
opsPopKind:{kind:'enum',values:()=>OPS_POP.slice()},
opsTplKey:{kind:'enum',values:()=>OPS_TPL.slice()},
// The build standard's targets (bstdSet).
bstdKey:{kind:'enum',values:()=>BSTD.map(x=>x.k)},
// The specialist's offers: a seat on a consortium cable, the charter, a vendor demo.
seatPairs:{kind:'enum',values:()=>SEAT_N.slice()},
callAmount:{kind:'enum',values:()=>CALL_AMTS.slice()},

View file

@ -327,7 +327,7 @@ const API_CMD={
opsParam:{args:[['k','opsKey'],['p','string'],['v','string',false]],watch:['ops'],
doc:'Step one of a standing order\'s settings to its next value (the provider to prefer, the port size to order, the load ceiling…). With v (a position in the list the sheet shows, 0 first) it picks that value instead, such as the model to standardize routers on.'},
opsCap:{args:[['k','opsKey'],['v','string',false]],watch:['ops'],
doc:'Step the monthly budget of an order that has one: 10k, 25k, 50k, 100k, 250k, no limit. With v (a position in that list, 0 first) it picks that one.'},
doc:'Step the monthly budget of an order that has one: 10k, 50k, 250k, 1M, 5M, no limit (for caches, a cap on the rent it adds: 1k, 2.5k, 5k, 10k, 25k, no limit). With v (a position in that list, 0 first) it picks that one.'},
opsFloor:{args:[['v','string',false]],watch:['ops'],
doc:'Step the floor under your cash that the intern keeps clear when paying for jobs: 0, 50k, 250k, 1M, 5M. With v (a position in that list, 0 first) it picks that one.'},
opsPop:{args:[['k','opsPopKind'],['city','cityId']],watch:['ops'],
@ -376,11 +376,16 @@ const API_CMD={
layShip:{args:[['id','entityId']],watch:['links.#id'],
quote:a=>{const l=S.links.find(x=>x.id===a.id),q=l&&layQuote(l);return q?{setup:q.cost}:{};},
doc:'Book a second lay ship on your own cable before laying starts: it lays from the other end and halves that part of the build.'},
/* ---------- standard POPs ---------- */
/* ---------- the build standard ---------- */
popStdSet:{args:[['city','cityId']],watch:['popStd'],
doc:'Make a POP\'s routers the standard: every new POP starts with that model and that number of routers while it is still empty.'},
doc:'Make a POP\'s build the standard\'s POP part: its router model, router count, second building and generator. New POPs start with them at once; the other targets are kept.'},
popStdClear:{args:[],watch:['popStd'],
doc:'Stop setting a standard; new POPs go back to one basic router.'},
doc:'Clear the whole build standard; new POPs go back to one basic router.'},
bstdSet:{args:[['k','bstdKey'],['v','string',false]],watch:['popStd'],
doc:'Set one target of the build standard: g router model, rt routers, site2 second building, gen generator, lag LAG members on transit, IX and PNI ports, split LAGs across both buildings, ix an IX port wherever the city has an exchange, pni PNIs per network in at least that many cities, sys line system, opt fastest optics, wv waves at least that size. Without v it steps to the next value; with v (a position in the list the sheet shows, 0 first, "keep" first) it picks that one.'},
bstdApply:{args:[],watch:['pops','transit','pni','ixp','ixn','ixSite','links','spares'],
quote:a=>{const q=bstdQuote(false);return {setup:q.cost,monthly:q.mo,blocked:q.held.map(w=>w.split('|').map(c=>CITY[c].name).join('–')+': its line system waits until the fiber is quiet or a parallel link can carry its load for the day it goes dark')};},
doc:'Bring everything up to the build standard now, the busiest first, while cash lasts: routers, buildings, generators, LAG members, IX ports, PNIs, line systems, optics and waves. A line-system swap waits unless the fiber is quiet or a parallel link carries its load: such a fiber gets the best optics its line system takes, and the quote lists it under blocked. The quote is the whole bill.'},
/* ---------- utilities ---------- */
utilityRouteServers:{args:[['city','cityId',false]],watch:['rs'],
doc:'Join the route server at every IX you have a port at. One call does what the button does.'},
@ -507,6 +512,7 @@ const API_VIEW={
keys:{args:[],doc:'Open the list of keyboard shortcuts (the ? key).'},
routingOpen:{args:[],doc:'Open the Routing & DDoS window: the traceroute, backbone, Auto-TE and DDoS settings (the button at the top of the NOC tab).'},
opsOpen:{args:[],doc:'Open the Ops sheet: the NOC intern\'s mood, weekly shift report and standing orders.'},
bstdOpen:{args:[],doc:'Open the build standard sheet: every target, how many POPs, ports and links are below it, what bringing them up costs, and the intern\'s order that keeps them there.'},
salesOpen:{args:[],doc:'Open the sales desk sheet: the three kinds of salesperson, who is at the desk and what they cost.'},
opsCity:{args:[['v','cityId',false]],doc:'Show one POP\'s standing-order exceptions in the Ops sheet.'},
utilities:{args:[['city','cityId',false]],doc:'Open the utilities sheet: route servers, the redundancy kit, caches and bulk peering, for one city or the whole network.'},

View file

@ -61,7 +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.'},
popStd:{type:'map',doc:'The standard POP: router model and count new POPs start with, or null for none.'},
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.'},
demo:{type:'map',doc:'Vendor demo units on order, by "kind:id" → ready day.'},
seatOff:{type:'map',doc:'The pending consortium-cable seat offer: landings, km, name, expiry day.'},
monkey:{type:'map',doc:'The chaos monkey: next visit day, whether it is in your network now, days left, whether anyone noticed.'},

View file

@ -15,7 +15,7 @@ function apiControls(root,player){
const o=b.dataset.act?{label:apiText(b,200).replace(/\n/g,' ')||b.getAttribute('aria-label')||b.dataset.act,act:b.dataset.act,args:apiParse(b.dataset.args),disabled:!!b.disabled}
// A list the game acts on when its value changes (the change handler in 96-map/95-clicks.js): click it with a value.
:{label:b.getAttribute('aria-label')||(b.closest('label')&&apiText(b.closest('label'),120).split('\n')[0])||b.dataset.chg,
select:b.dataset.chg,value:b.value,options:[...b.options].map(o=>({value:o.value,label:o.textContent.trim()})),disabled:!!b.disabled};
select:b.dataset.chg,args:apiParse(b.dataset.args),value:b.value,options:[...b.options].map(o=>({value:o.value,label:o.textContent.trim()})),disabled:!!b.disabled};
if(player)o.player=true;
out.push(o);}
return out;}

View file

@ -115,7 +115,8 @@ function apiClick(n,value){
if(!b)apiFail(`No button ${n} on the last screen. Call screen first.`);
if(b.disabled)apiFail(`"${b.label}" is greyed out.`);
if(b.player&&apiPlayerWin())apiFail(`"${b.label}" is in a window the player opened: it is theirs to press.`);
const name=b.select||b.act,args=b.select?{v:value===undefined?undefined:String(value)}:b.args;
// A list sends its own arguments with the value picked, as the page's change handler does (96-map/95-clicks.js).
const name=b.select||b.act,args=b.select?{...(b.args||{}),v:value===undefined?undefined:String(value)}:b.args;
if(b.select&&!b.options.some(o=>o.value===args.v))apiFail(`"${b.label}" is a list: click it with a value, one of ${b.options.map(o=>JSON.stringify(o.value)).join(', ')}.`);
const kind=apiAllowed(name,`"${b.label}" runs ${name}, which is not an action.`);
if(kind==='game'){const w=apiWaiting(name);if(w)return {clicked:b.label,...w};}

View file

@ -26,7 +26,8 @@ const RCAGE=6,CAGE_MUL=1.5,CAGE_MO=2000;
const routerCost=(g,rt)=>Math.round((ROUTER_COST+RG[g].cost*0.8)*((rt||1)>=RCAGE?CAGE_MUL:1)*hwMul('rt')*techMul(RG[g].lvl));
const routerMo=g=>ROUTER_MO+RG[g].mo,cageMo=rt=>Math.max(0,(rt||1)-RCAGE)*CAGE_MO;
// Old routers go on eBuy when you swap models or remove one (#82), like spare optics (#45). Chassis age faster.
const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCost=(c,g)=>{const p=S.pops[c],rt=p.routers||1;return Math.max(0,Math.round(RG[g].cost*rt*hwMul('rt')*techMul(RG[g].lvl))-tradeIn(p.rgen||0,rt));};
// swapCostOf: the same price for a POP on model old with rt routers (the build standard plans a few steps ahead).
const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCostOf=(g,old,rt)=>Math.max(0,Math.round(RG[g].cost*rt*hwMul('rt')*techMul(RG[g].lvl))-tradeIn(old,rt)),swapCost=(c,g)=>{const p=S.pops[c];return swapCostOf(g,p.rgen||0,p.routers||1);};
const RMAX=16;
// The plain, badge-less model of each class is the default upgrade path; the others are side-grades.
const mainRG=k=>RG.findIndex(r=>r.cls===k&&!r.badge);

View file

@ -17,6 +17,8 @@ const OPS=[
{k:'routers',i:'🧠',pop:1,cap:250000,t:N_('ops.o_routers'),d:N_('ops.o_routers_desc'),p:{at:{d:80,v:[60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'},how:{d:'auto',v:['auto','add','swap'],l:N_('ops.p_how'),f:v=>tr({auto:N_('ops.how_auto'),add:N_('ops.how_add'),swap:N_('ops.how_swap')}[v])},
// A model to standardize on: every POP on a smaller one is swapped to it, busiest first, within the budget.
model:{d:'next',ok:v=>v==='next'||(Number.isInteger(v)&&!!RG[v]),l:N_('ops.p_model'),f:v=>v==='next'?tr('ops.model_next'):RG[v].n}}},
// The build standard (96-pop-standard.js): its targets are set in their own sheet, so here it has only the budget.
{k:'std',i:'📐',pop:1,cap:250000,t:N_('ops.o_std'),d:N_('ops.o_std_d'),p:{}},
{k:'caches',i:'📦',pop:1,cap:5000,mo:1,t:N_('ops.o_caches'),d:N_('ops.o_caches_d'),p:{g:{d:5,v:[1,5,10,25,50],l:N_('ops.p_g'),f:v=>fmtG(v)}}},
{k:'ix',i:'🔀',t:N_('ops.o_ix'),d:N_('ops.o_ix_d'),p:{}},
{k:'pni',i:'🤝',pop:1,cap:50000,t:N_('ops.o_pni'),d:N_('ops.o_pni_d'),p:{g:{d:25,v:[5,10,25,50,100],l:N_('ops.p_g'),f:v=>fmtG(v)},tier:{d:0,v:[0,1,2],l:N_('ops.p_tier'),f:v=>tr('ops.at_least_port',{port:PORT[v].n})},paid:{d:false,v:[false,true],l:N_('ops.p_paid'),f:v=>v?tr('common.on'):tr('common.off')}}},
@ -31,7 +33,7 @@ const OPS=[
const OPSK=Object.fromEntries(OPS.map(o=>[o.k,o])),OPS_POP=OPS.filter(o=>o.pop).map(o=>o.k);
const OPS_TPL=['bb','transit','ix','kit'];
// What the shift log can say. One line per day: "{name} did this, that and the other."
const OPS_SAY={transit:N_('ops.l_transit'),ports:N_('ops.l_ports'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),optup:N_('ops.l_optup'),optswap:N_('ops.l_optswap'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')};
const OPS_SAY={std:N_('ops.l_std'),transit:N_('ops.l_transit'),ports:N_('ops.l_ports'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),optup:N_('ops.l_optup'),optswap:N_('ops.l_optswap'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')};
// Fat fingers: rare, visible, harmless. Only the LAG one costs anything, and only a little.
const OPS_FF=[N_('ops.ff_desc'),N_('ops.ff_hostname'),N_('ops.ff_typo'),N_('ops.ff_lag'),N_('ops.ff_ping')];
const OPS_FF_RATE={oncall:1/150,bgp:1/60};
@ -103,7 +105,7 @@ const opsPaid=e=>e.up||e.mo?' '+tr('ops.l_paid',{cost:fmt$(e.up||0),mo:opsMo$(e.
// What the network costs every month before traffic: what a job adds to the bill (ports, routers, rent, links, cache boxes).
// PNIs count from the day they are ordered, at the size they are going to be.
function opsMoNow(){let m=cachesMo();
for(const c in S.pops){const p=S.pops[c],rt=p.routers||1;m+=(rt-1)*ROUTER_MO+cageMo(rt)+rt*RG[p.rgen||0].mo;}
for(const c in S.pops){const p=S.pops[c],rt=p.routers||1;m+=(rt-1)*ROUTER_MO+cageMo(rt)+rt*RG[p.rgen||0].mo+(p.gen?GEN_MO:0)+(p.site2?SITE2_MO:0);}
for(const l of S.links)m+=(l.mo||0)+(l.kind==='df'?(l.spares?Math.round(150+(l.ch||[]).length*80):0)+(l.regen|0)*REGEN_MO:0);
for(const t of S.transit)m+=transitMo(t,0);
for(const p of S.pni){const q=p.up||p,N=NET[p.net];m+=(q.g1?Math.round(PORT[0].pni/2):PORT[q.tier].pni)*(q.n||1)+(N.pol==='paid'&&!paidFree(N)?N.paidFee:0);}
@ -137,6 +139,8 @@ const cheapestTransit=c=>NETS.filter(n=>sellsAt(n,c)&&opsTransitOk(n,c)).sort((a
const opsProv=c=>{const pv=opsP('transit','prov'),n=isNet(pv)?NET[pv]:null;return n&&sellsAt(n,c)&&opsTransitOk(n,c)?n:cheapestTransit(c);};
// The orders. Each takes the shift and does its jobs through the player's own actions.
const OPS_RUN={
// Bring POPs, ports and fiber up to the build standard: the busiest first, a few jobs a shift (96-pop-standard.js).
std(X){bstdShift(X);},
repair(X){purgeInc();for(const i of S.inc.slice())if(i.type!=='ddos'&&i.until>S.day&&i.cost>0&&!(i.slow&&i.rushed)&&X.can('repair',i.cost)&&X.pay('repair',()=>ACT.fixInc({id:i.id})))X.did('repair');},
routers(X){const at=opsP('routers','at')/100,how=opsP('routers','how'),m=opsP('routers','model'),fix=m!=='next',
load=c=>Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));
@ -206,7 +210,9 @@ const OPS_RUN={
// More of what is already lit, or else the most Gbps per dollar that reaches. Told to go big (#262), the intern
// picks the most Gbps per channel it can afford for a new kind of optic, but never swaps what is already lit.
const fit=Object.keys(OPT).filter(o=>!chWhy(l,o)),cheap=fit.slice().sort((a,b)=>gpd(b,l)-gpd(a,l)),
o=fit.filter(o=>cnt[o]).sort((a,b)=>cnt[b]-cnt[a])[0]||(big&&fit.slice().sort((a,b)=>optG(b,l)-optG(a,l)||gpd(b,l)-gpd(a,l)).find(o=>X.can('optics',opticCountCost(l,o,1),0,true)))||cheap[0];if(!o)break;
// A build standard that wants the fastest optics gets those first, so the two orders never undo each other.
fast=bstdFast()&&fit.slice().sort((a,b)=>optG(b,l)-optG(a,l)||optCost(a)-optCost(b)).find(o=>X.can('optics',opticCountCost(l,o,1),0,true)),
o=fast||fit.filter(o=>cnt[o]).sort((a,b)=>cnt[b]-cnt[a])[0]||(big&&fit.slice().sort((a,b)=>optG(b,l)-optG(a,l)||gpd(b,l)-gpd(a,l)).find(o=>X.can('optics',opticCountCost(l,o,1),0,true)))||cheap[0];if(!o)break;
const n=(cnt[o]||0)+1,cost=opticCountCost(l,o,n),before=(l.ch||[]).length;if(!X.can('optics',cost))break;
X.pay('optics',()=>{ACT.setChCount({id:l.id,o,n});return (l.ch||[]).length>before;});if((l.ch||[]).length<=before)break;
cap+=optG(o,l);X.did('optics',l.a+'|'+l.b);}}},
@ -253,15 +259,10 @@ const OPS_RUN={
for(const q of b.orders.filter(q=>opsHere('pni',q.city)&&loc(q)>=g&&(paid||NET[q.net].pol!=='paid'||paidFree(NET[q.net]))).sort((a,b)=>loc(b)-loc(a))){
if(!X.can('pni',q.cost))break;if(X.pay('pni',()=>{if(!spend(q.cost))return false;pniPlace(q);return true;}))X.did('pni',q.city+' '+q.net);}},
// Hand back smaller waves once a bigger link between the same cities carries the pair with a quarter to spare (#102).
decom(X){const keep=opsP('decom','keep'),by=new Map();for(const l of S.links)if(l.kind!=='vxc'){const k=edgeKey(l);(by.get(k)||by.set(k,[]).get(k)).push(l);}
decom(X){const by=new Map();for(const l of S.links)if(l.kind!=='vxc'){const k=edgeKey(l);(by.get(k)||by.set(k,[]).get(k)).push(l);}
// Loads must include what this shift already did (a customer just signed, a repair): recompute first, if anything could go.
if(X.dirty&&[...by.values()].some(ls=>ls.length>1&&ls.some(l=>l.kind==='wave'))){compute();X.dirty=false;}
for(const ls of by.values()){if(ls.length<2)continue;const live=ls.filter(l=>!linkDown(l)),big=live.reduce((a,l)=>!a||capOf(l)>capOf(a)?l:a,null);if(!big)continue;
let cap=live.reduce((a,l)=>a+capOf(l),0);const load=ls.reduce((a,l)=>a+((R.load&&R.load[l.id])||0),0);
const small=live.filter(l=>l!==big&&l.kind==='wave'&&!l.standby&&!l.premium&&capOf(l)<capOf(big)&&!S.biz.some(b=>b.link===l.id)).sort((a,b)=>capOf(b)-capOf(a));
// The spare is there for when the big link's trench is cut, so it has to live in another trench.
if(keep&&small.length){const tr=l=>l.trench||l.id,i=small.findIndex(l=>tr(l)!==tr(big));small.splice(Math.max(0,i),1);}
for(const l of small.reverse()){if(cap-capOf(l)<load*1.25)break;if(!opsDecomSafe(l))continue;cap-=capOf(l);UI.confirm=l.id;X.pay('decom',()=>ACT.rmLink({id:l.id}));if(!S.links.includes(l))X.did('decom',l.a+'|'+l.b);}}},
for(const ls of by.values())for(const l of opsDecomPick(ls)){UI.confirm=l.id;X.pay('decom',()=>ACT.rmLink({id:l.id}));if(!S.links.includes(l))X.did('decom',l.a+'|'+l.b);}},
};
// Line system swaps per shift, and how many fibers a shift may test for one: each test routes the whole network once,
// so a shift costs at most one routing more, and only on a night with a fiber to try. A fiber that failed the test is not tested again for a week
@ -276,11 +277,21 @@ function opsDarkOk(l,X){if(S.biz.some(b=>b.link===l.id)||!opsAround(l))return fa
const R0=R,e0=l.eqDown,s0=R0.served,L0=R0.l2||{};
try{l.eqDown=S.day+1;compute();return R.served>=s0-1e-6*Math.max(1,s0)&&Object.keys(L0).every(id=>(R.l2[id]||0)>=L0[id]-1e-6);}
finally{if(e0===undefined)delete l.eqDown;else l.eqDown=e0;R=R0;}}
// A wave can carry a promise: diverse paths, no subsea, a latency budget. Try the network without it first.
function opsDecomSafe(l){const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>k==='diverse'||k==='sharks'||k==='lat')&&b.city2);if(!bz.length)return true;
// The waves decom hands back on one city pair (ls: every link between them): the smaller ones the rest carry with 25% to
// spare, smallest first, less the spare it keeps. cf: each link's capacity (the build standard asks with the sizes its
// wave upgrades will give, so it never upgrades one that goes back).
function opsDecomPick(ls,cf=capOf){if(!ls||ls.length<2)return [];const live=ls.filter(l=>!linkDown(l)),big=live.reduce((a,l)=>!a||cf(l)>cf(a)?l:a,null),out=[];if(!big)return out;
let cap=live.reduce((a,l)=>a+cf(l),0);const load=ls.reduce((a,l)=>a+((R.load&&R.load[l.id])||0),0);
const small=live.filter(l=>l!==big&&l.kind==='wave'&&!l.standby&&!l.premium&&cf(l)<cf(big)&&!S.biz.some(b=>b.link===l.id)).sort((a,b)=>cf(b)-cf(a));
// The spare is there for when the big link's trench is cut, so it has to live in another trench.
if(opsP('decom','keep')&&small.length){const tr=l=>l.trench||l.id,i=small.findIndex(l=>tr(l)!==tr(big));small.splice(Math.max(0,i),1);}
for(const l of small.reverse()){if(cap-cf(l)<load*1.25)break;if(!opsDecomSafe(l,out))continue;cap-=cf(l);out.push(l);}
return out;}
// A wave can carry a promise: diverse paths, no subsea, a latency budget. Try the network without it (and gone) first.
function opsDecomSafe(l,gone=[]){const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>k==='diverse'||k==='sharks'||k==='lat')&&b.city2);if(!bz.length)return true;
const chk=b=>(b.reqs||[]).every(k=>k==='diverse'?diversePaths(b.city,b.city2):k==='sharks'?terrestrialPath(b.city,b.city2):k==='lat'?bestLat(b.city,b.city2)<=b.latMax:true);
const was=bz.filter(chk),all=S.links;S.links=all.filter(x=>x!==l);try{return was.every(chk);}finally{S.links=all;}}
const OPS_ORDER=['repair','routers','transit','ports','optup','optics','caches','ix','pni','decom'];
const was=bz.filter(chk),all=S.links;S.links=all.filter(x=>x!==l&&!gone.includes(x));try{return was.every(chk);}finally{S.links=all;}}
const OPS_ORDER=['repair','std','routers','transit','ports','optup','optics','caches','ix','pni','decom'];
// The shift: once per game day from dayTick, after outages and events have had their turn.
function opsDay(d){if(!opsHired())return;const O=S.ops,m=monthIdx(d);if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;O.addMo={};}
// A new week: last week's tally becomes the shift report, and the one NOC notice of the week.
@ -306,8 +317,9 @@ function opsTplQuote(c){if(!S||S.pops[c]||!cityOn(c)||(cnCity(c)&&!cnOk()))retur
if(T.transit&&!scnRule('noTransit')){net=opsProv(c);if(net){cost+=PORT[0].setup;parts.push(tr('ops.tpl_transit'));}}
// Priced as if the POP were already there (an IX port is dearer from afar). DE-KICKS wants a sales call first, so not those.
// The standard routers go in first (#261), so they are in the price and the kit is priced for them.
const sq=popStdQuote();if(sq){cost+=sq.cost;parts.push(tr('ops.tpl_std'));}
S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:sq?sq.rt:1,gen:false,rgen:sq?sq.g:0};
// The standard's building and generator too, so the kit only prices what the standard leaves out: nothing twice.
const sq=popStdQuote();if(sq){cost+=sq.cost;parts.push(sq.site2||sq.gen?tr('ops.tpl_bstd'):tr('ops.tpl_std'));}
S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:sq?sq.rt:1,gen:!!(sq&&sq.gen),rgen:sq?sq.g:0,...(sq&&sq.site2?{site2:true}:{})};
try{if(T.ix&&CITY[c].ix&&!isDk(c)&&S.ixp[c]===undefined){ix=c;cost+=ixPortMo(c,0);parts.push(tr('ops.tpl_ix'));}
if(T.kit){kit=utilityKit(c);if(kit&&kit.cost){cost+=kit.cost;parts.push(tr('ops.tpl_kit'));}}}finally{delete S.pops[c];}
return {cost,net:net&&net.id,ix,kit:!!(kit&&kit.cost),parts};}

View file

@ -1,16 +1,207 @@
/* ---------- The standard POP (#240) ----------
Big networks run one design everywhere. A new POP gets the standard routers at once, while the box is still idle
(no maintenance window): the model if it is unlocked and affordable, then the extra routers as cash allows. */
/* ---------- The build standard (#240, grown into a target state for every POP, port and fiber) ----------
Big networks run one design everywhere. The standard says what every POP, port and fiber should have: the router
model and count, a second building and a generator, LAGs, an exchange port, PNIs spread over cities, the line
system, the optics and the waves. A new POP gets its POP part at once, while the box is still idle (no maintenance
window). The rest is brought up by the intern's "Keep to the build standard" order, or in one tap from the sheet. */
// Every target, with the values its list offers ("keep" first: no target) and its default. Saved sparse: a target left
// at its default is not in the save, so an old {g, rt} standard is exactly the routers it always was.
const BSTD=[
{k:'g',grp:'pop',l:N_('bstd.l_model'),d:'keep',v:()=>['keep',...RG.map((r,i)=>i).sort((a,b)=>RG[a].cls-RG[b].cls||RG[a].cap-RG[b].cap||a-b)],ok:v=>v==='keep'||(Number.isInteger(v)&&!!RG[v])},
{k:'rt',grp:'pop',l:N_('common.routers'),d:1,v:()=>[1,2,3,4,6,8,12,16],ok:v=>Number.isInteger(v)&&v>=1&&v<=RMAX},
{k:'site2',grp:'pop',l:N_('bstd.l_site2'),d:false,v:()=>[false,true]},
{k:'gen',grp:'pop',l:N_('common.backup_generator'),d:false,v:()=>[false,true]},
{k:'lag',grp:'port',l:N_('bstd.l_lag'),d:1,v:()=>[1,2,4]},
{k:'split',grp:'port',l:N_('bstd.l_split'),d:false,v:()=>[false,true]},
{k:'ix',grp:'port',l:N_('bstd.l_ix'),d:false,v:()=>[false,true]},
{k:'pni',grp:'port',l:N_('bstd.l_pni'),d:0,v:()=>[0,2,3]},
{k:'sys',grp:'fiber',l:N_('common.line_system'),d:'keep',v:()=>['keep','roadm','cl']},
{k:'opt',grp:'fiber',l:N_('common.optics'),d:'keep',v:()=>['keep','fast']},
{k:'wv',grp:'fiber',l:N_('common.waves'),d:'keep',v:()=>['keep',...LT.map((x,i)=>i).filter(i=>i>0&&waveShown(i))],ok:v=>v==='keep'||(Number.isInteger(v)&&v>0&&!!LT[v])},
];
const BSTDK=Object.fromEntries(BSTD.map(x=>[x.k,x])),BSTD_MAX=16,BSTD_SYS={lite:0,roadm:1,cl:2};
const bstdOk=(x,v)=>x.ok?x.ok(v):x.v().includes(v);
// The whole standard, every target filled in. d: a saved one (untrusted: anything odd reads as "keep").
function bstd(d=S&&S.popStd){const o={},ob=d&&typeof d==='object'&&!Array.isArray(d)?d:{};
for(const x of BSTD){const v=ob[x.k];o[x.k]=x.k==='rt'?(own(ob,'rt')?int(v,1,RMAX,1):1):own(ob,x.k)&&bstdOk(x,v)?v:x.d;}return o;}
// Back to the saved form: the model and router count, and any other target that is not "keep". Nothing set: null.
function bstdPut(o){const d={};for(const x of BSTD)if(x.k==='rt'||o[x.k]!==x.d)d[x.k]=o[x.k];return Object.keys(d).length>1||d.rt>1?d:null;}
function popStdSanitize(s){s.popStd=s.popStd&&typeof s.popStd==='object'&&!Array.isArray(s.popStd)?bstdPut(bstd(s.popStd)):null;}
// A bank that forbids generators (Stormy Weather's covenant): the standard never installs one while that loan runs.
const bstdNoGen=()=>(S.loans||[]).some(l=>(l.covs||[]).includes('nogen'));
// The model a POP should get: the standard's if you can buy it, else the best main-line model that is unlocked and no
// bigger. Never a step down, never one that does not fit, and never one that would drop a POP out of the backbone core.
// c: an existing POP, or null for a new, empty one. -1: nothing to do. A vendor's demo unit (at its markup) only ever
// goes into a new POP, as before: swapping every POP onto one is the player's call, not the intern's. A new POP takes the
// model as chosen, even one smaller than the basic router (the Mikrowtik CCR has more ports): nothing is replaced there.
function bstdModel(g,c){if(g==='keep'||!RG[g])return -1;const p=c&&S.pops[c],cur=p?p.rgen||0:0,core=!!p&&coreRun()>0&&inCore(c);
const ok=i=>i>=0&&RG[i].cap<=RG[g].cap&&(!p||(RG[i].cap>RG[cur].cap&&!modelFits(c,i)&&(!core||rgCore(i,coreRun()))));
if((p?rgOpen(g):techOk('rg',g,RG[g].lvl))&&ok(g))return g;let b=-1;
for(let k=0;k<=4;k++){const i=mainRG(k);if(i!==g&&rgOpen(i)&&ok(i)&&(b<0||RG[i].cap>RG[b].cap))b=i;}return b;}
// What the standard adds to a fresh POP, priced the way popStdApply pays for it, so it can be on the button (#261).
function popStdQuote(){const d=S.popStd;if(!d||pzOn())return null;const g=techOk('rg',d.g,RG[d.g].lvl)?d.g:0;
let cost=g?Math.max(0,Math.round(RG[g].cost*hwMul('rt')*techMul(RG[g].lvl))-tradeIn(0,1)):0;for(let n=1;n<d.rt;n++)cost+=routerCost(g,n);
const mo=(d.rt-1)*ROUTER_MO+cageMo(d.rt)+d.rt*RG[g].mo-RG[0].mo;return cost||mo?{cost,mo,g,rt:d.rt}:null;}
// A new POP's setup with the standard's routers, for every way a POP gets built (links, cables, seats).
function popStdQuote(){if(!S||!S.popStd||pzOn())return null;const D=bstd(),m=bstdModel(D.g,null),g=m>0?m:0,rt=D.rt;
let cost=g?swapCostOf(g,0,1):0;for(let n=1;n<rt;n++)cost+=routerCost(g,n);
let mo=(rt-1)*ROUTER_MO+cageMo(rt)+rt*RG[g].mo-RG[0].mo;const site2=D.site2,gen=D.gen&&!bstdNoGen();
if(site2){cost+=SITE2_COST;mo+=SITE2_MO;}if(gen){cost+=GEN_COST;mo+=GEN_MO;}
return cost||mo?{cost,mo,g,rt,site2,gen}:null;}
// A new POP's setup with the standard, for every way a POP gets built (links, cables, seats).
function newPopCost(c){const q=popStdQuote();return popCost(c)+(q?q.cost:0);}
function popStdApply(city){const d=S.popStd,p=S.pops[city];if(!d||!p||pzOn())return;let miss=false;const c0=S.cash;
if(d.g!==(p.rgen||0)){if(techOk('rg',d.g,RG[d.g].lvl)&&S.cash>=swapCost(city,d.g)){spend(swapCost(city,d.g));p.rgen=d.g;}else miss=true;}
while((p.routers||1)<d.rt){const k=routerCost(p.rgen||0,p.routers||1);if(S.cash<k){miss=true;break;}spend(k);p.routers=(p.routers||1)+1;}
function popStdApply(city){const p=S.pops[city];if(!S.popStd||!p||pzOn())return;const D=bstd(),m=bstdModel(D.g,null),c0=S.cash;
// Short of the model asked for (it is locked): the best that is unlocked goes in, and the toast says so.
let miss=D.g!=='keep'&&RG[m>0?m:0].cap<RG[D.g].cap;
if(m>0&&m!==(p.rgen||0)){if(S.cash>=swapCost(city,m)){spend(swapCost(city,m));p.rgen=m;}else miss=true;}
while((p.routers||1)<D.rt){const k=routerCost(p.rgen||0,p.routers||1);if(S.cash<k){miss=true;break;}spend(k);p.routers=(p.routers||1)+1;}
if(D.site2&&!p.site2){if(S.cash>=SITE2_COST){spend(SITE2_COST);p.site2=true;p.site2Day=S.day;}else miss=true;}
if(D.gen&&!p.gen&&!bstdNoGen()){if(S.cash>=GEN_COST){spend(GEN_COST);p.gen=true;}else miss=true;}
if(c0===S.cash&&!miss)return;
toast(miss?tr('pop_std.not_all_of_the_standard',{city:CITY[city].name}):tr('pop_std.city_gets_the_standard_cost',{city:CITY[city].name,n:p.routers||1,model:esc(RG[p.rgen||0].n),cost:fmt$(c0-S.cash)}),miss?'bad':'good');}
// The line in a POP's router section: the standard, and a button to make this POP's routers the standard.
function popStdHtml(c){const p=S.pops[c];if(!p||pzOn())return '';const d=S.popStd,same=d&&d.g===(p.rgen||0)&&d.rt===(p.routers||1);
return `<div class="kv"><span>${tr('pop_std.standard_for_new_pops')}</span><b>${d?`${d.rt} × ${esc(RG[d.g].n)}`:tr('pop_std.none')}</b></div><div class="btns">${same?'':btn(tr('pop_std.make_this_the_standard'),'popStdSet',{city:c},'ghost sm')}${d?btn(tr('pop_std.clear'),'popStdClear',{},'ghost sm'):''}</div>`;}
// The line in a POP's router section: the standard, a button to edit it, and one to make this POP's build the standard.
function popStdHtml(c){const p=S.pops[c];if(!p||pzOn())return '';const D=bstd(),on=!!S.popStd,mine=bstd(bstdPut({...D,g:p.rgen||0,rt:p.routers||1,site2:!!p.site2,gen:!!p.gen})),
same=on&&BSTD.every(x=>D[x.k]===mine[x.k]);
return `<div class="kv"><span>${tr('bstd.title')}</span><b>${on?esc(bstdLine(D)):tr('pop_std.none')}</b></div><div class="btns">${btn(tr('bstd.edit'),'bstdOpen',{},'sm')}${same?'':btn(tr('pop_std.make_this_the_standard'),'popStdSet',{city:c},'ghost sm')}${on?btn(tr('pop_std.clear'),'popStdClear',{},'ghost sm'):''}</div>`;}
// "2 × Absolute Unit 3.2T, second building, generator": the POP part, what a new POP gets.
function bstdPopParts(D){const a=[];if(D.g!=='keep'||D.rt>1)a.push(`${D.rt} × ${D.g==='keep'?tr('bstd.any_model'):RG[D.g].n}`);if(D.site2)a.push(tr('bstd.second_building'));if(D.gen)a.push(tr('bstd.generator'));return a;}
// The POP part first, then how many other targets.
function bstdLine(D){const a=bstdPopParts(D),n=['lag','split','ix','pni','sys','opt','wv'].filter(k=>D[k]!==BSTDK[k].d).length;if(n)a.push(trn('bstd.n_more_targets',n));return a.join(', ')||tr('pop_std.none');}
/* What the standard still asks for, as jobs in the order they get done: POPs busiest first, then ports hottest first,
then fiber and waves hottest first. Pure: it reads S and R and changes nothing. Each job is priced with the game's
own helpers on a running copy of the few numbers earlier jobs change (routers, spares), so the sum is what the clicks
cost. Jobs that build on each other form a chain (ch: a POP's routers, a port, a fiber): when one cannot be done, the
rest of that chain waits. A job that needs another chain's work first (optics only the new router model takes, a split
that needs the second building) names that job in dep and waits for it too. Whether a fiber may go dark is settled
here, not on the way, so the plan is what the button does and its sum is the quote.
intern: only where the intern may work (per-POP exceptions). J.held: fibers whose line system has to wait. */
function bstdPlan(intern){const J=[];J.held=[];if(!S||!S.popStd||pzOn())return J;const D=bstd(),here=c=>!intern||opsHere('std',c);
const load=c=>Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));
const cs=Object.keys(S.pops).filter(here),ld={};for(const c of cs)ld[c]=load(c);cs.sort((a,b)=>ld[b]-ld[a]||(a<b?-1:1));
// Router ports: what the POP will have once its own jobs are done, less what pending PNI augments will take.
const V={},rmn={},resv=c=>S.pni.reduce((a,p)=>p.up&&p.city===c?a+Math.max(0,PORT_SLOT(p.up.tier)*(p.up.n||1)-PORT_SLOT(p.tier)*(p.n||1)):a,0);
const room=c=>rmn[c]??(rmn[c]=(V[c]?portsMax(c,V[c].g,V[c].rt)-portsUsed(c,V[c].g):portsMax(c)-portsUsed(c))-resv(c)+1e-9);
const take=(c,n,dry)=>{if(n<=0)return true;if(room(c)<n)return false;if(!dry)rmn[c]-=n;return true;};
const job=(grp,k,ch,w,cost,mo,go,x)=>{const j={grp,k,ch,w,cost,mo,go,...x};J.push(j);return j;};
for(const c of cs){const p=S.pops[c],ch='p:'+c;let g=p.rgen||0,rt=p.routers||1,sw=null,s2=null;
const add=()=>{const g0=g,r0=rt;job('pop','rt',ch,c+' +1',routerCost(g0,r0),routerMo(g0)+cageMo(r0+1)-cageMo(r0),()=>{const n=S.pops[c].routers||1;ACT.addRouter({city:c});return (S.pops[c].routers||1)>n;},{c});rt++;};
const m=p.rupDay===S.day?-1:bstdModel(D.g,c);
if(m>=0){
// One router carrying traffic: a second goes in first, so the swap rolls through with no maintenance window.
if(rt===1&&!popIdle(c))add();
const old=g,r=rt;sw=job('pop','g',ch,c+' ⇧'+RG[m].pn,swapCostOf(m,old,r),r*(RG[m].mo-RG[old].mo),()=>{ACT.upRouter({city:c,g:m});return (S.pops[c].rgen||0)===m;},{c});g=m;}
while(rt<D.rt&&rt<RMAX)add();
// A building and a generator do not wait for the routers, nor for each other.
if(D.site2&&!p.site2)s2=job('pop','site2','s:'+c,c,SITE2_COST,SITE2_MO,()=>{ACT.addSite({city:c});return !!S.pops[c].site2;},{c});
if(D.gen&&!p.gen&&!bstdNoGen())job('pop','gen','e:'+c,c,GEN_COST,GEN_MO,()=>{if(bstdNoGen())return false;ACT.addGen({city:c});return !!S.pops[c].gen;},{c});
V[c]={g,rt,site2:!!p.site2||D.site2,sw,s2};}
// Ports: LAG members up to the standard, then the members split over both buildings.
if(D.lag>1||D.split){const P=[];
for(const t of S.transit)if(S.pops[t.city]&&here(t.city))P.push({k:'t',c:t.city,id:t.id,o:t,n:t.n||1,tier:t.tier,u:(R.useT[t.id]||0)/lagCap(PORT[t.tier].g,t.n)});
for(const x of S.pni)if(S.pops[x.city]&&here(x.city)&&pniOn(x)&&!x.up)P.push({k:'p',c:x.city,id:x.id,o:x,n:x.n||1,tier:x.tier,u:(R.usePni[x.id]||0)/lagCap(pniG(x),x.n)});
for(const x in S.ixp){const c=ixCity(x);if(!S.myIx[x]&&S.pops[c]&&here(c))P.push({k:'ix',c,id:x,n:(S.ixn||{})[x]||1,tier:S.ixp[x],u:(R.useIx[x]||0)/Math.max(1e-9,lagCap(PORT[S.ixp[x]].g,(S.ixn||{})[x]))});}
P.sort((a,b)=>b.u-a.u||(a.id<b.id?-1:1));
for(const o of P)bstdPort(o,D,V[o.c],take,job);}
// An exchange port at every POP in a city with an exchange (not DE-KICKS: they want a sales call first).
if(D.ix)for(const c of cs){if(hasIxAt(c))continue;const x=ixIdsIn(c).find(x=>!isDk(x)&&!S.myIx[x]&&!!ixName(x)&&S.ixp[x]===undefined);if(!x||!take(c,PORT_SLOT(0)))continue;
const ch='i:'+x,pm=ixPortMo(x,0);job('port','ix',ch,x+' +'+PORT[0].n,pm,pm,()=>{ACT.buyIx({city:x,tier:0});return S.ixp[x]!==undefined;},{c});
bstdPort({k:'ix',c,id:x,n:1,tier:0,fresh:true},D,V[c],take,job);}
// PNIs spread out: every network you have a PNI with gets one in at least that many cities, where one is worth it.
if(D.pni){const by={};for(const p of S.pni)(by[p.net]||(by[p.net]=new Set())).add(p.city);
for(const net of Object.keys(by).sort()){let k=D.pni-by[net].size;if(k<=0||!isNet(net))continue;
const opts=NET[net].pops.filter(c=>S.pops[c]&&here(c)&&!by[net].has(c)).map(c=>({c,v:pniVal(net,c)})).filter(o=>o.v.worth).sort((a,b)=>b.v.want-a.v.want||(a.c<b.c?-1:1));
for(const {c,v} of opts){if(k<=0)break;let q=null;for(let t=Math.max(v.tier,pniMin(net));t>=pniMin(net)&&!q;t--){const x=pniQuote(c,net,t,resv(c));if(x&&!x.why)q=x;}
if(!q||!take(c,q.slots))continue;const tier=q.tier;k--;
job('port','pni','n:'+net+'@'+c,c+' '+net,q.cost,pniMo({net,tier,n:1},0),()=>{const x=pniQuote(c,net,tier,resv(c));if(!x||x.why||!spend(x.cost))return false;pniPlace(x);return true;},{c});}}}
// Fiber and waves, hottest first. A POP excepted from the order keeps its links as they are too.
if(D.sys!=='keep'||D.opt!=='keep'||D.wv!=='keep'){const sp={...(S.spares||{})},dk=new Map(),wv=new Map();
const ls=S.links.filter(l=>(l.kind==='df'||l.kind==='wave')&&here(l.a)&&here(l.b)&&S.pops[l.a]&&S.pops[l.b]).map(l=>({l,u:(R.load[l.id]||0)/Math.max(1e-9,capOf(l))})).sort((a,b)=>b.u-a.u||(a.l.id<b.l.id?-1:1));
// Waves: the size each goes up to. The decom order hands back the smaller waves a pair no longer needs, judged with
// the sizes these upgrades give: never pay a month's rent on one it is about to return.
if(D.wv!=='keep'){for(const {l} of ls)if(l.kind==='wave'&&l.tier<D.wv)for(let t=D.wv;t>l.tier;t--){if(subWaveWhy(t,l.km,l.sub)||soldOut(l.a,l.b,t,l.cable)||!waveOk(l.a,l.b,t))continue;wv.set(l,t);break;}
if(wv.size&&opsHired()&&S.ops.on.decom){const by=new Map(),cf=x=>wv.has(x)?capOf(x)*LT[wv.get(x)].g/LT[x.tier].g:capOf(x);
for(const x of S.links)if(x.kind!=='vxc'){const k=edgeKey(x);(by.get(k)||by.set(k,[]).get(k)).push(x);}
for(const k of new Set([...wv.keys()].map(edgeKey)))for(const x of opsDecomPick(by.get(k),cf))wv.delete(x);}}
for(const {l} of ls){const ch='l:'+l.id;
if(l.kind==='wave'){const t=wv.get(l);if(t){const nm=Math.round(waveMo(l.km,l.sub,t)*(l.mult||1));job('fiber','wv',ch,l.a+'|'+l.b,nm,nm-(l.mo||0),()=>{ACT.upLink({id:l.id,tier:t});return l.tier===t;},{l});}continue;}
if(l.eqDown>S.day)continue;
let sys=l.sys;const lit=l.ready<=S.day,nx=D.sys!=='keep'&&BSTD_SYS[sys]<BSTD_SYS[D.sys]&&sysNext({sys});
// A lit fiber goes dark for a day. Busy with nothing parallel to carry it: it keeps its line system for now, and
// gets the best optics that one takes. A parallel fiber goes dark first in this plan: it waits for next time.
if(nx&&techOk('sys',nx,DF_SYS[nx].lvl)){
if(lit&&!bstdDarkOk(l))J.held.push(l);
else if(lit&&!bstdDarkOk(l,dk)){J.held.push(l);continue;}
else{const busy=lit&&bstdBusy(l);
while(BSTD_SYS[sys]<BSTD_SYS[D.sys]){const to=sysNext({sys});if(!to||!techOk('sys',to,DF_SYS[to].lvl))break;
const s0=sys;job('fiber','sys',ch,l.a+'|'+l.b,sysCost(to)*(to==='cl'&&l.own?Math.max(1,l.pairs|0):1),0,()=>{if(l.sys!==s0)return false;ACT.upSys({id:l.id});return l.sys===to;},{l,dark:lit,busy});sys=to;}
if(lit)dk.set(l.id,busy);}}
// Optics for the line system the fiber will have.
if(D.opt==='fast'&&lit&&(l.ch||[]).length)J.push(...bstdOptJobs(l,sys,sp,V,take,ch));}}
return J;}
// One port's LAG members up to the standard, then split over both buildings. A PNI's new member is an augment that
// lands later; it remembers to split when it does. o.fresh: a port the plan is buying (the IX job before it).
function bstdPort(o,D,v,take,job){const {k,c,id}=o,ch=(o.fresh?'i:':'x:'+k+':')+id;let n=o.n;
const site2=v?v.site2:!!(S.pops[c]&&S.pops[c].site2),split=D.split&&site2,
// A second building still to buy is a job of its own: the split waits for it, or it would be tried every shift.
sx={c,...(v&&v.s2&&!S.pops[c].site2?{dep:[v.s2]}:{})};
if(k==='p'){const x=o.o;
if(n<D.lag&&n<LAG_MAX&&!msfNope(x.net,c)&&take(c,PORT_SLOT(x.tier))){const n0=n,mo=x.g1?Math.round(PORT[0].pni/2):PORT[x.tier].pni;
job('port','lag',ch,c+' +1×'+pniPN(x),1500+PORT[x.tier].setup/2,mo,()=>{if((x.n||1)!==n0||x.up)return false;ACT.lagP({id,d:1});return !!x.up||(x.n||1)>n0;},{c});n++;}
if(split&&n>=2&&x.site!=='ab')job('port','split',ch,c,0,0,()=>{if(!S.pops[c].site2)return false;if(x.up){if(x.up.n<2)return false;x.up.site='ab';return true;}
if((x.n||1)<2)return false;ACT.siteSet({k:'p',id,s:'ab'});return x.site==='ab';},sx);
return;}
const t=k==='t'?o.o:null,tier=o.tier,each=k==='t'?PORT[tier].setup:ixPortMo(id,tier);
while(n<D.lag&&n<LAG_MAX&&(k!=='t'||portOk(c,tier))&&take(c,PORT_SLOT(tier))){const n0=n,mo=k==='t'?transitMo({...t,n:n0+1},0)-transitMo({...t,n:n0},0):each;
job('port','lag',ch,(k==='t'?c:id)+' +1×'+PORT[tier].n,each,mo,k==='t'?()=>{if((t.n||1)!==n0)return false;ACT.lagT({id,d:1});return (t.n||1)>n0;}
:()=>{const m=(S.ixn||{})[id]||1;if(m!==n0)return false;ACT.lagIx({city:id,d:1});return ((S.ixn||{})[id]||1)>m;},{c});n++;}
const cur=k==='t'?t.site:(S.ixSite||{})[id];
if(split&&n>=2&&cur!=='ab')job('port','split',ch,k==='t'?c:id,0,0,()=>{if(!S.pops[c].site2)return false;
if(k==='t'){if((t.n||1)<2)return false;ACT.siteSet({k:'t',id,s:'ab'});return t.site==='ab';}
if(((S.ixn||{})[id]||1)<2)return false;ACT.siteSet({k:'ix',id,s:'ab'});return (S.ixSite||{})[id]==='ab';},sx);}
// Can it see the fastest optic that reaches, ignoring the free-slot check (a swap frees its own slot first)? rg: each
// end's router model once the plan's swaps are in, so the optics a new model takes are part of the plan.
const bstdOptFits=(l,o,sys,rg)=>{const O=OPT[o];return techOk('opt',o,O.lvl)&&(O.sys!=='roadm'||isRdm(sys))&&!!optMode(o,l)&&[l.a,l.b].every(c=>!S.pops[c]||RG[rg(c)].cls>=O.rg);};
const bstdCnt=(l,o)=>(l.ch||[]).filter(k=>k===o).length;
// Swap a fiber's slower optics for the fastest that reaches on it, one job per kind, slowest first: the old ones go on
// the spares shelf (setChCount), the new ones come from the shelf first. sp: spares as earlier jobs leave them.
function bstdOptJobs(l,sys,sp,V,take,ch){const rg=c=>V[c]?V[c].g:(S.pops[c].rgen||0),fits=Object.keys(OPT).filter(o=>bstdOptFits(l,o,sys,rg));if(!fits.length)return [];
const best=fits.sort((a,b)=>optG(b,l)-optG(a,l)||optCost(a)-optCost(b))[0],bg=optG(best,l),g=c=>V[c]?V[c].g:undefined,out=[];
// Optics only the new router model takes wait for its swap: until it is in, nothing is pulled.
const low=c=>!!S.pops[c]&&RG[S.pops[c].rgen||0].cls<OPT[best].rg,dep=[l.a,l.b].filter(low).map(c=>V[c]&&V[c].sw).filter(Boolean);
for(const o0 of [...new Set(l.ch||[])].filter(o=>OPT[o]&&optG(o,l)<bg).sort((a,b)=>optG(a,l)-optG(b,l)||(a<b?-1:1))){
// A faster optic can take more router ports than the one it replaces: as many as both ends have room for.
const per=c=>Math.max(0,chPorts(best,c,g(c))-chPorts(o0,c,g(c)));let k=bstdCnt(l,o0);
while(k>0&&!(take(l.a,per(l.a)*k,true)&&take(l.b,per(l.b)*k,true)))k--;if(!k)continue;take(l.a,per(l.a)*k);take(l.b,per(l.b)*k);
const r=REGEN_CH*(l.regen|0),c=optCost(best),s=Math.max(0,Math.min(k,sp[best]|0)),cost=s*Math.round(c*r)+(k-s)*Math.round(c*(1+r));
sp[best]=(sp[best]|0)-s;sp[o0]=(sp[o0]|0)+k;
// price: what it costs when it runs. The plan's price counts on the shelf as the jobs before it leave it; one of those
// refused (budget, cash) leaves the shelf emptier, and the budget and the floor must see the real bill.
out.push({grp:'fiber',k:'opt',ch,w:l.a+'|'+l.b,cost,mo:0,l,...(dep.length?{dep}:{}),price:()=>opticCountCost(l,best,bstdCnt(l,best)+k),
go:()=>{const n0=bstdCnt(l,o0),h0=bstdCnt(l,best);if(n0<k||[l.a,l.b].some(low))return false;
ACT.setChCount({id:l.id,o:o0,n:n0-k});if(bstdCnt(l,o0)!==n0-k)return false;ACT.setChCount({id:l.id,o:best,n:h0+k});if(bstdCnt(l,best)===h0+k)return true;
// The new ones could not go in (ports, cash): the old optics go back in from the shelf.
(l.ch=l.ch||[]).push(...Array(k).fill(o0));S.spares[o0]-=k;return false;}});}
return out;}
// A line-system swap darkens the fiber for a day: only while it carries little, or its parallel links can take its load.
// ex: fibers already going dark today (id → whether they carry traffic): they carry nothing for this one, and one whose
// traffic leans on its parallel links keeps them lit.
const bstdBusy=l=>((R.load&&R.load[l.id])||0)>Math.max(1,capOf(l)*0.1);
function bstdDarkOk(l,ex){const P=pairLinks(l.a,l.b).filter(x=>x!==l);if(ex&&P.some(x=>ex.get(x.id)))return false;if(!bstdBusy(l))return true;
return P.filter(x=>!linkDown(x)&&!x.standby&&!(ex&&ex.has(x.id))).reduce((a,x)=>a+Math.max(0,capOf(x)-((R.load&&R.load[x.id])||0)),0)>=((R.load&&R.load[l.id])||0);}
// Do the plan's jobs in order. can(j): may it be paid for (budget, floor, cash); pay(j): run it, true if it took.
// one: at most one fiber goes dark (the intern's shift); max: at most that many jobs tried, done or failed, so a shift's
// work stays bounded whatever goes wrong. Returns what was done.
function bstdDo(J,can,pay,one,max=1e9){const stop=new Set(),done=new Set(),dark=new Map();let n=0;
for(const j of J){if(n>=max)break;if(stop.has(j.ch))continue;if(j.dep&&!j.dep.every(d=>done.has(d))){stop.add(j.ch);continue;}
if(j.dark&&!dark.has(j.l.id)&&((one&&dark.size)||!bstdDarkOk(j.l,dark))){stop.add(j.ch);continue;}
if(!can(j)){stop.add(j.ch);continue;}n++;
if(!pay(j)){stop.add(j.ch);continue;}
if(j.dark)dark.set(j.l.id,!!j.busy);done.add(j);}
return [...done];}
// What a job costs as it runs (an optics swap is priced again then: see bstdOptJobs).
const bstdPrice=j=>j.price?j.price():j.cost;
// The sheet's summary and the MCP quote: how much is below the standard, and what bringing it all up costs. The plan is
// what the button does, so its sum is the bill. held: the fibers whose line system waits ("fra|ams"); they are below it.
function bstdQuote(intern){const J=bstdPlan(intern),P=new Set(),Q=new Set(),L=new Set(J.held.map(l=>l.id));let cost=0,mo=0;
for(const j of J){cost+=j.cost;mo+=j.mo;if(j.grp==='pop')P.add(j.c);else if(j.grp==='port')Q.add(j.ch);else L.add(j.l.id);}
return {cost:Math.round(cost),mo:Math.round(mo),pops:P.size,ports:Q.size,links:L.size,n:J.length,held:J.held.map(l=>l.a+'|'+l.b)};}
// The optics order lights the standard's fastest optics while this order keeps to a standard that wants them.
const bstdFast=()=>!!(S.popStd&&opsHired()&&S.ops.on.std&&bstd().opt==='fast');
// The intern's shift: the same plan, every job through the budget and the cash floor at what it costs then, a few at a time.
function bstdShift(X){bstdDo(bstdPlan(true),j=>X.can('std',bstdPrice(j),j.mo),j=>X.pay('std',()=>j.go())&&(X.did('std',j.w),true),true,BSTD_MAX);}

View file

@ -62,8 +62,8 @@ function sanitize(s){
for(const k of Object.keys(s.confReg))s.confReg[k]=s.confReg[k]==='sp'?'sp':!!s.confReg[k];
if(s.conf){const c=s.conf;if(typeof c!=='object'||!own(REG,c.reg))s.conf=null;else s.conf={until:num(c.until,0),reg:c.reg,name:String(c.name||'').slice(0,40),sp:!!c.sp};}
// The backbone's technology: a save from before it with Auto-TE bought keeps the old rules on RSVP-TE (legacy).
// The standard POP build (#240): a router model and how many.
{const d=s.popStd;s.popStd=d&&typeof d==='object'&&Number.isInteger(d.g)&&RG[d.g]?{g:d.g,rt:int(d.rt,1,RMAX,1)}:null;}
// The build standard (#240): a router model and how many, and since then every other target; odd values read as "keep".
popStdSanitize(s);
{const c=s.core&&typeof s.core==='object'?s.core:null,lv=c?int(c.lv,0,4,0):(s.te?2:0);s.core={lv,run:c?int(c.run,0,lv,lv):lv};if(c?c.legacy===true:!!s.te)s.core.legacy=true;if(c&&c.lab===true)s.core.lab=true;if(c&&c.since!==undefined)s.core.since=num(c.since,0);}
s.capDeal=s.capDeal&&typeof s.capDeal==='object'&&own(CAP_ROUTES,s.capDeal.c)?{at:num(s.capDeal.at,0),c:s.capDeal.c}:null;
s.inc=s.inc.filter(i=>i&&typeof i.type==='string').map(i=>(i.type==='maxpfx'&&(i.type='ixloop'),i.id=sid(i.id),i.until=num(i.until,s.day),i.cost=num(i.cost,0),i.msg=String(i.msg||'').slice(0,400),i.fix=i.fix==null?undefined:String(i.fix).slice(0,60),i));

View file

@ -12,8 +12,10 @@ Object.assign(ACT,{
setRoute:({id,m})=>{if(!own(RT,m))return;const b=S.biz.find(x=>x.id===id);if(b){b.route=m;sfx('click');after();}},
route:({r})=>{UI.route=r;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
addParallel:({id})=>{const l=S.links.find(x=>x.id===id);if(l)openLinkModal(l.a,l.b);},
popStdSet:({city})=>{const p=S.pops[city];if(!p||pzOn())return;S.popStd={g:p.rgen||0,rt:p.routers||1};toast(tr('pop_std.new_pops_now_start_with',{n:S.popStd.rt,model:esc(RG[S.popStd.g].n)}),'good');sfx('click');after();},
popStdClear:()=>{S.popStd=null;sfx('click');after();},
// This POP's build becomes the standard's POP part: its model, routers, second building and generator.
popStdSet:({city})=>{const p=S.pops[city];if(!p||pzOn())return;S.popStd=bstdPut({...bstd(),g:p.rgen||0,rt:p.routers||1,site2:!!p.site2,gen:!!p.gen});
toast(tr('pop_std.new_pops_now_start_with_list',{list:esc(bstdPopParts(bstd()).join(', '))}),'good');sfx('click');after();if(bstdShown())bstdModal();},
popStdClear:()=>{S.popStd=null;sfx('click');after();if(bstdShown())bstdModal();},
addRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)>=RMAX)return;if(!spend(routerCost(p.rgen||0,p.routers||1)))return;p.routers=(p.routers||1)+1;floater(CITY[city].x,CITY[city].y-30,tr('common.router_added'),'#FF4F9A');after();},
models:()=>{UI.models=!UI.models;renderPanel();},
rmRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)<=1)return;if(portsUsed(city)>portsMax(city,undefined,p.routers-1)){toast(tr('routing_and_routers.unplug_something_first_used_ports',{used:fmtPorts(portsUsed(city)),max:portsMax(city,undefined,p.routers-1)}),'bad');sfx('err');return;}p.routers--;{const back=tradeIn(p.rgen||0,1);if(back>0){S.cash+=back;toast(tr('routing_and_routers.sold_a_model_on_ebuy_price',{model:esc(RG[p.rgen||0].n),price:fmt$(back)}),'good');}}after();},

View file

@ -0,0 +1,14 @@
// The build standard sheet (93-ui/59-build-standard.js): pick a target, or bring everything up to the standard in one go.
Object.assign(ACT,{
bstdOpen:()=>{if(S&&!pzOn())bstdModal();},
// v: a position in the list the sheet shows; without v, the next value (the MCP tools step through a list).
bstdSet:({k,v})=>{if(!S||pzOn()||!own(BSTDK,k))return;const D=bstd(),x=opsPick(bstdOpts(k),D[k],v);if(x===undefined||!bstdOk(BSTDK[k],x))return;
D[k]=x;S.popStd=bstdPut(D);sfx('click');after();opsRedraw('bstdSet',{k},bstdModal);},
// The same jobs, in the same order and through the same gates as the intern's order, while the cash lasts. One
// recompute at the end, and one toast: what got done, and what still waits.
bstdApply:()=>{if(!S||pzOn()||!S.popStd)return;const J=bstdPlan(false);if(!J.length)return;const c0=S.cash;let n=0;
opsQuiet(()=>{n=bstdDo(J,j=>{const c=bstdPrice(j);return c<=0||S.cash>=c;},j=>!!j.go(),false).length;});
after();const q=bstdQuote(false),left=q.pops+q.ports+q.links;
toast((n?trn('bstd.applied',n,{cost:fmt$(c0-S.cash)}):tr('bstd.applied_none'))+(left?' '+trn('bstd.left',left):''),n?'good':'bad');sfx(n?'build':'err');
if(bstdShown())bstdModal();},
});

View file

@ -2,8 +2,10 @@
const opsCycle=(a,v)=>a[(a.indexOf(v)+1)%a.length];
// A pick from a list (v: its position, as the sheet's dropdown sends it), or without v the next value (the MCP tools step).
const opsPick=(a,cur,v)=>{if(v===undefined)return opsCycle(a,cur);const i=Number(v);return Number.isInteger(i)&&i>=0&&i<a.length?a[i]:undefined;};
// The sheet is drawn again after a pick: keep the keyboard on the list that was used.
const opsRedraw=(act,args)=>{opsModal();const j=JSON.stringify(args);for(const el of $('modalCard').querySelectorAll(`[data-chg="${act}"]`))if(el.dataset.args===j){el.focus();break;}};
// The sheet is drawn again after a pick: keep the keyboard on the list that was used. The build standard sheet shows the
// std order's switch and budget too: a pick there stays there.
const opsSheet=()=>(bstdShown()?bstdModal:opsModal)();
const opsRedraw=(act,args,draw=opsSheet)=>{draw();const j=JSON.stringify(args);for(const el of $('modalCard').querySelectorAll(`[data-chg="${act}"]`))if(el.dataset.args===j){el.focus();break;}};
Object.assign(ACT,{
opsOpen:()=>{if(S)opsModal();},
opsHire:({id})=>{if(!S||opsHired()||!own(INTERNS,id)||!opsCanHire()||!rule('clock'))return;if(!spend(INTERN_MO))return;const O=opsO(),m=monthIdx(S.day);O.intern=id;O.hired=S.day;O.wk=null;
@ -12,7 +14,7 @@ Object.assign(ACT,{
O.log.unshift({d:S.day,i:id,r:[]});toast(esc(tr('ops.hired',{name:opsName(true)})),'good',[{l:tr('ops.ops'),act:'opsOpen',args:{}}]);after();opsModal();},
opsFire:()=>{if(!opsHired())return;if(UI.confirm!=='opsFire'){UI.confirm='opsFire';opsModal();return;}UI.confirm=null;const nm=opsName();S.ops.intern=null;
toast(esc(tr('ops.fired',{name:nm})),'');after();opsModal();},
opsToggle:({k})=>{if(!opsHired()||!own(OPSK,k))return;S.ops.on[k]=!S.ops.on[k];sfx('click');after();opsModal();},
opsToggle:({k})=>{if(!opsHired()||!own(OPSK,k))return;S.ops.on[k]=!S.ops.on[k];sfx('click');after();opsSheet();},
opsParam:({k,p,v})=>{if(!opsHired()||!own(OPSK,k)||!own(OPSK[k].p,p))return;const P=OPSK[k].p[p],x=opsPick(opsOpts(k,p),opsP(k,p),v);if(x===undefined||!(P.ok?P.ok(x):P.v.includes(x)))return;
(S.ops.p[k]||(S.ops.p[k]={}))[p]=x;sfx('click');after();opsRedraw('opsParam',{k,p});},
opsCap:({k,v})=>{if(!opsHired()||!own(OPSK,k)||!OPSK[k].cap)return;const x=opsPick(opsCaps(k),opsCap(k),v);if(x===undefined)return;S.ops.cap[k]=x;sfx('click');after();opsRedraw('opsCap',{k});},

View file

@ -29,7 +29,7 @@ Object.assign(ACT,{
<div class="menu-list">
${btn(tr('common.back_to_the_map'),'closeModal',{},'pink big')}${saveFailing()?btn(tr('common.export_save'),'exportSave',{},'pink'):''}${saveFailing()&&UI.saveFail.full&&slotOthers().length?btn(tr('slots.free_up_space'),'slotSpace',{},'pink'):''}
</div>
<div class="menu-tiles">${[['🗂️',tr('slots.your_networks'),'toTitle'],['🧩',tr('puzzles.puzzles'),'puzzleMenu'],['🏆',tr('common.scenarios'),'scenarios'],['🧑‍💻',tr('ops.standing_orders'),'opsOpen'],['📸',tr('common.share'),'share'],['⚙️',tr('common.settings'),'settings']].map(([i,l,a])=>`<button class="mtile" data-act="${a}"><i aria-hidden="true">${i}</i><span>${l}</span></button>`).join('')}</div>
<div class="menu-tiles">${[['🗂️',tr('slots.your_networks'),'toTitle'],['🧩',tr('puzzles.puzzles'),'puzzleMenu'],['🏆',tr('common.scenarios'),'scenarios'],['🧑‍💻',tr('ops.standing_orders'),'opsOpen'],['📐',tr('bstd.title'),'bstdOpen'],['📸',tr('common.share'),'share'],['⚙️',tr('common.settings'),'settings']].map(([i,l,a])=>`<button class="mtile" data-act="${a}"><i aria-hidden="true">${i}</i><span>${l}</span></button>`).join('')}</div>
<p class="menu-links">${[saveFailing()?null:[tr('common.export_save'),'exportSave'],[tr('common.import_a_save'),'importPick'],[tr('common.how_to_play'),'help'],RELEASE_NOTES.length?[tr('common.what_s_new_in_v',{v:esc(APP_VERSION)}),'whatsNewShow']:null,[tr('common.start_a_new_network'),'resetAsk']].filter(Boolean).map(([l,a])=>`<button class="lnk" data-act="${a}">${l}</button>`).join(' · ')}</p>
</div><div class="menu-plugs"><a class="mplug" href="${SIGNAL}" target="_blank" rel="noopener">💬 ${tr('modal_and_names.join_the_noc_chat')} →</a><a class="mplug" href="${ISSUES}" target="_blank" rel="noopener">🐛 ${tr('modal_and_names.found_a_bug_or_have_an')} →</a></div>`);},
settings:()=>{UI.setOpen=true;openModal(settingsHtml());},

View file

@ -43,7 +43,7 @@ function bbCost(c){return 15000+CITY[c].P*20;}
/* A click that changes nothing routing reads (the log, offers, cash, names, settings…) keeps the routing it has:
compute() gives the same R again for the same state (tests/compute-idempotent), so it is skipped. The key is the save
without the fields routing never reads (tests/route-skip checks each one); any other change routes again. */
const RK_SKIP=new Set(['name','log','offers','usedNames','stats','cash','seen','tut','ach','achP','won','loanOffers','loanStrikes','uiSpeed','cam','richTold','demo','nextEvent','nextFail','done','confReg','auNews','calV','solWon','seatOff','chartSet','t1Now','ltv','capDeal','auV','pdeskRep','sv']);
const RK_SKIP=new Set(['name','log','offers','usedNames','stats','cash','seen','tut','ach','achP','won','loanOffers','loanStrikes','uiSpeed','cam','richTold','demo','nextEvent','nextFail','done','confReg','auNews','calV','solWon','seatOff','chartSet','t1Now','ltv','capDeal','auV','pdeskRep','sv','popStd']);
function routeKey(){const o={};for(const k in S)if(!RK_SKIP.has(k))o[k]=S[k];return JSON.stringify(o);}
function routeIfChanged(){const k=S&&!pzOn()?routeKey():null;if(k&&k===UI.rk&&R===UI.rkR)return false;compute();UI.rk=k;UI.rkR=R;return true;}
function after(){if(pzOn()){pzAfter();return;}NOC.dirty=true;if(S)purgeInc();routeIfChanged();checkGoals();renderAll();if(S&&!$('dash').hidden)renderDash();save();}

View file

@ -8,7 +8,7 @@ function cityPanel(c){
if(!p){
h+=`<div class="scroll">${C.note?`<p class="note" style="margin-top:0">${esc(C.note)}</p>`:''}
${C.cn?chinaSection(c):''}${C.cn&&!cnOk()?'':`<section><h3>${tr('city_panel.open_a_pop_here')}</h3><p class="lead">${tr('city_panel.a_pop_point_of_presence_is')}</p>
${C.ru?`<p class="why">${tr('city_panel.includes_the_mandatory_government',{cost:fmt$(RU_BOX),mo:fmt$(RU_BOX_MO)})}</p>`:''}${(q=>btn(tr('city_panel.build_pop_cost_mo_mo',{cost:fmt$(popCost(c)+(q?q.cost:0)),mo:fmt$(popMo(c)+(q?q.mo:0))}),'buildPop',{city:c},'pink big',S.cash<popCost(c))+(q?`<p class="note">${tr('pop_std.includes_the_standard_n_model',{n:q.rt,model:esc(RG[q.g].n),cost:fmt$(q.cost),mo:fmt$(q.mo)})}</p>`:''))(popStdQuote())}
${C.ru?`<p class="why">${tr('city_panel.includes_the_mandatory_government',{cost:fmt$(RU_BOX),mo:fmt$(RU_BOX_MO)})}</p>`:''}${(q=>btn(tr('city_panel.build_pop_cost_mo_mo',{cost:fmt$(popCost(c)+(q?q.cost:0)),mo:fmt$(popMo(c)+(q?q.mo:0))}),'buildPop',{city:c},'pink big',S.cash<popCost(c))+(q?`<p class="note">${q.site2||q.gen?tr('pop_std.includes_the_build_standard',{list:esc(bstdPopParts({g:q.g,rt:q.rt,site2:q.site2,gen:q.gen}).join(', ')),cost:fmt$(q.cost),mo:fmt$(q.mo)}):tr('pop_std.includes_the_standard_n_model',{n:q.rt,model:esc(RG[q.g].n),cost:fmt$(q.cost),mo:fmt$(q.mo)})}</p>`:''))(popStdQuote())}
<p class="note">${tr('city_panel.or_drag_from_one_of_your')}</p></section>${opsTplHtml(c)}`}`;
h+=offersHere(c);
const trs=NETS.filter(n=>sellsAt(n,c));

View file

@ -12,6 +12,7 @@ const opsCapName=(k,v)=>v?tr('common.price_mo',{price:(OPSK[k].mo?'+':'')+fmt$(v
function opsOrderHtml(d){const k=d.k,on=S.ops.on[k],cap=d.cap?opsCap(k):0,sp=S.ops.spent[k]||0,am=Math.round(S.ops.addMo[k]||0);
return `<div class="ops-o${on?' on':''}"><div class="ops-h"><span class="ops-i" aria-hidden="true">${d.i}</span><div class="grow"><div class="nm">${tr(d.t)}</div><div class="meta">${tr(d.d)}${k==='caches'?' '+tr('ops.caches_rent',{price:fmt$(CACHE_MO),big:fmt$(CACHE_BIG_MO)}):''}</div></div>
<button class="b sm ${on?'green':'ghost'}" data-act="opsToggle" data-args='{"k":"${k}"}' aria-pressed="${on}" aria-label="${esc(tr(d.t))}">${on?tr('common.on'):tr('ops.paused')}</button></div>
${k==='std'?`<div class="meta">${tr('bstd.now_line',{list:S.popStd?esc(bstdLine(bstd())):tr('pop_std.none')})}</div><div class="btns">${btn(tr('bstd.edit'),'bstdOpen',{},'ghost sm')}</div>`:''}
${on?`<div class="ops-p">${Object.keys(d.p).map(p=>opsSel(tr(d.p[p].l),'opsParam',{k,p},opsOpts(k,p),opsP(k,p),v=>opsVal(k,p,v))).join('')}
${d.cap?opsSel(d.mo?tr('ops.budget_running'):tr('ops.budget'),'opsCap',{k},opsCaps(k),cap,v=>opsCapName(k,v)):''}</div>
${sp||am?`<div class="meta">${tr('ops.spent_and_mo',{price:fmt$(sp),mo:opsMo$(am)})}</div>`:''}
@ -41,7 +42,8 @@ function opsReportHtml(){const O=S.ops,w=Math.floor(S.day/7),cur=O.wk&&O.wk.w===
const row=(t,x)=>`<div class="ops-rep"><div class="eyebrow">${t}</div><div>${esc(opsWeekLine(x))}</div></div>`;
return (rep?row(tr('ops.report_last'),rep):'')+(cur?row(tr('ops.report_now'),cur):'');}
// The big one-off batches (#181, #192) live here now, next to the orders that run them every week.
const opsOnceHtml=()=>`<section><h3>${tr('ops.by_hand')}</h3><p class="meta">${tr('ops.by_hand_note')}</p><div class="btns">${btn(tr('utilities.title'),'utilities',{},'sm')}${btn(tr('pni_all.peer_all_networks'),'pniAllOpen',{net:null},'sm')}</div></section>`;
// The build standard too: its sheet works with or without an intern (targets, new POPs, everything up in one tap).
const opsOnceHtml=()=>`<section><h3>${tr('ops.by_hand')}</h3><p class="meta">${tr('ops.by_hand_note')}</p><div class="btns">${btn(tr('utilities.title'),'utilities',{},'sm')}${btn(tr('pni_all.peer_all_networks'),'pniAllOpen',{net:null},'sm')}${pzOn()?'':btn(tr('bstd.title'),'bstdOpen',{},'sm')}</div></section>`;
// On a city without a POP: open it from the template in one tap.
function opsTplHtml(c){if(!opsHired())return '';const q=opsTplQuote(c);if(!q)return '';
return `<section><h3>${tr('ops.template')}</h3><p class="meta">${esc(tr('ops.tpl_offer',{name:opsName(),list:[tr('ops.tpl_pop'),...q.parts].join(', ')}))}</p><div class="btns">${btn(tr('ops.tpl_open',{cost:fmt$(q.cost)}),'opsNewPop',{city:c},'pink',S.cash<q.cost)}</div></section>`;}

View file

@ -0,0 +1,38 @@
/* The build standard sheet: every target as a list (two to a row on a phone), grouped POP / ports and peering / fiber;
what is below the standard and what bringing it up costs, priced without changing anything; one tap to do it now;
and the intern's order that keeps it there. A bottom sheet on phones, like the Ops sheet it sits next to. */
const BSTD_GRP=[['pop',N_('common.pops')],['port',N_('bstd.g_port')],['fiber',N_('bstd.g_fiber')]];
// Every value a target can take, in the order its list shows them; the current one is always on the list.
function bstdOpts(k){const L=BSTDK[k].v(),cur=bstd()[k];if(!L.includes(cur))L.push(cur);return L;}
function bstdVal(k,v){if(v===BSTDK[k].d&&k!=='rt')return tr('bstd.keep');
switch(k){case 'g':return RG[v].n+(rgOpen(v)?'':' '+tr('bstd.from_level',{lv:RG[v].lvl}));
case 'rt':return v>1?tr('bstd.at_least_n',{n:v}):tr('bstd.keep');
case 'site2':case 'gen':return tr('bstd.at_every_pop');
case 'lag':return tr('bstd.at_least_n',{n:v});
case 'split':return tr('bstd.both_buildings');
case 'ix':return tr('bstd.every_exchange');
case 'pni':return tr('bstd.in_n_cities',{n:v});
case 'sys':return tr('bstd.or_better',{x:DF_SYS[v].n});
case 'opt':return tr('bstd.fastest');
case 'wv':return tr('bstd.or_better',{x:LT[v].n});}
return String(v);}
const bstdShown=()=>!!$('modal')&&!$('modal').hidden&&!!$('modalCard').querySelector('[data-sheet="bstd"]');
function bstdModal(){if(!S||pzOn())return;const D=bstd(),q=bstdQuote(false),hired=opsHired(),on=hired&&S.ops.on.std;
let h=`<div data-sheet="bstd" style="display:flex;align-items:center"><div><div class="eyebrow">${tr('ops.ops')}</div><h2 style="font-size:26px">${tr('bstd.title')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>
<p class="tagline">${tr('bstd.tagline')}</p>`;
for(const [g,lab] of BSTD_GRP)h+=`<section><h3>${tr(lab)}</h3><div class="ops-p">${BSTD.filter(x=>x.grp===g).map(x=>opsSel(tr(x.l),'bstdSet',{k:x.k},bstdOpts(x.k),D[x.k],v=>bstdVal(x.k,v))).join('')}</div>
<p class="note">${g==='pop'?tr('bstd.new_pops_note'):g==='port'?tr('bstd.port_note'):tr('bstd.fiber_note')}</p></section>`;
// What is below it today, and what bringing it all up costs: a quote, nothing changes until the button. A fiber whose
// line system has to wait is below it too, but not on the bill.
const n={pop:q.pops,port:q.ports,fiber:q.links},w=q.held.length;
h+=`<section><h3>${tr('bstd.below')}</h3>${q.n||w?BSTD_GRP.map(([g,lab])=>`<div class="kv"><span>${tr(lab)}</span><b>${n[g]}</b></div>`).join('')
+`<div class="kv"><span>${tr('bstd.cost_now')}</span><b>${fmt$(q.cost)}</b></div><div class="kv"><span>${tr('bstd.cost_mo')}</span><b>${tr('common.price_mo',{price:opsMo$(q.mo)})}</b></div>`
+(w?`<p class="meta">${trn('bstd.held',w)}</p>`:'')
:`<p class="meta">${S.popStd?tr('bstd.all_up'):tr('bstd.none_set')}</p>`}</section>`;
// The intern keeps it there: the order's switch and budget, or a word on hiring one.
h+=`<section><h3>${tr('ops.o_std')}</h3>${hired?`<div class="ops-o${on?' on':''}"><div class="ops-h"><span class="ops-i" aria-hidden="true">${INTERNS[S.ops.intern].i}</span><div class="grow"><div class="nm">${esc(tr('bstd.intern_keeps',{name:opsName()}))}</div><div class="meta">${tr('ops.o_std_d')}</div></div>
<button class="b sm ${on?'green':'ghost'}" data-act="opsToggle" data-args='{"k":"std"}' aria-pressed="${on}" aria-label="${esc(tr('ops.o_std'))}">${on?tr('common.on'):tr('ops.paused')}</button></div>
${on?`<div class="ops-p">${opsSel(tr('ops.budget'),'opsCap',{k:'std'},opsCaps('std'),opsCap('std'),v=>opsCapName('std',v))}</div>`:''}</div>`
:`<p class="meta">${tr('bstd.hire_note')}</p><div class="btns">${btn(tr('ops.hire_an_intern'),'opsOpen',{},'ghost sm',!opsCanHire()||!rule('clock'))}</div>`}</section>`;
h+=`<div class="btns cta">${btn(q.n?tr('bstd.apply_now',{cost:fmt$(q.cost)}):w?tr('bstd.apply_wait'):tr('bstd.apply_nothing'),'bstdApply',{},'pink',!q.n)}</div>`;
openModal(h,'ops');}

View file

@ -396,6 +396,48 @@
"broker.win_text":"{name} (AS{asn}) laid its own cables onto {n} continents and sells {mo} a month of capacity to other carriers, in {days} days. The oceans are your trench now.",
"broker.won_on_date":"Won on {date}: your own cables span the oceans, and carriers pay you to use them.",
"broker.your_glass_gear_is_already_yours":"As a Cable broker, every fiber, line system, optic, subsea cable and the routers to light them are yours already, whatever the level says.",
"bstd.all_up":"Everything meets the standard.",
"bstd.any_model":"any model",
"bstd.applied":{"one":"One job done for the build standard, {cost}.","other":"{n} jobs done for the build standard, {cost}."},
"bstd.applied_none":"Nothing could be done for the build standard right now.",
"bstd.apply_nothing":"Nothing below the standard",
"bstd.apply_now":"Bring everything up now · {cost}",
"bstd.apply_wait":"Nothing to do until those fibers are free",
"bstd.at_every_pop":"At every POP",
"bstd.at_least_n":"At least {n}",
"bstd.below":"Below the standard today",
"bstd.both_buildings":"Across both buildings",
"bstd.cost_mo":"Running costs",
"bstd.cost_now":"To bring it all up now",
"bstd.edit":"Edit the build standard",
"bstd.every_exchange":"Wherever there is an IX",
"bstd.fastest":"Fastest that reaches",
"bstd.fiber_note":"A line system swap takes the fiber dark for a day: only on a quiet fiber, or where a parallel link carries its load.",
"bstd.from_level":"(level {lv})",
"bstd.g_fiber":"Fiber and waves",
"bstd.g_port":"Ports and peering",
"bstd.generator":"generator",
"bstd.held":{"one":"One fiber keeps its line system for now, until it is quiet or a parallel link can carry its load for the day it goes dark. Until then it gets the fastest optics its line system takes.","other":"{n} fibers keep their line system for now, until they are quiet or a parallel link can carry their load for the day they go dark. Until then they get the fastest optics their line system takes."},
"bstd.hire_note":"Hire a NOC intern in Ops and they keep every POP, port and fiber to the standard: a few jobs a day, the busiest first, within a monthly budget and only with money to spare.",
"bstd.in_n_cities":"In at least {n} cities",
"bstd.intern_keeps":"{name} keeps the network to it",
"bstd.keep":"Keep as is",
"bstd.l_ix":"Exchange port",
"bstd.l_lag":"LAG members",
"bstd.l_model":"Router model",
"bstd.l_pni":"PNIs per network",
"bstd.l_site2":"Second building",
"bstd.l_split":"Split LAGs",
"bstd.left":{"one":"One thing is still below it, waiting for cash, a quiet fiber or an augment to land.","other":"{n} things are still below it, waiting for cash, a quiet fiber or an augment to land."},
"bstd.n_more_targets":{"one":"{n} more target","other":"{n} more targets"},
"bstd.new_pops_note":"A new POP gets these at once, while it is still empty: no maintenance window. Short on cash, it gets what fits. A model you have not unlocked yet means the best unlocked one below it.",
"bstd.none_set":"No standard yet: every target says Keep as is.",
"bstd.now_line":"Standard: {list}",
"bstd.or_better":"{x} or better",
"bstd.port_note":"LAGs and splits apply to transit, IX and PNI ports. A new PNI member is an augment and lands weeks later.",
"bstd.second_building":"second building",
"bstd.tagline":"One design for the whole network: what every POP, port and fiber should have. New POPs get the POP part the day they open; your intern, or the button below, brings the rest up to it.",
"bstd.title":"Build standard",
"businesses.a_free_pni_with_voda_phony":"A free PNI with Voda-Phony. Gear: Absolute Unit 3.2T routers, 3.2T ports and 12.8T waves.",
"businesses.agi_lab_allegedly":"AGI lab (allegedly)",
"businesses.agi_labs_allegedly_wanting_ai_wans":"AGI labs (allegedly) wanting AI WANs of 12.8 to 25.6 Tbps, and free PNIs with Du-opoly and Ooh-redoo. Gear: Mikrowtik CCR 3.2T routers.",
@ -3236,6 +3278,7 @@
"ops.l_routers":{"one":"upgraded routers in {where}","other":"upgraded routers in {n} places ({where})"},
"ops.l_rs":{"one":"joined a route server","other":"joined {n} route servers"},
"ops.l_snag":{"one":"got stuck on {where} and paused it until you have a look","other":"got stuck on {n} orders ({where}) and paused them until you have a look"},
"ops.l_std":{"one":"brought {where} up to the build standard","other":"did {n} jobs for the build standard ({where})"},
"ops.l_transit":{"one":"topped up transit in {where}","other":"topped up transit {n} times ({where})"},
"ops.locked":"The NOC hires interns from customer level {lv}.",
"ops.model_next":"Next generation, when busy",
@ -3269,6 +3312,8 @@
"ops.o_repair_d":"Pay for the rush repair on every outage that has one, while the budget lasts.",
"ops.o_routers":"Keep routers ahead",
"ops.o_routers_desc":"Add a router, or swap to the next generation where a second router carries the traffic, when load or ports pass a level. Pick a model, and every POP on a smaller one is swapped to it, the busiest first, within the budget.",
"ops.o_std":"Keep to the build standard",
"ops.o_std_d":"Bring POPs, ports and fiber up to your build standard, the busiest first, a few jobs a shift. A second router goes in before a swap, and a line system only changes on a quiet fiber.",
"ops.o_transit":"Keep transit headroom",
"ops.o_transit_d":"Keep transit at each POP above a multiple of its 30-day peak: add a LAG member, or move up a port size.",
"ops.ops":"Ops",
@ -3301,6 +3346,7 @@
"ops.template":"New POP from template",
"ops.template_note":"Pick what {name} sets up when you open a city from the template. The standing orders take it from there.",
"ops.tpl_bb":"Broadband",
"ops.tpl_bstd":"build standard",
"ops.tpl_done":"{name} opened {city}: {list}.",
"ops.tpl_ix":"IX port",
"ops.tpl_just_pop":"just the POP",
@ -3799,12 +3845,12 @@
"pnis.us_east_is_sold_out_until":"US East is sold out until further notice. Further notice is also sold out.",
"pop_std.city_gets_the_standard_cost":"{city} gets the standard: {n} × {model} for {cost}.",
"pop_std.clear":"Clear",
"pop_std.includes_the_build_standard":"Includes your build standard: {list}, {cost} + {mo}/mo. Short on cash, the POP gets what fits.",
"pop_std.includes_the_standard_n_model":"Includes your standard routers: {n} × {model}, {cost} + {mo}/mo. Short on cash, the POP gets what fits.",
"pop_std.make_this_the_standard":"Make this the standard",
"pop_std.new_pops_now_start_with":"New POPs now start with {n} × {model}.",
"pop_std.new_pops_now_start_with_list":"New POPs now start with {list}.",
"pop_std.none":"None",
"pop_std.not_all_of_the_standard":"Not enough cash or level for the whole standard in {city}: it got what fit.",
"pop_std.standard_for_new_pops":"Standard for new POPs",
"pops_transit_ix.40_off_for_6_months":"40% off for 6 months",
"pops_transit_ix.40_off_ix_for_6_months":"<b>40% off {ix} for 6 months.</b><br>Your account manager is relieved. Read the small print later.",
"pops_transit_ix.after_consulting_with_management_the":"<b>\"After consulting with management…\"</b><br>The price went up. Management was consulted.",

View file

@ -0,0 +1,518 @@
// The build standard: one target state for every POP, port and fiber, set in its own sheet, applied to new POPs at
// once, brought up by the intern's "Keep to the build standard" order or in one tap, and priced before anything changes.
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 (one Edge Lord, broadband, 100G Cogentle transit) and Amsterdam (one router, nothing on it yet), level 7,
// PNIs up the moment they are ordered and Change Freeze (no fat fingers, no dice).
const BASE = "ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=7;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');S.rules.pnis='instant';" +
"ACT.launchBB({city:'fra'});S.pops.fra.rgen=1;ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buildPop({city:'ams'});compute()";
const AU = "RG.findIndex(r=>r.n==='Absolute Unit 3.2T')";
const hire = ev => ev("ACT.opsHire({id:'kevin'});S.ops.floor=0;S.ops.cap.std=0;S.ops.on.std=true;closeModal()");
const shift = ev => ev('opsDay(S.day)');
function game(t, extra = '') {
const h = load();
t.after(() => h.dom.window.close());
h.ev(BASE);
if (extra) h.ev(extra);
return h;
}
const pop = (ev, c) => JSON.parse(ev(`JSON.stringify(S.pops.${c})`));
const std = (ev, d) => ev(`S.popStd=${lit(d)}`);
// A leased dark fiber between two POPs, built and lit with these optics.
const fiber = (ev, a, b, ch, sys = 'lite') => ev(`(()=>{const id=uid();S.links.push({id,a:'${a}',b:'${b}',kind:'df',own:false,sys:'${sys}',ch:${lit(ch)},km:Math.round(kmBetween('${a}','${b}')),sub:false,cable:null,mo:1000,trench:id,cut:0,day:S.day,ready:S.day,spares:false});return id;})()`);
test('the POP part: model, routers, second building and generator, the busiest POP first, at exactly what the plan priced', t => {
const { ev, errors } = game(t);
hire(ev);
std(ev, { g: ev(AU), rt: 2, site2: true, gen: true });
const q = JSON.parse(ev('JSON.stringify(bstdQuote(true))')), c0 = ev('S.cash');
assert.equal(q.pops, 2);
shift(ev);
for (const c of ['fra', 'ams']) {
const p = pop(ev, c);
assert.deepEqual([p.rgen, p.routers, !!p.site2, !!p.gen], [ev(AU), 2, true, true], c);
}
assert.equal(c0 - ev('S.cash'), q.cost, 'the shift paid what the plan said');
// Frankfurt has one router carrying broadband: a second went in first, so the swap rolled through.
assert.equal(ev("S.inc.some(i=>i.type==='maint')"), false, 'no maintenance window');
assert.match(ev('opsLine(S.ops.log[0])'), /build standard/);
assert.match(ev('opsLine(S.ops.log[0])'), /Frankfurt/);
assert.equal(ev('opsWhereOk(S.ops.log[0].r[0][2][0])'), true, 'the log survives a save');
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdPlan(true))')), [], 'nothing left to do');
// Its monthly books include the building and the generator now.
ev('compute()');
assert.equal(ev('opsMoNow()') > ev('2*(SITE2_MO+GEN_MO)'), true);
assert.deepEqual(errors, []);
});
test('a busy POP with one router never gets a maintenance window; never a step down; the core keeps its routers', t => {
const { ev, errors } = game(t);
hire(ev);
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
// A small budget: only the extra router fits this month, so the swap waits for it (and never goes ahead alone).
std(ev, { g: chonk, rt: 1 });
ev(`S.ops.cap.std=OPS_CAPS.find(c=>c>=routerCost(1,1)&&c<routerCost(1,1)+swapCostOf(${chonk},1,2))`);
shift(ev);
assert.deepEqual([pop(ev, 'fra').routers, pop(ev, 'fra').rgen], [2, 1], 'Frankfurt: a second router first, no swap yet');
assert.equal(pop(ev, 'ams').rgen || 0, 0, 'Amsterdam waits for the budget too');
assert.ok(ev("S.ops.log[0].r.some(x=>x[0]==='broke')"), 'the log says the budget ran out');
ev('{const m0=monthIdx(S.day);while(monthIdx(S.day)===m0)S.day++;}S.ops.cap.std=0;compute();opsDay(S.day)');
assert.deepEqual([pop(ev, 'fra').routers, pop(ev, 'fra').rgen], [2, chonk], 'then the swap rolls through');
assert.equal(ev("S.inc.some(i=>i.type==='maint')"), false);
// A smaller model as the standard: nobody is swapped back.
std(ev, { g: 1, rt: 1 });
ev('S.day++;compute();opsDay(S.day)');
assert.equal(pop(ev, 'fra').rgen, chonk);
// A POP in the backbone core is never swapped onto a model that cannot run it (the Whitebox 64 has no label stack for
// RSVP-TE): the best main-line model no bigger than it that can, instead.
const sonic = ev("RG.findIndex(r=>r.n==='Sonic the Whitebox 64')");
ev(`S.pops.ams.rgen=RG.findIndex(r=>r.n==='Arrrhipster 7280R');S.pops.ams.routers=2`);
std(ev, { g: sonic, rt: 1 });
assert.equal(ev("bstdModel(S.popStd.g,'ams')"), sonic, 'a plain IGP backbone takes any model');
ev('S.core={lv:2,run:2}');
assert.ok(ev("inCore('ams')"));
assert.equal(ev("bstdModel(S.popStd.g,'ams')"), chonk, 'RSVP-TE in the core: the Chonk 800 instead');
assert.deepEqual(errors, []);
});
test('budget, cash floor, per-POP exceptions; without an intern nothing runs and no dice are rolled', t => {
const { ev, errors } = game(t);
std(ev, { rt: 2, gen: true });
ev('S.ops.on.std=true');
const r = ev('window.__n=0;window.__r=Math.random;Math.random=()=>{__n++;return __r()};const s=JSON.stringify(S);opsDay(S.day);Math.random=__r;s===JSON.stringify(S)&&__n===0');
assert.equal(r, true, 'no intern: nothing happens, nothing random');
hire(ev);
// Amsterdam is excepted: the intern never touches it.
ev("S.ops.skip.ams=['std']");
// The floor: only what leaves the floor clear. A generator is $12k, a router more.
ev('S.ops.floor=50000;S.cash=50000+GEN_COST+1');
shift(ev);
assert.deepEqual([pop(ev, 'fra').gen, pop(ev, 'fra').routers], [true, 1], 'the generator fit above the floor, the router did not');
assert.ok(ev('S.cash') >= 50000, 'never below the floor');
assert.deepEqual([pop(ev, 'ams').gen, pop(ev, 'ams').routers], [false, 1], 'the excepted POP is untouched');
assert.equal(ev("bstdQuote(true).pops"), 1, 'the intern\'s own view leaves the exception out');
assert.equal(ev("bstdQuote(false).pops"), 2, 'the sheet still shows it below the standard');
// A monthly cap of setup fees.
ev("S.cash=1e8;S.ops.floor=0;S.ops.cap.std=10000;S.day++;opsDay(S.day)");
assert.equal(pop(ev, 'fra').routers, 1, 'a router is more than the budget');
assert.deepEqual(errors, []);
});
test('the bank that forbids generators gets none; DE-KICKS is skipped; an exchange port where there is one', t => {
const { ev, dom, errors } = game(t);
hire(ev);
ev("S.loans.push({id:'L1',bank:'storm',amount:1e6,covs:['nogen'],apr:0.05,term:24,pay:0,start:S.day,left:24})");
std(ev, { gen: true, ix: true });
assert.equal(ev('popStdQuote()'), null, 'a new POP is not quoted a generator either');
shift(ev);
assert.equal(pop(ev, 'fra').gen, false);
assert.equal(pop(ev, 'ams').gen, false);
assert.equal(ev("COVS.nogen.ok()"), true, 'the covenant holds');
// Frankfurt's exchange is DE-KICKS: that wants a sales call (a quote window), so the intern leaves it alone.
assert.equal(ev('isDk("fra")'), true);
assert.equal(ev('S.ixp.fra'), undefined);
assert.equal(ev('!!(S.dk&&S.dk.q)'), false, 'no DE-KICKS quote was asked for');
assert.equal(dom.window.document.getElementById('modal').hidden, true, 'and no window opened');
assert.equal(ev('S.ixp.ams'), 0, 'Amsterdam gets a 10G port');
ev('ACT.bstdApply()');
assert.equal(pop(ev, 'fra').gen, false, 'the button respects the covenant too');
assert.deepEqual(errors, []);
});
test('ports: LAG members up to the standard, split over both buildings; PNIs spread to more cities; never fewer members', t => {
const { ev, errors } = game(t);
hire(ev);
const net = ev("NETS.find(n=>n.pops.includes('fra')&&n.pops.includes('ams')&&pniMin(n.id)===0&&peerOk(n.id,'pni','ams').ok&&peerOk(n.id,'pni','fra').ok).id");
ev(`S.pops.fra.site2=true;S.pni.push({id:'P1',city:'fra',net:${lit(net)},tier:1,ready:S.day});ACT.buyIx({city:'ams',tier:1});(S.ixn=S.ixn||{}).ams=4;compute()`);
// The PNI list says a second one in Amsterdam is worth it.
ev(`const _v=pniVal;pniVal=(id,c)=>id===${lit(net)}&&c==='ams'?{..._v(id,c),worth:true,want:40,tier:1}:_v(id,c)`);
std(ev, { lag: 2, split: true, pni: 2 });
shift(ev);
const t0 = JSON.parse(ev('JSON.stringify(S.transit[0])'));
assert.deepEqual([t0.n, t0.site], [2, 'ab'], 'transit: a second member, split over both buildings');
const p = JSON.parse(ev(`JSON.stringify(S.pni.find(x=>x.id==='P1'))`));
assert.deepEqual([p.n, p.site], [2, 'ab'], 'the PNI too');
assert.equal(ev('S.ixn.ams'), 4, 'a bigger LAG stays as it is');
assert.equal(ev(`S.pni.filter(x=>x.net===${lit(net)}).length`), 2, 'a PNI in a second city');
assert.ok(ev(`S.pni.some(x=>x.net===${lit(net)}&&x.city==='ams')`));
assert.equal(ev("S.ixSite&&S.ixSite.ams"), undefined, 'Amsterdam has one building: nothing to split');
assert.deepEqual(errors, []);
});
test('fiber: the line system only on a quiet fiber or with a parallel link, one a shift; faster optics, old ones on the shelf; bigger waves', t => {
const { ev, errors } = game(t);
hire(ev);
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`ACT.buildPop({city:'par'});for(const c of ['fra','ams','par']){S.pops[c].rgen=${chonk};S.pops[c].routers=4;}`);
const a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']), b = fiber(ev, 'fra', 'par', ['zr4']);
ev("compute();for(const l of S.links)R.load[l.id]=0");
std(ev, { sys: 'roadm', opt: 'fast' });
const cap0 = ev(`S.links.find(l=>l.id===${lit(a)}).ch.reduce((s,o)=>s+optG(o,S.links.find(l=>l.id===${lit(a)})),0)`);
shift(ev);
const L = id => JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(id)}))`));
assert.deepEqual([L(a).sys, L(b).sys].sort(), ['lite', 'roadm'], 'one fiber goes dark per shift');
const up = L(a).sys === 'roadm' ? a : b, other = up === a ? b : a;
assert.equal(L(up).eqDown, ev('S.day+1'));
assert.ok(L(up).ch.every(o => o === 'tp16'), 'its optics are the fastest that reach on the new line system: ' + L(up).ch);
// The other one only waits its turn: no optics in between that its own swap would put on the shelf a day later.
assert.ok(L(other).ch.every(o => o === 'zr4'), 'a quiet fiber waiting its turn keeps its optics: ' + L(other).ch);
assert.equal(ev('S.spares.zr4'), L(up).ch.length, 'the old optics of the swapped fiber went on the shelf');
assert.equal(ev('S.spares.zr8'), undefined, 'and no stand-in optics were bought');
// Busy and alone between its cities: it keeps its line system, and gets the fastest optics that one takes.
ev(`S.day+=2;compute();R.load[${lit(other)}]=capOf(S.links.find(l=>l.id===${lit(other)}))*0.9;opsDay(S.day)`);
assert.equal(L(other).sys, 'lite', 'not while it is busy and alone');
assert.ok(L(other).ch.every(o => o === 'zr8'), 'the fastest the old line system takes: ' + L(other).ch);
assert.equal(ev('S.spares.zr4'), 3, 'all the old optics went on the shelf');
// A parallel wave with room carries its load: now it can go dark for a day, and gets the bigger optics.
ev(`const o=S.links.find(l=>l.id===${lit(other)});UI.lmode='wave';UI.pending={a:o.a,b:o.b};ACT.buildLink({tier:3});S.day++;compute();R.load[o.id]=capOf(o)*0.9;for(const l of S.links)if(l.kind==='wave')R.load[l.id]=0;opsDay(S.day)`);
assert.equal(L(other).sys, 'roadm');
assert.ok(L(other).ch.every(o => o === 'tp16'), L(other).ch);
assert.equal(ev('S.spares.zr8'), L(other).ch.length);
const cap1 = ev(`S.links.find(l=>l.id===${lit(a)}).ch.reduce((s,o)=>s+optG(o,S.links.find(l=>l.id===${lit(a)})),0)`);
assert.ok(cap1 > cap0, `capacity went up: ${cap0} → ${cap1}`);
// Waves: a bigger one than the standard stays as it is; a smaller one goes up.
const w = ev("S.links.find(l=>l.kind==='wave').id");
assert.equal(L(w).tier, 3);
std(ev, { wv: 2 });
ev('S.day++;compute();opsDay(S.day)');
assert.equal(L(w).tier, 3, 'an 800G wave is never made smaller');
std(ev, { wv: 3 });
ev(`S.links.find(l=>l.id===${lit(w)}).tier=1;S.day++;compute();opsDay(S.day)`);
assert.equal(L(w).tier, 3, 'a 100G wave goes up to 800G');
assert.deepEqual(errors, []);
});
test('quiet fibers take their line system one a shift and buy nothing in between: the intern spends what the quote said', t => {
const { ev, errors } = game(t);
hire(ev);
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`ACT.buildPop({city:'par'});ACT.buildPop({city:'lon'});for(const c of ['fra','ams','par','lon']){S.pops[c].rgen=${chonk};S.pops[c].routers=4;}`);
const ids = ['ams', 'par', 'lon'].map(c => fiber(ev, 'fra', c, ['zr4', 'zr4']));
const quiet = 'compute();for(const l of S.links)R.load[l.id]=0';
ev(quiet);
std(ev, { sys: 'roadm', opt: 'fast' });
const q = JSON.parse(ev('JSON.stringify(bstdQuote(true))')), c0 = ev('S.cash');
assert.deepEqual([q.links, q.held], [3, []]);
for (let d = 1; d <= 3; d++) {
ev(`${quiet};opsDay(S.day);S.day++`);
const ls = ids.map(id => JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(id)}))`)));
assert.equal(ls.filter(l => l.sys === 'roadm').length, d, 'one more fiber a shift');
for (const l of ls) assert.deepEqual(l.ch, l.sys === 'roadm' ? ['tp16', 'tp16'] : ['zr4', 'zr4'], 'tp16 on the new line system, the old optics until then');
assert.equal(ev('S.spares.zr8'), undefined, 'no optics bought only to be shelved a day later');
}
assert.equal(c0 - ev('S.cash'), q.cost, 'three shifts spent exactly the quote');
assert.deepEqual(errors, []);
});
test('an optics swap is checked at what it costs when it runs: a refused job before it never lets one past the floor or the cap', t => {
const { ev, errors } = game(t);
hire(ev);
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`ACT.buildPop({city:'par'});for(const c of ['fra','ams','par']){S.pops[c].rgen=${chonk};S.pops[c].routers=4;}`);
// Paris's fiber is the hotter one: its zr8s go to tp16 first and onto the shelf, where Amsterdam's swap expects them.
const b = fiber(ev, 'fra', 'par', ['zr8', 'zr8'], 'roadm'), a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']);
const loads = `compute();for(const l of S.links)R.load[l.id]=0;R.load[${lit(b)}]=50;`;
ev(`S.spares={};${loads}`);
std(ev, { opt: 'fast' });
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdPlan(true).map(j=>[j.w,j.cost]))')), [['fra|par', 140000], ['fra|ams', 0]], 'priced as if the first one ran');
const ch = id => JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(id)}).ch)`));
// The first is more than the budget: the second is not free then, and the cap and the floor see its real price.
ev(`S.ops.cap.std=10000;S.ops.floor=50000;S.cash=80000;S.ops.spent={};${loads}opsDay(S.day)`);
assert.equal(ev('S.cash'), 80000, 'nothing spent past the cap or the floor');
assert.deepEqual([ch(a), ch(b)], [['zr4', 'zr4'], ['zr8', 'zr8']]);
assert.ok(ev("S.ops.log[0].r.some(x=>x[0]==='broke')"), 'the log says the money ran out');
ev(`S.ops.cap.std=0;S.day++;${loads}opsDay(S.day)`);
assert.equal(ev('S.cash'), 80000, 'no cap: the floor alone still holds');
// Exactly enough above the floor for Amsterdam's own zr8s, bought new: it goes ahead, down to the floor and no further.
ev(`S.cash=50000+2*optCost('zr8');S.day++;${loads}opsDay(S.day)`);
assert.deepEqual(ch(a), ['zr8', 'zr8']);
assert.equal(ev('S.cash'), 50000);
// The button checks the price at the click too: never more than the cash in hand.
std(ev, { opt: 'fast' });
ev(`S.spares={};S.links.find(l=>l.id===${lit(a)}).ch=['zr4','zr4'];S.cash=30000;${loads}ACT.bstdApply()`);
assert.deepEqual(ch(a), ['zr4', 'zr4'], 'two zr8 at $44k do not fit $30k');
assert.equal(ev('S.cash'), 30000);
assert.deepEqual(errors, []);
});
test('a busy fiber with nothing parallel keeps its line system: the sheet, the button and the MCP quote say what the click buys', t => {
const h = load({ agent: true });
t.after(() => h.dom.window.close());
const { ev, errors } = h;
ev(BASE);
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`for(const c of ['fra','ams']){S.pops[c].rgen=${chonk};S.pops[c].routers=4;}`);
const a = fiber(ev, 'fra', 'ams', Array(6).fill('zr4'));
const busy = `compute();R.load[${lit(a)}]=capOf(S.links.find(l=>l.id===${lit(a)}))*0.9;`;
// tp16 on the shelf: the quote must not count on a line-system swap that will not happen today.
ev(`S.spares={tp16:6};${busy}`);
std(ev, { sys: 'roadm', opt: 'fast' });
const q = JSON.parse(ev('JSON.stringify(bstdQuote(false))'));
assert.deepEqual([q.held, q.links, q.n], [['fra|ams'], 1, 1]);
assert.equal(q.cost, 6 * ev("optCost('zr8')"), 'six zr8 for the line system it keeps');
ev(`closeModal();${busy}`);
const dry = JSON.parse(ev("JSON.stringify(apiRun('bstdApply',{},{dryRun:true}))"));
assert.equal(dry.quote.setup, q.cost, 'the MCP quote is the same bill');
assert.match(dry.quote.blocked[0], /^Frankfurt–Amsterdam: its line system waits/);
ev(`${busy}ACT.bstdOpen()`);
const doc = h.dom.window.document;
assert.match(doc.getElementById('modalCard').textContent, /One fiber keeps its line system for now/);
assert.equal(doc.querySelector('#modalCard [data-act="bstdApply"]').textContent, `Bring everything up now · ${ev(`fmt$(${q.cost})`)}`);
const c0 = ev('S.cash');
ev(`${busy}document.querySelector('#modalCard [data-act="bstdApply"]').click()`);
assert.equal(c0 - ev('S.cash'), q.cost, 'the click spent the quote');
const l = JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(a)}))`));
assert.deepEqual([l.sys, l.ch], ['lite', Array(6).fill('zr8')], 'and bought what it listed');
assert.deepEqual(JSON.parse(ev('JSON.stringify(S.spares)')), { tp16: 6, zr4: 6 });
// Two busy fibers that carry each other: one goes dark, the other waits for tomorrow, and the quote knew.
const b = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']);
ev(`S.links.find(l=>l.id===${lit(a)}).ch=['zr4','zr4']`);
const both = `compute();for(const id of [${lit(a)},${lit(b)}])R.load[id]=capOf(S.links.find(l=>l.id===id))*0.4;`;
ev(both);
const q2 = JSON.parse(ev('JSON.stringify(bstdQuote(false))')), c1 = ev('S.cash');
assert.deepEqual([q2.links, q2.held.length], [2, 1]);
ev(`${both}ACT.bstdApply()`);
assert.equal(c1 - ev('S.cash'), q2.cost);
assert.deepEqual(JSON.parse(ev(`JSON.stringify([${lit(a)},${lit(b)}].map(id=>S.links.find(l=>l.id===id).sys).sort())`)), ['lite', 'roadm'], 'never both dark on the same day');
assert.deepEqual(errors, []);
});
test('optics a new router model takes are on the bill with it, and wait for its swap', t => {
const { ev, errors } = game(t);
// Edge Lords take no zr8: the Absolute Unit does.
ev('S.pops.ams.rgen=1;S.pops.fra.routers=2;S.pops.ams.routers=2');
const a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']);
ev('compute()');
assert.equal(ev("RG[1].cls<OPT.zr8.rg"), true);
std(ev, { g: ev(AU), rt: 2, opt: 'fast' });
const plan = JSON.parse(ev("JSON.stringify(bstdPlan(false).map(j=>[j.k,j.w,j.dep?j.dep.length:0]))"));
assert.deepEqual(plan.filter(j => j[0] === 'opt'), [['opt', 'fra|ams', 2]], 'the optics wait for both swaps');
// The intern: the swaps are over the budget, so the optics are not pulled out and put back.
hire(ev);
ev('S.ops.cap.std=50000;compute();opsDay(S.day)');
assert.deepEqual(JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(a)}).ch)`)), ['zr4', 'zr4']);
assert.ok(!(ev('S.ops.spent.std') > 0));
// The button: the swaps and the optics, exactly the quote, and nothing left over.
ev('S.ops.on.std=false;compute()');
const q = JSON.parse(ev('JSON.stringify(bstdQuote(false))')), c0 = ev('S.cash');
ev('ACT.bstdApply()');
assert.equal(c0 - ev('S.cash'), q.cost);
assert.deepEqual(JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(a)}).ch)`)), ['zr8', 'zr8']);
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(false))')), { cost: 0, mo: 0, pops: 0, ports: 0, links: 0, n: 0, held: [] }, 'one tap brought everything up');
assert.deepEqual(errors, []);
});
test('waves the decom order is about to hand back are never upgraded first', t => {
const { ev, errors } = game(t);
hire(ev);
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`for(const c of ['fra','ams']){S.pops[c].rgen=${chonk};S.pops[c].routers=4;}`);
ev("UI.lmode='wave';UI.pending={a:'fra',b:'ams'};ACT.buildLink({tier:3});for(let i=0;i<2;i++){UI.pending={a:'fra',b:'ams'};UI.route='diverse';ACT.buildLink({tier:1});}compute()");
const waves = () => JSON.parse(ev("JSON.stringify(S.links.filter(l=>l.kind==='wave').map(l=>l.tier))"));
assert.deepEqual(waves(), [3, 1, 1]);
std(ev, { wv: 2 });
assert.equal(ev('bstdQuote(true).n'), 2, 'without decom both small waves go up');
ev('S.ops.on.decom=true');
const q = JSON.parse(ev('JSON.stringify(bstdQuote(true))'));
assert.equal(q.n, 1, 'decom keeps one spare in another trench and hands the other back: only the spare goes up');
const c0 = ev('S.cash');
ev('S.day++;compute();opsDay(S.day)');
assert.deepEqual(waves(), [3, 2], 'the spare went up, the other went back');
assert.equal(c0 - ev('S.cash'), q.cost, 'no month of rent paid on a wave that went back');
assert.deepEqual(JSON.parse(ev('JSON.stringify(S.ops.log[0].r.map(x=>[x[0],x[1]]))')), [['std', 1], ['decom', 1]]);
assert.deepEqual(errors, []);
});
test('a new POP gets the whole POP standard, priced on the button; the template\'s kit never pays for it twice', t => {
const { ev, dom, errors } = game(t);
std(ev, { g: ev(AU), rt: 2, site2: true, gen: true, lag: 2 });
const q = JSON.parse(ev('JSON.stringify(popStdQuote())'));
assert.deepEqual([q.g, q.rt, q.site2, q.gen], [ev(AU), 2, true, true]);
ev("selectCity('par');renderPanel()");
assert.match(dom.window.document.getElementById('panelBody').textContent, /Includes your build standard: 2 × Absolute Unit 3\.2T, second building, generator/);
let c0 = ev('S.cash');
ev("ACT.buildPop({city:'par'})");
assert.equal(c0 - ev('S.cash'), ev("popCost('par')") + q.cost, 'the button\'s price is what it costs');
const p = pop(ev, 'par');
assert.deepEqual([p.rgen, p.routers, p.site2, p.gen], [ev(AU), 2, true, true]);
// The template: broadband, transit, an IX port and the kit, all with the standard. The kit has nothing left to add.
hire(ev);
const tq = JSON.parse(ev("JSON.stringify(opsTplQuote('lon'))"));
assert.equal(tq.kit, false, 'the standard already has the generator, the building and the second router');
assert.ok(tq.parts.includes('build standard'));
c0 = ev('S.cash');
ev("ACT.opsNewPop({city:'lon'})");
assert.equal(c0 - ev('S.cash'), tq.cost, 'the template costs what it quoted');
assert.equal(pop(ev, 'lon').gen, true);
// Without a generator in the standard, the kit adds just that.
std(ev, { g: ev(AU), rt: 2, site2: true });
const tq2 = JSON.parse(ev("JSON.stringify(opsTplQuote('mad'))"));
assert.equal(tq2.kit, true);
c0 = ev('S.cash');
ev("ACT.opsNewPop({city:'mad'})");
assert.equal(c0 - ev('S.cash'), tq2.cost);
assert.deepEqual([pop(ev, 'mad').gen, pop(ev, 'mad').routers], [true, 2]);
assert.deepEqual(errors, []);
});
test('"Bring everything up now" spends what the quote said and does what it listed; the quote changes nothing', t => {
const { ev, errors } = game(t);
ev(`S.pops.fra.routers=2;S.pops.fra.site2=true;ACT.buyIx({city:'ams',tier:0})`);
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`for(const c of ['fra','ams'])S.pops[c].rgen=${chonk}`);
fiber(ev, 'fra', 'ams', ['zr4']);
ev("compute()");
std(ev, { g: ev(AU), rt: 3, site2: true, gen: true, lag: 2, split: true, ix: true, sys: 'roadm', opt: 'fast' });
const s0 = ev('JSON.stringify(S)');
const q = JSON.parse(ev('JSON.stringify(bstdQuote(false))'));
ev('ACT.bstdOpen()');
assert.equal(ev('JSON.stringify(S)'), s0, 'the quote and the sheet leave the game alone');
assert.ok(q.n > 0 && q.pops === 2 && q.ports >= 2 && q.links === 1, JSON.stringify(q));
const c0 = ev('S.cash');
ev("document.querySelector('#modalCard [data-act=\"bstdApply\"]').click()");
assert.equal(c0 - ev('S.cash'), q.cost, 'it cost exactly the quote');
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(false))')), { cost: 0, mo: 0, pops: 0, ports: 0, links: 0, n: 0, held: [] }, 'and everything is up to the standard');
assert.match(ev("document.getElementById('toasts').textContent"), /jobs done for the build standard/);
assert.match(ev("document.getElementById('modalCard').textContent"), /Everything meets the standard/);
assert.equal(ev('S.ixSite.ams'), 'ab');
assert.deepEqual(errors, []);
});
test('saves: an old {g, rt} standard loads unchanged and still means the same; junk is repaired; none stays none', t => {
const { ev, errors } = game(t);
const back = d => ev(`(()=>{const s=JSON.parse(JSON.stringify(S));s.popStd=${d};sanitize(s);return JSON.stringify(s.popStd);})()`);
assert.deepEqual(JSON.parse(back(`{g:${ev(AU)},rt:2}`)), { g: ev(AU), rt: 2 }, 'an old standard is exactly the routers it was');
assert.equal(back('undefined'), 'null', 'an old save without one');
assert.equal(back('null'), 'null');
assert.equal(back("'x'"), 'null');
assert.deepEqual(JSON.parse(back("{g:'x',rt:'7',site2:'yes',gen:true,lag:3,split:1,ix:true,pni:9,sys:'warp',opt:'fast',wv:99}")), { rt: 7, gen: true, ix: true, opt: 'fast' }, 'each odd value reads as keep');
assert.equal(back('{g:999}'), 'null', 'nothing left is no standard');
// The old meaning: a new POP gets those routers, and nothing else is done anywhere unless the order is switched on.
ev(`S=migrate(JSON.parse(JSON.stringify(Object.assign(S,{popStd:{g:${ev(AU)},rt:2}}))));delete S.ops.on.std;S=migrate(JSON.parse(JSON.stringify(S)))`);
assert.equal(ev('S.ops.on.std'), false, 'an old save has the order off');
ev("ACT.buildPop({city:'par'})");
assert.deepEqual([pop(ev, 'par').rgen, pop(ev, 'par').routers, !!pop(ev, 'par').site2, !!pop(ev, 'par').gen], [ev(AU), 2, false, false]);
// A model smaller than the basic router (the Mikrowtik has more ports) is still what a new POP gets, as it always was.
const mk = ev("RG.findIndex(r=>r.n==='Mikrowtik CCR')");
assert.ok(ev(`RG[${mk}].cap<RG[0].cap`));
ev(`S=migrate(JSON.parse(JSON.stringify(Object.assign(S,{popStd:{g:${mk},rt:2}}))))`);
assert.deepEqual(JSON.parse(ev('JSON.stringify(S.popStd)')), { g: mk, rt: 2 });
assert.equal(ev('popStdQuote().g'), mk);
ev("ACT.buildPop({city:'mad'})");
assert.deepEqual([pop(ev, 'mad').rgen, pop(ev, 'mad').routers], [mk, 2]);
// Make this the standard copies the POP part of a POP and keeps the other targets, and says what it copied.
ev("S.pops.ams.site2=true;S.pops.ams.gen=true;S.popStd={g:0,rt:1,lag:2}");
ev("ACT.popStdSet({city:'ams'})");
assert.deepEqual(JSON.parse(ev('JSON.stringify(S.popStd)')), { g: 0, rt: 1, site2: true, gen: true, lag: 2 });
assert.match(ev("document.getElementById('toasts').textContent"), /New POPs now start with 1 × Rusty Router 9000, second building, generator\./);
// The router section names the whole standard, not just what new POPs get.
ev("selectCity('ams');ACT.tab({t:'links'})");
const txt = ev("document.getElementById('panelBody').textContent");
assert.match(txt, /Build standard1 × Rusty Router 9000, second building, generator, 1 more target/);
assert.doesNotMatch(txt, /Standard for new POPs/);
assert.deepEqual(errors, []);
});
test('the sheet at 360 px in every language: every list works by changing it, from the menu, the Ops sheet and the city panel', () => {
for (const lang of ['en', 'de', 'es', 'fr', 'it', 'pt']) {
const h = load(lang === 'en' ? {} : { lang });
const { ev, dom, errors } = h;
ev(BASE);
dom.window.innerWidth = 360;
const doc = dom.window.document;
const leaks = () => {
const txt = doc.getElementById('modalCard').textContent;
assert.doesNotMatch(txt, /\b(bstd|ops|pop_std|common)\.[a-z_]+/, lang + ': a raw label');
assert.doesNotMatch(txt, /\{[a-z]\w*\}|undefined|NaN/, lang);
};
ev('ACT.menu()');
doc.querySelector('#modalCard [data-act="bstdOpen"]').click();
assert.ok(ev('bstdShown()'), lang + ': from the menu');
leaks();
// Every target is a list; pick its last value and the standard follows, the sheet stays open and in focus.
const keys = JSON.parse(ev('JSON.stringify(BSTD.map(x=>x.k))'));
assert.equal(doc.querySelectorAll('#modalCard select[data-chg="bstdSet"]').length, keys.length);
for (const k of keys) {
const s = [...doc.querySelectorAll('#modalCard select[data-chg="bstdSet"]')].find(x => JSON.parse(x.dataset.args).k === k);
assert.ok(s.closest('.ops-sel'), 'the Ops sheet\'s two-to-a-row lists');
s.value = String(s.options.length - 1);
s.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
assert.ok(ev('bstdShown()'), lang + ' ' + k);
assert.equal(doc.activeElement && doc.activeElement.dataset.args, JSON.stringify({ k }), 'the keyboard stays on the list');
assert.notEqual(ev(`bstd()[${lit(k)}]`), ev(`BSTDK[${lit(k)}].d`), lang + ' ' + k);
}
leaks();
if (lang === 'fr') assert.match(doc.getElementById('modalCard').textContent, /Répartis sur les deux bâtiments/, 'LAG is masculine');
// The Ops sheet has a way in before anyone is hired too.
ev('ACT.opsOpen()');
assert.equal(ev('opsHired()'), false);
doc.querySelector('#modalCard [data-act="bstdOpen"]').click();
assert.ok(ev('bstdShown()'), lang + ': from the Ops sheet with no intern');
// The intern's switch and budget sit in the sheet once one is hired, and stay there when used.
ev("ACT.opsHire({id:'annie'});closeModal();ACT.bstdOpen()");
doc.querySelector('#modalCard [data-act="opsToggle"]').click();
assert.ok(ev('S.ops.on.std') && ev('bstdShown()'), lang);
const cap = doc.querySelector('#modalCard select[data-chg="opsCap"]');
cap.value = String(cap.options.length - 1);
cap.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
assert.equal(ev("opsCap('std')"), 0, lang);
assert.ok(ev('bstdShown()'), lang);
leaks();
// From the Ops sheet and the city panel.
ev('ACT.opsOpen()');
doc.querySelector('#modalCard [data-act="bstdOpen"]').click();
assert.ok(ev('bstdShown()'), lang + ': from the Ops sheet');
ev("closeModal();selectCity('fra');ACT.tab({t:'links'})");
assert.doesNotMatch(doc.getElementById('panelBody').textContent, /\b(bstd|pop_std)\.[a-z_]+/, lang);
doc.querySelector('#panelBody [data-act="bstdOpen"]').click();
assert.ok(ev('bstdShown()'), lang + ': from the city panel');
assert.deepEqual(errors, [], lang);
dom.window.close();
}
});
test('puzzles have no standard; the MCP tools see every action', () => {
const { ev, errors } = load();
ev(BASE);
std(ev, { rt: 2 });
ev("ACT.puzzleMenu();ACT.pzStart({id:PZ[0].id})");
assert.ok(ev('pzOn()'));
assert.equal(ev('popStdQuote()'), null);
assert.equal(ev('bstdPlan(false).length'), 0);
ev("ACT.bstdSet({k:'rt'})");
assert.equal(ev('bstdShown()'), false);
assert.deepEqual(errors, []);
});
test('the big network: one shift of the order takes a few milliseconds', t => {
const { ev, errors } = load({ seed: 3 });
t.after(() => ev('0'));
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()`);
ev(`S.ops.intern='kevin';S.ops.on.std=true;S.ops.floor=0;S.ops.cap.std=0;S.rules.pnis='instant';S.popStd={g:${AU},rt:2,site2:true,gen:true,lag:2,split:true,ix:true,pni:2,sys:'cl',opt:'fast',wv:4}`);
const plan = ev('(()=>{const t=performance.now();for(let i=0;i<5;i++)bstdPlan(true);return (performance.now()-t)/5;})()');
const jobs = ev('bstdPlan(true).length');
const shiftMs = ev('(()=>{const t=performance.now();opsDay(S.day);return performance.now()-t;})()');
console.log(`# big network: plan ${plan.toFixed(1)} ms (${jobs} jobs), one shift ${shiftMs.toFixed(1)} ms with its recompute`);
assert.ok(jobs > 0);
assert.ok(plan < 250, 'planning stays cheap: ' + plan);
assert.ok(ev("S.ops.log[0].r.find(x=>x[0]==='std')[1]") <= ev('BSTD_MAX'), 'a few jobs a shift');
// Second buildings the month's budget cannot pay for: the LAG splits that need them wait with them, instead of being
// tried (two opsMoNow runs each) and failing at every POP, every shift.
ev('for(const t of S.transit)t.n=Math.max(2,t.n||1);S.ixn=S.ixn||{};for(const x in S.ixp)if(!S.myIx[x])S.ixn[x]=Math.max(2,S.ixn[x]||1);for(const p of S.pni)if(pniOn(p)&&!p.up)p.n=Math.max(2,p.n||1)');
ev('for(const k in S.ops.on)S.ops.on[k]=false;S.ops.on.std=true;S.popStd={rt:1,site2:true,split:true};S.ops.cap.std=OPS_CAPS[0];window.__m=0;const _m=opsMoNow;opsMoNow=function(){__m++;return _m.apply(this,arguments);};compute()');
assert.ok(ev("bstdPlan(true).filter(j=>j.k==='split'&&j.dep).length") > 100, 'many splits wait for a building');
for (let d = 0; d < 3; d++) {
const ms = ev("(()=>{__m=0;S.day++;S.ops.mon=monthIdx(S.day);S.ops.spent.std=OPS_CAPS[0];const t=performance.now();opsDay(S.day);return performance.now()-t;})()");
const did = ev("(S.ops.log[0].d===S.day&&(S.ops.log[0].r.find(x=>x[0]==='std')||[])[1])||0");
console.log(`# big network, budget spent: shift ${ms.toFixed(1)} ms, ${did} splits done, ${ev('__m')} opsMoNow runs`);
assert.equal(ev('__m'), 2 * did, 'every job tried was one that could be done');
assert.ok(did <= ev('BSTD_MAX'));
}
assert.deepEqual(errors, []);
});

View file

@ -35,7 +35,9 @@ function tour(ev) {
['scenarios', 'scenarioModal();closeModal()'], ['trace', "traceModal('fra');closeModal()"],
['route script', 'S.lvl=Math.max(S.lvl,3);S.cash+=1e6;ACT.coreUp();ACT.coreUp();ACT.buyTE();ACT.teEdit();ACT.teExample();ACT.teCheck();closeModal()'],
['routers', "selectCity('fra');ACT.tab({t:'links'});ACT.models()"], ['vxc', "openVxcModal({from:'fra',to:'ams'});closeModal()"],
['tutorial', 'S.tut=0;renderCoach();S.tut=3;renderCoach();S.tut=null;renderCoach()'], ['win', 'showWin()']]) step(label, src);
['tutorial', 'S.tut=0;renderCoach();S.tut=3;renderCoach();S.tut=null;renderCoach()'], ['win', 'showWin()'],
// The build standard sheet with every target set (and the game left as it was).
['build standard', "{const was=S.popStd;S.popStd={g:3,rt:2,site2:true,gen:true,lag:2,split:true,ix:true,pni:2,sys:'roadm',opt:'fast',wv:2};ACT.bstdOpen();S.popStd=was;closeModal()}"]]) step(label, src);
const failSrc = ev('fireFailure.toString()');
for (const t of ['harmless', 'fatwave', 'label', 'mtu', 'oops', 'cleaner', 'prepend', 'rpki', 'amp', 'roadmff', 'optic', 'ac', 'cut', 'crash', 'power', 'transit', 'ixloop', 'leak', 'ddos']) {
const kind = ['harmless', 'fatwave', 'label', 'mtu', 'oops', 'cleaner', 'prepend', 'rpki', 'roadmff', 'ac'].includes(t) ? 'funny' : t;

View file

@ -318,6 +318,30 @@ test('the dashboard, the bank, the left drawer and the puzzle box read as text;
assert.deepEqual(s.errors(), []);
});
test('a list in a sheet sends its own arguments with the value picked: the build standard and the intern\'s budget', () => {
const { s, T, ev } = sandbox({ pops: [] });
act(T, 'bstdOpen');
const list = (sel, k) => T('screen').buttons.find((b) => b.select === sel && b.args && b.args.k === k);
const g = list('bstdSet', 'g');
assert.ok(g, 'the router model list, with its target');
const v = g.options[g.options.length - 1].value;
assert.equal(T('click', { button: g.n, value: v }).outcome, 'applied');
assert.equal(ev('S.popStd.g'), ev(`bstdOpts('g')[${v}]`));
const lag = list('bstdSet', 'lag');
assert.equal(T('click', { button: lag.n, value: '1' }).outcome, 'applied');
assert.equal(ev('S.popStd.lag'), 2);
ev('closeModal()');
act(T, 'opsHire', { id: ev('Object.keys(INTERNS)[0]') });
ev('closeModal()');
act(T, 'opsToggle', { k: 'std' });
act(T, 'opsOpen');
const cap = list('opsCap', 'std');
assert.ok(cap, 'the order\'s budget list');
assert.equal(T('click', { button: cap.n, value: String(cap.options.length - 1) }).outcome, 'applied');
assert.equal(ev("opsCap('std')"), 0, 'no limit');
assert.deepEqual(s.errors(), []);
});
test('new_game takes your own ASN and the sandbox chaos dial', () => {
const s = createSession(), T = tools(s), ev = (x) => s.game.ev(x);
assert.equal(T('new_game', { city: 'ams', asn: 213337, seed: 2 }).asn, 213337);