Merge review fixes: puzzles

This commit is contained in:
Frederic Jung 2026-10-28 20:25:02 +01:00
commit b485b54d20
No known key found for this signature in database
13 changed files with 321 additions and 74 deletions

View file

@ -9,7 +9,7 @@ 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.
- 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.

View file

@ -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.",
@ -2878,6 +2879,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_zealand_is_far_from_everything":"Neuseeland ist weit weg von allem. Genau das ist der Witz, und das Problem.",
"puzzles.next_pack_unlocks_at_n":"Nächstes Paket, {pack}, ab {n}⭐",
@ -2886,7 +2888,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.",
@ -2913,6 +2914,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)",
@ -2923,6 +2925,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}",
@ -2945,7 +2948,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",
"reach_and_subsea.premium_submarine_terminals":"Premium-Seekabel-Terminals",
"release_notes.and_n_more_change":{"one":"… und {n} weitere Änderung","other":"… und {n} weitere Änderungen"},

View file

@ -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.",
@ -2876,6 +2877,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_zealand_is_far_from_everything":"Nueva Zelanda está lejos de todo. Esa es la gracia, y el problema.",
"puzzles.next_pack_unlocks_at_n":"El siguiente pack, {pack}, se desbloquea con {n}⭐",
@ -2884,7 +2886,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.",
@ -2911,6 +2912,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)",
@ -2921,6 +2923,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}",
@ -2943,7 +2946,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",
"reach_and_subsea.premium_submarine_terminals":"Terminales submarinas premium",
"release_notes.and_n_more_change":{"one":"…y {n} cambio más","other":"…y {n} cambios más"},

View file

@ -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.",
@ -2876,6 +2877,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_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.",
"puzzles.next_pack_unlocks_at_n":"Prochain pack, {pack}, à {n}⭐",
@ -2884,7 +2886,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.",
@ -2911,6 +2912,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)",
@ -2921,6 +2923,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}",
@ -2943,7 +2946,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",
"reach_and_subsea.premium_submarine_terminals":"Terminaux sous-marins premium",
"release_notes.and_n_more_change":{"one":"…et {n} autre changement","other":"…et {n} autres changements"},

View file

@ -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.",
@ -2876,6 +2877,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_zealand_is_far_from_everything":"La Nuova Zelanda è lontana da tutto. È proprio questo il bello, e il problema.",
"puzzles.next_pack_unlocks_at_n":"Il prossimo pacchetto, {pack}, si sblocca a {n}⭐",
@ -2884,7 +2886,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.",
@ -2911,6 +2912,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)",
@ -2921,6 +2923,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}",
@ -2943,7 +2946,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",
"reach_and_subsea.premium_submarine_terminals":"Terminali sottomarini avanzati",
"release_notes.and_n_more_change":{"one":"…e {n} altra modifica","other":"…e altre {n} modifiche"},

View file

@ -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.",
@ -2876,6 +2877,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_zealand_is_far_from_everything":"A Nova Zelândia fica longe de tudo. Essa é a graça, e o problema.",
"puzzles.next_pack_unlocks_at_n":"O próximo pacote, {pack}, abre com {n}⭐",
@ -2884,7 +2886,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.",
@ -2911,6 +2912,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)",
@ -2921,6 +2923,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}",
@ -2943,7 +2946,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",
"reach_and_subsea.premium_submarine_terminals":"Terminais submarinos premium",
"release_notes.and_n_more_change":{"one":"…e mais {n} mudança","other":"…e mais {n} mudanças"},

View file

@ -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=[

View file

@ -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,24 +52,37 @@ 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 weekly puzzle: the same for everyone, seeded by the ISO week like the weekly challenge ----------
function pzWeekKey(dt){const {y,w}=isoWeek(dt);return `${y}-W${String(w).padStart(2,'0')}`;}
function pzPrevKey(key){const m=/^(\d{4})-W(\d{2})$/.exec(key);if(!m)return null;return pzWeekKey(new Date(+m[1],0,4+(+m[2]-2)*7));}
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;}
@ -76,13 +90,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};
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();}
@ -97,8 +111,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;}

View file

@ -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);}

View file

@ -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)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):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>`;
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 ----------

View file

@ -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.",
@ -2877,6 +2878,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_zealand_is_far_from_everything":"New Zealand is far from everything. That is the point, and the problem.",
"puzzles.next_pack_unlocks_at_n":"Next pack, {pack}, unlocks at {n}⭐",
@ -2885,7 +2887,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.",
@ -2912,6 +2913,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)",
@ -2922,6 +2924,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}",
@ -2944,7 +2947,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",
"reach_and_subsea.premium_submarine_terminals":"Premium submarine terminals",
"release_notes.and_n_more_change":{"one":"…and {n} more change","other":"…and {n} more changes"},

View file

@ -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}
}

View file

@ -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, []);
});