Merge v2 into v2-weekly
This commit is contained in:
commit
faac3427f3
39 changed files with 729 additions and 120 deletions
18
CHANGELOG.md
18
CHANGELOG.md
|
|
@ -10,15 +10,13 @@ All notable changes to this project are documented here. The project follows
|
|||
- A new start screen with four doors: Puzzles, Sandbox, Normal, and Scenarios & weekly. Every network now picks its rules when it starts, and they stay locked for that network; your saved games carry on exactly as before.
|
||||
- Normal comes in three flavours. Change Freeze has a third of the outages and no DDoS floods, delivers PNIs, cross-connects and builds in days instead of months (#151), and skips the peering inbox, hardware shortages and sold-out routes. On-call is the classic game. BGP at 3 a.m. brings almost twice the outages, lasting half as long again, and twice the DDoS. The HUD and the share card show which one you picked.
|
||||
- Sandbox is a real sandbox now (#188): everything is unlocked from day one, your own subsea cable included, money never runs out, deliveries are quick, and you pick how much chaos you want, from none to spicy.
|
||||
- Puzzles: small, calm network builds you can finish in a coffee break (#190). Connect a few cities on the real map with POPs and leased waves, with no clock, no bills and nothing breaking, and earn up to three stars: one for the goal, one for staying under budget, and one if the network survives any single cut. Eighteen puzzles in four packs (more stars open the next pack), some with a twist like a latency target, no subsea cables or a ring, plus a weekly puzzle that is the same for everyone, with a streak and a result to share. Puzzles never touch your saved network; only your stars are kept.
|
||||
- Puzzles: small, calm network builds you can finish in a coffee break (#190). Connect a few cities on the real map with POPs and leased waves, with no clock, no bills and nothing breaking, and earn up to three stars: one for the goal, one for staying under budget, and one if the network survives any single cut (a trench, or a whole cable). Eighteen puzzles in four packs, with roomy budgets at first and tighter ones as you go (more stars open the next pack), some with a twist like a latency target, no subsea cables or a ring, plus a weekly puzzle that is the same for everyone, with a streak and a result to share. Puzzles never touch your saved network; only your stars are kept.
|
||||
- Tier 1 now works like the real thing: peer with the Tier 1 club and their customers come along for free (#85). A PNI or an exchange session reaches the networks you peer with and everyone who buys transit from them, so you no longer chase every tiny ISP for the win; only networks that buy transit from nobody, like the content giants and the big incumbents, still need peering of their own. Small networks and more real eyeball ISPs now buy transit from real-world upstreams, a peer's customers are tried after your direct peers and before transit (so peering widely still pays), the traceroute shows the hand-off, and the Road to Tier 1 card counts who already comes along. Games already won stay won.
|
||||
- Badges now come in variants: games under the Change Freeze rules earn frosted Freeze-dried badges, and games under BGP at 3 a.m. earn fiery ones worth bragging about. Earning a badge again under harder rules upgrades its look, and the badge list counts your collection of each kind on this device. On-call games earn the standard badges; Sandbox and puzzles earn none.
|
||||
- China Telecomet now sells its CN-Too premium crossing in Moscow too, at the same price as in Hong Kong (#195). Haul your European traffic to Moscow and it reaches China with about 3% loss; nothing else of theirs is on offer there.
|
||||
- Series of Tubes now speaks German. The game follows your browser's language the first time, and you can switch to German under Settings or on the title screen. Networking terms like Peering and Transit stay in English, the way network engineers say them.
|
||||
- Glowball Sakura Lager joins the map: a Tier 2 carrier in the big hubs of the US, Europe and Asia-Pacific that sells transit, takes PNIs and peers openly wherever it is. It is not a Tier 1, so it buys its own transit from three of them, while 13 smaller networks in its regions buy theirs from it, and one PNI with it reaches about 3% of all traffic. Far from home, in Asia and New Zealand, it charges more than the locals, and it sells no transit in Australia.
|
||||
- Only Spätzle-IX now asks for 50% reach instead of 45%, since peering with the Tier 1 club brings their customers along. Two Tier 1 PNIs and the exchange are no longer quite enough (#114).
|
||||
- Badges now come in variants: games under the Change Freeze rules earn frosted Freeze-dried badges, and games under BGP at 3 a.m. earn fiery ones worth bragging about. Earning a badge under harder rules than before upgrades it in your collection on this device, and the badge list counts how many of each kind you have. On-call games earn the standard badges; Sandbox and puzzles earn none.
|
||||
- Check a selected link’s redundancy against current demand: see disconnected endpoints, additional service loss and full fallback links without changing the live network.
|
||||
- Links can now use a custom routing metric, set either as a multiplier or as an exact cost. Pick Custom under Routing metric to fine-tune where your traffic goes; it explains how a link's cost is worked out and what each preset comes to on that link.
|
||||
- Prices now follow how connected each city really is, based on PeeringDB and Hurricane Electric data. Transit costs up to 1.8× more in cities where few networks are present, a POP costs 1.25× to 1.5× where there is little or no carrier-neutral data center, and countries with thousands of networks, like Brazil and the US, bring more ISP customers. Big hubs such as Frankfurt, Amsterdam, New York and São Paulo keep their prices.
|
||||
- Prices now follow how connected each city really is, based on public peering and routing data. Every city on the map now has it, from Düsseldorf and Riga to Malé, the Caribbean and the Russian Arctic. Transit costs up to 1.8× more in cities where few networks are present, a POP costs 1.25× to 1.5× where there is little or no carrier-neutral data center, and countries with thousands of networks, like Brazil and the US, bring more ISP customers. Big hubs such as Frankfurt, Amsterdam, New York and São Paulo keep their prices.
|
||||
- Attacks are more varied: sizes, lengths and ingress ports change from one attack to the next, and several can hit at once. Hosting game servers or cloud gaming makes attacks more frequent, as it does in real life.
|
||||
- The link traffic breakdown now shows the correct source city for scrubbing traffic. Cities using the same center no longer overwrite each other's labels.
|
||||
- Live attacks now show one scrubbing detour from the attacked city to its nearest active scrubbing center, using the links' one-way latency.
|
||||
|
|
@ -31,11 +29,17 @@ All notable changes to this project are documented here. The project follows
|
|||
- Attacks can now use Memcached amplification or an ACK flood. Flowspec catches the former; the latter need mitigation.
|
||||
- Set the number of each optic model directly on land and subsea fiber links. Apply a whole change at once, with its total price shown before buying; removed optics return to the spares shelf.
|
||||
- Order PNIs with one network or every network at all shared POPs from the NOC Traffic tab: choose a port size, review the total cost, and add missing connections or upgrade smaller ones in one go. Each network keeps its own smallest PNI size and delivery time.
|
||||
- Utilities join route servers and request eligible peers across every joined IX, install missing PoP redundancy hardware and balance caches between sites, and request a cache from each eligible provider at each site.
|
||||
- Utilities join route servers and request eligible peers across every joined IX, install missing PoP redundancy hardware and balance caches between sites, and request a cache from each eligible provider at each site. A POP's Infra tab shows the redundancy kit as one line with its price, above the rows it fills in.
|
||||
- Hire a NOC intern and give them standing orders: from customer level 2, Kevin from the night shift, Anycast Annie or Tracy Route runs your rules once a game day and pays exactly what your own clicks would. Keep transit above a multiple of its peak, add or swap routers above a load, take free caches, peer at every IX and PNI with the big networks every week, sign ready customers and decline tiny ones, rush repairs, light more fiber and retire small parallel waves. Each order has a pause switch, its own settings, a monthly budget and per-POP exceptions, and the intern writes one line a day in the NOC (#98, #100, #102, #181, #185, #192, #177).
|
||||
- Open a new city from a template in one tap: POP, broadband, transit, an IX port and the redundancy kit, priced up front, with your standing orders taking it from there (#98, #192).
|
||||
- Auto-accept and auto-pay repairs are now the intern's sales and repair orders and run once a game day; saved games keep both switched on, and they start working once you hire an intern. The bulk peering and PNI batches moved into the Ops sheet, next to the orders that repeat them (#185, #181, #192).
|
||||
|
||||
## [1.37.0] — 2026-10-28
|
||||
|
||||
- Series of Tubes now speaks German. The game follows your browser's language the first time, and you can switch to German under Settings or on the title screen. Networking terms like Peering and Transit stay in English, the way network engineers say them.
|
||||
- Glowball Sakura Lager joins the map: a Tier 2 carrier in the big hubs of the US, Europe and Asia-Pacific that sells transit, takes PNIs and peers openly wherever it is. It is not a Tier 1, so it buys its own transit from three of them, while 13 smaller networks in its regions buy theirs from it, and one PNI with it reaches about 3% of all traffic. Far from home, in Asia and New Zealand, it charges more than the locals, and it sells no transit in Australia.
|
||||
- China Telecomet now sells its CN-Too premium crossing in Moscow too, at the same price as in Hong Kong (#195). Haul your European traffic to Moscow and it reaches China with about 3% loss; nothing else of theirs is on offer there.
|
||||
|
||||
## [1.36.0] — 2026-10-28
|
||||
|
||||
- You can put a link on standby, so one of two links between the same cities sits idle as a backup (#122). It carries traffic only when the other links are full or down, so its capacity is never wasted, and the map draws it dashed while it waits. The routing metric still applies to every link between the two cities.
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.36.0",
|
||||
"version": "1.37.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.36.0",
|
||||
"version": "1.37.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"jsdom": "24.1.3",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.36.0",
|
||||
"version": "1.37.0",
|
||||
"description": "A cartoon browser game about building the internet.",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -2856,6 +2856,7 @@
|
|||
"puzzles.euro_trip":"Euro-Trip",
|
||||
"puzzles.every_internet_starts_with_one_tube":"Jedes Internet beginnt mit einer Röhre.",
|
||||
"puzzles.every_link_n_g_or_more":"Jeder Link {n}G oder mehr",
|
||||
"puzzles.every_star_in_this_pack_is":"Alle Sterne in diesem Paket gehören dir.",
|
||||
"puzzles.fat_pipes_only":"Nur dicke Rohre",
|
||||
"puzzles.flash_boys":"Flash Boys",
|
||||
"puzzles.for_architects_who_sleep_through_backhoes":"Für Architekten, die die Baggersaison verschlafen.",
|
||||
|
|
@ -2879,6 +2880,7 @@
|
|||
"puzzles.n_1_club":"N-1-Club",
|
||||
"puzzles.n_1_connect_everything_first":"N-1: erst alles verbinden",
|
||||
"puzzles.n_g_links":"{n}G-Links",
|
||||
"puzzles.n_stars_left_in_this_pack":{"one":"Noch {n} ⭐ in diesem Paket","other":"Noch {n} ⭐ in diesem Paket"},
|
||||
"puzzles.n_week_streak":{"one":"{n} Woche in Folge","other":"{n} Wochen in Folge"},
|
||||
"puzzles.new_this_sunday":"Neu diesen Sonntag!",
|
||||
"puzzles.new_zealand_is_far_from_everything":"Neuseeland ist weit weg von allem. Genau das ist der Witz, und das Problem.",
|
||||
|
|
@ -2890,7 +2892,6 @@
|
|||
"puzzles.no_budget_star_on_the_house":"kein Budget: ⭐ geht aufs Haus",
|
||||
"puzzles.no_cable_lands_in_both_try":"Kein Kabel landet in {a} und {b}. Versuch es mit einem Trittstein dazwischen.",
|
||||
"puzzles.no_clock_no_bills_nothing_breaks":"Keine Uhr, keine Rechnungen, nichts geht kaputt. Verbinde die Städte und hol dir drei Sterne: unter Budget, und noch verbunden, wenn irgendein Link durchtrennt wird.",
|
||||
"puzzles.no_pop_in_list":"Kein POP in {list}",
|
||||
"puzzles.no_subsea":"kein Seekabel",
|
||||
"puzzles.no_subsea_cables":"Keine Seekabel",
|
||||
"puzzles.nobody_ever_got_fired_for_buying":"Für 100G ist noch nie jemand gefeuert worden.",
|
||||
|
|
@ -2917,6 +2918,7 @@
|
|||
"puzzles.ring":"Ring",
|
||||
"puzzles.ring_of_fire":"Ring of Fire",
|
||||
"puzzles.rock_solid_and_gold_plated_the":"Felsenfest und vergoldet. Der CFO hat Fragen.",
|
||||
"puzzles.rule_not_via_list":"Regel: nicht über {list}",
|
||||
"puzzles.samba_sprint":"Samba-Sprint",
|
||||
"puzzles.same_puzzle_for_everyone_this_week":"Diese Woche für alle dasselbe Puzzle",
|
||||
"puzzles.same_trench_cheaper_one_backhoe_cuts":"Gleicher Graben (billiger, ein Bagger kappt beide)",
|
||||
|
|
@ -2927,6 +2929,7 @@
|
|||
"puzzles.size":"Größe",
|
||||
"puzzles.small_calm_network_builds":"Kleine, entspannte Netzbauten",
|
||||
"puzzles.smorgasbord":"Smörgåsbord",
|
||||
"puzzles.so_close_one_more_link_and":"Fast: noch ein Link, und kein Bagger kann dir was.",
|
||||
"puzzles.speed_runs":"Speedruns",
|
||||
"puzzles.spent_x":"Ausgegeben {x}",
|
||||
"puzzles.spent_x_of_y":"Ausgegeben {x} / {y}",
|
||||
|
|
@ -2949,7 +2952,7 @@
|
|||
"puzzles.weekly_puzzle":"Wochenpuzzle",
|
||||
"puzzles.weekly_puzzle_key":"Wochenpuzzle {key}",
|
||||
"puzzles.with_the_pop_price":"mit POP: {price}",
|
||||
"puzzles.your_first_tubes_no_pressure":"Deine ersten Röhren. Kein Druck, kein Budget.",
|
||||
"puzzles.your_first_tubes_roomy_budgets":"Deine ersten Röhren. Großzügige Budgets, und die ersten zwei gehen aufs Haus.",
|
||||
"puzzles.your_stars":"Deine Sterne",
|
||||
"puzzles_weekly.detour":"Umleitung",
|
||||
"puzzles_weekly.island_hopping":"Inselhüpfen",
|
||||
|
|
@ -3239,7 +3242,7 @@
|
|||
"scenarios.ponta_delgada_in_the_azores_halfway":"Ponta Delgada auf den Azoren, mitten im Atlantik. Florida–Spanien und Lissabon–Lagos sind einfach zu lang für eine 1.6T-Wave: direkt hinüber trägt jede nur 1.2T. Lande auf den Inseln dazwischen, starte das Licht neu, und jeder Hop läuft mit 1.6T oder besser. Du startest mit freigeschalteter 1.6T-Hardware.",
|
||||
"scenarios.pops_in_bogota_lima_santiago_and":"POPs in Bogotá, Lima, Santiago und São Paulo, und 150 Gbps bedient",
|
||||
"scenarios.ports_on_15_ix_brrr_exchanges":"Ports an 15 IX.brrr-Exchanges, einer davon in Manaus, und 200 Gbps bedient",
|
||||
"scenarios.reach_45_of_the_internet_and":"Erreiche 45 % des Internets und bediene 300 Gbps",
|
||||
"scenarios.reach_50_of_the_internet_and":"Erreiche 50 % des Internets und bediene 300 Gbps",
|
||||
"scenarios.red_sea_crisis":"Krise im Roten Meer",
|
||||
"scenarios.rio_from_scratch_carnaval_starts_in":"Rio, ganz von vorn. Der Karneval beginnt in 90 Tagen und will fünf Tage am Stück 400 Gbps. Die ganze Welt schaut zu.",
|
||||
"scenarios.sandbox_mode_a_billion_dollars_chaos":"<b>Sandbox-Modus</b><br>Eine Milliarde Dollar und alles freigeschaltet. Chaos: {chaos}. Bau das Internet, das du immer wolltest, und halt einen Ersatzbagger bereit.",
|
||||
|
|
|
|||
|
|
@ -2854,6 +2854,7 @@
|
|||
"puzzles.euro_trip":"Euro Trip",
|
||||
"puzzles.every_internet_starts_with_one_tube":"Todo internet empieza con un tubo.",
|
||||
"puzzles.every_link_n_g_or_more":"Cada enlace de {n}G o más",
|
||||
"puzzles.every_star_in_this_pack_is":"Todas las estrellas de este paquete son tuyas.",
|
||||
"puzzles.fat_pipes_only":"Solo tuberías gordas",
|
||||
"puzzles.flash_boys":"Flash Boys",
|
||||
"puzzles.for_architects_who_sleep_through_backhoes":"Para arquitectos que duermen tranquilos en temporada de retroexcavadoras.",
|
||||
|
|
@ -2877,6 +2878,7 @@
|
|||
"puzzles.n_1_club":"Club N-1",
|
||||
"puzzles.n_1_connect_everything_first":"N-1: primero conéctalo todo",
|
||||
"puzzles.n_g_links":"enlaces de {n}G",
|
||||
"puzzles.n_stars_left_in_this_pack":{"one":"Queda {n} ⭐ en este paquete","other":"Quedan {n} ⭐ en este paquete"},
|
||||
"puzzles.n_week_streak":{"one":"{n} semana seguida","other":"{n} semanas seguidas"},
|
||||
"puzzles.new_this_sunday":"¡Nuevo este domingo!",
|
||||
"puzzles.new_zealand_is_far_from_everything":"Nueva Zelanda está lejos de todo. Esa es la gracia, y el problema.",
|
||||
|
|
@ -2888,7 +2890,6 @@
|
|||
"puzzles.no_budget_star_on_the_house":"sin presupuesto: ⭐ invita la casa",
|
||||
"puzzles.no_cable_lands_in_both_try":"Ningún cable llega a {a} y a {b}. Prueba con una escala entre medias.",
|
||||
"puzzles.no_clock_no_bills_nothing_breaks":"Sin reloj, sin facturas, nada se rompe. Conecta las ciudades y ve a por tres estrellas: bajo presupuesto, y aún conectado si se corta cualquier enlace.",
|
||||
"puzzles.no_pop_in_list":"Ningún POP en {list}",
|
||||
"puzzles.no_subsea":"sin submarinos",
|
||||
"puzzles.no_subsea_cables":"Sin cables submarinos",
|
||||
"puzzles.nobody_ever_got_fired_for_buying":"A nadie lo han despedido nunca por comprar 100G.",
|
||||
|
|
@ -2915,6 +2916,7 @@
|
|||
"puzzles.ring":"anillo",
|
||||
"puzzles.ring_of_fire":"Anillo de fuego",
|
||||
"puzzles.rock_solid_and_gold_plated_the":"A prueba de bombas, y bañado en oro. El director financiero tiene preguntas.",
|
||||
"puzzles.rule_not_via_list":"Regla: sin pasar por {list}",
|
||||
"puzzles.samba_sprint":"Sprint de samba",
|
||||
"puzzles.same_puzzle_for_everyone_this_week":"El mismo puzle para todos esta semana",
|
||||
"puzzles.same_trench_cheaper_one_backhoe_cuts":"Misma zanja (más barata, una retroexcavadora corta las dos)",
|
||||
|
|
@ -2925,6 +2927,7 @@
|
|||
"puzzles.size":"Tamaño",
|
||||
"puzzles.small_calm_network_builds":"Redes pequeñas y tranquilas",
|
||||
"puzzles.smorgasbord":"Smörgåsbord",
|
||||
"puzzles.so_close_one_more_link_and":"Casi: un enlace más y ninguna retroexcavadora podrá contigo.",
|
||||
"puzzles.speed_runs":"Contrarreloj",
|
||||
"puzzles.spent_x":"Gastado {x}",
|
||||
"puzzles.spent_x_of_y":"Gastado {x} / {y}",
|
||||
|
|
@ -2947,7 +2950,7 @@
|
|||
"puzzles.weekly_puzzle":"Puzle semanal",
|
||||
"puzzles.weekly_puzzle_key":"Puzle semanal {key}",
|
||||
"puzzles.with_the_pop_price":"con el POP: {price}",
|
||||
"puzzles.your_first_tubes_no_pressure":"Tus primeros tubos. Sin presión, sin presupuesto.",
|
||||
"puzzles.your_first_tubes_roomy_budgets":"Tus primeros tubos. Presupuestos holgados, y los dos primeros invita la casa.",
|
||||
"puzzles.your_stars":"Tus estrellas",
|
||||
"puzzles_weekly.detour":"Desvío",
|
||||
"puzzles_weekly.island_hopping":"De isla en isla",
|
||||
|
|
@ -3237,7 +3240,7 @@
|
|||
"scenarios.ponta_delgada_in_the_azores_halfway":"Ponta Delgada, en las Azores, a medio camino por el Atlántico. De Florida a España y de Lisboa a Lagos es demasiado largo para una onda de 1.6T: en línea recta, cada una lleva 1.2T. Aterriza en las islas intermedias, empieza la luz de nuevo, y cada salto va a 1.6T o más. Empiezas con equipo de 1.6T desbloqueado.",
|
||||
"scenarios.pops_in_bogota_lima_santiago_and":"POPs en Bogotá, Lima, Santiago y São Paulo, y 150 Gbps servidos",
|
||||
"scenarios.ports_on_15_ix_brrr_exchanges":"Puertos en 15 intercambios IX.brrr, uno de ellos en Manaos, y 200 Gbps servidos",
|
||||
"scenarios.reach_45_of_the_internet_and":"Llega al 45 % de internet y sirve 300 Gbps",
|
||||
"scenarios.reach_50_of_the_internet_and":"Llega al 50 % de internet y sirve 300 Gbps",
|
||||
"scenarios.red_sea_crisis":"Crisis del Mar Rojo",
|
||||
"scenarios.rio_from_scratch_carnaval_starts_in":"Río desde cero. El Carnaval empieza en 90 días y quiere 400 Gbps durante cinco días seguidos. Todo el mundo está mirando.",
|
||||
"scenarios.sandbox_mode_a_billion_dollars_chaos":"<b>Modo sandbox</b><br>Mil millones de dólares y todo desbloqueado. Caos: {chaos}. Construye el internet que siempre quisiste, y ten a mano una excavadora de repuesto.",
|
||||
|
|
|
|||
|
|
@ -2854,6 +2854,7 @@
|
|||
"puzzles.euro_trip":"Euro Trip",
|
||||
"puzzles.every_internet_starts_with_one_tube":"Tout internet commence par un tube.",
|
||||
"puzzles.every_link_n_g_or_more":"Chaque lien à {n}G ou plus",
|
||||
"puzzles.every_star_in_this_pack_is":"Toutes les étoiles de ce pack sont à toi.",
|
||||
"puzzles.fat_pipes_only":"Gros tuyaux uniquement",
|
||||
"puzzles.flash_boys":"Flash Boys",
|
||||
"puzzles.for_architects_who_sleep_through_backhoes":"Pour les architectes qui dorment pendant la saison des pelleteuses.",
|
||||
|
|
@ -2877,6 +2878,7 @@
|
|||
"puzzles.n_1_club":"Club N-1",
|
||||
"puzzles.n_1_connect_everything_first":"N-1 : relie d’abord tout",
|
||||
"puzzles.n_g_links":"liens {n}G",
|
||||
"puzzles.n_stars_left_in_this_pack":{"one":"Encore {n} ⭐ dans ce pack","other":"Encore {n} ⭐ dans ce pack"},
|
||||
"puzzles.n_week_streak":{"one":"{n} semaine d’affilée","other":"{n} semaines d’affilée"},
|
||||
"puzzles.new_this_sunday":"Nouveau ce dimanche !",
|
||||
"puzzles.new_zealand_is_far_from_everything":"La Nouvelle-Zélande est loin de tout. C’est tout l’intérêt, et tout le problème.",
|
||||
|
|
@ -2888,7 +2890,6 @@
|
|||
"puzzles.no_budget_star_on_the_house":"sans budget : ⭐ offerte par la maison",
|
||||
"puzzles.no_cable_lands_in_both_try":"Aucun câble n’atterrit à la fois à {a} et à {b}. Essaie une escale entre les deux.",
|
||||
"puzzles.no_clock_no_bills_nothing_breaks":"Pas d’horloge, pas de factures, rien ne casse. Relie les villes, puis vise trois étoiles : sous le budget, et toujours relié si n’importe quel lien est coupé.",
|
||||
"puzzles.no_pop_in_list":"Aucun POP à {list}",
|
||||
"puzzles.no_subsea":"pas de sous-marin",
|
||||
"puzzles.no_subsea_cables":"Pas de câbles sous-marins",
|
||||
"puzzles.nobody_ever_got_fired_for_buying":"Personne ne s’est jamais fait virer pour avoir acheté du 100G.",
|
||||
|
|
@ -2915,6 +2916,7 @@
|
|||
"puzzles.ring":"anneau",
|
||||
"puzzles.ring_of_fire":"Ceinture de feu",
|
||||
"puzzles.rock_solid_and_gold_plated_the":"Solide comme un roc, et plaqué or. Le DAF a des questions.",
|
||||
"puzzles.rule_not_via_list":"Règle : pas par {list}",
|
||||
"puzzles.samba_sprint":"Sprint samba",
|
||||
"puzzles.same_puzzle_for_everyone_this_week":"Le même puzzle pour tout le monde cette semaine",
|
||||
"puzzles.same_trench_cheaper_one_backhoe_cuts":"Même tranchée (moins cher, une pelleteuse coupe les deux)",
|
||||
|
|
@ -2925,6 +2927,7 @@
|
|||
"puzzles.size":"Taille",
|
||||
"puzzles.small_calm_network_builds":"Petits réseaux, tranquillement",
|
||||
"puzzles.smorgasbord":"Smörgåsbord",
|
||||
"puzzles.so_close_one_more_link_and":"Presque : encore un lien et aucune pelleteuse ne pourra rien contre toi.",
|
||||
"puzzles.speed_runs":"Contre la montre",
|
||||
"puzzles.spent_x":"Dépensé {x}",
|
||||
"puzzles.spent_x_of_y":"Dépensé {x} / {y}",
|
||||
|
|
@ -2947,7 +2950,7 @@
|
|||
"puzzles.weekly_puzzle":"Puzzle de la semaine",
|
||||
"puzzles.weekly_puzzle_key":"Puzzle de la semaine {key}",
|
||||
"puzzles.with_the_pop_price":"avec le POP : {price}",
|
||||
"puzzles.your_first_tubes_no_pressure":"Tes premiers tubes. Pas de pression, pas de budget.",
|
||||
"puzzles.your_first_tubes_roomy_budgets":"Tes premiers tubes. Des budgets confortables, et les deux premiers sont offerts par la maison.",
|
||||
"puzzles.your_stars":"Tes étoiles",
|
||||
"puzzles_weekly.detour":"Détour",
|
||||
"puzzles_weekly.island_hopping":"Saut d’île en île",
|
||||
|
|
@ -3237,7 +3240,7 @@
|
|||
"scenarios.ponta_delgada_in_the_azores_halfway":"Ponta Delgada, aux Açores, à mi-chemin de l’Atlantique. De la Floride à l’Espagne et de Lisbonne à Lagos, c’est juste trop long pour une onde de 1.6T : en ligne droite, chacune transporte 1.2T. Atterrissez sur les îles entre les deux, relancez la lumière, et chaque saut passe à 1.6T ou mieux. Vous commencez avec l’équipement 1.6T débloqué.",
|
||||
"scenarios.pops_in_bogota_lima_santiago_and":"Des POP à Bogotá, Lima, Santiago et São Paulo, et 150 Gbps servis",
|
||||
"scenarios.ports_on_15_ix_brrr_exchanges":"Des ports sur 15 IX.brrr, dont un à Manaus, et 200 Gbps servis",
|
||||
"scenarios.reach_45_of_the_internet_and":"Couvre 45 % d’internet et sers 300 Gbps",
|
||||
"scenarios.reach_50_of_the_internet_and":"Couvre 50 % d’internet et sers 300 Gbps",
|
||||
"scenarios.red_sea_crisis":"Crise en mer Rouge",
|
||||
"scenarios.rio_from_scratch_carnaval_starts_in":"Rio en partant de zéro. Le Carnaval commence dans 90 jours et veut 400 Gbps pendant cinq jours d’affilée. Le monde entier regarde.",
|
||||
"scenarios.sandbox_mode_a_billion_dollars_chaos":"<b>Mode bac à sable</b><br>Un milliard de dollars et tout débloqué. Chaos : {chaos}. Construis l’internet dont tu as toujours rêvé, et garde une pelleteuse de rechange sous la main.",
|
||||
|
|
|
|||
|
|
@ -2854,6 +2854,7 @@
|
|||
"puzzles.euro_trip":"Euro Trip",
|
||||
"puzzles.every_internet_starts_with_one_tube":"Ogni internet comincia con un tubo.",
|
||||
"puzzles.every_link_n_g_or_more":"Ogni link da {n}G o più",
|
||||
"puzzles.every_star_in_this_pack_is":"Tutte le stelle di questo pacchetto sono tue.",
|
||||
"puzzles.fat_pipes_only":"Solo tubi grossi",
|
||||
"puzzles.flash_boys":"Flash Boys",
|
||||
"puzzles.for_architects_who_sleep_through_backhoes":"Per architetti che dormono sonni tranquilli nella stagione delle ruspe.",
|
||||
|
|
@ -2877,6 +2878,7 @@
|
|||
"puzzles.n_1_club":"Club N-1",
|
||||
"puzzles.n_1_connect_everything_first":"N-1: prima collega tutto",
|
||||
"puzzles.n_g_links":"link da {n}G",
|
||||
"puzzles.n_stars_left_in_this_pack":{"one":"Ancora {n} ⭐ in questo pacchetto","other":"Ancora {n} ⭐ in questo pacchetto"},
|
||||
"puzzles.n_week_streak":{"one":"{n} settimana di fila","other":"{n} settimane di fila"},
|
||||
"puzzles.new_this_sunday":"Nuovo questa domenica!",
|
||||
"puzzles.new_zealand_is_far_from_everything":"La Nuova Zelanda è lontana da tutto. È proprio questo il bello, e il problema.",
|
||||
|
|
@ -2888,7 +2890,6 @@
|
|||
"puzzles.no_budget_star_on_the_house":"senza budget: ⭐ offerta dalla casa",
|
||||
"puzzles.no_cable_lands_in_both_try":"Nessun cavo approda sia a {a} che a {b}. Prova con una tappa in mezzo.",
|
||||
"puzzles.no_clock_no_bills_nothing_breaks":"Niente orologio, niente bollette, non si rompe niente. Collega le città, poi punta alle tre stelle: sotto budget, e ancora collegato se si taglia un link qualsiasi.",
|
||||
"puzzles.no_pop_in_list":"Nessun POP a {list}",
|
||||
"puzzles.no_subsea":"niente sottomarini",
|
||||
"puzzles.no_subsea_cables":"Niente cavi sottomarini",
|
||||
"puzzles.nobody_ever_got_fired_for_buying":"Nessuno è mai stato licenziato per aver comprato 100G.",
|
||||
|
|
@ -2915,6 +2916,7 @@
|
|||
"puzzles.ring":"anello",
|
||||
"puzzles.ring_of_fire":"Cintura di fuoco",
|
||||
"puzzles.rock_solid_and_gold_plated_the":"Solida come una roccia, e placcata d’oro. Il CFO ha delle domande.",
|
||||
"puzzles.rule_not_via_list":"Regola: niente passaggi da {list}",
|
||||
"puzzles.samba_sprint":"Sprint di samba",
|
||||
"puzzles.same_puzzle_for_everyone_this_week":"Lo stesso puzzle per tutti questa settimana",
|
||||
"puzzles.same_trench_cheaper_one_backhoe_cuts":"Stesso scavo (più economico, una ruspa li taglia tutti e due)",
|
||||
|
|
@ -2925,6 +2927,7 @@
|
|||
"puzzles.size":"Taglia",
|
||||
"puzzles.small_calm_network_builds":"Piccole reti, con calma",
|
||||
"puzzles.smorgasbord":"Smörgåsbord",
|
||||
"puzzles.so_close_one_more_link_and":"Ci sei quasi: ancora un link e nessuna ruspa può toccarti.",
|
||||
"puzzles.speed_runs":"Corse contro il tempo",
|
||||
"puzzles.spent_x":"Speso {x}",
|
||||
"puzzles.spent_x_of_y":"Speso {x} / {y}",
|
||||
|
|
@ -2947,7 +2950,7 @@
|
|||
"puzzles.weekly_puzzle":"Puzzle della settimana",
|
||||
"puzzles.weekly_puzzle_key":"Puzzle della settimana {key}",
|
||||
"puzzles.with_the_pop_price":"con il POP: {price}",
|
||||
"puzzles.your_first_tubes_no_pressure":"I tuoi primi tubi. Niente pressione, niente budget.",
|
||||
"puzzles.your_first_tubes_roomy_budgets":"I tuoi primi tubi. Budget comodi, e i primi due li offre la casa.",
|
||||
"puzzles.your_stars":"Le tue stelle",
|
||||
"puzzles_weekly.detour":"Deviazione",
|
||||
"puzzles_weekly.island_hopping":"Di isola in isola",
|
||||
|
|
@ -3237,7 +3240,7 @@
|
|||
"scenarios.ponta_delgada_in_the_azores_halfway":"Ponta Delgada, nelle Azzorre, a metà dell’Atlantico. Dalla Florida alla Spagna e da Lisbona a Lagos è appena troppo lungo per un’onda da 1.6T: in linea diretta ognuna porta 1.2T. Approda sulle isole in mezzo, fai ripartire la luce e ogni tratto va a 1.6T o più. Parti con l’attrezzatura da 1.6T sbloccata.",
|
||||
"scenarios.pops_in_bogota_lima_santiago_and":"POP a Bogotá, Lima, Santiago e São Paulo, e 150 Gbps serviti",
|
||||
"scenarios.ports_on_15_ix_brrr_exchanges":"Porte su 15 exchange IX.brrr, una delle quali a Manaus, e 200 Gbps serviti",
|
||||
"scenarios.reach_45_of_the_internet_and":"Raggiungi il 45% di internet e servi 300 Gbps",
|
||||
"scenarios.reach_50_of_the_internet_and":"Raggiungi il 50% di internet e servi 300 Gbps",
|
||||
"scenarios.red_sea_crisis":"Crisi nel Mar Rosso",
|
||||
"scenarios.rio_from_scratch_carnaval_starts_in":"Rio da zero. Il Carnaval comincia tra 90 giorni e vuole 400 Gbps per cinque giorni di fila. Il mondo intero sta guardando.",
|
||||
"scenarios.sandbox_mode_a_billion_dollars_chaos":"<b>Modalità sandbox</b><br>Un miliardo di dollari e tutto sbloccato. Caos: {chaos}. Costruisci l’internet che hai sempre sognato, e tieni una ruspa di scorta a portata di mano.",
|
||||
|
|
|
|||
|
|
@ -2854,6 +2854,7 @@
|
|||
"puzzles.euro_trip":"Euro Trip",
|
||||
"puzzles.every_internet_starts_with_one_tube":"Toda internet começa com um tubo.",
|
||||
"puzzles.every_link_n_g_or_more":"Todo link com {n}G ou mais",
|
||||
"puzzles.every_star_in_this_pack_is":"Todas as estrelas deste pacote são suas.",
|
||||
"puzzles.fat_pipes_only":"Só tubos grossos",
|
||||
"puzzles.flash_boys":"Flash Boys",
|
||||
"puzzles.for_architects_who_sleep_through_backhoes":"Para arquitetos que dormem tranquilos na temporada das retroescavadeiras.",
|
||||
|
|
@ -2877,6 +2878,7 @@
|
|||
"puzzles.n_1_club":"Clube N-1",
|
||||
"puzzles.n_1_connect_everything_first":"N-1: conecte tudo primeiro",
|
||||
"puzzles.n_g_links":"links de {n}G",
|
||||
"puzzles.n_stars_left_in_this_pack":{"one":"Falta {n} ⭐ neste pacote","other":"Faltam {n} ⭐ neste pacote"},
|
||||
"puzzles.n_week_streak":{"one":"{n} semana seguida","other":"{n} semanas seguidas"},
|
||||
"puzzles.new_this_sunday":"Novo neste domingo!",
|
||||
"puzzles.new_zealand_is_far_from_everything":"A Nova Zelândia fica longe de tudo. Essa é a graça, e o problema.",
|
||||
|
|
@ -2888,7 +2890,6 @@
|
|||
"puzzles.no_budget_star_on_the_house":"sem orçamento: ⭐ por conta da casa",
|
||||
"puzzles.no_cable_lands_in_both_try":"Nenhum cabo chega a {a} e a {b}. Tente uma escala no meio.",
|
||||
"puzzles.no_clock_no_bills_nothing_breaks":"Sem relógio, sem contas, nada quebra. Conecte as cidades e busque três estrelas: dentro do orçamento, e ainda conectado se qualquer link for cortado.",
|
||||
"puzzles.no_pop_in_list":"Nenhum POP em {list}",
|
||||
"puzzles.no_subsea":"sem submarino",
|
||||
"puzzles.no_subsea_cables":"Sem cabos submarinos",
|
||||
"puzzles.nobody_ever_got_fired_for_buying":"Ninguém nunca foi demitido por comprar 100G.",
|
||||
|
|
@ -2915,6 +2916,7 @@
|
|||
"puzzles.ring":"anel",
|
||||
"puzzles.ring_of_fire":"Anel de Fogo",
|
||||
"puzzles.rock_solid_and_gold_plated_the":"Sólida como rocha, e banhada a ouro. O CFO tem perguntas.",
|
||||
"puzzles.rule_not_via_list":"Regra: sem passar por {list}",
|
||||
"puzzles.samba_sprint":"Corrida de samba",
|
||||
"puzzles.same_puzzle_for_everyone_this_week":"O mesmo puzzle para todo mundo nesta semana",
|
||||
"puzzles.same_trench_cheaper_one_backhoe_cuts":"Mesma vala (mais barata, uma retroescavadeira corta as duas)",
|
||||
|
|
@ -2925,6 +2927,7 @@
|
|||
"puzzles.size":"Tamanho",
|
||||
"puzzles.small_calm_network_builds":"Redes pequenas, com calma",
|
||||
"puzzles.smorgasbord":"Smörgåsbord",
|
||||
"puzzles.so_close_one_more_link_and":"Quase lá: mais um link e nenhuma retroescavadeira te alcança.",
|
||||
"puzzles.speed_runs":"Contra o relógio",
|
||||
"puzzles.spent_x":"Gasto {x}",
|
||||
"puzzles.spent_x_of_y":"Gasto {x} / {y}",
|
||||
|
|
@ -2947,7 +2950,7 @@
|
|||
"puzzles.weekly_puzzle":"Puzzle da semana",
|
||||
"puzzles.weekly_puzzle_key":"Puzzle da semana {key}",
|
||||
"puzzles.with_the_pop_price":"com o POP: {price}",
|
||||
"puzzles.your_first_tubes_no_pressure":"Seus primeiros tubos. Sem pressão, sem orçamento.",
|
||||
"puzzles.your_first_tubes_roomy_budgets":"Seus primeiros tubos. Orçamentos folgados, e os dois primeiros são por conta da casa.",
|
||||
"puzzles.your_stars":"Suas estrelas",
|
||||
"puzzles_weekly.detour":"Desvio",
|
||||
"puzzles_weekly.island_hopping":"De ilha em ilha",
|
||||
|
|
@ -3237,7 +3240,7 @@
|
|||
"scenarios.ponta_delgada_in_the_azores_halfway":"Ponta Delgada, nos Açores, no meio do Atlântico. Da Flórida à Espanha e de Lisboa a Lagos é um pouco longo demais para uma onda de 1.6T: em linha direta, cada uma leva 1.2T. Pouse nas ilhas no meio, recomece a luz, e cada trecho roda a 1.6T ou mais. Você começa com equipamento de 1.6T desbloqueado.",
|
||||
"scenarios.pops_in_bogota_lima_santiago_and":"POPs em Bogotá, Lima, Santiago e São Paulo, e 150 Gbps servidos",
|
||||
"scenarios.ports_on_15_ix_brrr_exchanges":"Portas em 15 exchanges IX.brrr, uma delas em Manaus, e 200 Gbps servidos",
|
||||
"scenarios.reach_45_of_the_internet_and":"Alcance 45% da internet e atenda 300 Gbps",
|
||||
"scenarios.reach_50_of_the_internet_and":"Alcance 50% da internet e atenda 300 Gbps",
|
||||
"scenarios.red_sea_crisis":"Crise no Mar Vermelho",
|
||||
"scenarios.rio_from_scratch_carnaval_starts_in":"Rio do zero. O Carnaval começa em 90 dias e quer 400 Gbps por cinco dias seguidos. O mundo inteiro está assistindo.",
|
||||
"scenarios.sandbox_mode_a_billion_dollars_chaos":"<b>Modo sandbox</b><br>Um bilhão de dólares e tudo desbloqueado. Caos: {chaos}. Construa a internet que você sempre quis, e deixe uma retroescavadeira reserva à mão.",
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
/* Real-world calibration, pulled 2026-10-25 (Pacific islands 2026-10-26). Per city: [carrier-neutral facilities, network presences across them,
|
||||
ASNs registered in its country]. Facilities and presences are PeeringDB facilities within 50 km or in the same city
|
||||
(peeringdb.com/api/fac, net_count summed); ASNs per country are from bgp.he.net/report/world.
|
||||
A city missing here keeps the plain regional price. One entry per line, sorted by id. */
|
||||
Cities PeeringDB barely knows (added 2026-10-28) are marked: est. is an estimate from what is known to be there, with
|
||||
the country's ASN count. A city missing here keeps the plain regional price. One entry per line, sorted by id. */
|
||||
const CITY_PDB={
|
||||
abj:[5,11,32],
|
||||
acc:[7,78,124],
|
||||
add:[2,3,10],
|
||||
adl:[6,70,3196], // est.
|
||||
aju:[4,3,9693],
|
||||
akl:[27,398,755],
|
||||
alg:[0,0,16],
|
||||
ams:[69,2731,1827],
|
||||
anc:[3,12,33300], // est.
|
||||
apw:[0,0,11],
|
||||
ash:[86,1010,33300],
|
||||
asu:[3,8,124],
|
||||
|
|
@ -17,11 +20,13 @@ const CITY_PDB={
|
|||
atn:[42,589,33300],
|
||||
auh:[4,1,231],
|
||||
bcn:[13,159,1341],
|
||||
bda:[2,8,25], // est.
|
||||
bde:[0,0,4027],
|
||||
beg:[7,49,227],
|
||||
bel:[3,7,9693],
|
||||
ber:[22,351,3705],
|
||||
bet:[16,174,152],
|
||||
bgi:[1,5,20], // est.
|
||||
bhz:[13,40,9693],
|
||||
bkk:[32,397,675],
|
||||
blr:[14,104,6412],
|
||||
|
|
@ -30,6 +35,7 @@ const CITY_PDB={
|
|||
bom:[59,1050,6412],
|
||||
bos:[31,209,33300],
|
||||
bru:[33,328,443],
|
||||
brw:[0,0,33300], // est.
|
||||
bsb:[14,108,9693],
|
||||
bud:[6,146,369],
|
||||
bue:[28,372,1357],
|
||||
|
|
@ -41,15 +47,18 @@ const CITY_PDB={
|
|||
cas:[2,2,39],
|
||||
cau:[2,2,9693],
|
||||
cbo:[1,0,33],
|
||||
cbr:[5,60,3196], // est.
|
||||
ccs:[6,32,296],
|
||||
cgb:[4,5,9693],
|
||||
cgr:[4,4,9693],
|
||||
chc:[4,30,755], // est.
|
||||
chi:[64,809,33300],
|
||||
cor:[2,29,1357],
|
||||
cph:[30,290,529],
|
||||
cpq:[19,65,9693],
|
||||
cpt:[6,267,879],
|
||||
cpv:[4,12,9693],
|
||||
cur:[3,20,25], // est.
|
||||
cwb:[11,79,9693],
|
||||
cxj:[2,3,9693],
|
||||
dac:[30,107,2105],
|
||||
|
|
@ -58,26 +67,37 @@ const CITY_PDB={
|
|||
del:[31,479,6412],
|
||||
den:[28,310,33300],
|
||||
dkr:[2,4,23],
|
||||
dks:[0,0,6683], // est.
|
||||
dla:[3,14,34],
|
||||
doh:[6,29,31],
|
||||
drw:[3,15,3196],
|
||||
dub:[21,277,350],
|
||||
dur:[4,137,879],
|
||||
dus:[13,350,3705], // 14 listed, one closed; Digital Realty DUS1-3 alone has 141 networks
|
||||
dut:[0,0,33300], // est.
|
||||
dxb:[8,135,231],
|
||||
dyr:[0,0,6683], // est.
|
||||
ebj:[1,5,529], // est.
|
||||
edi:[4,46,4027],
|
||||
fdf:[1,5,10], // est.
|
||||
fec:[5,4,9693],
|
||||
fih:[7,19,57],
|
||||
fln:[5,23,9693],
|
||||
for:[16,362,9693],
|
||||
fra:[56,2450,3705],
|
||||
fuj:[1,49,231],
|
||||
fuk:[5,50,1330], // QTnet QD3 has 14 networks, BBIX Fukuoka is there; the rest est.
|
||||
gbe:[1,2,39],
|
||||
gdl:[4,22,814],
|
||||
gdx:[1,2,6683], // est.
|
||||
gua:[5,16,103],
|
||||
gum:[6,28,11],
|
||||
gyn:[5,28,9693],
|
||||
ham:[26,228,3705],
|
||||
hav:[0,0,8], // est.: no neutral data center
|
||||
hba:[2,10,3196], // est.
|
||||
hel:[23,232,427],
|
||||
hfx:[3,20,2595], // est.
|
||||
hir:[1,0,11],
|
||||
hkg:[57,1107,1514],
|
||||
hnl:[7,33,33300],
|
||||
|
|
@ -87,15 +107,20 @@ const CITY_PDB={
|
|||
icn:[37,201,1197],
|
||||
igu:[5,26,124],
|
||||
ist:[28,334,1290],
|
||||
ivc:[1,2,755], // est.
|
||||
jam:[0,0,2], // est.
|
||||
jed:[5,25,220],
|
||||
jib:[3,19,5],
|
||||
jkt:[98,3015,4108],
|
||||
jnb:[14,561,879],
|
||||
jnu:[1,2,33300], // est.
|
||||
jpa:[4,18,9693],
|
||||
kcy:[22,313,33300],
|
||||
kgl:[5,14,34],
|
||||
khi:[7,15,488],
|
||||
kin:[2,10,30], // est.
|
||||
kla:[2,18,71],
|
||||
krs:[3,15,448], // est.
|
||||
kul:[20,210,434],
|
||||
kyv:[33,506,2342],
|
||||
lad:[8,27,79],
|
||||
|
|
@ -115,6 +140,7 @@ const CITY_PDB={
|
|||
mao:[7,15,9693],
|
||||
mba:[4,176,274],
|
||||
mcp:[2,0,9693],
|
||||
mct:[3,25,45], // Equinix MC1 and WCS; presences est.
|
||||
mcz:[1,5,9693],
|
||||
mde:[2,18,598],
|
||||
mel:[20,395,3196],
|
||||
|
|
@ -122,54 +148,71 @@ const CITY_PDB={
|
|||
mgf:[4,9,9693],
|
||||
mia:[27,553,33300],
|
||||
mil:[29,728,1534],
|
||||
mle:[1,3,15], // est.
|
||||
mmk:[2,4,6683], // est.
|
||||
mnl:[17,352,750],
|
||||
mos:[49,632,6683],
|
||||
mpm:[7,20,36],
|
||||
mrs:[8,273,2249],
|
||||
mru:[3,20,60], // est.
|
||||
mtl:[35,283,2595],
|
||||
mty:[5,27,814],
|
||||
muc:[22,230,3705],
|
||||
mvd:[1,2,53],
|
||||
nas:[1,4,20], // est.
|
||||
nat:[1,3,9693],
|
||||
nbo:[9,283,274],
|
||||
nou:[2,2,19],
|
||||
nyc:[96,1322,33300],
|
||||
ome:[0,0,33300], // est.
|
||||
oos:[5,22,443],
|
||||
osa:[19,229,1330],
|
||||
osl:[20,209,448],
|
||||
ott:[6,21,2595],
|
||||
pan:[8,26,158],
|
||||
par:[77,1528,2249],
|
||||
pcn:[0,0,0], // est.: no network of its own
|
||||
pdl:[1,3,187], // est.
|
||||
pek:[10,15,6717],
|
||||
per:[12,248,3196],
|
||||
phx:[26,279,33300],
|
||||
pkc:[1,2,6683], // est.
|
||||
pmo:[3,46,1534],
|
||||
pmw:[3,8,9693],
|
||||
poa:[22,120,9693],
|
||||
pom:[2,0,46],
|
||||
pos:[2,10,35], // est.
|
||||
ppg:[0,0,2],
|
||||
ppt:[0,0,6],
|
||||
prg:[24,336,775],
|
||||
prr:[0,0,2595], // est.
|
||||
pvh:[3,4,9693],
|
||||
pvs:[0,0,6683], // est.
|
||||
qro:[11,144,814],
|
||||
rai:[1,3,8], // est.
|
||||
rao:[6,3,9693],
|
||||
rbr:[0,0,9693],
|
||||
rec:[6,31,9693],
|
||||
rek:[15,51,93],
|
||||
ria:[2,2,9693],
|
||||
rio:[33,577,9693],
|
||||
rix:[8,60,330], // 8 listed, Perses 2 has 19 networks; presences est.
|
||||
rom:[12,213,1534],
|
||||
ror:[0,0,4],
|
||||
ruh:[8,29,220],
|
||||
run:[3,15,15], // est.
|
||||
sao:[70,1875,9693],
|
||||
scl:[36,274,450],
|
||||
sdq:[4,25,90], // est.
|
||||
sea:[37,539,33300],
|
||||
sez:[1,4,20], // est.
|
||||
sgn:[6,36,1068],
|
||||
sha:[11,27,6717],
|
||||
sin:[58,1271,782],
|
||||
sjc:[57,1048,33300],
|
||||
sjo:[8,6,128],
|
||||
sjp:[2,4,9693],
|
||||
sju:[5,40,60], // est.
|
||||
slc:[22,202,33300],
|
||||
slz:[1,6,9693],
|
||||
sof:[15,451,889],
|
||||
|
|
@ -180,16 +223,21 @@ const CITY_PDB={
|
|||
svg:[2,14,448],
|
||||
syd:[40,979,3196],
|
||||
tbu:[0,0,5],
|
||||
tci:[3,30,1341], // est.
|
||||
the:[2,1,9693],
|
||||
tik:[0,0,6683], // est.
|
||||
tll:[7,80,256],
|
||||
tnr:[1,4,25], // est.
|
||||
tok:[58,917,1330],
|
||||
tor:[46,509,2595],
|
||||
tpe:[15,274,500],
|
||||
tun:[2,0,30],
|
||||
uio:[9,16,287],
|
||||
uus:[1,3,6683], // est.
|
||||
van:[13,214,2595],
|
||||
vie:[30,377,860],
|
||||
vix:[6,30,9693],
|
||||
vvo:[5,25,6683], // est.
|
||||
waw:[25,855,2743],
|
||||
wdh:[1,2,22],
|
||||
zrh:[38,535,1209],
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ const NET=Object.fromEntries(NETS.map(n=>[n.id,n])),NET_IDS=NETS.map(n=>n.id);
|
|||
PLDTea Time (Not That, Ta-Ta), TIM-Tam (its sibling Sparkly Seabone), Floptus (its parent SingTell), Sky-High and
|
||||
Tele-Nor-Way (Tell-Ya, Level Tree), Virgin Mediocre (Level Tree, Not That), and the long tail (tailUp()). The rest stay
|
||||
islands because they are too: the content giants, the transit-free incumbents (Doitsche, Comecast, Jio-graphy, Bee-Tee),
|
||||
China and Korea, and Australians, who buy only from Australian carriers. */
|
||||
China and Korea, and Australia's big ISPs, which buy only from Australian carriers. Smaller Australians do sit in Tier 1
|
||||
cones: Kangaroo Courier buys from Cogentle, Doodoo and Spin2wintel from Hocus Pocus (Not That, Tell-Ya), Lintel from
|
||||
Speedyloop (Tell-Ya). */
|
||||
const CONE={},CONE_S={},DOWN={};
|
||||
{const dn={};for(const n of NETS)for(const u of n.up||[])(dn[u]||(dn[u]=[])).push(n.id);
|
||||
for(const n of NETS){const s=new Set([n.id]),q=[n.id];while(q.length){for(const y of dn[q.pop()]||[])if(!s.has(y)){s.add(y);q.push(y);}}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const scnName=()=>S.scn.id==='weekly'?tr('scenarios.weekly_key',{key:S.scn.key})
|
|||
const AU_BB=['syd','mel','bne','adl','per'],auExits=()=>new Set(S.links.filter(l=>l.sub&&!!CITY[l.a].au!==!!CITY[l.b].au&&!(l.ready>S.day)).map(l=>l.cable||l.id)).size;
|
||||
const brIxN=()=>CITIES.filter(c=>c.br&&S.ixp[c.id]!==undefined).length;
|
||||
const SCN=[
|
||||
{id:'stg',n:tr('scenarios.only_spatzle_ix'),city:'stg',cash:400000,days:730,rules:{noTransit:true,local:true},d:tr('scenarios.start_in_stuttgart_where_nobody'),goal:tr('scenarios.reach_45_of_the_internet_and'),ok:()=>R.reach>=0.45&&R.served>=300},
|
||||
{id:'stg',n:tr('scenarios.only_spatzle_ix'),city:'stg',cash:400000,days:730,rules:{noTransit:true,local:true},d:tr('scenarios.start_in_stuttgart_where_nobody'),goal:tr('scenarios.reach_50_of_the_internet_and'),ok:()=>R.reach>=0.5&&R.served>=300},
|
||||
{id:'redsea',n:tr('scenarios.red_sea_crisis'),city:'mrs',cash:2500000,days:540,rules:{banCities:['cai','jed'],banPairs:['eig:dxb-mrs','gbi:fuj-mrs','smw4:khi-mrs','smw6:mrs-bom','smw6:mrs-sin','peace:mrs-sin','aae:mrs-hkg','twoaf:mrs-bom','medn:cai-mrs','medn:ist-mrs','twoaf:jnb-mrs','eassy:nbo-mrs']},d:tr('scenarios.every_cable_through_the_red_sea'),goal:tr('scenarios.a_path_from_marseille_to_singapore'),ok:()=>pathExists('mrs','sin')&&(S.stats.asiaRun||0)>=RS_DAYS},
|
||||
{id:'spat',n:tr('scenarios.the_cogentle_spat'),city:'nyc',cash:700000,days:540,rules:{spat:true},d:tr('scenarios.cogentle_and_goggle_are_not_speaking'),goal:tr('scenarios.99_reach_and_150_gbps_served'),ok:()=>R.reach>=0.99&&R.served>=150},
|
||||
{id:'carnaval',n:tr('common.carnaval'),city:'rio',cash:600000,days:100,rules:{},setup:()=>{S.biz.push({id:uid(),scripted:true,city:'rio',city2:null,reqs:[],name:'Carnaval Parade in Rio de Janeiro',type:'event',bw:400,rate:0,mood:100,since:0,start:90,dur:5,fee:400*5*70});},d:tr('scenarios.rio_from_scratch_carnaval_starts_in'),goal:tr('scenarios.deliver_carnaval_in_full'),ok:()=>(S.stats.evFull||0)>=1},
|
||||
|
|
|
|||
|
|
@ -10,9 +10,12 @@ function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev
|
|||
for(const x of S.caches)if(x.net===net&&popUp(x.city)&&!siteDown(x.city,'a'))out.push({k:'c',rank:0,city:x.city,pref:'normal',lab:tr('common.name_cache',{name:NET[net].cache.name}),used:R.useCache[x.id]||0,cap:CACHE_CAP});
|
||||
// A peer's customer cone (#85): one AS hop more, so tried after direct peering and before transit, as in compute().
|
||||
for(const p of S.pni)if(CONE_S[p.net].has(net)&&pniOn(p)&&popUp(p.city)&&liveN(p.city,p.site,p.n))out.push({k:'p',rank:p.net===net?1:CONE_RANK,via:p.net===net?null:p.net,city:p.city,pref:p.pref||'normal',lab:tr('common.pni_with_net',{net:NET[p.net].name}),used:R.usePni[p.id]||0,cap:liveCap(pniG(p),p.city,p.site,p.n)});
|
||||
for(const c in S.ixp){const ses=ixSessions(c),via=ses.has(net)?null:[...ses].find(id=>CONE_S[id].has(net));if((ses.has(net)||via)&&(popUp(ixCity(c))||remoteCities().includes(ixCity(c)))&&!(ev.ixdown&&ev.ixdown[c]>day))out.push({k:'ix',rank:via?CONE_RANK:2,via,city:ixCity(c),id:c,pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('common.ix_peering',{ix:ixName(c)}),used:R.useIx[c]||0,cap:ixCap(c)});}
|
||||
for(const c in S.ixp){const ses=ixSessions(c),via=ses.has(net)?null:ANC[net].find(u=>ses.has(u))||null;if((ses.has(net)||via)&&(popUp(ixCity(c))||remoteCities().includes(ixCity(c)))&&!(ev.ixdown&&ev.ixdown[c]>day))out.push({k:'ix',rank:via?CONE_RANK:2,via,city:ixCity(c),id:c,pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('common.ix_peering',{ix:ixName(c)}),used:R.useIx[c]||0,cap:ixCap(c)});}
|
||||
for(const t of S.transit)if(popUp(t.city)&&!(t.down>day)&&liveN(t.city,t.site,t.n)&&net!==leak&&!((ev.depeer>day||scnRule('spat'))&&t.net==='cog'&&net==='ggl'))out.push({k:'t',rank:3,city:t.city,pref:t.pref||'normal',lab:tr('traceroute.name_transit',{name:NET[t.net].name}),tnet:t.net,used:R.useT[t.id]||0,cap:liveCap(PORT[t.tier].g,t.city,t.site,t.n)});
|
||||
return out;}
|
||||
// coneChain(peer,net): [peer, …, net], the shortest walk down customer links (the network's up lists, read backwards).
|
||||
function coneChain(top,id){const prev={[id]:null},q=[id];while(q.length){const x=q.shift();if(x===top)break;for(const u of NET[x].up||[])if(NET[u]&&!(u in prev)){prev[u]=x;q.push(u);}}
|
||||
if(!(top in prev))return [top,id];const out=[];for(let x=top;x!==null;x=prev[x])out.push(x);return out;}
|
||||
function traceroute(src,to){const P=trPaths(src),me=slug(S.name)+'.net',lines=[],ip=(a,b)=>`100.64.${a%250}.${b%250}`;let rtt=0.3,n=1;
|
||||
const hop=(host,addr,extra,note)=>{rtt+=extra;lines.push(`${String(n++).padStart(2)} ${host} (${addr}) ${rtt.toFixed(1)} ms${note?' ← '+note:''}`);};
|
||||
hop(`lo0.cr1.${src}.${me}`,ip(hstr(src),1),0,tr('traceroute.city_your_router',{city:CITY[src].name}));
|
||||
|
|
@ -30,7 +33,8 @@ function traceroute(src,to){const P=trPaths(src),me=slug(S.name)+'.net',lines=[]
|
|||
hop(`${slug(N.name)}-peer.${far}.${slug(T.name)}.net`,`198.51.100.${hstr(N.id)%250}`,0.4,tr('traceroute.net_hands_it_to_to',{net:T.name,to:N.name}));}}
|
||||
else if(e.k==='ix'){hop(`${slug(ixName(e.city))}.peering.${e.city}`,`185.0.${hstr(e.city)%250}.${hstr(N.id)%250}`,0.3,tr('traceroute.across_the_ix_switch',{ix:ixName(e.city)}));}
|
||||
else if(e.k==='p'){hop(`pni-${slug(NET[e.via||N.id].name)}.${e.city}.${me}`,ip(hstr(N.id),3),0.2,tr('traceroute.private_cross_connect'));}
|
||||
if(e.via){const V=NET[e.via];asPath.push(V.asn);hop(`${slug(N.name)}-cust.${e.city}.${slug(V.name)}.net`,`198.51.100.${(hstr(V.id)+3)%250}`,1.2,tr('traceroute.net_hands_it_to_its_customer',{net:V.name,to:N.name}));}
|
||||
// Down the cone one customer at a time: the shortest chain of upstreams from the peer to the network, each AS on the path.
|
||||
if(e.via){const ch=coneChain(e.via,N.id);for(let i=0;i<ch.length-1;i++){const V=NET[ch[i]],C=NET[ch[i+1]];asPath.push(V.asn);hop(`${slug(C.name)}-cust.${e.city}.${slug(V.name)}.net`,`198.51.100.${(hstr(V.id)+3)%250}`,1.2,tr('traceroute.net_hands_it_to_its_customer',{net:V.name,to:C.name}));}}
|
||||
else{hop(`cache-${slug(N.name)}.${e.city}.${me}`,ip(hstr(N.id),4),0.1,tr('traceroute.embedded_cache_in_your_rack'));}
|
||||
asPath.push(N.asn);if(e.k!=='c')hop(`www.${slug(N.name)}.example`,`198.51.100.${(hstr(N.id)+1)%250}`,0.5+(e.k==='t'?1:0.2),`${N.name}`);
|
||||
const order=e.via?tr('traceroute.a_peer_s_customers_come_after'):{c:tr('traceroute.caches_beat_pnis'),p:tr('traceroute.pnis_beat_ix_peering'),ix:tr('traceroute.ix_peering_beats_transit'),t:tr('traceroute.transit_is_the_last_resort')}[e.k];
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ function shareCanvas(){const Wc=1200,Hc=630,cv=document.createElement('canvas');
|
|||
if(S.scn)rows.unshift([scnName(),S.scn.done?(S.scn.id==='weekly'?tr('share_card.score_v',{v:fmtG(S.scn.score||S.stats.peak||0)}):tr('features.done_in_d_days',{d:S.scn.done})):S.scn.failed?tr('share_card.not_this_time'):tr('common.in_progress')]);
|
||||
let y=150;for(const [k,v] of rows.slice(0,9)){g.fillStyle='#fff';g.strokeStyle='#1E2640';g.lineWidth=3;g.beginPath();g.roundRect?g.roundRect(770,y,390,42,12):g.rect(770,y,390,42);g.fill();g.stroke();g.fillStyle='#5A6280';g.font='800 18px Nunito, sans-serif';g.fillText(k,786,y+11);g.fillStyle='#1E2640';g.font='900 22px Nunito, sans-serif';const tw=g.measureText(v).width;g.fillText(v,1146-tw,y+9);y+=48;}
|
||||
// Badge variants show as a ring: frosted for Change Freeze, fiery for BGP at 3 a.m.
|
||||
top.forEach((b,i)=>{const v=S.achP&&S.achP[b.id];if(v&&v!=='oncall'&&BVAR[v]){g.strokeStyle=BVAR[v].col;g.lineWidth=4;g.beginPath();g.arc(60+i*48,537,22,0,7);g.stroke();}});
|
||||
top.forEach((b,i)=>{const v=S.achP&&S.achP[b.id];if(v&&v!=='oncall'&&own(BVAR,v)){g.strokeStyle=BVAR[v].col;g.lineWidth=4;g.beginPath();g.arc(60+i*48,537,22,0,7);g.stroke();}});
|
||||
g.font='34px sans-serif';top.forEach((b,i)=>g.fillText(b.i,40+i*48,520));
|
||||
{const n=v=>got.filter(b=>(S.achP&&S.achP[b.id]||'oncall')===v).length,f=n('freeze'),h=n('bgp');if(f||h){g.fillStyle='#1E2640';g.font='800 18px Nunito, sans-serif';g.fillText([h?`🔥 ${h}`:'',f?`🧊 ${f}`:''].filter(Boolean).join(' '),40+Math.max(1,top.length)*48+8,526);}}
|
||||
g.fillStyle='#1E2640';g.font='900 30px "Baloo 2", sans-serif';g.fillText('seriesoftub.es',40,572);g.font='700 20px Nunito, sans-serif';g.fillText(tr('share_card.build_the_internet_one_tube_at'),300,580);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,14 @@ function autoOffer(o){if(!o||!own(BIZ_T,o.type)||!(o.exp>S.day)||!(o.bw>0)||o.ra
|
|||
// Trial the added demand before signing; failed trials leave the live game untouched.
|
||||
try{S={...S,biz:S.biz};
|
||||
// shortcut: future events reserve capacity together; use per-date trials if separate bookings must share capacity.
|
||||
if(future){S.biz=S.biz.map(x=>BIZ_T[x.type].event&&x.start>S.day?{...x,start:S.day}:x);compute();}
|
||||
if(future){S.biz=S.biz.map(x=>BIZ_T[x.type].event&&x.start>S.day?{...x,start:S.day}:x);
|
||||
/* Signed if the offer works and nobody who works without it breaks. compute() reads the last result only for
|
||||
scenic circuits, so without them the pass with the offer can go first: when the offer fails, or nobody is
|
||||
unhappy with it, the pass without it cannot change the answer and is skipped. */
|
||||
const fut=S.biz,all=fut.concat(b);
|
||||
if(!all.some(x=>x.route==='scenic')){if(T.event)b.start=S.day;if(T.cap)b.live=true;S.biz=all;compute();if(bizWhy(b).length)return null;
|
||||
const bad=fut.filter(x=>bizWhy(x).length);if(!bad.length)return b;S.biz=fut;compute();return bad.every(x=>bizWhy(x).length)?b:null;}
|
||||
compute();}
|
||||
const healthy=S.biz.filter(x=>!bizWhy(x).length);if(T.event)b.start=S.day;if(T.cap)b.live=true;S.biz=S.biz.concat(b);compute();
|
||||
return !bizWhy(b).length&&healthy.every(x=>!bizWhy(x).length)?b:null;
|
||||
}finally{S=state;R=result;UI.hotMap=hot;b.start=o.start;if(T.cap)delete b.live;}}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
noSub (no subsea cables), ring (one ring through every POP), lat:[a,b,ms] (best path under ms), minG (every link at
|
||||
least this many Gbps), avoid (cities shown on the map that you may not build in). */
|
||||
const PZ_PACKS=[
|
||||
{id:'hello',n:tr('puzzles.hello_world'),d:tr('puzzles.your_first_tubes_no_pressure'),need:0},
|
||||
{id:'hello',n:tr('puzzles.hello_world'),d:tr('puzzles.your_first_tubes_roomy_budgets'),need:0},
|
||||
{id:'fire',n:tr('puzzles.ring_of_fire'),d:tr('puzzles.the_pacific_rim_where_every_hop'),need:6},
|
||||
{id:'speed',n:tr('puzzles.speed_runs'),d:tr('puzzles.beat_the_clock_light_in_glass'),need:14},
|
||||
{id:'n1',n:tr('puzzles.n_1_club'),d:tr('puzzles.for_architects_who_sleep_through_backhoes'),need:22},
|
||||
|
|
@ -12,22 +12,22 @@ const PZ_PACKS=[
|
|||
const PZ=[
|
||||
{id:'hello',pack:'hello',n:tr('puzzles.hello_world'),j:tr('puzzles.every_internet_starts_with_one_tube'),cities:['lon','nyc'],budget:0},
|
||||
{id:'eurotrip',pack:'hello',n:tr('puzzles.euro_trip'),j:tr('puzzles.three_cities_two_currencies_one_very'),cities:['lon','ams','fra'],budget:0},
|
||||
{id:'shining',pack:'hello',n:tr('puzzles.sea_to_shining_sea'),j:tr('puzzles.four_cities_one_continent_and_a'),cities:['nyc','chi','dal','sjc'],budget:300000},
|
||||
{id:'smorgas',pack:'hello',n:tr('puzzles.smorgasbord'),j:tr('puzzles.four_capitals_one_very_long_winter'),cities:['osl','sto','cph','hel'],budget:190000},
|
||||
{id:'downunder',pack:'hello',n:tr('puzzles.down_under_up_and_running'),j:tr('puzzles.one_very_big_island_and_a'),cities:['syd','mel','bne','adl'],budget:300000},
|
||||
{id:'aloha',pack:'fire',n:tr('puzzles.aloha_latency'),j:tr('puzzles.honolulu_the_world_s_most_scenic'),cities:['sjc','hnl','syd'],budget:1750000},
|
||||
{id:'rimshot',pack:'fire',n:tr('puzzles.pacific_rim_shot'),j:tr('puzzles.seattle_to_singapore_with_a_stop'),cities:['sea','tok','hkg','sin'],budget:1200000},
|
||||
{id:'fire',pack:'fire',n:tr('puzzles.ring_of_fire'),j:tr('puzzles.four_cities_four_cables_one_ring'),cities:['tok','hkg','sin','syd'],ring:true,budget:1600000},
|
||||
{id:'kiwi',pack:'fire',n:tr('puzzles.kiwi_fruit_salad'),j:tr('puzzles.new_zealand_is_far_from_everything'),cities:['akl','syd','sea'],via:['hnl','suv'],budget:1400000},
|
||||
{id:'guam',pack:'fire',n:tr('puzzles.guam_slam'),j:tr('puzzles.a_tiny_island_where_half_the'),cities:['tok','mnl','syd'],via:['gum'],budget:1600000},
|
||||
{id:'flash',pack:'speed',n:tr('puzzles.flash_boys'),j:tr('puzzles.traders_paid_millions_to_shave_milliseconds'),cities:['nyc','lon'],lat:['nyc','lon',27],budget:450000},
|
||||
{id:'pingpong',pack:'speed',n:tr('puzzles.ping_pong_to_tokyo'),j:tr('puzzles.the_pacific_is_big_light_is'),cities:['lax','tok'],via:['sea','sjc'],lat:['lax','tok',47],budget:850000},
|
||||
{id:'suez',pack:'speed',n:tr('puzzles.suez_you_later'),j:tr('puzzles.frankfurt_to_singapore_the_short_way'),cities:['fra','sin'],via:['mrs','bom'],lat:['fra','sin',68],budget:1000000},
|
||||
{id:'samba',pack:'speed',n:tr('puzzles.samba_sprint'),j:tr('puzzles.sao_paulo_to_miami_before_the'),cities:['sao','mia'],via:['for','rio'],lat:['sao','mia',45],budget:950000},
|
||||
{id:'shining',pack:'hello',n:tr('puzzles.sea_to_shining_sea'),j:tr('puzzles.four_cities_one_continent_and_a'),cities:['nyc','chi','dal','sjc'],budget:340000},
|
||||
{id:'smorgas',pack:'hello',n:tr('puzzles.smorgasbord'),j:tr('puzzles.four_capitals_one_very_long_winter'),cities:['osl','sto','cph','hel'],budget:210000},
|
||||
{id:'downunder',pack:'hello',n:tr('puzzles.down_under_up_and_running'),j:tr('puzzles.one_very_big_island_and_a'),cities:['syd','mel','bne','adl'],budget:320000},
|
||||
{id:'aloha',pack:'fire',n:tr('puzzles.aloha_latency'),j:tr('puzzles.honolulu_the_world_s_most_scenic'),cities:['sjc','hnl','syd'],budget:1830000},
|
||||
{id:'rimshot',pack:'fire',n:tr('puzzles.pacific_rim_shot'),j:tr('puzzles.seattle_to_singapore_with_a_stop'),cities:['sea','tok','hkg','sin'],budget:1240000},
|
||||
{id:'fire',pack:'fire',n:tr('puzzles.ring_of_fire'),j:tr('puzzles.four_cities_four_cables_one_ring'),cities:['tok','hkg','sin','syd'],ring:true,budget:1610000},
|
||||
{id:'kiwi',pack:'fire',n:tr('puzzles.kiwi_fruit_salad'),j:tr('puzzles.new_zealand_is_far_from_everything'),cities:['akl','syd','sea'],via:['hnl','suv','lax'],budget:1450000},
|
||||
{id:'guam',pack:'fire',n:tr('puzzles.guam_slam'),j:tr('puzzles.a_tiny_island_where_half_the'),cities:['tok','mnl','syd'],via:['gum'],budget:1700000},
|
||||
{id:'flash',pack:'speed',n:tr('puzzles.flash_boys'),j:tr('puzzles.traders_paid_millions_to_shave_milliseconds'),cities:['nyc','lon'],lat:['nyc','lon',27],budget:465000},
|
||||
{id:'pingpong',pack:'speed',n:tr('puzzles.ping_pong_to_tokyo'),j:tr('puzzles.the_pacific_is_big_light_is'),cities:['lax','tok'],via:['sea','sjc'],lat:['lax','tok',47],budget:880000},
|
||||
{id:'suez',pack:'speed',n:tr('puzzles.suez_you_later'),j:tr('puzzles.frankfurt_to_singapore_the_short_way'),cities:['fra','sin'],via:['mrs','bom'],lat:['fra','sin',68],budget:1010000},
|
||||
{id:'samba',pack:'speed',n:tr('puzzles.samba_sprint'),j:tr('puzzles.sao_paulo_to_miami_before_the'),cities:['sao','mia'],via:['for','rio'],lat:['sao','mia',45],budget:1060000},
|
||||
{id:'sharks',pack:'n1',n:tr('puzzles.the_shark_tank'),j:tr('puzzles.the_sharks_have_been_biting_again'),cities:['lis','mad','par','mil'],via:['bcn','mrs'],noSub:true,budget:210000},
|
||||
{id:'braces',pack:'n1',n:tr('puzzles.belt_and_braces'),j:tr('puzzles.two_cables_across_the_atlantic_because'),cities:['nyc','lon','dub'],budget:380000},
|
||||
{id:'nofra',pack:'n1',n:tr('puzzles.not_through_frankfurt'),j:tr('puzzles.de_kicks_sales_has_your_number'),cities:['ams','ber','muc','zrh'],via:['ham','dus'],avoid:['fra'],budget:200000},
|
||||
{id:'fatpipes',pack:'n1',n:tr('puzzles.fat_pipes_only'),j:tr('puzzles.nobody_ever_got_fired_for_buying'),cities:['par','mrs','mil','zrh'],minG:100,budget:240000},
|
||||
{id:'nofra',pack:'n1',n:tr('puzzles.not_through_frankfurt'),j:tr('puzzles.de_kicks_sales_has_your_number'),cities:['ams','ber','muc','zrh'],via:['ham','dus'],avoid:['fra'],budget:192000},
|
||||
{id:'fatpipes',pack:'n1',n:tr('puzzles.fat_pipes_only'),j:tr('puzzles.nobody_ever_got_fired_for_buying'),cities:['par','mrs','mil','zrh'],minG:100,budget:235000},
|
||||
];
|
||||
// Weekly puzzle pools: each is one landmass and one region, so every pair has an overland route.
|
||||
const PZ_WEEK_POOLS=[
|
||||
|
|
|
|||
|
|
@ -28,11 +28,12 @@ function pzRoutes(a,b){const out=[],sub=isSub(a,b);
|
|||
return out;}
|
||||
const pzMo=(r,tier,div)=>Math.round(waveMo(r.km,r.sub,tier)*r.f*(div?DIVERSE:1));
|
||||
const pzLinkCost=(r,tier,div)=>pzMo(r,tier,div)*PZ_YEAR;// leased waves have no setup fee: a year of rent
|
||||
const pzPopCost=c=>popCost(c)+PZ_YEAR*POP_MO;
|
||||
const pzPopCost=c=>popCost(c)+PZ_YEAR*popMo(c);// thin markets cost more every month too (#94)
|
||||
const PZ_TIERS=[0,1,2];
|
||||
function pzSpend(){let s=0;for(const c in S.pops)s+=pzPopCost(c);for(const l of S.links)s+=l.mo*PZ_YEAR;return s;}
|
||||
// What one backhoe or one anchor takes out: waves in the same trench, or on the same cable between the same cities.
|
||||
const pzUnit=l=>l.cable?'cab:'+l.cable+':'+edgeKey(l):String(l.trench||l.id);
|
||||
// What one backhoe or one anchor takes out: waves in the same trench, or every wave on the same cable (a cable fails
|
||||
// as a whole, as in the main game's diversity checks).
|
||||
const pzUnit=l=>l.cable?'cab:'+l.cable:String(l.trench||l.id);
|
||||
// ---------- checks ----------
|
||||
function pzComp(ls,skip,from){const adj={};for(const l of ls){if(skip&&pzUnit(l)===skip)continue;(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}
|
||||
const seen=new Set([from]),q=[from];while(q.length){const u=q.pop();for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return seen;}
|
||||
|
|
@ -51,22 +52,35 @@ function pzEval(){const P=S.pz,ls=S.links,cs=P.cities,spend=pzSpend();
|
|||
if(P.minG)tw.push({k:'g',ok:ls.every(l=>LT[l.tier].g>=P.minG)});
|
||||
if(P.avoid.length)tw.push({k:'avoid',ok:P.avoid.every(c=>!S.pops[c])});
|
||||
const goal=conn&&tw.every(t=>t.ok),units=[...new Set(ls.map(pzUnit))];
|
||||
// N-1: the goal cities stay joined whichever single trench or cable segment is cut.
|
||||
// N-1: the goal cities stay joined whichever single trench or cable is cut.
|
||||
const weak=conn?units.filter(u=>{const g=pzComp(ls,u,cs[0]);return !cs.every(c=>g.has(c));}):[];
|
||||
const n1=conn&&units.length>0&&!weak.length,cheap=!P.budget||spend<=P.budget;
|
||||
return {marks,conn,tw,goal,spend,cheap,n1,weak,stars:goal?1+(cheap?1:0)+(n1?1:0):0};}
|
||||
// Two stars, and one more link within budget would survive any cut? Then the third star is close. Tries every route
|
||||
// between the puzzle's cities at the smallest allowed size, so the nudge is true, not a guess.
|
||||
function pzOneMore(e){const P=S.pz;if(e.stars!==2||!e.cheap||e.n1)return false;const cs=[...P.cities,...P.via],tier=P.minG?1:0,cs0=P.cities[0];
|
||||
for(const a of cs)for(const b of cs){if(a>=b)continue;for(const r of pzRoutes(a,b)){if((P.noSub&&r.sub)||subWaveWhy(tier,r.km,r.sub))continue;
|
||||
const div=!r.sub&&S.links.some(l=>edgeKey(l)===edgeKey({a,b})&&!l.cable),cost=pzLinkCost(r,tier,div)+(S.pops[a]?0:pzPopCost(a))+(S.pops[b]?0:pzPopCost(b));
|
||||
if(e.spend+cost>P.budget)continue;const ls=[...S.links,{id:'pz?',a,b,cable:r.cab,trench:r.cab?'cab:'+r.cab:'pz?'}];if(P.ring&&!pzRingOk(ls))continue;
|
||||
if([...new Set(ls.map(pzUnit))].every(u=>{const g=pzComp(ls,u,cs0);return P.cities.every(c=>g.has(c));}))return true;}}
|
||||
return false;}
|
||||
// ---------- the seeded weekly puzzle: the same for everyone, and the stand-in when the published one (93-puzzles-weekly.js) is not there ----------
|
||||
function pzWeekly(dt){const key=pzWeekKey(dt||new Date());let r=hstr('puzzle|'+key)||1;const nx=()=>{r=(Math.imul(r,1103515245)+12345)>>>0;return r/4294967296;};
|
||||
const pool=PZ_WEEK_POOLS[Math.floor(nx()*PZ_WEEK_POOLS.length)].slice(),n=4+Math.floor(nx()*2),cities=[];
|
||||
while(cities.length<n&&pool.length)cities.push(pool.splice(Math.floor(nx()*pool.length),1)[0]);
|
||||
// The budget is a ring through the cities, nearest first, on the cheapest 10G route of each hop, plus 10%:
|
||||
// a ring survives any single cut, so three stars are always possible.
|
||||
// The budget is a ring through the cities, nearest first, on the cheapest 10G route of each hop, plus 10%. A ring
|
||||
// survives any single cut only if no two hops share a cable, so each hop takes the cheapest route on a cable the ring
|
||||
// has not used yet (overland is always there: a pool is one landmass), and three stars are always possible.
|
||||
const ring=[cities[0]],left=cities.slice(1);while(left.length){const u=ring[ring.length-1];left.sort((a,b)=>kmBetween(u,a)-kmBetween(u,b));ring.push(left.shift());}
|
||||
let cost=cities.reduce((a,c)=>a+pzPopCost(c),0);for(let i=0;i<ring.length;i++)cost+=Math.min(...pzRoutes(ring[i],ring[(i+1)%ring.length]).map(x=>pzLinkCost(x,0,false)));
|
||||
return {id:'weekly',key,cities,via:[],budget:Math.ceil(cost*1.1/10000)*10000,ref:ring};}
|
||||
let cost=cities.reduce((a,c)=>a+pzPopCost(c),0);const used=new Set(),via=[];
|
||||
for(let i=0;i<ring.length;i++){const r=pzRoutes(ring[i],ring[(i+1)%ring.length]).filter(x=>!x.cab||!used.has(x.cab)).sort((x,y)=>pzLinkCost(x,0,false)-pzLinkCost(y,0,false))[0];
|
||||
if(r.cab)used.add(r.cab);via.push(r.via);cost+=pzLinkCost(r,0,false);}
|
||||
return {id:'weekly',key,cities,via:[],budget:Math.ceil(cost*1.1/10000)*10000,ref:ring,refVia:via};}
|
||||
function pzStreak(p,key){const st=p.streak;if(st.last===key)return;st.n=st.last&&st.last===pzPrevKey(key)?st.n+1:1;st.last=key;st.best=Math.max(st.best,st.n);}
|
||||
function pzShareText(e){const P=S.pz;return tr('puzzles.share_line',{what:P.id==='weekly'?P.key:pzName(pzDef(P.id)),stars:pzStarStr(e.stars),spend:fmt$(e.spend)});}
|
||||
// ---------- entering and leaving ----------
|
||||
// Toasts from one world never carry over into the other (their buttons act on the S they came from).
|
||||
const pzToastsClear=()=>{$('toasts').textContent='';};
|
||||
// The running game gets its usual save first, so leaving the puzzle can load it back exactly as booting does. A huge
|
||||
// save is compressed in the background and may not have landed yet, so the game object is kept in memory too.
|
||||
function pzFlush(){save(true);UI.pzKeep=UI.gzBusy||saveFailing()?S:null;}
|
||||
|
|
@ -74,13 +88,13 @@ function pzBegin(def){if(!def)return;
|
|||
const go=()=>{newGame(pzName(def),def.cities[0]);S.pops={};S.mode='puzzle';S.rules=makeRules('puzzle');S.nextFail=S.nextEvent=1e9;S.tut=null;
|
||||
S.pz={id:def.id,key:def.key||null,cities:def.cities.slice(),via:(def.via||[]).slice(),avoid:(def.avoid||[]).slice(),budget:def.budget||0,noSub:!!def.noSub,ring:!!def.ring,minG:def.minG||0,lat:def.lat?def.lat.slice():null,wn:def.wn||null,wj:def.wj||null,theme:def.theme||null};
|
||||
UI.pzHist=[];UI.pzTop=0;UI.speed=0;UI.resumeSpeed=null;UI.started=true;UI.sel=null;UI.leftOpen=false;UI.confirm=null;UI._pzh=null;
|
||||
$('dash').hidden=true;$('bankBox').hidden=true;closeModal();document.body.classList.add('pz');
|
||||
$('dash').hidden=true;$('bankBox').hidden=true;closeModal();pzToastsClear();document.body.classList.add('pz');
|
||||
compute();pzCam();renderAll();track('puzzle_'+def.id);
|
||||
toast(`<b>${esc(pzName(def))}</b><br>${tr('puzzles.connect_list',{list:def.cities.map(c=>CITY[c].name).join(', ')})}`,'goal');};
|
||||
if(pzOn()){go();return;}
|
||||
const live=!!(S&&UI.started&&!S.lost);UI.pzFrom=live?'game':'title';
|
||||
if(live)pzFlush();go();}
|
||||
function pzLeave(){const from=UI.pzFrom;document.body.classList.remove('pz');UI.sel=null;UI.pzHist=null;UI.pzFrom=null;closeModal();$('panel').hidden=true;$('pzBox').hidden=true;S=null;R=emptyR();UI.started=false;
|
||||
function pzLeave(){const from=UI.pzFrom;pzToastsClear();document.body.classList.remove('pz');UI.sel=null;UI.pzHist=null;UI.pzFrom=null;closeModal();$('panel').hidden=true;$('pzBox').hidden=true;S=null;R=emptyR();UI.started=false;
|
||||
if(from==='game'){const sv=UI.pzKeep||loadSave();UI.pzKeep=null;
|
||||
if(sv){try{S=migrate(sv);compute();UI.started=true;UI.speed=[0,0.5,1,2,4,8].includes(S.uiSpeed)?S.uiSpeed:1;if(S.cam&&isFinite(S.cam.x))Object.assign(cam,S.cam);renderAll();return;}catch(e){S=null;UI.started=false;}}}
|
||||
renderAll();showTitle();}
|
||||
|
|
@ -95,8 +109,11 @@ const pzNewPop=()=>({day:0,bb:null,boost:0,down:0,routers:1,gen:false});
|
|||
function pzAfter(){if(UI.sel&&((UI.sel.type==='link'&&!S.links.some(l=>l.id===UI.sel.id))||(UI.sel.type==='city'&&!pzKind(UI.sel.id))))UI.sel=null;
|
||||
compute();renderAll();pzCheck();}
|
||||
// Stars count the moment they are earned: a better result than this attempt has had opens the results card.
|
||||
function pzCheck(){const e=pzEval();if(e.stars<=(UI.pzTop||0))return e;const prev=UI.pzTop||0;UI.pzTop=e.stars;pzRecord(e);pzResults(e,prev);return e;}
|
||||
// Every solved state is recorded, so a cheaper build at the same stars counts too.
|
||||
function pzCheck(){const e=pzEval();if(e.stars)pzRecord(e);if(e.stars<=(UI.pzTop||0))return e;const prev=UI.pzTop||0;UI.pzTop=e.stars;pzResults(e,prev);return e;}
|
||||
// The best spend belongs to the best star count: more stars start it again, the same stars keep the lower spend.
|
||||
function pzRecord(e){const p=pzLoad(),P=S.pz,bag=P.id==='weekly'?p.wk:p.s,k=P.id==='weekly'?P.key:P.id,r=bag[k]||{st:0,sp:null};
|
||||
r.st=Math.max(r.st,e.stars);r.sp=r.sp==null?e.spend:Math.min(r.sp,e.spend);bag[k]=r;if(P.id==='weekly')pzStreak(p,P.key);pzStore(p);}
|
||||
if(e.stars<r.st||(e.stars===r.st&&r.sp!=null&&r.sp<=e.spend))return;
|
||||
r.sp=e.spend;r.st=e.stars;bag[k]=r;if(P.id==='weekly')pzStreak(p,P.key);pzStore(p);}
|
||||
// The next puzzle in the list whose pack is open.
|
||||
function pzNextDef(){const p=pzLoad(),i=PZ.findIndex(x=>x.id===S.pz.id);for(let j=i+1;j<PZ.length;j++)if(pzPackOpen(PZ[j].pack,p))return PZ[j];return null;}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// tr() with one placeholder, remembered: compute() labels every port, PNI and cache on every run.
|
||||
const LABS=new Map();function labOf(s,k,v){const key=s+'|'+v;let o=LABS.get(key);if(o===undefined)LABS.set(key,o=tr(s,{[k]:v}));return o;}
|
||||
// Who carries a network reached only through a cone (kept out of compute(), whose size the JIT is sensitive to).
|
||||
function coneBy(L,id){let by=null;for(const e of L){if(e.k==='p')return e.net;if(!by&&e.k==='ix'&&e.dir)by=ANC[id].find(u=>e.dir.has(u))||null;}return by||1;}
|
||||
function compute(){
|
||||
const day=S.day, R2=emptyR(), pops=Object.keys(S.pops).filter(popUp), NC=CITIES.length;
|
||||
// The graph works on city indices: adj[i] lists [neighbour, edge] in S.links order.
|
||||
|
|
@ -14,6 +16,8 @@ function compute(){
|
|||
// ALONE[i]: no other city lies within 1e-6 of POP i (so only its own exits can be at distance 0 from it).
|
||||
const SPD={},SPP={},SDi=[],SPi=[],ALONE=new Uint8Array(NC),wW=e=>e.w,wLat=e=>e.lat+0.05;
|
||||
for(const s of pops){const i=CIDX[s],r=dijkstra(adj,i,wW);SDi[i]=SPD[s]=r.D;SPi[i]=SPP[s]=r.P;ALONE[i]=1;for(let x=0;x<NC;x++)if(x!==i&&r.D[x]<1e-6)ALONE[i]=0;}
|
||||
// COMP[i]: the island city i is on (-1: no POP reaches it). Links run both ways, so reaching is mutual.
|
||||
const COMP=new Int32Array(NC).fill(-1);let NCOMP=0;for(const s of pops){const i=CIDX[s];if(COMP[i]>=0)continue;const D=SDi[i],k=NCOMP++;for(let x=0;x<NC;x++)if(D[x]<Infinity)COMP[x]=k;}
|
||||
const E=[], ev=S.ev;
|
||||
const depeer=ev.depeer>day||scnRule('spat'), leak=ev.leak&&ev.leak.until>day?ev.leak.net:null;
|
||||
for(const t of S.transit){if(!popUp(t.city)||t.down>day||!liveN(t.city,t.site,t.n))continue;
|
||||
|
|
@ -41,8 +45,9 @@ function compute(){
|
|||
// dup: shares its key with another exit (a hand-edited save), so R.egDesc shows whichever pushed last.
|
||||
for(const e of E){e.desc={lab:e.lab,city:e.city,k:e.k};e.dup=ekN[e.ek]>1;e.told=false;e.hp=e.pref==='high'?0:1;e.ci=CIDX[e.city];e.cn=cnCity(e.city);e.vis=0;for(const n of e.nets||NET_IDS){const L=okBy[n];if(L&&L[L.length-1]!==e&&e.ok(n))L.push(e);}}
|
||||
for(const n of NETS){R2.reachable[n.id]=okBy[n.id].some(e=>e.rank>0);if(R2.reachable[n.id])R2.reach+=NSH[n.id];if(okBy[n.id].some(e=>e.rank>0&&e.k!=='t')){R2.nt[n.id]=1;R2.reachNT+=NSH[n.id];
|
||||
// Reached without transit only through the customers of networks you peer with (#85).
|
||||
if(!okBy[n.id].some(e=>(e.k==='p'||e.k==='ix')&&!coneOf(e,n.id)))R2.cone[n.id]=1;}}
|
||||
// Reached without transit only through the customers of networks you peer with (#85). R.cone[id]: the peer that
|
||||
// carries it, the first PNI's network or else the nearest upstream that is a member of an exchange you are on.
|
||||
if(!okBy[n.id].some(e=>(e.k==='p'||e.k==='ix')&&!coneOf(e,n.id)))R2.cone[n.id]=coneBy(okBy[n.id],n.id);}}
|
||||
const cacheNets=new Set(S.caches.filter(c=>popUp(c.city)).map(c=>c.net));
|
||||
const viral=(ev.viral>day?1.25:1)*(ev.php&&ev.php>day?0.7:1);
|
||||
// Every flow has the same shape and carries what routing asks about it again and again (nj: its network's index).
|
||||
|
|
@ -165,8 +170,15 @@ function compute(){
|
|||
const PASSES=TR&&TR.protect?[x=>x.bz,x=>!x.bz]:null;
|
||||
// Each network's exits by the rank they route at (RouteScript can move an exit per network), in E's order.
|
||||
// Each list also knows whether it holds a preferred exit (hi) and its exits by city (at), in list order.
|
||||
// With several islands (POPs no backbone joins), each list is split by island: a flow only scans exits it can reach.
|
||||
const idx=L=>{L.hi=L.some(e=>e.hp===0);L.at=new Map();for(const e of L){const h=L.at.get(e.ci);if(h)h.push(e);else L.at.set(e.ci,[e]);}};
|
||||
// Networks with the same exits at a rank share one list (LIST, by content), so what one flow learns serves them all.
|
||||
const LIST=new Map();for(let i=0;i<E.length;i++)E[i].xi=i;
|
||||
const byRank={},RSET=new Set();for(const id of NET_IDS){const m=byRank[id]={};for(const e of okBy[id]){const r=TR?eff(e,id):base(e,id);RSET.add(r);(m[r]||(m[r]=[])).push(e);}
|
||||
for(const r in m){const L=m[r];L.hi=L.some(e=>e.hp===0);L.at=new Map();for(const e of L){const h=L.at.get(e.ci);if(h)h.push(e);else L.at.set(e.ci,[e]);}}}
|
||||
for(const r in m){const L=m[r],key=L.map(e=>e.xi).join(','),o=LIST.get(key);if(o){m[r]=o;continue;}
|
||||
let V=L;if(NCOMP>1){const cs=[];for(const e of L){const k=COMP[e.ci];if(k>=0)(cs[k]||(cs[k]=[])).push(e);}for(const s of cs)if(s)idx(s);V={cs};}else idx(L);LIST.set(key,V);m[r]=V;}}
|
||||
// Attack flows pinned to their entry port route at its plain rank, which RouteScript may have left with no list.
|
||||
for(const f of flows)if(f.pin)for(const e of ingressE[f.pin]||[])RSET.add(base(e));
|
||||
// The flow being routed, and from its POP: distances, arriving edges and the paths walked so far, by city index.
|
||||
let f=null,Dv=null,Pv=null,PP=null,vis=0;const walked=[],G=[],REST=[],NEG=[];
|
||||
// An exit the flow can still try: not visited yet, not full when the flow started, and reachable from the POP.
|
||||
|
|
@ -216,7 +228,7 @@ function compute(){
|
|||
if(f.rem<=1e-6||(rank===0&&!f.cache)||(pass&&!pass(f)))continue;
|
||||
Dv=SDi[f.ci];Pv=SPi[f.ci];PP=walked[f.ci]||(walked[f.ci]=[]);vis++;
|
||||
if(f.pin){for(const e of ingressE[f.pin]||[])if(base(e)===rank&&e.used<e.cap&&Dv[e.ci]<Infinity)send(e,f.rem);continue;}
|
||||
const lst=byRank[f.n][rank];if(!lst)continue;
|
||||
let lst=byRank[f.n][rank];if(!lst)continue;if(lst.cs){lst=lst.cs[COMP[f.ci]];if(!lst)continue;}
|
||||
/* Groups are tried nearest first, preferred exits before the rest, in the order a stable sort of the usable
|
||||
exits gives. Exits only fill up once tried, so the usable ones stay the same until then. Nearly every flow
|
||||
fits in its first group: find that one with a scan (nothing is visited yet), and sort only what is left
|
||||
|
|
@ -228,13 +240,18 @@ function compute(){
|
|||
// One scan: the best (preference, distance) so far and, in list order, the exits within 1e-6 of it. The best
|
||||
// distance only goes down, so dropping the ones it leaves behind gives exactly the exits a second scan would.
|
||||
// Exits that are full stay full for this pass: when a quarter of a list is, it is rewritten without them.
|
||||
/* gc[ci]: the first group this list gave a flow from city ci. Exits only fill up during routing, so while all of
|
||||
them still have room no other exit can have become better, and the scan would find the same group (an
|
||||
empty one, no usable exit, stays empty). */
|
||||
const gc=lst.gc||(lst.gc=[]),c=gc[f.ci];
|
||||
if(c!==undefined&&c.every(e=>e.used<e.cap)){if(!c.length)continue;for(let k=0;k<c.length;k++)G.push(c[k]);}else{
|
||||
let bh=2,bd=Infinity,full=0;
|
||||
for(let li=0,LN=lst.length;li<LN;li++){const e=lst[li];if(e.used>=e.cap){full++;continue;}const d=Dv[e.ci];if(d===Infinity)continue;const h=e.hp;
|
||||
if(h<bh){bh=h;bd=d;G.length=0;G.push(e);}
|
||||
else if(h===bh){if(d<bd){bd=d;let k=0;for(let gi=0;gi<G.length;gi++){const x=G[gi];if(Dv[x.ci]-d<1e-6)G[k++]=x;}G.length=k;G.push(e);}else if(d-bd<1e-6)G.push(e);}}
|
||||
if(full*4>=lst.length&&full){let k=0;for(let li=0;li<lst.length;li++){const e=lst[li];if(e.used<e.cap)lst[k++]=e;}lst.length=k;}
|
||||
if(bh>1)continue;
|
||||
if(G.length>1)sortD(G);}
|
||||
if(bh>1){gc[f.ci]=[];continue;}
|
||||
if(G.length>1)sortD(G);gc[f.ci]=G.slice();}}
|
||||
sendGroup(G,0,G.length);
|
||||
if(f.rem<=1e-6)continue;
|
||||
REST.length=0;for(let li=0;li<lst.length;li++)if(usable(lst[li]))REST.push(lst[li]);sortD(REST);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ function sanitize(s){
|
|||
s.auV=s.auV===1?1:0;if(s.auNews!==true)delete s.auNews;
|
||||
// Badges: S.ach[id] is the day it was earned (any save); S.achP[id] the variant (2.0). A missing variant is the standard one.
|
||||
for(const k of Object.keys(s.ach))s.ach[k]=num(s.ach[k],0);
|
||||
{const p=s.achP&&typeof s.achP==='object'&&!Array.isArray(s.achP)?s.achP:{};s.achP={};for(const k of Object.keys(s.ach))s.achP[k]=BVAR[p[k]]?p[k]:'oncall';}
|
||||
{const p=s.achP&&typeof s.achP==='object'&&!Array.isArray(s.achP)?s.achP:{};s.achP={};for(const k of Object.keys(s.ach))s.achP[k]=typeof p[k]==='string'&&own(BVAR,p[k])?p[k]:'oncall';}
|
||||
if(s.merged){const o={};if(typeof s.merged==='object')for(const m of MERGERS)if(isFinite(s.merged[m.id]))o[m.id]=+s.merged[m.id];s.merged=Object.keys(o).length?o:undefined;}
|
||||
// The rules (2.0): a save without them is the classic game, On-call (or a sandbox or puzzle, if it was one). Locked after the start.
|
||||
{const r=s.rules&&typeof s.rules==='object'&&!Array.isArray(s.rules)?s.rules:{},p=s.mode==='sandbox'?'sandbox':s.mode==='puzzle'?'puzzle':own(PRESETS,r.preset)?r.preset:'oncall';s.rules=makeRules(p,own(PRESETS,r.preset)?r:{});}
|
||||
|
|
|
|||
|
|
@ -74,10 +74,10 @@ const BADGES=[
|
|||
fiery one; Sandbox and the puzzles earn none (puzzles have stars). Earning a badge again under a harder preset
|
||||
upgrades its look, here and in the hall of fame. S.ach[id] stays the day it was earned; S.achP[id] is its variant. */
|
||||
const BVAR={freeze:{k:'freeze',lv:1,i:'🧊',n:N_('badges.variant_freeze_dried'),col:'#5BC0EB'},oncall:{k:'oncall',lv:2,i:'⭐',n:N_('badges.variant_on_call'),col:'#FFD23F'},bgp:{k:'bgp',lv:3,i:'🔥',n:N_('badges.variant_forged_at_3_a_m'),col:'#FF5A1F'}};
|
||||
const BVAR_IDS=['freeze','oncall','bgp'],bvar=k=>BVAR[k]||BVAR.oncall;
|
||||
const BVAR_IDS=['freeze','oncall','bgp'],bvar=k=>own(BVAR,k)?BVAR[k]:BVAR.oncall;
|
||||
// The preset this save plays under ('oncall' for every save from before rulesets), and the variant it earns (null: none).
|
||||
const rulePre=()=>(typeof rulePreset==='function'?rulePreset():(S&&S.rules&&S.rules.preset))||'oncall';
|
||||
function badgeVar(){if(!S||S.mode==='sandbox')return null;const p=rulePre();return p==='sandbox'||p==='puzzle'?null:BVAR[p]?p:'oncall';}
|
||||
function badgeVar(){if(!S||S.mode==='sandbox')return null;const p=rulePre();return p==='sandbox'||p==='puzzle'?null:own(BVAR,p)?p:'oncall';}
|
||||
// The hall of fame is this device's localStorage, so it is checked like a save: unknown variants count as standard.
|
||||
function hof(){let h;try{h=JSON.parse(localStorage.getItem('sot-badges')||'{}');}catch(e){h=null;}if(!h||typeof h!=='object'||Array.isArray(h))return {};
|
||||
for(const k of Object.keys(h)){const x=h[k];if(!x||typeof x!=='object'){delete h[k];continue;}const vs=x.vs&&typeof x.vs==='object'&&!Array.isArray(x.vs)?x.vs:{};
|
||||
|
|
@ -87,8 +87,9 @@ function hof(){let h;try{h=JSON.parse(localStorage.getItem('sot-badges')||'{}');
|
|||
function checkBadges(){S.ach=S.ach||{};S.achP=S.achP||{};const v=badgeVar();if(!v)return;let h=null;const V=BVAR[v];
|
||||
for(const b of BADGES){const had=S.ach[b.id]!==undefined;if(had&&bvar(S.achP[b.id]).lv>=V.lv)continue;let ok=false;try{ok=b.ok();}catch(e){}
|
||||
if(!ok)continue;if(!had)S.ach[b.id]=S.day;S.achP[b.id]=v;const R0=RARITY[b.r];
|
||||
if(!h)h=hof();const today=new Date().toISOString().slice(0,10),x=h[b.id]||(h[b.id]={d:today,n:S.name,vs:{}});if(x.vs[v]===undefined)x.vs[v]=today;if(bvar(x.v).lv<V.lv||!x.v)x.v=v;
|
||||
toast(`<b>${b.i} ${had?tr('badges.badge_upgraded_name',{name:esc(b.t)}):tr('badges.badge_unlocked_name',{name:esc(b.t)})}</b><br><span style="color:${R0.col};font-weight:900">${R0.n}</span>${v==='oncall'?'':` · <span class="bvt v-${v}">${V.i} ${tr(V.n)}</span>`} · ${esc(b.d)}`,'goal',[],{a:'tab',v:'goals'});sfx('coin');track('badge_'+b.id+(v==='oncall'?'':'_'+v));}
|
||||
// "Upgraded" is about this device's collection: the hall of fame already held the badge, only in a lower variant.
|
||||
if(!h)h=hof();const today=new Date().toISOString().slice(0,10),up=!!h[b.id]&&bvar(h[b.id].v).lv<V.lv,x=h[b.id]||(h[b.id]={d:today,n:S.name,vs:{}});if(x.vs[v]===undefined)x.vs[v]=today;if(bvar(x.v).lv<V.lv||!x.v)x.v=v;
|
||||
toast(`<b>${b.i} ${up?tr('badges.badge_upgraded_name',{name:esc(b.t)}):tr('badges.badge_unlocked_name',{name:esc(b.t)})}</b><br><span style="color:${R0.col};font-weight:900">${R0.n}</span>${v==='oncall'?'':` · <span class="bvt v-${v}">${V.i} ${tr(V.n)}</span>`} · ${esc(b.d)}`,'goal',[],{a:'tab',v:'goals'});sfx('coin');track('badge_'+b.id+(v==='oncall'?'':'_'+v));}
|
||||
if(h)try{localStorage.setItem('sot-badges',JSON.stringify(h));}catch(e){}}
|
||||
// How many badges this device has ever earned in each variant: the collection.
|
||||
function badgeShelf(h){const o={freeze:0,oncall:0,bgp:0};for(const b of BADGES){const x=h[b.id];if(x)for(const v of BVAR_IDS)if(x.vs[v]!==undefined)o[v]++;}return o;}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ Object.assign(ACT,{
|
|||
setPref:({kind,id,v})=>{if(!own(PREF,v))return;if(kind!=='t'&&kind!=='p'&&!(isIx(id)&&S.ixp[id]!==undefined))return;if(kind==='t'){const t=S.transit.find(x=>x.id===id);if(t)t.pref=v;}else if(kind==='p'){const x=S.pni.find(y=>y.id===id);if(x)x.pref=v;}else{S.ixPref=S.ixPref||{};S.ixPref[id]=v;}sfx('click');after();},
|
||||
setMetric:({id,v})=>{if(v!=='custom'&&!own(MET,v))return;const l=S.links.find(x=>x.id===id);if(!l)return;const m=S.pairMet||(S.pairMet={}),k=edgeKey(l);
|
||||
// Switching to custom starts from the current preset's factor, so nothing moves until the player edits it.
|
||||
if(v==='custom'){if(!pairCm(k))m[k]={k:'f',v:MET[pairMet(k)].f};}else if(v==='normal')delete m[k];else m[k]=v;sfx('click');after();},
|
||||
if(v==='custom'){if(!pairCm(k))m[k]={k:'f',v:MET[pairMet(k)].f};}else if(v==='normal')delete m[k];else m[k]=v;metBlur();sfx('click');after();},
|
||||
metricMode:({id,k})=>{if(k!=='f'&&k!=='w')return;const l=S.links.find(x=>x.id===id);if(!l)return;const key=edgeKey(l),c=pairCm(key);if(!c||c.k===k)return;
|
||||
// The cost stays what it was on this link, written the other way.
|
||||
const w=pairW(key,l.km);S.pairMet[key]={k,v:clampM(k,k==='w'?w:w/(l.km+60))};sfx('click');after();},
|
||||
const w=pairW(key,l.km);S.pairMet[key]={k,v:clampM(k,k==='w'?w:w/(l.km+60))};metBlur();sfx('click');after();},
|
||||
metricSet:({id})=>{const l=S.links.find(x=>x.id===id),t=$('metIn');if(!l||!t)return;const key=edgeKey(l),c=pairCm(key);if(!c)return;const v=parseFloat(String(t.value).replace(',','.'));if(!Number.isFinite(v)){sfx('err');return;}
|
||||
t.blur();S.pairMet[key]={k:c.k,v:clampM(c.k,v)};sfx('click');after();},
|
||||
setStandby:({id,on})=>{const l=S.links.find(x=>x.id===id);if(!l)return;if(on)l.standby=true;else delete l.standby;sfx('click');after();},
|
||||
|
|
|
|||
|
|
@ -24,3 +24,8 @@ Object.assign(ACT,{
|
|||
const copied=()=>toast(tr('puzzles.copied_paste_it_anywhere',{t:esc(t)}),'good'),copy=()=>{try{navigator.clipboard.writeText(t).then(copied,()=>toast(esc(t),''));}catch(e){toast(esc(t),'');}};
|
||||
if(navigator.share&&isPhone()){navigator.share({text:t}).catch(()=>{});return;}copy();track('puzzle_share');},
|
||||
});
|
||||
// A puzzle is its own S: a leftover main-game button (an old toast, a stale panel, a shortcut) must not build, buy or
|
||||
// open anything in it. Everything but these and the pz* actions does nothing while a puzzle is on. This file is the
|
||||
// last of the actions, so every one is here to wrap.
|
||||
const PZ_ACTS=new Set(['animSet','closeModal','closePanel','help','helpClose','install','keepPlaying','langSet','menu','mute','prefSet','puzzleDoor','puzzleMenu','selLink','settings','settingsClose','soundSet','speed','updateLater','updateNow','vpSet','whatsNewShow']);
|
||||
for(const k of Object.keys(ACT))if(!PZ_ACTS.has(k)&&!/^pz[A-Z]/.test(k)){const f=ACT[k];ACT[k]=a=>pzOn()?undefined:f(a);}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ function renderLeft(){checkLayer();
|
|||
h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('common.all_networks'),'netFilter',{f:'all'},!foc&&!out?'sm':'ghost sm')}${btn(tr('hud_and_panels.out_of_reach_without_transit_n',{n:lostN}),'netFilter',{f:'out'},out?'sm':'ghost sm')}</div>`;
|
||||
if(out&&!lostN)h+=`<p class="empty">${tr('hud_and_panels.nothing_every_network_is_reachable')}</p>`;
|
||||
for(const n of foc?[foc]:out?ntLost():NETS){if(n.tail&&!UI.tailOpen&&!foc&&!out)continue;
|
||||
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="meta">AS${n.asn}</span></div><div class="meta"><span class="tag ${n.type}">${TYPE_L[n.type]}</span> <span class="tag ${n.pol}">${n.pol}</span> · ${tr('hud_and_panels.p_of_traffic',{p:(NSH[n.id]*100).toFixed(1)})}${n.price?` · ${tr('hud_and_panels.transit_price_gbps',{price:(n.price*S.priceMul).toFixed(2)})}`:''}</div><div class="meta">${esc(n.blurb)}</div>${netWhere(n,where)}${(foc||out)&&!R.nt[n.id]?`<p class="why">${esc(offTransitHint(n.id))}</p>`:''}${(foc||out)&&coneVia(n.id)&&(R.cone[n.id]||!R.nt[n.id])?`<p class="meta">${R.cone[n.id]?tr('hud_and_panels.reached_through_the_customer_cone_of',{net:esc(coneVia(n.id).name)}):tr('hud_and_panels.buys_transit_from_net_peer_with',{net:esc(coneVia(n.id).name)})}</p>`:''}${foc||out&&!R.nt[n.id]?meetLine(n,foc?24:4):''}</div></div>`;}
|
||||
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="meta">AS${n.asn}</span></div><div class="meta"><span class="tag ${n.type}">${TYPE_L[n.type]}</span> <span class="tag ${n.pol}">${n.pol}</span> · ${tr('hud_and_panels.p_of_traffic',{p:(NSH[n.id]*100).toFixed(1)})}${n.price?` · ${tr('hud_and_panels.transit_price_gbps',{price:(n.price*S.priceMul).toFixed(2)})}`:''}</div><div class="meta">${esc(n.blurb)}</div>${netWhere(n,where)}${(foc||out)&&!R.nt[n.id]?`<p class="why">${esc(offTransitHint(n.id))}</p>`:''}${(foc||out)&&coneVia(n.id)&&(R.cone[n.id]||!R.nt[n.id])?`<p class="meta">${R.cone[n.id]?tr('hud_and_panels.reached_through_the_customer_cone_of',{net:esc((NET[R.cone[n.id]]||coneVia(n.id)).name)}):tr('hud_and_panels.buys_transit_from_net_peer_with',{net:esc(coneVia(n.id).name)})}</p>`:''}${foc||out&&!R.nt[n.id]?meetLine(n,foc?24:4):''}</div></div>`;}
|
||||
if(!foc&&!out)h+=`<div class="row"><div class="grow"><div class="nm">${tr('hud_and_panels.the_long_tail')} <span class="meta">${tr('hud_and_panels.n_small_networks',{n:tl.length})}</span></div><div class="meta">${tr('hud_and_panels.p_of_traffic_between_them_scattered',{p:(tl.reduce((a,n)=>a+NSH[n.id],0)*100).toFixed(1),n:tlOn})}</div></div>${btn(UI.tailOpen?tr('common.hide'):tr('common.show'),'tailTog',{},'ghost sm')}</div>`;
|
||||
}
|
||||
if(h!==UI._lh){UI._lh=h;morph($('leftBody'),h);}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ function cityPanel(c){
|
|||
${have.length?btn(tr('common.remove'),'rmCache',{id:(have.find(x=>x.site==='b')||have[0]).id},'ghost sm'):''}${btn(have.length?tr('common.box'):tr('common.request'),'cache',{city:c,net:n.id},'sm',!ok)}</div>${S.pops[c].site2&&have.length?(()=>{const nb=have.filter(x=>x.site==='b').length,na=have.length-nb;return `<div class="seg site"><span class="meta">${tr('city_panel.boxes_a_in_a_b_in',{a:na,b:nb})}</span>${na?btn(tr('city_panel.move_one_to_b'),'cacheSite',{city:c,net:n.id,s:'b'},'ghost sm'):''}${nb?btn(tr('city_panel.move_one_to_a'),'cacheSite',{city:c,net:n.id,s:'a'},'ghost sm'):''}</div>`;})():''}`;}
|
||||
h+=`</section>`;
|
||||
}else{
|
||||
h+=utilityKitHtml(c);
|
||||
h+=utilityKitLine(c);
|
||||
const ls=S.links.filter(l=>l.a===c||l.b===c);
|
||||
const rt=p.routers||1,g=p.rgen||0,G=RG[g],nl=R.nodeLoad[c]||0,nc=R.nodeCap[c]||nodeCap(c),Ni=g===mainRG(G.cls)?mainRG(G.cls+1):-1,N=Ni>=0?RG[Ni]:null,pu=portsUsed(c),pm=portsMax(c);
|
||||
h+=`<section><h3>${tr('common.routers')}</h3><p class="lead">${tr('city_panel.the_model_sets_your_fastest')}</p>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ function utilityKitHtml(city,modal=false){const q=utilityKit(city);if(!q)return
|
|||
<p class="meta">${tr('utilities.cache_moves',{n:q.moves.length})}</p>
|
||||
${q.cost||q.moves.length?`<p class="meta">${tr('utilities.kit_cost',{cost:fmt$(q.cost),mo:fmt$(q.mo)})}</p><div class="btns">${btn(tr('utilities.apply_kit'),'utilityKit',{city,cost:q.cost,modal},'pink',q.cost>0&&S.cash<q.cost)}</div>`:`<p class="meta">${tr('utilities.kit_balanced')}</p>`}
|
||||
<p class="note">${tr('utilities.redundancy_note')}</p></section>${utilityCachesHtml(city,modal)}`;}
|
||||
// In the Infra tab (#192): one line and the button, since the generator, second site, routers and caches each have
|
||||
// their own rows below; the full kit with its caches is in Utilities.
|
||||
function utilityKitLine(city){const q=utilityKit(city);if(!q)return '';const todo=q.cost||q.moves.length;
|
||||
return `<section><p class="meta"><b>${tr('utilities.redundancy_kit')}</b> · ${todo?tr('utilities.kit_cost',{cost:fmt$(q.cost),mo:fmt$(q.mo)})+(q.moves.length?' · '+tr('utilities.cache_moves',{n:q.moves.length}):''):tr('utilities.kit_balanced')}</p>
|
||||
<div class="btns">${todo?btn(tr('utilities.apply_kit'),'utilityKit',{city,cost:q.cost},'pink sm',q.cost>0&&S.cash<q.cost):''}${btn(tr('utilities.title'),'utilities',{city},'ghost sm')}</div></section>`;}
|
||||
function utilityCachesHtml(city,modal=false){const q=utilityCaches(city);if(!q)return '';
|
||||
return `<section><h3>${tr('common.embedded_caches')}</h3><p class="lead">${tr('utilities.cache_note')}</p>
|
||||
<p class="meta">${tr('utilities.cache_quote',{n:q.add.length,mo:fmt$(q.mo)})}</p>
|
||||
|
|
|
|||
|
|
@ -34,10 +34,11 @@ function vxcPanel(l){
|
|||
return h;
|
||||
}
|
||||
function prefCtl(kind,id,cur){cur=cur||'normal';return `<div class="btns"><span class="meta" style="align-self:center">${tr('common.egress')}</span>${Object.keys(PREF).map(v=>btn(PREF[v],'setPref',{kind,id,v},cur===v?'pink sm':'ghost sm')).join('')}</div>`;}
|
||||
// Trial routing is isolated from the live save, counters and scenic-route memory.
|
||||
// Trial routing is isolated from the live save, counters and scenic-route memory. "Before" is the live routing, which
|
||||
// after() keeps current, so a check costs one compute() on a big network, not two.
|
||||
function linkTrial(id){const save=S,live=R,hot=UI.hotMap,cache=TE_CACHE;
|
||||
try{S=JSON.parse(JSON.stringify(save));const l=S.links.find(x=>x.id===id);if(!l||linkDown(l))return null;
|
||||
compute();const before=R;l.cut=S.day+1;compute();
|
||||
try{const l0=save.links.find(x=>x.id===id);if(!l0||linkDown(l0))return null;
|
||||
S=JSON.parse(JSON.stringify(save));const l=S.links.find(x=>x.id===id),before=live;l.cut=S.day+1;compute();
|
||||
const allowed=new Set(Object.keys(S.pops).filter(popUp).concat(remoteCities())),adj={};
|
||||
for(const x of S.links)if(!linkDown(x)&&allowed.has(x.a)&&allowed.has(x.b)){(adj[x.a]=adj[x.a]||[]).push(x.b);(adj[x.b]=adj[x.b]||[]).push(x.a);}
|
||||
const seen=new Set([l.a]),q=[l.a];for(let i=0;i<q.length;i++)for(const c of adj[q[i]]||[])if(!seen.has(c)){seen.add(c);q.push(c);}
|
||||
|
|
@ -67,6 +68,8 @@ function trafficSection(l){
|
|||
if(u>=0.8&&egs.length){const d=R.egDesc[egs[0][0]];h+=`<p class="why">${tr('link_panels.biggest_feeder_egress_in_city_set',{egress:esc(d.lab),city:CITY[d.city].name})}</p>`;}
|
||||
return h+`</section>`;
|
||||
}
|
||||
// Safari keeps the number field focused through a button tap, and renderPanel() skips a focused field: let go first (#131).
|
||||
const metBlur=()=>{const t=$('metIn');if(t&&document.activeElement===t)t.blur();};
|
||||
function metricSection(l){const key=edgeKey(l),cur=pairMet(key),pl=pairLinks(l.a,l.b),sb=!!l.standby,base=l.km+60,sel=k=>cur===k?'pink sm':'ghost sm';
|
||||
let h=`<section><h3>${tr('common.routing_metric')}</h3><p class="lead">${tr('link_panels.your_routers_pick_the_lowest_cost_0160')}</p><div class="btns">${Object.keys(MET).map(k=>btn(MET[k].l,'setMetric',{id:l.id,v:k},sel(k))).join('')}${btn(tr('common.custom'),'setMetric',{id:l.id,v:'custom'},sel('custom'))}</div>`;
|
||||
const cm=pairCm(key);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const RS_G=80,RS_DAYS=30,asiaG=()=>S.links.reduce((a,l)=>a+((CITY[l.a].reg==='AS
|
|||
const pSrv=g=>({l:tr('common.traffic_served'),v:R.served,max:g,txt:`${fmtG(R.served)} / ${fmtG(g)}`});
|
||||
const pReach=()=>({l:tr('common.reach'),v:R.reach,max:0.99,txt:`${pct(R.reach)} / 99%`});
|
||||
const pChk=(l,ok)=>({l,v:ok?1:0,max:1,txt:ok?'✓':'—'});
|
||||
const SCN_PROG={stg:()=>[{l:tr('common.reach'),v:R.reach,max:0.45,txt:`${pct(R.reach)} / 45%`},pSrv(300)],redsea:()=>{const g=asiaG(),n=S.stats.asiaRun||0;return [pChk(tr('progress.a_path_from_marseille_to_singapore'),pathExists('mrs','sin')),{l:tr('progress.your_traffic_to_and_from_asia'),v:Math.min(g,RS_G),max:RS_G,txt:`${fmtG(g)} / ${fmtG(RS_G)}`},{l:tr('progress.days_in_a_row_at_g',{g:fmtG(RS_G)}),v:n,max:RS_DAYS,txt:`${n} / ${RS_DAYS}`}];},spat:()=>[pReach(),pSrv(150)],
|
||||
const SCN_PROG={stg:()=>[{l:tr('common.reach'),v:R.reach,max:0.5,txt:`${pct(R.reach)} / 50%`},pSrv(300)],redsea:()=>{const g=asiaG(),n=S.stats.asiaRun||0;return [pChk(tr('progress.a_path_from_marseille_to_singapore'),pathExists('mrs','sin')),{l:tr('progress.your_traffic_to_and_from_asia'),v:Math.min(g,RS_G),max:RS_G,txt:`${fmtG(g)} / ${fmtG(RS_G)}`},{l:tr('progress.days_in_a_row_at_g',{g:fmtG(RS_G)}),v:n,max:RS_DAYS,txt:`${n} / ${RS_DAYS}`}];},spat:()=>[pReach(),pSrv(150)],
|
||||
carnaval:()=>[pChk(tr('progress.carnaval_delivered_in_full'),(S.stats.evFull||0)>=1)],ixbr:()=>{const n=brIxN();return [{l:tr('progress.ix_brrr_ports'),v:n,max:15,txt:`${n} / 15`},pChk(tr('progress.a_port_on_ix_brrr_manaus'),S.ixp.mao!==undefined),pSrv(200)];},
|
||||
c2c:()=>[pChk(tr('progress.a_path_from_cape_town_to'),pathExists('cpt','cai')),...['lag','nbo'].map(c=>pChk(tr('progress.pop_in_city',{city:CITY[c].name}),!!S.pops[c])),pSrv(150)],
|
||||
pac:()=>[pChk(tr('progress.1_6t_on_every_hop_from'),fastPath('lax','syd',1600)),pChk(tr('progress.a_path_from_los_angeles_to'),pathExists('lax','tok')),pSrv(150)],
|
||||
|
|
|
|||
|
|
@ -4,23 +4,25 @@ function pzTwistTxt(t){const P=S.pz;
|
|||
if(t.k==='sub')return tr('puzzles.no_subsea_cables');
|
||||
if(t.k==='ring')return tr('puzzles.one_ring_through_every_pop');
|
||||
if(t.k==='g')return tr('puzzles.every_link_n_g_or_more',{n:P.minG});
|
||||
if(t.k==='avoid')return tr('puzzles.no_pop_in_list',{list:P.avoid.map(c=>CITY[c].name).join(', ')});
|
||||
const [a,b,ms]=P.lat;return isFinite(t.ms)?tr('puzzles.a_to_b_under_ms_now',{a:CITY[a].name,b:CITY[b].name,ms,now:t.ms.toFixed(1)}):tr('puzzles.a_to_b_under_ms',{a:CITY[a].name,b:CITY[b].name,ms});}
|
||||
// The short version, for the puzzle list.
|
||||
function pzTwistTag(d){const t=[];if(d.noSub)t.push(tr('puzzles.no_subsea'));if(d.ring)t.push(tr('puzzles.ring'));if(d.lat)t.push(tr('puzzles.under_n_ms',{n:d.lat[2]}));if(d.minG)t.push(tr('puzzles.n_g_links',{n:d.minG}));if(d.avoid&&d.avoid.length)t.push(tr('puzzles.avoid_list',{list:d.avoid.map(c=>CITY[c].name).join(', ')}));return t;}
|
||||
const pzUnitName=u=>{const l=S.links.find(x=>pzUnit(x)===u);return l?`${CITY[l.a].name} ⇄ ${CITY[l.b].name}${l.cable?' ('+esc(CAB[l.cable].name)+')':''}`:'';};
|
||||
// A cable carrying several of your waves is named on its own: cutting it takes them all.
|
||||
const pzUnitName=u=>{const ls=S.links.filter(x=>pzUnit(x)===u),l=ls[0];return !l?'':l.cable&&ls.length>1?esc(CAB[l.cable].name):`${CITY[l.a].name} ⇄ ${CITY[l.b].name}${l.cable?' ('+esc(CAB[l.cable].name)+')':''}`;};
|
||||
function pzRender(){const el=$('pzBox');if(!pzOn()){el.hidden=true;return;}el.hidden=false;
|
||||
const e=pzEval(),P=S.pz,d=pzDef(P.id),pk=d&&PZ_PACKS.find(x=>x.id===d.pack);
|
||||
const star=(on,l)=>`<span class="${on?'on':''}">⭐<small>${l}</small></span>`;
|
||||
let h=`<div class="grab" data-grab="pz" aria-hidden="true"></div><div class="pzh"><div class="grow"><div class="eyebrow">${pk?esc(pk.n):P.theme&&own(PZ_WK_THEMES,P.theme)?`${PZ_WK_THEMES[P.theme].i} ${tr('puzzles.weekly_puzzle')} · ${tr(PZ_WK_THEMES[P.theme].t)}`:tr('puzzles.weekly_puzzle')}</div><h3>${esc(pzName(d||P))}</h3></div>${btn('☰','puzzleMenu',{},'ghost sm')}</div>`;
|
||||
if(d)h+=`<p class="pzj">${esc(d.j)}</p>`;else if(P.wj)h+=`<p class="pzj">${esc(pzTxt(P.wj))}</p>`;
|
||||
h+=`<div class="pzs">${star(e.goal,tr('puzzles.goal'))}${star(e.goal&&e.cheap,P.budget?tr('puzzles.budget'):tr('puzzles.free'))}${star(e.goal&&e.n1,'N-1')}</div>`;
|
||||
h+=`<div class="pzck">${e.marks.map(m=>`<span class="pzc s${m.st}">${esc(CITY[m.c].name)}${m.st===2?' ✓':m.st===1?' ·':' …'}</span>`).join('')}</div>`;
|
||||
for(const t of e.tw)h+=`<div class="pztw ${t.ok?'ok':''}">${t.ok?'✓':'✗'} ${pzTwistTxt(t)}</div>`;
|
||||
// ○ still to reach, ◐ has a POP, ✓ joined up. A leading mark, so nothing looks cut off.
|
||||
h+=`<div class="pzck">${e.marks.map(m=>`<span class="pzc s${m.st}"><i aria-hidden="true">${m.st===2?'✓':m.st===1?'◐':'○'}</i> ${esc(CITY[m.c].name)}</span>`).join('')}</div>`;
|
||||
// Cities to avoid cannot be built in at all, so they read as a rule, not as a box to tick.
|
||||
for(const t of e.tw)h+=t.k==='avoid'?`<div class="pztw rule">🚫 ${tr('puzzles.rule_not_via_list',{list:P.avoid.map(c=>esc(CITY[c].name)).join(', ')})}</div>`:`<div class="pztw ${t.ok?'ok':''}">${t.ok?'✓':'✗'} ${pzTwistTxt(t)}</div>`;
|
||||
const sp=fmt$(e.spend);
|
||||
h+=P.budget?`<div class="pzbud"><div class="kv"><span>${tr('puzzles.spent_x_of_y',{x:sp,y:fmt$(P.budget)})}</span><b>${e.cheap?'✓':'✗'}</b></div><div class="bar ${e.cheap?(e.spend>P.budget*0.85?'warn':''):'bad'}"><i style="width:${Math.min(100,e.spend/P.budget*100).toFixed(1)}%"></i></div></div>`
|
||||
:`<div class="pzbud"><div class="kv"><span>${tr('puzzles.spent_x',{x:sp})}</span><b>${tr('puzzles.no_budget_star_on_the_house')}</b></div></div>`;
|
||||
h+=!e.conn?`<div class="pzn1">🛡 ${tr('puzzles.n_1_connect_everything_first')}</div>`:e.n1?`<div class="pzn1 on">🛡 ${tr('puzzles.survives_any_single_cut')}</div>`:`<div class="pzn1 bad">⚠️ ${tr('puzzles.one_cut_splits_it_where',{where:pzUnitName(e.weak[0])})}</div>`;
|
||||
h+=!e.conn?`<div class="pzn1">🛡 ${tr('puzzles.n_1_connect_everything_first')}</div>`:e.n1?`<div class="pzn1 on">🛡 ${tr('puzzles.survives_any_single_cut')}</div>`:`<div class="pzn1 bad">⚠️ ${tr('puzzles.one_cut_splits_it_where',{where:pzUnitName(e.weak[0])})}${pzOneMore(e)?`<br><small>${tr('puzzles.so_close_one_more_link_and')}</small>`:''}</div>`;
|
||||
h+=`<div class="btns">${btn('↶ '+tr('puzzles.undo'),'pzUndo',{},'ghost sm',!(UI.pzHist&&UI.pzHist.length))}${btn(tr('puzzles.reset'),'pzReset',{},'ghost sm',!S.links.length&&!Object.keys(S.pops).length)}${btn(UI.pzFrom==='game'?tr('puzzles.back_to_my_network'):tr('puzzles.back_to_the_title'),'pzLeave',{},'ghost sm')}</div>`;
|
||||
if(h!==UI._pzh){UI._pzh=h;morph(el,h);}}
|
||||
function pzPanel(sel){const head=(eb,name,facts)=>`<div class="ph"><div style="min-width:0"><div class="eyebrow">${eb}</div><h2>${name}</h2>${facts?`<div class="facts">${facts}</div>`:''}</div><button class="x" data-act="closePanel" aria-label="${tr('common.close')}">×</button></div>`;
|
||||
|
|
@ -28,7 +30,7 @@ function pzPanel(sel){const head=(eb,name,facts)=>`<div class="ph"><div style="m
|
|||
const eb=k==='goal'?tr('puzzles.goal_city'):k==='via'?tr('puzzles.stepping_stone_optional'):tr('puzzles.off_limits');
|
||||
let h=head(`${PZ_ICON[k]} ${eb}`,esc(C.name),p?`<span class="fact mine">${tr('common.your_pop')}</span>`:'')+'<div class="scroll">';
|
||||
if(k==='avoid')return h+`<p class="lead">${tr('puzzles.not_this_one_find_a_way_around')}</p></div>`;
|
||||
if(!p)h+=`<p class="lead">${tr('puzzles.a_pop_costs_setup_plus_a_year',{setup:fmt$(popCost(c)),mo:fmt$(POP_MO)})}</p><div class="btns">${btn(tr('puzzles.open_a_pop_cost',{cost:fmt$(pzPopCost(c))}),'pzPop',{city:c},'pink big')}</div>`;
|
||||
if(!p)h+=`<p class="lead">${tr('puzzles.a_pop_costs_setup_plus_a_year',{setup:fmt$(popCost(c)),mo:fmt$(popMo(c))})}</p><div class="btns">${btn(tr('puzzles.open_a_pop_cost',{cost:fmt$(pzPopCost(c))}),'pzPop',{city:c},'pink big')}</div>`;
|
||||
else{const others=[...S.pz.cities,...S.pz.via].filter(x=>x!==c);
|
||||
h+=`<p class="lead">${tr('puzzles.drag_from_this_pop_onto_another')}</p><h3>${tr('puzzles.lease_a_wave_to')}</h3><div class="seg">${others.map(x=>btn(esc(CITY[x].name),'pzLinkTo',{a:c,b:x},S.pops[x]?'':'ghost')).join('')}</div>`;
|
||||
const ls=S.links.filter(l=>l.a===c||l.b===c);if(ls.length)h+=`<h3 style="margin-top:10px">${tr('common.links')}</h3>`+ls.map(l=>`<div class="row"><div class="grow"><div class="nm">${esc(CITY[l.a===c?l.b:l.a].name)}</div><div class="meta">${capName(l)} · ${linkLat(l).toFixed(1)} ms</div></div>${btn(tr('common.open'),'selLink',{id:l.id},'ghost sm')}</div>`).join('');
|
||||
|
|
@ -54,17 +56,21 @@ function pzLinkModal(a,b,keep){const kb=pzKind(b);
|
|||
h+=`<div class="tiers">${PZ_TIERS.map(i=>{const why=subWaveWhy(i,r.km,r.sub),c=pzLinkCost(r,i,div)+pop;return `<button class="tierbtn" data-act="pzLink" data-args='{"tier":${i}}'${why||(P.noSub&&r.sub)?' disabled':''}><span class="sz">${LT[i].n}</span><span class="grow meta">${why?tr('common.too_far_for_this_cable'):pop?tr('puzzles.with_the_pop_price',{price:fmt$(c)}):''}</span><span class="pr num">${tr('puzzles.price_per_year',{price:fmt$(pzLinkCost(r,i,div))})}</span></button>`;}).join('')}</div>`;
|
||||
openModal(h);}
|
||||
// ---------- results ----------
|
||||
function pzLine(e){return e.stars>=3?tr('puzzles.a_backhoe_walks_into_your_network'):!e.n1&&!e.cheap?tr('puzzles.it_works_finance_and_the_backhoe'):!e.n1?tr('puzzles.one_backhoe_away_from_a_very'):tr('puzzles.rock_solid_and_gold_plated_the');}
|
||||
function pzLine(e){return e.stars>=3?tr('puzzles.a_backhoe_walks_into_your_network'):!e.n1&&!e.cheap?tr('puzzles.it_works_finance_and_the_backhoe'):!e.n1?(pzOneMore(e)?tr('puzzles.so_close_one_more_link_and'):tr('puzzles.one_backhoe_away_from_a_very')):tr('puzzles.rock_solid_and_gold_plated_the');}
|
||||
// Stars still to win in this puzzle's pack, from the progress just saved.
|
||||
function pzPackLeft(P){const d=pzDef(P.id);if(!d)return null;const p=pzLoad(),xs=PZ.filter(x=>x.pack===d.pack);return xs.length*3-xs.reduce((a,x)=>a+((p.s[x.id]||{}).st|0),0);}
|
||||
function pzConfetti(){if(!animOn())return '';const cols=['#FF4F9A','#FFD23F','#22C47A','#2F8CFF','#FF8A3D','#7B61FF'];let h='';
|
||||
for(let i=0;i<28;i++)h+=`<i style="--x:${(i*37)%100}%;--c:${cols[i%cols.length]};--r:${(i%2?1:-1)*(180+(i*53)%360)}deg;--t:${1.4+(i%5)*0.25}s;--dl:${((i*7)%10)/10}s"></i>`;
|
||||
return `<div class="pzconf" aria-hidden="true">${h}</div>`;}
|
||||
function pzResults(e,prev){const P=S.pz,nx=P.id==='weekly'?null:pzNextDef();
|
||||
function pzResults(e,prev){const P=S.pz,nx=P.id==='weekly'?null:pzNextDef(),left=pzPackLeft(P),done=e.stars>=3;
|
||||
const row=(ok,l,v)=>`<div class="kv"><span>${ok?'⭐':'☆'} ${l}</span><b>${v}</b></div>`;
|
||||
const stars=[0,1,2].map(i=>`<span class="pzbig${i<e.stars?' on':''}${i>=prev&&i<e.stars?' pop':''}" style="--d:${Math.max(0,i-prev)*0.45}s">⭐</span>`).join('');
|
||||
openModal(`<div class="pzres">${e.stars>=3?pzConfetti():''}<div style="display:flex;align-items:center"><div class="grow"><div class="eyebrow">${tr('puzzles.puzzle_solved')}</div><h2 style="font-size:28px">${esc(pzName(pzDef(P.id)||P))}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>
|
||||
<div class="pzstars">${stars}</div><p class="tagline" style="text-align:center">${pzLine(e)}</p>
|
||||
<div class="pzstars">${stars}</div><p class="tagline" style="text-align:center">${pzLine(e)}</p>${left==null?'':`<p class="pzleft">${left?trn('puzzles.n_stars_left_in_this_pack',left):tr('puzzles.every_star_in_this_pack_is')}</p>`}
|
||||
${row(true,tr('puzzles.goal'),tr('puzzles.connected'))}${row(e.cheap,tr('puzzles.budget'),P.budget?tr('puzzles.spent_x_of_y',{x:fmt$(e.spend),y:fmt$(P.budget)}):tr('puzzles.on_the_house'))}${row(e.n1,'N-1',e.n1?tr('puzzles.survives_any_single_cut'):tr('puzzles.one_cut_splits_it'))}
|
||||
<div class="btns cta" style="margin-top:12px">${nx?btn(tr('puzzles.next_puzzle'),'pzStart',{id:nx.id},'pink big'):btn(tr('puzzles.more_puzzles'),'puzzleMenu',{},'pink big')}${e.stars<3?btn(tr('puzzles.retry_for_3_stars'),'pzRetry',{},''):''}${btn(tr('common.share_2cd9'),'pzShare',{},'')}${btn(tr('puzzles.keep_building'),'closeModal',{},'ghost')}</div></div>`);
|
||||
<div class="btns cta${done?' pzdone':''}" style="margin-top:12px">${nx?btn(tr('puzzles.next_puzzle')+(done?' →':''),'pzStart',{id:nx.id},'pink big pznext'):btn(tr('puzzles.more_puzzles'),'puzzleMenu',{},'pink big pznext')}${!done?btn(tr('puzzles.retry_for_3_stars'),'pzRetry',{},''):''}${btn(tr('common.share_2cd9'),'pzShare',{},done?'ghost':'')}${btn(tr('puzzles.keep_building'),'closeModal',{},'ghost')}</div></div>`);
|
||||
// Three stars: Next is the one big obvious tap (and the keyboard's default).
|
||||
if(done){const b=document.querySelector('#modalCard .pznext');if(b)try{b.focus({preventScroll:true});}catch(_){}}
|
||||
for(let i=prev;i<e.stars;i++)setTimeout(()=>{sfx('star');haptic(15);},Math.max(0,i-prev)*450+150);
|
||||
if(e.stars>=3&&prev<3)setTimeout(()=>sfx('fanfare'),(3-prev)*450+250);}
|
||||
// ---------- the list ----------
|
||||
|
|
|
|||
|
|
@ -2855,6 +2855,7 @@
|
|||
"puzzles.euro_trip":"Euro Trip",
|
||||
"puzzles.every_internet_starts_with_one_tube":"Every internet starts with one tube.",
|
||||
"puzzles.every_link_n_g_or_more":"Every link {n}G or more",
|
||||
"puzzles.every_star_in_this_pack_is":"Every star in this pack is yours.",
|
||||
"puzzles.fat_pipes_only":"Fat Pipes Only",
|
||||
"puzzles.flash_boys":"Flash Boys",
|
||||
"puzzles.for_architects_who_sleep_through_backhoes":"For architects who sleep through backhoe season.",
|
||||
|
|
@ -2878,6 +2879,7 @@
|
|||
"puzzles.n_1_club":"N-1 Club",
|
||||
"puzzles.n_1_connect_everything_first":"N-1: connect everything first",
|
||||
"puzzles.n_g_links":"{n}G links",
|
||||
"puzzles.n_stars_left_in_this_pack":{"one":"{n} ⭐ left in this pack","other":"{n} ⭐ left in this pack"},
|
||||
"puzzles.n_week_streak":{"one":"{n} week in a row","other":"{n} weeks in a row"},
|
||||
"puzzles.new_this_sunday":"New this Sunday!",
|
||||
"puzzles.new_zealand_is_far_from_everything":"New Zealand is far from everything. That is the point, and the problem.",
|
||||
|
|
@ -2889,7 +2891,6 @@
|
|||
"puzzles.no_budget_star_on_the_house":"no budget: ⭐ on the house",
|
||||
"puzzles.no_cable_lands_in_both_try":"No cable lands in both {a} and {b}. Try a stepping stone in between.",
|
||||
"puzzles.no_clock_no_bills_nothing_breaks":"No clock, no bills, nothing breaks. Connect the cities, then go for three stars: under budget, and still connected when any one link is cut.",
|
||||
"puzzles.no_pop_in_list":"No POP in {list}",
|
||||
"puzzles.no_subsea":"no subsea",
|
||||
"puzzles.no_subsea_cables":"No subsea cables",
|
||||
"puzzles.nobody_ever_got_fired_for_buying":"Nobody ever got fired for buying 100G.",
|
||||
|
|
@ -2916,6 +2917,7 @@
|
|||
"puzzles.ring":"ring",
|
||||
"puzzles.ring_of_fire":"Ring of Fire",
|
||||
"puzzles.rock_solid_and_gold_plated_the":"Rock solid, and gold plated. The CFO has questions.",
|
||||
"puzzles.rule_not_via_list":"Rule: not via {list}",
|
||||
"puzzles.samba_sprint":"Samba Sprint",
|
||||
"puzzles.same_puzzle_for_everyone_this_week":"Same puzzle for everyone this week",
|
||||
"puzzles.same_trench_cheaper_one_backhoe_cuts":"Same trench (cheaper, one backhoe cuts both)",
|
||||
|
|
@ -2926,6 +2928,7 @@
|
|||
"puzzles.size":"Size",
|
||||
"puzzles.small_calm_network_builds":"Small, calm network builds",
|
||||
"puzzles.smorgasbord":"Smörgåsbord",
|
||||
"puzzles.so_close_one_more_link_and":"So close: one more link and a backhoe can't touch you.",
|
||||
"puzzles.speed_runs":"Speed Runs",
|
||||
"puzzles.spent_x":"Spent {x}",
|
||||
"puzzles.spent_x_of_y":"Spent {x} / {y}",
|
||||
|
|
@ -2948,7 +2951,7 @@
|
|||
"puzzles.weekly_puzzle":"Weekly puzzle",
|
||||
"puzzles.weekly_puzzle_key":"Weekly puzzle {key}",
|
||||
"puzzles.with_the_pop_price":"with the POP: {price}",
|
||||
"puzzles.your_first_tubes_no_pressure":"Your first tubes. No pressure, no budget.",
|
||||
"puzzles.your_first_tubes_roomy_budgets":"Your first tubes. Roomy budgets, and the first two are on the house.",
|
||||
"puzzles.your_stars":"Your stars",
|
||||
"puzzles_weekly.detour":"Detour",
|
||||
"puzzles_weekly.island_hopping":"Island hopping",
|
||||
|
|
@ -3238,7 +3241,7 @@
|
|||
"scenarios.ponta_delgada_in_the_azores_halfway":"Ponta Delgada, in the Azores, halfway across the Atlantic. Florida to Spain and Lisbon to Lagos are just too long for a 1.6T wave: straight across, each carries 1.2T. Land on the islands in between, start the light fresh, and every hop runs at 1.6T or better. You start with 1.6T gear unlocked.",
|
||||
"scenarios.pops_in_bogota_lima_santiago_and":"POPs in Bogotá, Lima, Santiago and São Paulo, and 150 Gbps served",
|
||||
"scenarios.ports_on_15_ix_brrr_exchanges":"Ports on 15 IX.brrr exchanges, one of them in Manaus, and 200 Gbps served",
|
||||
"scenarios.reach_45_of_the_internet_and":"Reach 45% of the internet and serve 300 Gbps",
|
||||
"scenarios.reach_50_of_the_internet_and":"Reach 50% of the internet and serve 300 Gbps",
|
||||
"scenarios.red_sea_crisis":"Red Sea Crisis",
|
||||
"scenarios.rio_from_scratch_carnaval_starts_in":"Rio from scratch. Carnaval starts in 90 days and wants 400 Gbps for five days straight. The whole world is watching.",
|
||||
"scenarios.sandbox_mode_a_billion_dollars_chaos":"<b>Sandbox mode</b><br>A billion dollars and every unlock. Chaos: {chaos}. Build the internet you always wanted, and keep a spare backhoe handy.",
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
.pzs{display:flex;gap:6px;margin:6px 0}.pzs span{flex:1;display:flex;flex-direction:column;align-items:center;border:2.5px solid var(--ink);border-radius:11px;padding:3px 0;font-size:20px;filter:grayscale(1);opacity:.45;transition:transform .25s,opacity .25s}
|
||||
.pzs span small{font:900 10px var(--body);text-transform:uppercase;letter-spacing:.05em}.pzs span.on{filter:none;opacity:1;background:#FFF3C4;transform:scale(1.05)}
|
||||
.pzck{display:flex;flex-wrap:wrap;gap:5px;margin:6px 0}.pzc{font-weight:900;font-size:12px;border:2px solid var(--ink);border-radius:999px;padding:1px 8px;background:#fff}
|
||||
.pzc i{font-style:normal}
|
||||
.pzc.s1{background:#FFE3F0}.pzc.s2{background:var(--ok);color:#fff}
|
||||
.pztw{font-size:12.5px;font-weight:800;color:var(--bad);margin:3px 0}.pztw.ok{color:var(--eye)}
|
||||
.pztw{font-size:12.5px;font-weight:800;color:var(--bad);margin:3px 0}.pztw.ok{color:var(--eye)}.pztw.rule{color:var(--ink2)}
|
||||
.pzbud{margin:6px 0}.pzbud .kv{font-size:12.5px}
|
||||
.pzn1{font-size:12.5px;font-weight:800;margin:6px 0;padding:4px 8px;border:2px solid var(--line);border-radius:10px;color:var(--ink2)}
|
||||
.pzn1.on{border-color:var(--ok);background:#DFFBEA;color:var(--ink);animation:pzglow 1.6s ease-in-out infinite}.pzn1.bad{border-color:var(--warn);background:#FFF4D6;color:var(--ink)}
|
||||
|
|
@ -18,6 +19,10 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
.scn.lock{opacity:.5}
|
||||
.pzres{position:relative}.pzstars{display:flex;justify-content:center;gap:10px;margin:10px 0 2px}
|
||||
.pzbig{font-size:46px;filter:grayscale(1);opacity:.3}.pzbig.on{filter:none;opacity:1}
|
||||
.pzleft{text-align:center;font-weight:900;font-size:13px;margin:2px 0 0;color:var(--ink2)}
|
||||
.btns.pzdone .pznext{flex:1 1 100%;font-size:22px;padding:10px 18px 8px;animation:pznudge 1.8s ease-in-out 1.6s infinite}
|
||||
@keyframes pznudge{50%{transform:translateY(-2px);box-shadow:0 5px 0 var(--ink)}}
|
||||
@media (prefers-reduced-motion:reduce){.btns.pzdone .pznext{animation:none}}
|
||||
.pzbig.pop{animation:pzpop .5s cubic-bezier(.3,1.6,.5,1) var(--d) both}
|
||||
@keyframes pzpop{0%{transform:scale(0) rotate(-40deg);opacity:0}100%{transform:scale(1) rotate(0);opacity:1}}
|
||||
.pzconf{position:absolute;inset:-16px;pointer-events:none;overflow:hidden;z-index:2}
|
||||
|
|
@ -26,6 +31,9 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
@media (max-width:760px),(max-height:500px) and (pointer:coarse){
|
||||
#pzBox{top:auto;left:0;right:0;width:auto;bottom:0;max-height:min(46%,330px);border-radius:20px 20px 0 0;border-bottom:0;box-shadow:0 -3px 0 var(--ink);padding:0 12px calc(10px + env(safe-area-inset-bottom,0px))}
|
||||
#pzBox .grab{display:block}
|
||||
#pzBox .btns .b,#pzBox .pzh .b{min-height:40px;min-width:40px;padding:4px 12px}
|
||||
/* Long languages make the sheet scroll: Undo, Reset and Back stay pinned at its foot. */
|
||||
#pzBox>.btns{position:sticky;bottom:0;background:var(--paper);margin:6px -12px 0;padding:6px 12px 0;box-shadow:0 -6px 6px -6px rgba(30,38,64,.25)}
|
||||
#pzBox.mini{max-height:none}#pzBox.mini>:not(.grab):not(.pzh):not(.pzs){display:none}
|
||||
#pzBox.mini .pzs{margin-top:0}
|
||||
body.pz.sheet-open #pzBox{display:none}
|
||||
|
|
@ -34,7 +42,8 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
.pzbig{font-size:40px}
|
||||
}
|
||||
@media (orientation:landscape) and (max-height:500px) and (pointer:coarse),(orientation:landscape) and (max-width:760px) and (max-height:500px){
|
||||
#pzBox{left:auto;right:0;width:min(360px,52%);top:calc(env(safe-area-inset-top,0px) + 50px);max-height:none;border-radius:20px 0 0 0;border-right:0}
|
||||
#pzBox{left:auto;right:0;width:min(360px,52%);top:calc(env(safe-area-inset-top,0px) + 50px);max-height:calc(100% - 50px - env(safe-area-inset-top,0px));overscroll-behavior:contain;border-radius:20px 0 0 0;border-right:0}
|
||||
#pzBox .pzj{display:none}#pzBox .pzs span{font-size:16px;padding:1px 0}
|
||||
body.pz #hint{bottom:12px !important;left:30% !important}
|
||||
body.pz #toasts{left:8px !important;transform:none !important;width:calc(48% - 16px) !important}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,3 +135,37 @@ test('the share card rings the variant badges', () => {
|
|||
assert.ok(fiery > plain, `the ring and the tally are drawn (${fiery} > ${plain} calls)`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a variant named after an Object prototype key is not a variant', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
for (const k of ['constructor', 'toString', '__proto__', 'hasOwnProperty']) {
|
||||
ev(`const o=JSON.parse(JSON.stringify(S));o.ach={hello:3};o.achP={hello:${JSON.stringify(k)}};S=migrate(o)`);
|
||||
assert.equal(ev('S.achP.hello'), 'oncall', k);
|
||||
assert.equal(ev(`bvar(${JSON.stringify(k)}).k`), 'oncall', `bvar(${k})`);
|
||||
ev(`S.rules={preset:${JSON.stringify(k)}}`);
|
||||
assert.equal(ev('badgeVar()'), 'oncall', `badgeVar() under preset ${k}`);
|
||||
}
|
||||
ev("S.rules={preset:'oncall'};S.achP.hello='constructor';shareCanvas()");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('"Badge upgraded" means the collection on this device got a better variant', () => {
|
||||
const { ev, errors } = load();
|
||||
const spy = () => ev("window.__t=[];if(!window.__sp){window.__sp=1;const _t=toast;toast=(h,...a)=>{window.__t.push(h);return _t(h,...a);};}");
|
||||
// a new game, but this device already holds the frosted badge: the standard one upgrades it
|
||||
start(ev, 'oncall');
|
||||
ev("localStorage.setItem('sot-badges',JSON.stringify({hello:{d:'2026-01-01',n:'Old',vs:{freeze:'2026-01-01'}}}))");
|
||||
spy(); earnHello(ev);
|
||||
assert.match(ev("window.__t.join(' ')"), /Badge upgraded/);
|
||||
assert.equal(hof(ev).hello.v, 'oncall');
|
||||
// another new game, the device already holds the fiery one: earning the frosted one is a plain unlock
|
||||
start(ev, 'freeze');
|
||||
ev("localStorage.setItem('sot-badges',JSON.stringify({hello:{d:'2026-01-01',n:'Old',vs:{bgp:'2026-01-01'}}}))");
|
||||
spy(); earnHello(ev);
|
||||
const t = ev("window.__t.join(' ')");
|
||||
assert.match(t, /Badge unlocked/);
|
||||
assert.doesNotMatch(t, /Badge upgraded/);
|
||||
assert.equal(hof(ev).hello.v, 'bgp', 'the best variant stays on the shelf');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
24
tests/link-trial.test.js
Normal file
24
tests/link-trial.test.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// #62 on a big network: a redundancy check routes once (the failed link), and uses the live routing as "before".
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
test('#62 a redundancy check computes only the trial, and matches comparing two fresh routings', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});S.cash=1e8;ACT.buildPop({city:'bde'});ACT.buildPop({city:'ams'});S.biz=[{id:'circuit',name:'Test Circuit',type:'l2vpn',city:'fra',city2:'bde',bw:80,rate:1,reqs:[]}]");
|
||||
ev("S.links=[{id:'main',a:'fra',b:'bde',kind:'wave',tier:1,km:100,mo:100,cut:0},{id:'a',a:'fra',b:'ams',kind:'wave',tier:0,km:100,mo:100,cut:0},{id:'b',a:'ams',b:'bde',kind:'wave',tier:0,km:100,mo:100,cut:0}];compute()");
|
||||
ev("window.__n=0;window.__c=compute;compute=function(){window.__n++;return window.__c.apply(this,arguments);}");
|
||||
const t = JSON.parse(ev("JSON.stringify(linkTrial('main'))"));
|
||||
assert.equal(ev('window.__n'), 1, 'one routing pass per check');
|
||||
assert.equal(t.split, false);
|
||||
assert.equal(t.loss, 70);
|
||||
assert.equal(ev("linkTrial('nope')"), null);
|
||||
assert.equal(ev('window.__n'), 1, 'an unknown link costs nothing');
|
||||
ev('compute=window.__c');
|
||||
// the old way: route the copy twice, before and after the cut
|
||||
const old = ev(`(()=>{const save=S,live=R;try{S=JSON.parse(JSON.stringify(save));compute();const b=R;S.links[0].cut=S.day+1;compute();
|
||||
const g=c=>Math.max(0,(b.citySrv[c]||0)-(R.citySrv[c]||0)),l2=Math.max(0,(b.l2.circuit||0)-(R.l2.circuit||0));
|
||||
return Object.keys(S.pops).reduce((a,c)=>a+(g(c)>.01?g(c):0),0)+(l2>.01?l2:0);}finally{S=save;R=live;}})()`);
|
||||
assert.equal(t.loss, old);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
40
tests/metric-panel.test.js
Normal file
40
tests/metric-panel.test.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// #131 on Safari: the custom metric field keeps focus through a button tap, and the panel skips re-rendering a
|
||||
// focused field, so switching between multiplier and cost (or to a preset) left the old panel on screen.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
const setup = (ev) => {
|
||||
ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buildPop({city:'ams'});UI.via=null;openLinkModal('fra','ams');ACT.buildLink({tier:1});closeModal()");
|
||||
ev("window.L=S.links[0].id;ACT.selLink({id:L});renderAll();ACT.setMetric({id:L,v:'custom'});renderAll()");
|
||||
};
|
||||
|
||||
test('#131 switching the custom metric mode re-renders even while the field has focus', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
const d = dom.window.document;
|
||||
setup(ev);
|
||||
d.getElementById('metIn').focus();
|
||||
assert.equal(d.activeElement.id, 'metIn');
|
||||
ev("ACT.metricMode({id:L,k:'w'})");
|
||||
assert.equal(d.getElementById('metIn').getAttribute('step'), '1', 'the field is now the exact cost');
|
||||
assert.equal(+d.getElementById('metIn').value, ev("S.pairMet[edgeKey(S.links[0])].v"));
|
||||
d.getElementById('metIn').focus();
|
||||
ev("ACT.metricMode({id:L,k:'f'})");
|
||||
assert.equal(d.getElementById('metIn').getAttribute('step'), '0.1', 'and back to a multiplier');
|
||||
d.getElementById('metIn').focus();
|
||||
ev("ACT.setMetric({id:L,v:'normal'})");
|
||||
assert.equal(d.getElementById('metIn'), null, 'a preset hides the field');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#131 the daily re-render still keeps a half-typed value', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
const d = dom.window.document;
|
||||
setup(ev);
|
||||
const t = d.getElementById('metIn');
|
||||
t.focus(); t.value = '3.5';
|
||||
ev("S.day++;renderPanel()");
|
||||
assert.equal(d.getElementById('metIn').value, '3.5');
|
||||
assert.equal(d.activeElement.id, 'metIn');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
@ -409,8 +409,8 @@ test('#114 Only Spätzle-IX can be won by peering alone', () => {
|
|||
const { ev, errors } = load();
|
||||
ev("ACT.startScn({id:'stg',sure:1})");
|
||||
assert.equal(ev("scnRule('local')&&scnRule('noTransit')"), true);
|
||||
assert.match(ev("SCN.find(x=>x.id==='stg').goal"), /45%.*300 Gbps/);
|
||||
assert.deepEqual(JSON.parse(ev("JSON.stringify(scnProg().items.map(x=>x.max))")), [0.45, 300]);
|
||||
assert.match(ev("SCN.find(x=>x.id==='stg').goal"), /50%.*300 Gbps/);
|
||||
assert.deepEqual(JSON.parse(ev("JSON.stringify(scnProg().items.map(x=>x.max))")), [0.5, 300]);
|
||||
// a game saved before the fix picks the rule up on load
|
||||
ev("const o=JSON.parse(JSON.stringify(S));delete o.scn.rules.local;migrate(o);window.__mig=o.scn.rules.local");
|
||||
assert.equal(ev('window.__mig'), true);
|
||||
|
|
|
|||
|
|
@ -7,23 +7,24 @@ const { load } = require('./harness');
|
|||
// `one` earns the goal star, `three` earns all three. A second land link on the same pair is a diverse route.
|
||||
const REF = {
|
||||
hello: { one: [['lon', 'nyc', 'grace']], three: [['lon', 'nyc', 'grace'], ['lon', 'nyc', 'amitie']] },
|
||||
eurotrip: { one: [['lon', 'ams', 'uly'], ['ams', 'fra', 'land']], three: [['lon', 'ams', 'uly'], ['lon', 'ams', 'concerto'], ['ams', 'fra', 'land'], ['ams', 'fra', 'land']] },
|
||||
shining: { one: [['nyc', 'chi', 'land'], ['chi', 'dal', 'land'], ['dal', 'sjc', 'land']], three: [['nyc', 'chi', 'land'], ['chi', 'sjc', 'land'], ['sjc', 'dal', 'land'], ['dal', 'nyc', 'land']] },
|
||||
smorgas: { one: [['osl', 'sto', 'land'], ['sto', 'hel', 'land'], ['osl', 'cph', 'land']], three: [['osl', 'sto', 'land'], ['sto', 'hel', 'land'], ['hel', 'cph', 'land'], ['cph', 'osl', 'land']] },
|
||||
downunder: { one: [['syd', 'mel', 'land'], ['mel', 'adl', 'land'], ['syd', 'bne', 'land']], three: [['syd', 'mel', 'land'], ['mel', 'adl', 'land'], ['adl', 'bne', 'land'], ['bne', 'syd', 'land']] },
|
||||
aloha: { one: [['sjc', 'hnl', 'scx'], ['hnl', 'syd', 'hwk']], three: [['sjc', 'hnl', 'scx'], ['sjc', 'hnl', 'aag'], ['hnl', 'syd', 'hwk'], ['hnl', 'syd', 'aloha']] },
|
||||
rimshot: { one: [['sea', 'tok', 'fast'], ['tok', 'hkg', 'adc'], ['hkg', 'sin', 'sjc2']], three: [['sea', 'tok', 'fast'], ['sea', 'tok', 'ncp'], ['tok', 'hkg', 'adc'], ['tok', 'hkg', 'apg'], ['hkg', 'sin', 'sjc2'], ['hkg', 'sin', 'land']] },
|
||||
fire: { one: [['tok', 'hkg', 'adc'], ['hkg', 'sin', 'sjc2'], ['sin', 'syd', 'indigo'], ['syd', 'tok', 'guam']], three: [['tok', 'hkg', 'adc'], ['hkg', 'sin', 'sjc2'], ['sin', 'syd', 'indigo'], ['syd', 'tok', 'guam']] },
|
||||
kiwi: { one: [['akl', 'sea', 'hwk'], ['akl', 'syd', 'tasman']], three: [['akl', 'sea', 'hwk'], ['sea', 'hnl', 'hwk'], ['hnl', 'akl', 'hwk'], ['akl', 'syd', 'tasman'], ['akl', 'syd', 'scx']] },
|
||||
guam: { one: [['tok', 'gum', 'jga'], ['gum', 'syd', 'guam'], ['tok', 'mnl', 'jup']], three: [['tok', 'mnl', 'jup'], ['mnl', 'gum', 'bifrost'], ['gum', 'syd', 'guam'], ['syd', 'tok', 'guam']] },
|
||||
flash: { one: [['nyc', 'lon', 'hibx']], three: [['nyc', 'lon', 'hibx'], ['nyc', 'lon', 'grace']] },
|
||||
eurotrip: { one: [['lon', 'ams', 'uly'], ['ams', 'fra', 'land']], three: [['ams', 'lon', 'concerto'], ['ams', 'lon', 'nshuttle'], ['ams', 'fra', 'land'], ['ams', 'fra', 'land']] },
|
||||
shining: { one: [['nyc', 'chi', 'land'], ['chi', 'dal', 'land'], ['dal', 'sjc', 'land']], three: [['chi', 'nyc', 'land'], ['chi', 'sjc', 'land'], ['dal', 'nyc', 'land'], ['dal', 'sjc', 'land']] },
|
||||
smorgas: { one: [['osl', 'sto', 'land'], ['sto', 'hel', 'land'], ['osl', 'cph', 'land']], three: [['osl', 'sto', 'land'], ['cph', 'osl', 'land'], ['cph', 'hel', 'land'], ['hel', 'sto', 'land']] },
|
||||
downunder: { one: [['syd', 'mel', 'land'], ['mel', 'adl', 'land'], ['syd', 'bne', 'land']], three: [['mel', 'syd', 'land'], ['bne', 'syd', 'land'], ['adl', 'mel', 'land'], ['adl', 'bne', 'land']] },
|
||||
aloha: { one: [['sjc', 'hnl', 'scx'], ['hnl', 'syd', 'hwk']], three: [['hnl', 'sjc', 'scx'], ['hnl', 'sjc', 'aag'], ['hnl', 'syd', 'hwk'], ['hnl', 'syd', 'aloha']] },
|
||||
rimshot: { one: [['sea', 'tok', 'fast'], ['tok', 'hkg', 'adc'], ['hkg', 'sin', 'sjc2']], three: [['sea', 'tok', 'fast'], ['sea', 'tok', 'ncp'], ['hkg', 'tok', 'apg'], ['hkg', 'tok', 'adc'], ['hkg', 'sin', 'land'], ['hkg', 'sin', 'land']] },
|
||||
fire: { one: [['tok', 'hkg', 'adc'], ['hkg', 'sin', 'sjc2'], ['sin', 'syd', 'indigo'], ['syd', 'tok', 'guam']], three: [['hkg', 'tok', 'adc'], ['hkg', 'sin', 'land'], ['sin', 'syd', 'indigo'], ['syd', 'tok', 'guam']] },
|
||||
// Hawaiki is Seattle's only cable south, so the second way out runs overland to LA and on via Suva.
|
||||
kiwi: { one: [['akl', 'sea', 'hwk'], ['akl', 'syd', 'tasman']], three: [['akl', 'syd', 'tasman'], ['akl', 'sea', 'hwk'], ['suv', 'syd', 'scxn'], ['lax', 'sea', 'land'], ['lax', 'suv', 'scxn']] },
|
||||
guam: { one: [['tok', 'gum', 'jga'], ['gum', 'syd', 'guam'], ['tok', 'mnl', 'jup']], three: [['mnl', 'tok', 'jup'], ['syd', 'tok', 'sushi'], ['gum', 'mnl', 'bifrost'], ['gum', 'syd', 'guam']] },
|
||||
flash: { one: [['nyc', 'lon', 'hibx']], three: [['lon', 'nyc', 'grace'], ['lon', 'nyc', 'hibx']] },
|
||||
pingpong: { one: [['lax', 'tok', 'jup']], three: [['lax', 'tok', 'jup'], ['lax', 'sea', 'land'], ['sea', 'tok', 'fast']] },
|
||||
suez: { one: [['fra', 'mrs', 'land'], ['mrs', 'sin', 'peace']], three: [['fra', 'mrs', 'land'], ['fra', 'mrs', 'land'], ['mrs', 'sin', 'peace'], ['mrs', 'bom', 'twoaf'], ['bom', 'sin', 'land']] },
|
||||
samba: { one: [['sao', 'mia', 'monet']], three: [['sao', 'mia', 'monet'], ['sao', 'for', 'land'], ['for', 'mia', 'monet']] },
|
||||
sharks: { one: [['lis', 'mad', 'land'], ['mad', 'par', 'land'], ['par', 'mil', 'land']], three: [['lis', 'mad', 'land'], ['mad', 'par', 'land'], ['par', 'mil', 'land'], ['mil', 'lis', 'land']] },
|
||||
braces: { one: [['nyc', 'lon', 'grace'], ['lon', 'dub', 'celtix']], three: [['nyc', 'lon', 'grace'], ['lon', 'dub', 'celtix'], ['dub', 'nyc', 'havf']] },
|
||||
nofra: { one: [['ams', 'ber', 'land'], ['ber', 'muc', 'land'], ['muc', 'zrh', 'land']], three: [['ams', 'ber', 'land'], ['ber', 'muc', 'land'], ['muc', 'zrh', 'land'], ['zrh', 'ams', 'land']] },
|
||||
fatpipes: { one: [['par', 'mrs', 'land', 1], ['mrs', 'mil', 'land', 1], ['mil', 'zrh', 'land', 1]], three: [['par', 'mrs', 'land', 1], ['mrs', 'mil', 'land', 1], ['mil', 'zrh', 'land', 1], ['zrh', 'par', 'land', 1]] },
|
||||
suez: { one: [['fra', 'mrs', 'land'], ['mrs', 'sin', 'peace']], three: [['fra', 'mrs', 'land'], ['fra', 'mrs', 'land'], ['mrs', 'sin', 'peace'], ['bom', 'sin', 'land'], ['bom', 'mrs', 'twoaf']] },
|
||||
samba: { one: [['sao', 'mia', 'monet']], three: [['for', 'sao', 'land'], ['for', 'sao', 'land'], ['for', 'mia', 'monet'], ['for', 'mia', 'sam1']] },
|
||||
sharks: { one: [['lis', 'mad', 'land'], ['mad', 'par', 'land'], ['par', 'mil', 'land']], three: [['lis', 'mad', 'land'], ['lis', 'mil', 'land'], ['mad', 'par', 'land'], ['mil', 'par', 'land']] },
|
||||
braces: { one: [['nyc', 'lon', 'grace'], ['lon', 'dub', 'celtix']], three: [['lon', 'nyc', 'grace'], ['dub', 'nyc', 'havf'], ['dub', 'lon', 'celtix']] },
|
||||
nofra: { one: [['ams', 'ber', 'land'], ['ber', 'muc', 'land'], ['muc', 'zrh', 'land']], three: [['ams', 'ber', 'land'], ['ams', 'zrh', 'land'], ['ber', 'muc', 'land'], ['muc', 'zrh', 'land']] },
|
||||
fatpipes: { one: [['par', 'mrs', 'land', 1], ['mrs', 'mil', 'land', 1], ['mil', 'zrh', 'land', 1]], three: [['par', 'zrh', 'land', 1], ['mrs', 'par', 'land', 1], ['mil', 'mrs', 'land', 1], ['mil', 'zrh', 'land', 1]] },
|
||||
};
|
||||
|
||||
// Builds links the way a player does: POP at the first city, then the link picker for each hop.
|
||||
|
|
@ -61,6 +62,45 @@ test('puzzle data: every puzzle is valid, solvable, and its 3-star reference ear
|
|||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
// Brute force over every route between the puzzle's cities (one size: 10G, or 100G under minG): is any 3-star build
|
||||
// cheaper than `limit`? Each cable is one failure unit; each overland link its own trench (a second one is diverse).
|
||||
function cheaper3(ev, id, limit) {
|
||||
const D = JSON.parse(ev(`(()=>{pzBegin(pzDef('${id}'));const P=S.pz,cs=[...P.cities,...P.via],tier=P.minG?1:0,o=[];
|
||||
for(const a of cs)for(const b of cs)if(a<b)for(const r of pzRoutes(a,b)){if((P.noSub&&r.sub)||subWaveWhy(tier,r.km,r.sub))continue;
|
||||
o.push({a,b,cab:r.cab,cost:pzLinkCost(r,tier,false),ms:r.ms});if(!r.cab)o.push({a,b,cab:null,cost:pzLinkCost(r,tier,true),ms:r.ms,div:1});}
|
||||
const pop={};for(const c of cs)pop[c]=pzPopCost(c);return JSON.stringify({P,o,pop});})()`));
|
||||
const { P, o, pop } = D, unit = (i) => o[i].cab ? 'c' + o[i].cab : 't' + i;
|
||||
const reach = (ls, skip) => { const adj = {}; for (const i of ls) { if (unit(i) === skip) continue; const { a, b } = o[i]; (adj[a] = adj[a] || []).push(b); (adj[b] = adj[b] || []).push(a); }
|
||||
const seen = new Set([P.cities[0]]), q = [P.cities[0]]; while (q.length) for (const v of adj[q.pop()] || []) if (!seen.has(v)) { seen.add(v); q.push(v); } return P.cities.every((c) => seen.has(c)); };
|
||||
const lat = (ls) => { const d = { [P.lat[0]]: 0 }, done = new Set(); for (;;) { let u = null; for (const k in d) if (!done.has(k) && (u === null || d[k] < d[u])) u = k; if (u === null) return Infinity; if (u === P.lat[1]) return d[u]; done.add(u);
|
||||
for (const i of ls) { const l = o[i]; if (l.a !== u && l.b !== u) continue; const v = l.a === u ? l.b : l.a, nd = d[u] + l.ms + 0.05; if (!(nd >= d[v])) d[v] = nd; } } };
|
||||
const ring = (ls) => { const nb = {}; for (const i of ls) { const { a, b } = o[i]; (nb[a] = nb[a] || new Set()).add(b); (nb[b] = nb[b] || new Set()).add(a); } const ns = Object.keys(nb);
|
||||
if (ns.length < 3 || !ns.every((c) => nb[c].size === 2)) return false; let prev = null, cur = ns[0], n = 0; do { const nx = [...nb[cur]].find((x) => x !== prev); prev = cur; cur = nx; n++; } while (cur !== ns[0] && n <= ns.length); return n === ns.length; };
|
||||
const ok = (ls) => { if (!reach(ls, null) || (P.ring && !ring(ls)) || (P.lat && lat(ls) > P.lat[2])) return false; return [...new Set(ls.map(unit))].every((u) => reach(ls, u)); };
|
||||
let found = null;
|
||||
const rec = (start, ls, cost) => { if (found) return; if (ls.length && cost < limit - 1) { const pops = new Set(P.cities); for (const i of ls) { pops.add(o[i].a); pops.add(o[i].b); } const tot = cost + [...pops].reduce((x, c) => x + pop[c], 0); if (tot < limit - 1 && ok(ls)) { found = tot; return; } }
|
||||
if (ls.length >= 7) return; for (let i = start; i < o.length; i++) { if (o[i].div && !ls.some((j) => !o[j].div && !o[j].cab && o[j].a === o[i].a && o[j].b === o[i].b)) continue; if (cost + o[i].cost < limit - 1) rec(i + 1, [...ls, i], cost + o[i].cost); } };
|
||||
rec(0, [], 0);
|
||||
return found;
|
||||
}
|
||||
|
||||
test('budgets follow the difficulty curve: roomy first pack, ~10% in the middle, tight N-1 Club', () => {
|
||||
const { ev, errors } = load();
|
||||
const SLACK = { hello: [0.15, 0.2], fire: [0.09, 0.11], speed: [0.09, 0.11], n1: [0.05, 0.08] };
|
||||
const rows = JSON.parse(ev('JSON.stringify(PZ.filter(p=>p.budget).map(p=>({id:p.id,pack:p.pack,budget:p.budget})))'));
|
||||
for (const { id, pack, budget } of rows) {
|
||||
ev(`pzBegin(pzDef('${id}'))`);
|
||||
build(ev, REF[id].three);
|
||||
const e = evalP(ev);
|
||||
assert.equal(e.stars, 3, id);
|
||||
assert.equal(cheaper3(ev, id, e.spend), null, `${id}: the reference is the cheapest 3-star build`);
|
||||
const slack = budget / e.spend - 1, [lo, hi] = SLACK[pack];
|
||||
assert.ok(slack >= lo && slack <= hi, `${id}: ${(slack * 100).toFixed(1)}% slack, want ${lo * 100}-${hi * 100}%`);
|
||||
}
|
||||
assert.match(ev("PZ_PACKS[0].d"), /Roomy budgets/, 'the first pack does not promise "no budget"');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('stars: goal, budget, N-1 and twists each count', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("pzBegin(pzDef('braces'))");
|
||||
|
|
@ -77,6 +117,15 @@ test('stars: goal, budget, N-1 and twists each count', () => {
|
|||
build(ev, REF.shining.one);
|
||||
ev("ACT.pzLinkTo({a:'nyc',b:'chi'});ACT.pzVia({v:'land'});ACT.pzDiv({v:0});ACT.pzLink({tier:0})");
|
||||
assert.equal(ev("new Set(S.links.filter(l=>edgeKey(l)==='chi|nyc').map(pzUnit)).size"), 1, 'same trench shares the cut');
|
||||
// A cable fails as a whole: two waves on one cable, even between different cities, are one cut.
|
||||
ev("pzBegin(pzDef('guam'))");
|
||||
build(ev, [['tok', 'mnl', 'jup'], ['mnl', 'gum', 'bifrost'], ['gum', 'syd', 'guam'], ['syd', 'tok', 'guam']]);
|
||||
e = evalP(ev);
|
||||
assert.ok(e.goal && !e.n1, 'both of Sydney\'s links ride the Guam cable: one anchor splits Sydney off');
|
||||
assert.equal(ev("new Set(S.links.filter(l=>l.cable==='guam').map(pzUnit)).size"), 1, 'one cable, one failure unit');
|
||||
assert.ok(ev("document.getElementById('pzBox').textContent").includes('One cut splits it: ' + ev('CAB.guam.name')), 'the weak spot names the cable');
|
||||
ev("ACT.pzRmLink({id:S.links[3].id})");build(ev, [['tok', 'syd', 'sushi']]);
|
||||
assert.equal(evalP(ev).stars, 3, 'a second cable into Sydney fixes it');
|
||||
// Twists: no subsea, ring, latency, minimum size, cities to avoid.
|
||||
ev("pzBegin(pzDef('sharks'))");build(ev, REF.sharks.one);
|
||||
assert.ok(evalP(ev).goal);
|
||||
|
|
@ -180,16 +229,16 @@ test('weekly puzzle: stable seed per ISO week, solvable, share string and streak
|
|||
assert.equal(w.key, '2026-W44');
|
||||
assert.ok(w.cities.length >= 4 && w.cities.length <= 5 && w.budget > 0);
|
||||
// Every week of a few years can be solved with three stars by its own reference ring.
|
||||
for (let i = 0; i < 160; i += 7) {
|
||||
for (let i = 0; i < 400; i += 7) {
|
||||
ev(`pzBegin(pzWeekly(new Date(2026,0,1+${i})))`);
|
||||
const ring = JSON.parse(ev('JSON.stringify(pzWeekly(new Date(2026,0,1+' + i + ')).ref)'));
|
||||
const links = ring.map((x, j) => { const y = ring[(j + 1) % ring.length]; return [x, y, ev(`pzRoutes('${x}','${y}').sort((p,q)=>pzLinkCost(p,0)-pzLinkCost(q,0))[0].via`)]; });
|
||||
build(ev, links);
|
||||
const w = JSON.parse(ev('JSON.stringify(pzWeekly(new Date(2026,0,1+' + i + ')))'));
|
||||
const cabs = w.refVia.filter((v) => v !== 'land');
|
||||
assert.equal(new Set(cabs).size, cabs.length, `week +${i}: no two hops of the reference ring share a cable`);
|
||||
build(ev, w.ref.map((x, j) => [x, w.ref[(j + 1) % w.ref.length], w.refVia[j]]));
|
||||
assert.equal(evalP(ev).stars, 3, `week +${i}`);
|
||||
}
|
||||
ev("localStorage.removeItem('sot-puzzles');pzBegin(pzWeekly(new Date(2026,9,28)))");
|
||||
const ring = w.ref;
|
||||
build(ev, ring.map((x, j) => { const y = ring[(j + 1) % ring.length]; return [x, y, ev(`pzRoutes('${x}','${y}').sort((p,q)=>pzLinkCost(p,0)-pzLinkCost(q,0))[0].via`)]; }));
|
||||
build(ev, w.ref.map((x, j) => [x, w.ref[(j + 1) % w.ref.length], w.refVia[j]]));
|
||||
assert.match(ev('pzShareText(pzEval())'), /^Series of Tubes puzzle 2026-W44 ⭐⭐⭐ \$\d+k · seriesoftub\.es$/);
|
||||
assert.equal(ev("JSON.parse(localStorage.getItem('sot-puzzles')).streak.n"), 1);
|
||||
// A streak counts weeks in a row; a gap starts again.
|
||||
|
|
@ -253,3 +302,146 @@ test('puzzles in every language', () => {
|
|||
assert.deepEqual(errors, [], lang);
|
||||
}
|
||||
});
|
||||
|
||||
test('a POP in a thin market costs its higher monthly rent too, and the panel says so', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("pzBegin(pzDef('kiwi'))");
|
||||
assert.ok(ev('colo("suv")') > 1, 'Suva is a thin market');
|
||||
assert.equal(ev("pzPopCost('suv')"), ev("popCost('suv')+12*popMo('suv')"));
|
||||
assert.ok(ev("pzPopCost('suv')") > ev("popCost('suv')+12*POP_MO"));
|
||||
ev("selectCity('suv')");
|
||||
assert.ok(ev("document.getElementById('panelBody').textContent").includes(ev("fmt$(popMo('suv'))") + '/mo'));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('best spend: kept for the best star count, and a cheaper build at the same stars counts', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("localStorage.removeItem('sot-puzzles');pzBegin(pzDef('braces'))");
|
||||
const rec = () => JSON.parse(ev("JSON.stringify(pzLoad().s.braces||null)"));
|
||||
build(ev, REF.braces.one);
|
||||
const two = evalP(ev).spend;
|
||||
assert.deepEqual(rec(), { st: 2, sp: two });
|
||||
// A gold-plated third link: N-1 but over budget is still two stars, and dearer, so the best stays.
|
||||
ev("ACT.pzLinkTo({a:'dub',b:'nyc'});ACT.pzVia({v:'havf'});ACT.pzLink({tier:2});closeModal()");
|
||||
assert.equal(evalP(ev).stars, 2);
|
||||
assert.deepEqual(rec(), { st: 2, sp: two });
|
||||
// Shrinking it to 10G earns the third star: the best spend starts again at the 3-star build.
|
||||
ev('ACT.pzTier({id:S.links[2].id,tier:0})');
|
||||
const three = evalP(ev);
|
||||
assert.equal(three.stars, 3);
|
||||
assert.deepEqual(rec(), { st: 3, sp: three.spend });
|
||||
// With a looser budget, a dearer 3-star build does not replace it; going back to the cheaper one keeps it.
|
||||
ev('S.pz.budget=1e7;ACT.pzTier({id:S.links[0].id,tier:1})');
|
||||
assert.equal(evalP(ev).stars, 3);
|
||||
assert.deepEqual(rec(), { st: 3, sp: three.spend });
|
||||
// A cheaper 3-star build after a dearer first one is recorded (the old code only recorded star rises).
|
||||
ev("localStorage.removeItem('sot-puzzles')");
|
||||
ev('ACT.pzTier({id:S.links[1].id,tier:1})');
|
||||
const dear = evalP(ev).spend;
|
||||
assert.deepEqual(rec(), { st: 3, sp: dear });
|
||||
ev('ACT.pzTier({id:S.links[1].id,tier:0});ACT.pzTier({id:S.links[0].id,tier:0})');
|
||||
assert.deepEqual(rec(), { st: 3, sp: three.spend });
|
||||
// Fewer stars never overwrite more.
|
||||
ev('ACT.pzRmLink({id:S.links[2].id})');
|
||||
assert.deepEqual(rec(), { st: 3, sp: three.spend });
|
||||
ev('ACT.puzzleMenu({})');
|
||||
assert.ok(ev("document.getElementById('modalCard').textContent").includes('best ' + ev(`fmt$(${three.spend})`)));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('main-game toasts and leftover buttons do nothing in a puzzle', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});S.cash=1e7;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buildPop({city:'ams'});save(true)");
|
||||
ev("toast('main game news','bad',[{l:'Fix',act:'opsOpen',args:{}}]);save(true)");
|
||||
assert.ok(ev("document.querySelectorAll('#toasts .toast').length") > 0);
|
||||
const before = ev("localStorage.getItem('sot-save-v1')");
|
||||
ev("ACT.pzStart({id:'hello'})");
|
||||
assert.equal(ev("[...document.querySelectorAll('#toasts .toast')].filter(t=>/main game news/.test(t.textContent)).length"), 0, 'main-game toasts are cleared');
|
||||
ev("ACT.pzPop({city:'lon'})");
|
||||
const st = () => ev("JSON.stringify({p:S.pops,l:S.links.length,c:S.cash,m:S.mode,te:!!S.te,ops:S.ops,sc:S.scrubs.length,dash:$('dash').hidden,bank:$('bankBox').hidden,left:$('left').hidden,modal:$('modal').hidden,cam:[cam.x,cam.y]})");
|
||||
const s0 = st();
|
||||
for (const a of ["opsOpen({})", "inbox({})", "leftTab({t:'noc'})", "focusCity({city:'par'})", "fixInc({id:'x'})", "custGo({id:'x'})", "bank({})", "dash({})",
|
||||
"exportSave({})", "launchBB({city:'lon'})", "ad({city:'lon'})", "addRouter({city:'lon'})", "upRouter({city:'lon'})", "addSite({city:'lon'})", "buyTE({})",
|
||||
"buildScrub({city:'lon',tier:0})", "buildPop({city:'par'})", "buyTransit({city:'lon',net:'cog',tier:1})", "scenarios({})", "share({})", "importGo({})", "cont({})", "start({})", "newgame({})"]) {
|
||||
ev('ACT.' + a);
|
||||
assert.equal(st(), s0, `${a} does nothing in a puzzle`);
|
||||
}
|
||||
assert.equal(ev('S.mode'), 'puzzle');
|
||||
// A leftover toast button is a no-op too, through the real click path.
|
||||
ev("toast('stray','',[{l:'Go',act:'opsOpen',args:{}}]);document.querySelector('#toasts [data-act=opsOpen]').click()");
|
||||
assert.equal(st(), s0);
|
||||
ev("toast('puzzle news','good')");
|
||||
ev('ACT.pzLeave({})');
|
||||
assert.equal(ev("document.querySelectorAll('#toasts .toast').length"), 0, 'puzzle toasts do not follow you home');
|
||||
assert.equal(ev("localStorage.getItem('sot-save-v1')"), before);
|
||||
// Back in the main game, the same actions work again.
|
||||
ev("ACT.addRouter({city:'ams'})");
|
||||
assert.equal(ev('S.pops.ams.routers'), 2);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a city to avoid reads as a rule, not a goal that can fail', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("pzBegin(pzDef('nofra'))");
|
||||
const tw = () => ev("[...document.querySelectorAll('#pzBox .pztw')].map(x=>x.className+'|'+x.textContent).join('\\n')");
|
||||
assert.match(tw(), /pztw rule\|🚫 Rule: not via Frankfurt/);
|
||||
assert.doesNotMatch(tw(), /[✓✗].*Frankfurt/);
|
||||
build(ev, REF.nofra.three);
|
||||
assert.match(tw(), /pztw rule\|🚫 Rule: not via Frankfurt/, 'still a rule once solved');
|
||||
assert.equal(evalP(ev).stars, 3);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('phone sheet: 40 px touch targets, pinned actions, and goal chips with a clear mark', () => {
|
||||
const { ev, errors } = load();
|
||||
// jsdom has no layout: read the phone media rules from the page's stylesheet (Chromium at 360 px measures 40 px).
|
||||
const rules = JSON.parse(ev(`JSON.stringify([...document.styleSheets].flatMap(s=>[...s.cssRules]).filter(r=>r.media&&/max-width: ?760px/.test(r.media.mediaText))
|
||||
.flatMap(m=>[...m.cssRules]).filter(r=>/#pzBox/.test(r.selectorText||'')).map(r=>({sel:r.selectorText,mh:r.style.getPropertyValue('min-height'),mw:r.style.getPropertyValue('min-width'),pos:r.style.getPropertyValue('position'),bottom:r.style.getPropertyValue('bottom')})))`));
|
||||
const tap = rules.find((r) => /#pzBox \.btns \.b/.test(r.sel) && /#pzBox \.pzh \.b/.test(r.sel));
|
||||
assert.ok(tap && parseFloat(tap.mh) >= 40 && parseFloat(tap.mw) >= 40, `Undo/Reset/Back/☰ are at least 40 px (${JSON.stringify(tap)})`);
|
||||
const pin = rules.find((r) => /^#pzBox ?> ?\.btns$/.test(r.sel));
|
||||
assert.ok(pin && pin.pos === 'sticky' && parseFloat(pin.bottom) === 0, `the action row stays at the foot of a scrolling sheet (${JSON.stringify(pin)})`);
|
||||
ev("innerWidth=360;innerHeight=740;dispatchEvent(new Event('resize'));pzBegin(pzDef('braces'))");
|
||||
const chips = () => ev("[...document.querySelectorAll('#pzBox .pzc')].map(x=>x.textContent).join('|')");
|
||||
assert.equal(chips(), '○ New York|○ London|○ Dublin', 'not reached yet: a hollow mark, nothing that looks cut off');
|
||||
assert.doesNotMatch(chips(), /…/);
|
||||
build(ev, [['nyc', 'lon', 'grace']]);
|
||||
ev("ACT.pzPop({city:'dub'})");
|
||||
assert.equal(chips(), '✓ New York|✓ London|◐ Dublin');
|
||||
assert.ok(ev("[...document.querySelectorAll('#pzBox button')].every(b=>b.classList.contains('b'))"), 'every sheet button is a .b the rule sizes');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('results pull you on: Next is the big tap after three stars, stars left in the pack, and a nudge when 3 stars are one link away', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("localStorage.removeItem('sot-puzzles');pzBegin(pzDef('braces'))");
|
||||
build(ev, REF.braces.one);
|
||||
let card = ev("document.getElementById('modalCard').textContent");
|
||||
assert.equal(evalP(ev).stars, 2);
|
||||
assert.match(card, /So close: one more link and a backhoe can't touch you\./, 'Dublin to New York would do it, within budget');
|
||||
assert.match(ev("document.getElementById('pzBox').textContent"), /So close/);
|
||||
assert.match(card, /10 ⭐ left in this pack/, '4 puzzles × 3 stars, 2 won');
|
||||
assert.ok(ev("!!document.querySelector('#modalCard [data-act=pzRetry]')"));
|
||||
assert.ok(!ev("document.querySelector('#modalCard .btns.cta').classList.contains('pzdone')"));
|
||||
build(ev, [['dub', 'nyc', 'havf']]);
|
||||
card = ev("document.getElementById('modalCard').textContent");
|
||||
assert.match(card, /9 ⭐ left in this pack/);
|
||||
assert.ok(ev("document.querySelector('#modalCard .btns.cta').classList.contains('pzdone')"), 'three stars: the big Next layout');
|
||||
assert.ok(ev("document.activeElement===document.querySelector('#modalCard .pznext')"), 'the big button has the focus');
|
||||
assert.equal(ev("document.querySelector('#modalCard [data-act=pzRetry]')"), null, 'no retry after three stars');
|
||||
assert.match(ev("document.querySelector('#modalCard .pznext').textContent"), /More puzzles/, 'the last pack points back to the list');
|
||||
ev("pzBegin(pzDef('eurotrip'))");build(ev, REF.eurotrip.three);
|
||||
assert.match(ev("document.querySelector('#modalCard .pznext').textContent"), /Next puzzle →/);
|
||||
assert.equal(ev("document.activeElement.dataset.act"), 'pzStart');
|
||||
// No nudge when no single link fits the budget: an over-budget gold plate is not "close".
|
||||
ev("pzBegin(pzDef('braces'));S.pz.budget=245000");
|
||||
build(ev, REF.braces.one);
|
||||
assert.equal(evalP(ev).stars, 2);
|
||||
assert.doesNotMatch(ev("document.getElementById('modalCard').textContent"), /So close/);
|
||||
assert.match(ev("document.getElementById('modalCard').textContent"), /One backhoe away/);
|
||||
// A finished pack says so.
|
||||
ev("localStorage.setItem('sot-puzzles',JSON.stringify({s:{sharks:{st:3},braces:{st:3},nofra:{st:3},fatpipes:{st:2}}}));pzBegin(pzDef('fatpipes'))");
|
||||
build(ev, REF.fatpipes.three);
|
||||
assert.match(ev("document.getElementById('modalCard').textContent"), /Every star in this pack is yours/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1076,7 +1076,12 @@ test('prices follow real connectivity: thin markets cost more, hubs stay put', (
|
|||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
assert.deepEqual(JSON.parse(ev('JSON.stringify(Object.keys(CITY_PDB).filter(c=>!CITY[c]))')), [], 'every entry is a city on the map');
|
||||
assert.ok(ev('Object.keys(CITY_PDB).length') >= 190, 'real-world data for most cities');
|
||||
assert.deepEqual(JSON.parse(ev('JSON.stringify(CITIES.filter(c=>!CITY_PDB[c.id]).map(c=>c.id))')), [], 'every city has data, so none keeps the plain price by accident');
|
||||
assert.ok(ev('Object.values(CITY_PDB).every(q=>Array.isArray(q)&&q.length===3&&q.every(x=>Number.isInteger(x)&&x>=0)&&q[1]>=0)'), '[facilities, presences, ASNs], whole numbers');
|
||||
// The cities that used to have none: thin markets cost more than Frankfurt, and the Arctic has no neutral data center.
|
||||
for (const c of ['dus', 'rix', 'mct', 'mle', 'fuk', 'sju', 'kin', 'anc', 'tik']) assert.ok(ev(`txComp('${c}')`) > 1, `${c} is no hub`);
|
||||
for (const c of ['brw', 'tik', 'pvs', 'hav']) assert.equal(ev(`colo('${c}')`), 1.5, `${c}: no carrier-neutral data center`);
|
||||
assert.ok(ev("txComp('dus')") < ev("txComp('rix')") && ev("txComp('rix')") < ev("txComp('mle')"), 'Düsseldorf, Riga, Malé: ever thinner');
|
||||
// A city without data keeps the plain regional price.
|
||||
assert.equal(ev("(()=>{const q=CITY_PDB.fra;delete CITY_PDB.fra;const r=[txComp('fra'),colo('fra'),popMo('fra')];CITY_PDB.fra=q;return r.join()})()"), `1,1,${ev('POP_MO')}`);
|
||||
assert.equal(ev("regionMult('syd')"), ev('AU_TRANSIT'), 'Australia keeps its hand-set transit price');
|
||||
|
|
|
|||
|
|
@ -54,3 +54,28 @@ test('indexed routing matches the simple allocation loop across network changes'
|
|||
} finally { dom.window.close(); }
|
||||
});
|
||||
|
||||
|
||||
// Islands: POPs no backbone joins. Exit lists are split per island (a flow only scans exits it can reach),
|
||||
// and must route exactly like the full scan, also when a cut splits an island or joins two.
|
||||
test('indexed routing matches the simple allocation loop on a network of islands', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
try {
|
||||
network(ev);
|
||||
ev("S.links=S.links.filter(l=>!['df4','df9','w3','w4','w8','w9'].includes(l.id));compute()");
|
||||
assert.ok(ev("Object.keys(S.pops).some(c=>!pathExists('fra',c))"), 'the network is in pieces');
|
||||
const changes = [
|
||||
'',
|
||||
"S.pni.forEach((p,i)=>p.pref=i%3===0?'high':i%3===1?'low':'normal')",
|
||||
"S.te={on:true,script:'prefer pni for goggle\\nspill at 80%'}",
|
||||
"S.ev.ddos={city:'fra',until:S.day+3,gbps:300,vec:'syn',entry:{k:'edge'}}",
|
||||
"S.links[0].cut=S.day+2",
|
||||
"S.te=null;S.links[0].cut=0;S.links.push({id:'join',a:'par',b:'pek',kind:'wave',tier:2,km:8000,cut:0,mo:100})",
|
||||
];
|
||||
for (const change of changes) {
|
||||
ev(change);
|
||||
ev('window.priorR=JSON.stringify(R);referenceCompute();window.expectedR=JSON.stringify(R);R=JSON.parse(priorR);compute()');
|
||||
assert.deepEqual(JSON.parse(ev('JSON.stringify(R)')), JSON.parse(ev('expectedR')), change || 'baseline');
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
} finally { dom.window.close(); }
|
||||
});
|
||||
|
|
|
|||
73
tests/sales-trial.test.js
Normal file
73
tests/sales-trial.test.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
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');
|
||||
|
||||
// The sales trial (#185, the intern's sales order) runs the pass with the offer first and skips the pass without
|
||||
// it when it cannot change the answer. It must sign exactly the offers the original two-pass trial signs.
|
||||
const ORIGINAL = `(function(o){if(!o||!own(BIZ_T,o.type)||!(o.exp>S.day)||!(o.bw>0)||o.rate<0||!bCities(o).length||!bCities(o).every(popUp)||!reqOk(o))return null;
|
||||
const T=BIZ_T[o.type],b=offerCustomer(o);if(T.event&&(!(o.start>S.day)||!(o.dur>0)))return null;
|
||||
if(o.type==='capfib'&&S.biz.some(x=>x.type==='capfib'&&capPend(x)&&!x.link&&((x.city===o.city&&x.city2===o.city2)||(x.city===o.city2&&x.city2===o.city))))return null;
|
||||
if(T.fiber){const l=o.type==='capfib'?capFibLink(b):S.links.find(x=>x.id===o.link);if(!l)return null;b.link=l.id;
|
||||
if(!fiberOk(b)||(o.type==='wwave'&&(!(o.slots>0)||freeCh(l)<o.slots))||(o.type==='dfpair'&&!pairFree(l))||
|
||||
(o.type==='pairs'&&(!l.own||S.biz.some(x=>x.link===l.id&&['pairs','capfib','dfpair'].includes(x.type)))))return null;}
|
||||
const state=S,result=R,hot=UI.hotMap,future=S.biz.some(x=>BIZ_T[x.type].event&&x.start>S.day);
|
||||
try{S={...S,biz:S.biz};
|
||||
if(future){S.biz=S.biz.map(x=>BIZ_T[x.type].event&&x.start>S.day?{...x,start:S.day}:x);compute();}
|
||||
const healthy=S.biz.filter(x=>!bizWhy(x).length);if(T.event)b.start=S.day;if(T.cap)b.live=true;S.biz=S.biz.concat(b);compute();
|
||||
return !bizWhy(b).length&&healthy.every(x=>!bizWhy(x).length)?b:null;
|
||||
}finally{S=state;R=result;UI.hotMap=hot;b.start=o.start;if(T.cap)delete b.live;}})`;
|
||||
|
||||
test('the faster sales trial signs exactly the offers the two-pass trial signs', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
try {
|
||||
const save = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8');
|
||||
ev(`S=migrate(JSON.parse(${JSON.stringify(save)}));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();compute();window.slowOffer=${ORIGINAL};`);
|
||||
assert.ok(ev('S.biz.some(x=>BIZ_T[x.type].event&&x.start>S.day)'), 'the fixture has events booked ahead, so the shortcut runs');
|
||||
const seen = { yes: 0, no: 0, skipped: 0, third: 0 };
|
||||
ev('window.__n=0;const _c=compute;window.compute=function(){__n++;return _c.apply(this,arguments)}');
|
||||
for (let day = 0; day < 6; day++) {
|
||||
ev(`__reseed(${1000 + day});S.offers=[];for(let i=0;i<10;i++)spawnOffer();`);
|
||||
// Small offers that fit, and on alternate days a squeeze, so offers fail on capacity and on others' service too.
|
||||
ev(`for(const o of S.offers)o.bw=Math.max(1,Math.round(o.bw*${day % 2 ? 1 : 0.05}))`);
|
||||
if (day % 2) ev('for(const c in S.pops)S.pops[c].bb&&(S.pops[c].bb.d*=1.3)');
|
||||
// And circuits over the busiest links, which take bandwidth from customers who had it.
|
||||
ev(`for(const l of S.links.filter(l=>!linkDown(l)&&S.pops[l.a]&&S.pops[l.b]&&R.load[l.id]>1).sort((x,y)=>R.load[y.id]/capOf(y)-R.load[x.id]/capOf(x)).slice(${day},${day}+2))
|
||||
S.offers.push({id:'sq'+l.id,city:l.a,city2:l.b,name:'Squeeze',type:'l2vpn',bw:${day % 2 ? 300 : 2},rate:100,reqs:[],exp:S.day+30})`);
|
||||
for (const id of JSON.parse(ev('JSON.stringify(S.offers.map(o=>o.id))'))) {
|
||||
const o = `S.offers.find(x=>x.id===${JSON.stringify(id)})`;
|
||||
const before = ev('JSON.stringify(R.load)+R.served');
|
||||
ev('__n=0');const fast = ev(`JSON.stringify(autoOffer(${o}))`);const n = ev('__n');
|
||||
assert.equal(ev('JSON.stringify(R.load)+R.served'), before, 'a trial leaves the live result alone');
|
||||
const slow = ev(`JSON.stringify(slowOffer(${o}))`);
|
||||
assert.equal(fast, slow, `offer ${id} (${ev(`${o}.type`)}) on day ${day}`);
|
||||
if (fast !== 'null') seen.yes++; else seen.no++;
|
||||
if (n === 1) seen.skipped++;
|
||||
if (n === 2) seen.third++;
|
||||
}
|
||||
ev('S.nextFail=S.day+99;S.nextEvent=S.day+99;dayTick()');
|
||||
}
|
||||
assert.ok(seen.yes >= 3 && seen.no >= 3, `both answers come up (${JSON.stringify(seen)})`);
|
||||
assert.ok(seen.skipped >= 5, `the second pass is often skipped (${JSON.stringify(seen)})`);
|
||||
assert.ok(seen.third >= 3, `and run when the offer hurts someone (${JSON.stringify(seen)})`);
|
||||
assert.deepEqual(errors, []);
|
||||
} finally { dom.window.close(); }
|
||||
});
|
||||
|
||||
test('with a scenic circuit the sales trial keeps both passes in their original order', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
try {
|
||||
const save = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8');
|
||||
ev(`S=migrate(JSON.parse(${JSON.stringify(save)}));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();S.biz.find(b=>BIZ_T[b.type].l2).route='scenic';compute();window.slowOffer=${ORIGINAL};`);
|
||||
ev('window.__n=0;const _c=compute;window.compute=function(){__n++;return _c.apply(this,arguments)}');
|
||||
ev('__reseed(77);S.offers=[];for(let i=0;i<6;i++)spawnOffer();');
|
||||
for (const id of JSON.parse(ev('JSON.stringify(S.offers.map(o=>o.id))'))) {
|
||||
const o = `S.offers.find(x=>x.id===${JSON.stringify(id)})`;
|
||||
ev('__n=0');const fast = ev(`JSON.stringify(autoOffer(${o}))`);const n = ev('__n');
|
||||
assert.equal(fast, ev(`JSON.stringify(slowOffer(${o}))`), id);
|
||||
assert.ok(n === 0 || n === 2, 'both passes, as before');
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
} finally { dom.window.close(); }
|
||||
});
|
||||
|
|
@ -23,8 +23,12 @@ test('cones are built once at load and hold customers of customers', () => {
|
|||
assert.equal(ev("NETS.filter(n=>n.tail).every(n=>ANC[n.id].some(u=>NET[u].type==='t1'))"), true, 'from a Tier 1, directly or through a carrier');
|
||||
assert.equal(ev("NET.tail45.up.join()"), 'mag', 'Auckland has no Tier 1: Hobbit Hole buys from a carrier that is there');
|
||||
assert.equal(ev("NETS.filter(n=>n.tail).map(n=>n.up.join('+')).join()"), ev("NETS.filter(n=>n.tail).map(n=>tailUp(n.name,n.pops).join('+')).join()"), 'stable: picked by name');
|
||||
// Australians buy only from Australian carriers, so a Tier 1 PNI is still no back door into Australia.
|
||||
assert.equal(ev("['opt','tpr','abb','npt','lpt','lnt','pnt','stb','blg'].some(id=>t1Need().some(t=>CONE_S[t.id].has(id)))"), false);
|
||||
// Australia's big ISPs buy only from Australian carriers, so a Tier 1 PNI is no back door to them.
|
||||
assert.equal(ev("['opt','tpr','abb','npt','lpt','lnt','pnt','stb','blg','inp'].some(id=>t1Need().some(t=>CONE_S[t.id].has(id)))"), false);
|
||||
// The smaller ones that buy from a Tier 1 or a carrier of one do come along, and these are exactly the ones.
|
||||
const au = "NETS.filter(n=>n.type==='eye'&&n.pops.length&&n.pops.every(c=>CITY[c].au)&&t1Need().some(t=>CONE_S[t.id].has(n.id))).map(n=>n.id).sort().join()";
|
||||
assert.equal(ev(au), 'ddo,ext,spn,tail44', 'Doodoo, Lintel, Spin2wintel, Kangaroo Courier');
|
||||
assert.equal(ev("[NET.tail44.name,NET.tail44.up.join(),NET.ddo.up.join(),NET.spn.up.join(),NET.ext.up.join(),NET.voc.up.join(),NET.spl.up.join()].join('|')"), 'Kangaroo Courier|cog|voc|voc|spl|ntt,tly|tly');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
|
@ -146,3 +150,48 @@ test('routing with cones costs about what it did: exits are asked once, cones ar
|
|||
assert.ok(t < plain * 2 + 20, `compute() with cones ${t.toFixed(1)} ms vs without ${plain.toFixed(1)} ms`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the panel names the peer that really carries a network, not the first Tier 1 it buys from', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;S.lvl=6;ACT.launchBB({city:'fra'});S.pops.fra.bb.d=50");
|
||||
// a long-tail network that buys from Cogentle first and Level Tree second; peer only with Level Tree
|
||||
const t = ev("NETS.find(n=>n.tail&&n.up.length===2&&n.up[0]==='cog'&&n.up[1]==='lvl').id");
|
||||
ev("S.transit=[];S.ixp={};S.peers={};S.grace=null;S.pni=[{id:'pl',net:'lvl',city:'fra',tier:2}];compute()");
|
||||
assert.equal(ev(`R.cone.${t}`), 'lvl');
|
||||
ev(`UI.left='goals';UI.leftOpen=true;ACT.netFocus({id:'${t}'})`);
|
||||
const txt = dom.window.document.getElementById('leftBody').textContent;
|
||||
assert.match(txt, /Reached through the customer cone of Level Tree/);
|
||||
assert.doesNotMatch(txt, /customer cone of Cogentle/);
|
||||
// over an exchange: the member you have a session with
|
||||
ev("S.pni=[];compute()");
|
||||
assert.equal(ev(`!!R.cone.${t}`), false);
|
||||
assert.match(ev(`(ACT.netFocus({id:'${t}'}),document.getElementById('leftBody').textContent)`), /Buys transit from Cogentle/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a traceroute down a two-level cone shows every network on the way', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;S.lvl=6;ACT.launchBB({city:'fra'});S.pops.fra.bb.d=50");
|
||||
// Doodoo buys from Hocus Pocus, which buys from Not That Telecom; a PNI with Not That Telecom only
|
||||
ev("S.transit=[];S.ixp={};S.peers={};S.grace=null;S.pni=[{id:'pn',net:'ntt',city:'fra',tier:2}];compute()");
|
||||
const tr = JSON.parse(ev("JSON.stringify(traceroute('fra',{net:'ddo'}))"));
|
||||
assert.deepEqual(tr.asPath, [ev('S.asn'), ev('NET.ntt.asn'), ev('NET.voc.asn'), ev('NET.ddo.asn')]);
|
||||
assert.match(tr.text, /Not That Telecom hands it to its customer Hocus Pocus/);
|
||||
assert.match(tr.text, /Hocus Pocus hands it to its customer Doodoo/);
|
||||
assert.equal(ev("coneChain('ntt','ddo').join()"), 'ntt,voc,ddo');
|
||||
assert.equal(ev("R.cone.ddo"), 'ntt');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#114 Only Spätzle-IX still takes more than the exchange and two Tier 1 PNIs, now that cones count', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("UI.pitched=true;beginGame('T','stg',{scn:SCN.find(x=>x.id==='stg')});S.cash=1e9;S.lvl=10;S.pops.stg.bb={d:400};S.ixp.stg=0;for(const id of ixMembers('stg'))S.peers[id+'@stg']=1;compute()");
|
||||
const reach = (ts) => ev(`S.pni=[];for(const t of ${JSON.stringify(ts)})S.pni.push({id:'p'+t,net:t,city:'stg',tier:2});compute();R.reach`);
|
||||
const T = ['lvl', 'ntt', 'tly', 'cog', 'tat'];
|
||||
const goal = ev("SCN.find(x=>x.id==='stg').ok.toString()");
|
||||
assert.match(goal, /R\.reach>=0\.5/);
|
||||
for (let i = 0; i < T.length; i++) for (let j = i + 1; j < T.length; j++)
|
||||
assert.ok(reach([T[i], T[j]]) < 0.5, `${T[i]}+${T[j]} is not enough`);
|
||||
assert.ok(reach(['lvl', 'ntt', 'tly']) >= 0.5, 'three Tier 1 PNIs and the exchange can be');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -136,3 +136,24 @@ test('route-server batch leaves peering policy and player-owned exchanges alone'
|
|||
assert.equal(ev('S.rs.fra'), false, 'owned exchange has no join-route-server control');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#192 the Infra tab shows the kit as one line, without repeating its rows', t => {
|
||||
for (const w of [1280, 360]) {
|
||||
const { ev, dom, errors } = setup(t);
|
||||
ev(`window.innerWidth=${w}`);
|
||||
ev("S.caches=[{id:'c1',city:'fra',net:'cfl'},{id:'c2',city:'fra',net:'cfl'}];compute();selectCity('fra');ACT.tab({t:'links'})");
|
||||
const body = dom.window.document.getElementById('panelBody');
|
||||
const txt = body.textContent;
|
||||
assert.match(txt, /PoP redundancy kit · One-off: /);
|
||||
assert.doesNotMatch(txt, /Second site(None|Installed)/, 'no second copy of the second-site row');
|
||||
assert.doesNotMatch(txt, /At least two routers/, 'no second copy of the routers row');
|
||||
assert.doesNotMatch(txt, /Request missing caches/, 'caches are in the Peering tab and Utilities');
|
||||
assert.equal(body.querySelectorAll('section h3').length, [...body.querySelectorAll('section h3')].filter(h => h.textContent !== 'PoP redundancy kit').length);
|
||||
assert.equal(txt.split('Backup generator').length - 1, 1, 'the generator shows once, in Power');
|
||||
assert.ok(body.querySelector('[data-act="utilityKit"]'), 'the kit is one tap away');
|
||||
body.querySelector('[data-act="utilities"]').click();
|
||||
assert.match(dom.window.document.getElementById('modalCard').textContent, /At least two routers/, 'the full kit is in Utilities');
|
||||
assert.equal(dom.window.document.querySelector('#utilityCity').value, 'fra');
|
||||
assert.deepEqual(errors, [], `${w}px`);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue