Puzzles on phones: three goals in plain words with Show me, the problem marked on the map, a sheet that starts small, and a quieter map

The stars become three goals; the current one says what is wrong and what to do. A red ring marks a city still short, a pulsing ✂ the link whose cut hurts. Cities far from the puzzle are left off the map, and idle stepping stones are nameless dots until tapped, used or zoomed in on.
This commit is contained in:
Frederic Jung 2026-11-04 21:48:13 +01:00
parent b2dddf8f06
commit 29af343739
No known key found for this signature in database
17 changed files with 256 additions and 20 deletions

View file

@ -8,6 +8,7 @@ All notable changes to this project are documented here. The project follows
- The NOC charts have tooltips, on the dashboard and on the wallboard in the NOC window: hover (or touch) a chart to see every series on that day, with a total. Click an entry in the legend to hide or show that series, and the scale follows what is left. The "how it arrives" bars on the Traffic tab show the same kind of tooltip, and its legend picks which ways in (caches, PNIs, IX peering, transit) the table counts.
- Bilbao joins the map, where the transatlantic cables really come ashore: Marea Carey, Grace Hopscotch and Sol Survivor now land there instead of Madrid. It has no exchange of its own, so traffic heads inland to Madrid, and Drizzle Electric, Tangerine Telecom and the big carriers sell transit there. A link you already run on the old Madrid landings keeps working as a plain subsea link, and the Mid-Atlantic Accent scenario now goes Azores, Bilbao, Madrid, and Marea Carey now leaves the American coast at Virginia Beach instead of crossing the northeast to New Jersey. Columbus III-and-a-half now comes ashore near Cádiz, where it really landed, on its way to Madrid.
- Puzzles are easier to read, above all on phones: the three stars are now three goals in plain words, and the one you are working on says what is wrong and what to do, with a Show me button. The map marks it too: a red ring around a city that still needs traffic, and a pulsing ✂ on a link whose cut would hurt. On phones the sheet starts small so the map gets the screen; swipe it up for the rest. Cities far from the puzzle are left off the map, and stepping stones you are not using are small dots without a name until you tap one, build there or zoom in.
## [2.9.1] — 2026-11-04
- Jokes in the game now poke fun at networks, cables and routers, never at people, countries or beliefs. A few networks have new names (Atlas Hold-the-Line Telecom, Star-Blink, Telekom Malay-tency, Oh Yas Sénégal, Afghan Tele-Pass, Island-Hop Micronesia, Tel-One-derful, Tango Two-Step), so do three of the names for your own cables, and about forty descriptions of networks, cities, cables and events were rewritten.

View file

@ -3449,9 +3449,20 @@
"puzzles.framed_n_stars_from_the_old":"Gerahmt an der Wand: {n} ⭐ aus den alten Puzzles",
"puzzles.frankfurt_to_singapore_the_short_way":"Frankfurt nach Singapur auf dem kurzen Weg. Der lange führt über Land, und das merkt man.",
"puzzles.free":"Gratis",
"puzzles.goal_budget":"Im Budget bleiben",
"puzzles.goal_city":"Zielstadt",
"puzzles.goal_deliver":"Den ganzen Verkehr hinbringen",
"puzzles.goal_n1":"Jeden einzelnen Schnitt überstehen",
"puzzles.goal_x_of_y":"{x} von {y}",
"puzzles.grand_tour":"Grand Tour",
"puzzles.hello_world":"Hallo, Welt",
"puzzles.hint_cut":"Wird {where} gekappt, gehen auf dem Weg nach {list} {g} verloren. Gib ihnen einen zweiten Weg.",
"puzzles.hint_eye_none":"Bei {city} kommt noch nichts an. Schließ es an.",
"puzzles.hint_eye_short":"{city} bekommt {got} von {g}. Mehr Kapazität auf dem Weg dorthin.",
"puzzles.hint_l2_none":"{name} hat noch keinen Weg. Schließ beide Enden an.",
"puzzles.hint_l2_short":"{name} bekommt {got} von {g}. Mehr Kapazität auf ihrem Weg.",
"puzzles.hint_l2_slow":"{name} braucht {ms} ms, erlaubt sind {cap} ms. Finde einen schnelleren Weg.",
"puzzles.hint_over":"Du liegst {x} darüber. Versuch kleinere Röhren oder weniger Links.",
"puzzles.hub_cap":"Radkappe",
"puzzles.includes_a_new_pop_in_city":"Mit neuem POP in {city} ({price} für ein Jahr).",
"puzzles.installed":"verbaut",
@ -3529,6 +3540,7 @@
"puzzles.sao_paulo_to_miami_before_the":"São Paulo nach Miami, bevor der Caipirinha warm wird.",
"puzzles.sea_to_shining_sea":"Von Küste zu Küste",
"puzzles.share_line":"Series of Tubes Puzzle {what} {stars} {spend} · seriesoftub.es",
"puzzles.show_me":"Zeig's mir",
"puzzles.six_cities_a_few_gigs_each":"Sechs Städte, je ein paar Gigabit, und ein Router mit acht Ports. Erst zählen, dann graben.",
"puzzles.size":"Größe",
"puzzles.skip_the_monkey":"Überspringen",

View file

@ -3447,9 +3447,20 @@
"puzzles.framed_n_stars_from_the_old":"Enmarcadas en la pared: {n} ⭐ de los puzles antiguos",
"puzzles.frankfurt_to_singapore_the_short_way":"De Fráncfort a Singapur por el camino corto. El largo va por tierra, y se nota.",
"puzzles.free":"Gratis",
"puzzles.goal_budget":"No pasarte del presupuesto",
"puzzles.goal_city":"Ciudad objetivo",
"puzzles.goal_deliver":"Llevar todo el tráfico",
"puzzles.goal_n1":"Aguantar cualquier corte",
"puzzles.goal_x_of_y":"{x} de {y}",
"puzzles.grand_tour":"Grand Tour",
"puzzles.hello_world":"Hola, mundo",
"puzzles.hint_cut":"Si se corta {where}, se pierden {g} camino de {list}. Dales un segundo camino.",
"puzzles.hint_eye_none":"A {city} todavía no llega nada. Conéctala.",
"puzzles.hint_eye_short":"{city} recibe {got} de {g}. Añade capacidad en el camino.",
"puzzles.hint_l2_none":"{name} aún no tiene camino. Conecta los dos extremos.",
"puzzles.hint_l2_short":"{name} recibe {got} de {g}. Añade capacidad en su camino.",
"puzzles.hint_l2_slow":"{name} tarda {ms} ms; el límite es {cap} ms. Busca un camino más rápido.",
"puzzles.hint_over":"Te pasas en {x}. Prueba tubos más pequeños o menos enlaces.",
"puzzles.hub_cap":"Tapacubos",
"puzzles.includes_a_new_pop_in_city":"Incluye un POP nuevo en {city} ({price} por un año).",
"puzzles.installed":"instalado",
@ -3527,6 +3538,7 @@
"puzzles.sao_paulo_to_miami_before_the":"De São Paulo a Miami antes de que se caliente la caipiriña.",
"puzzles.sea_to_shining_sea":"De costa a costa",
"puzzles.share_line":"Series of Tubes puzle {what} {stars} {spend} · seriesoftub.es",
"puzzles.show_me":"Muéstramelo",
"puzzles.six_cities_a_few_gigs_each":"Seis ciudades, pocos gigas cada una, y un router con ocho puertos. Cuenta antes de cavar.",
"puzzles.size":"Tamaño",
"puzzles.skip_the_monkey":"Saltar",

View file

@ -3447,9 +3447,20 @@
"puzzles.framed_n_stars_from_the_old":"Encadrées au mur : {n} ⭐ des anciens puzzles",
"puzzles.frankfurt_to_singapore_the_short_way":"Francfort–Singapour par le chemin court. Le long passe par la terre, et ça se voit.",
"puzzles.free":"Gratuit",
"puzzles.goal_budget":"Rester dans le budget",
"puzzles.goal_city":"Ville objectif",
"puzzles.goal_deliver":"Faire arriver tout le trafic",
"puzzles.goal_n1":"Résister à n'importe quelle coupure",
"puzzles.goal_x_of_y":"{x} sur {y}",
"puzzles.grand_tour":"Grand Tour",
"puzzles.hello_world":"Hello, World",
"puzzles.hint_cut":"Si {where} est coupé, {g} se perdent en route vers {list}. Donne-leur un deuxième chemin.",
"puzzles.hint_eye_none":"Rien n'arrive encore à {city}. Connecte-la.",
"puzzles.hint_eye_short":"{city} reçoit {got} sur {g}. Ajoute de la capacité en chemin.",
"puzzles.hint_l2_none":"{name} n'a pas encore de chemin. Connecte les deux bouts.",
"puzzles.hint_l2_short":"{name} reçoit {got} sur {g}. Ajoute de la capacité sur son chemin.",
"puzzles.hint_l2_slow":"{name} met {ms} ms ; la limite est de {cap} ms. Trouve un chemin plus rapide.",
"puzzles.hint_over":"Tu dépasses de {x}. Essaie des tubes plus petits ou moins de liens.",
"puzzles.hub_cap":"Enjoliveur",
"puzzles.includes_a_new_pop_in_city":"Inclut un nouveau POP à {city} ({price} pour un an).",
"puzzles.installed":"installé",
@ -3527,6 +3538,7 @@
"puzzles.sao_paulo_to_miami_before_the":"São Paulo–Miami avant que la caïpirinha ne tiédisse.",
"puzzles.sea_to_shining_sea":"D’une côte à l’autre",
"puzzles.share_line":"Series of Tubes puzzle {what} {stars} {spend} · seriesoftub.es",
"puzzles.show_me":"Montre-moi",
"puzzles.six_cities_a_few_gigs_each":"Six villes, quelques gigas chacune, et un routeur à huit ports. Compte avant de creuser.",
"puzzles.size":"Taille",
"puzzles.skip_the_monkey":"Passer",

View file

@ -3447,9 +3447,20 @@
"puzzles.framed_n_stars_from_the_old":"Incorniciate sul muro: {n} ⭐ dei vecchi puzzle",
"puzzles.frankfurt_to_singapore_the_short_way":"Da Francoforte a Singapore per la via corta. Quella lunga è via terra, e si vede.",
"puzzles.free":"Gratis",
"puzzles.goal_budget":"Restare nel budget",
"puzzles.goal_city":"Città obiettivo",
"puzzles.goal_deliver":"Portare lì tutto il traffico",
"puzzles.goal_n1":"Reggere a qualsiasi taglio",
"puzzles.goal_x_of_y":"{x} su {y}",
"puzzles.grand_tour":"Grand Tour",
"puzzles.hello_world":"Ciao, mondo",
"puzzles.hint_cut":"Se {where} viene tagliato, si perdono {g} verso {list}. Dai loro una seconda strada.",
"puzzles.hint_eye_none":"A {city} non arriva ancora niente. Collegala.",
"puzzles.hint_eye_short":"{city} riceve {got} su {g}. Aggiungi capacità lungo la strada.",
"puzzles.hint_l2_none":"{name} non ha ancora un percorso. Collega entrambe le estremità.",
"puzzles.hint_l2_short":"{name} riceve {got} su {g}. Aggiungi capacità sul suo percorso.",
"puzzles.hint_l2_slow":"{name} impiega {ms} ms; il limite è {cap} ms. Trova un percorso più veloce.",
"puzzles.hint_over":"Sei {x} sopra. Prova tubi più piccoli o meno collegamenti.",
"puzzles.hub_cap":"Coprimozzo",
"puzzles.includes_a_new_pop_in_city":"Include un nuovo POP a {city} ({price} per un anno).",
"puzzles.installed":"installato",
@ -3527,6 +3538,7 @@
"puzzles.sao_paulo_to_miami_before_the":"Da São Paulo a Miami prima che la caipirinha si scaldi.",
"puzzles.sea_to_shining_sea":"Da costa a costa",
"puzzles.share_line":"Series of Tubes puzzle {what} {stars} {spend} · seriesoftub.es",
"puzzles.show_me":"Fammi vedere",
"puzzles.six_cities_a_few_gigs_each":"Sei città, pochi giga ciascuna, e un router con otto porte. Conta prima di scavare.",
"puzzles.size":"Taglia",
"puzzles.skip_the_monkey":"Salta",

View file

@ -3447,9 +3447,20 @@
"puzzles.framed_n_stars_from_the_old":"Emolduradas na parede: {n} ⭐ dos puzzles antigos",
"puzzles.frankfurt_to_singapore_the_short_way":"De Frankfurt a Singapura pelo caminho curto. O longo vai por terra, e dá pra notar.",
"puzzles.free":"Grátis",
"puzzles.goal_budget":"Ficar dentro do orçamento",
"puzzles.goal_city":"Cidade objetivo",
"puzzles.goal_deliver":"Levar todo o tráfego até lá",
"puzzles.goal_n1":"Aguentar qualquer corte",
"puzzles.goal_x_of_y":"{x} de {y}",
"puzzles.grand_tour":"Grand Tour",
"puzzles.hello_world":"Olá, mundo",
"puzzles.hint_cut":"Se {where} for cortado, perdem-se {g} a caminho de {list}. Dá-lhes um segundo caminho.",
"puzzles.hint_eye_none":"Ainda não chega nada a {city}. Liga-a.",
"puzzles.hint_eye_short":"{city} recebe {got} de {g}. Acrescenta capacidade no caminho.",
"puzzles.hint_l2_none":"{name} ainda não tem caminho. Liga as duas pontas.",
"puzzles.hint_l2_short":"{name} recebe {got} de {g}. Acrescenta capacidade no seu caminho.",
"puzzles.hint_l2_slow":"{name} demora {ms} ms; o limite é {cap} ms. Encontra um caminho mais rápido.",
"puzzles.hint_over":"Estás {x} acima. Experimenta tubos mais pequenos ou menos ligações.",
"puzzles.hub_cap":"Calota",
"puzzles.includes_a_new_pop_in_city":"Inclui um POP novo em {city} ({price} por um ano).",
"puzzles.installed":"instalado",
@ -3527,6 +3538,7 @@
"puzzles.sao_paulo_to_miami_before_the":"De São Paulo a Miami antes que a caipirinha esquente.",
"puzzles.sea_to_shining_sea":"De costa a costa",
"puzzles.share_line":"Series of Tubes puzzle {what} {stars} {spend} · seriesoftub.es",
"puzzles.show_me":"Mostra-me",
"puzzles.six_cities_a_few_gigs_each":"Seis cidades, poucos gigas cada, e um router com oito portas. Conte antes de cavar.",
"puzzles.size":"Tamanho",
"puzzles.skip_the_monkey":"Pular",

View file

@ -471,6 +471,7 @@ const API_VIEW={
pzFinish:{args:[],doc:'Puzzles only: run the star count and show the results sheet.'},
pzMonkey:{args:[],doc:'Puzzles only: send the chaos monkey round the build to prove the N-1 star.'},
pzMkSkip:{args:[],doc:'Puzzles only: skip the monkey\'s tour to the verdict.'},
pzLook:{args:[['c','cityId',false],['u','string',false]],doc:'Puzzles only: move the map to the city (c) or the cut (u, a link unit) that the sheet\'s next line names.'},
pzArAll:{args:[],doc:'Architect runs only: show every city on the map, not just the run\'s own.'},
tailTog:{args:[],doc:'Show or hide the long tail of small networks.'},
teEdit:{args:[],doc:'Open the RouteScript editor.'},

View file

@ -11,7 +11,18 @@ const pzOn=()=>!!(S&&S.mode==='puzzle'&&S.pz);
const pzDef=id=>PZ.find(p=>p.id===id)||null;
// goal: a city the traffic starts or ends in; via: a suggested stepping stone; avoid: off limits; off: any other city
// (the whole world is open, it just is not part of the plan).
const pzKind=c=>!pzOn()?null:S.ar?arKind(c):S.pz.cities.includes(c)?'goal':S.pz.via.includes(c)?'via':S.pz.avoid.includes(c)?'avoid':pzCityOk(c)?'off':null;
const pzKind=c=>!pzOn()?null:S.ar?arKind(c):S.pz.cities.includes(c)?'goal':S.pz.via.includes(c)?'via':S.pz.avoid.includes(c)?'avoid':pzCityOk(c)&&(S.pops[c]||pzNear(c))?'off':null;
// The puzzle's area: its cities' box plus a margin. Stepping stones outside it are off the map (a far capital is no use).
function pzArea(){const P=S.pz,k=P.id+'|'+(P.key||'')+'|'+P.cities.join();if(UI.pzArea&&UI.pzArea.k===k)return UI.pzArea;
const cs=[...new Set([...P.cities,...P.via,...P.avoid])].map(c=>CITY[c]).filter(Boolean),x0=cs[0].x;let a=Infinity,b=-Infinity,c=Infinity,d=-Infinity;
for(const C of cs){const x=x0+wrapDx(x0,C.x);a=Math.min(a,x);b=Math.max(b,x);c=Math.min(c,C.y);d=Math.max(d,C.y);}
const m=20+0.15*Math.max(b-a,d-c);return UI.pzArea={k,x0,a:a-m,b:b+m,c:c-m,d:d+m};}
const pzNear=c=>{const A=pzArea(),C=CITY[c],x=A.x0+wrapDx(A.x0,C.x);return x>=A.a&&x<=A.b&&C.y>=A.c&&C.y<=A.d;};
// Not drawn at all: Architect's cities outside the run, a puzzle's cities outside its area.
const pzHide=c=>pzOn()&&!pzKind(c);
// A stepping stone with no part to play yet is a quiet dot with no name, until it is picked, used or zoomed in on
// (twice the zoom the puzzle opened at: a phone and a desktop open at very different zooms).
const pzQuiet=c=>pzKind(c)==='off'&&!S.pops[c]&&cam.z<2*(UI.pzZ0||1)&&!(UI.sel&&UI.sel.id===c)&&UI.hover!==c&&!(UI.snap&&UI.snap.id===c)&&!(UI.drag&&UI.drag.from===c)&&!(UI.pending&&(UI.pending.a===c||UI.pending.b===c));
const pzName=d=>d.id==='weekly'?(d.wn?pzTxt(d.wn):tr('puzzles.weekly_puzzle_key',{key:d.key})):d.n;
const pzStarStr=n=>'⭐'.repeat(n)+'⬜'.repeat(3-n);
// Every city a puzzle's traffic touches, origins first.
@ -139,8 +150,8 @@ function pzLeave(){pzMkStop();if(S&&S.ar)arStop(true);mkStop();const from=UI.pzF
// The camera frames the puzzle's cities beside the puzzle card: left on wide screens, right on phones on their side, a bottom sheet on phones.
function pzCam(){const cs=[...S.pz.cities,...S.pz.via].map(c=>CITY[c]),x0=cs[0].x;let a=Infinity,b=-Infinity,c=Infinity,d=-Infinity;
for(const C of cs){const x=x0+wrapDx(x0,C.x);a=Math.min(a,x);b=Math.max(b,x);c=Math.min(c,C.y);d=Math.max(d,C.y);}
const ph=isPhone(),side=ph&&CW>CH,pl=side?-Math.min(360,CW*0.52):ph?0:S.ar&&CW>760&&CH>500?410:330,pb=ph&&!side?Math.min(230,CH*0.4):0,aw=Math.max(120,CW-Math.abs(pl)-90),ah=Math.max(120,CH-pb-150);
cam.z=clamp(Math.min(aw/Math.max(40,b-a),ah/Math.max(40,d-c)),0.5,4);cam.x=(a+b)/2-pl/2/cam.z;cam.y=(c+d)/2+(pb/2-30)/cam.z;wrapCam();}
const ph=isPhone(),side=ph&&CW>CH,pl=side?-Math.min(360,CW*0.52):ph?0:S.ar&&CW>760&&CH>500?410:330,pb=ph&&!side?(S.ar?Math.min(230,CH*0.4):Math.min(230,CH*0.3)):0,aw=Math.max(120,CW-Math.abs(pl)-90),ah=Math.max(120,CH-pb-150);
cam.z=clamp(Math.min(aw/Math.max(40,b-a),ah/Math.max(40,d-c)),0.5,4);UI.pzZ0=cam.z;cam.x=(a+b)/2-pl/2/cam.z;cam.y=(c+d)/2+(pb/2-30)/cam.z;wrapCam();}
// ---------- building ----------
function pzSnap(){pzMkStop();if(S.ar)arStop();const h=UI.pzHist||(UI.pzHist=[]);h.push(JSON.stringify({p:S.pops,l:S.links,m:S.pairMet||{},r:S.biz.map(b=>b.route),k:S.ar?S.ar.sunk:0}));if(h.length>60)h.shift();}
function pzAfter(){if(UI.sel&&((UI.sel.type==='link'&&!S.links.some(l=>l.id===UI.sel.id))||(UI.sel.type==='city'&&!pzKind(UI.sel.id))))UI.sel=null;

View file

@ -13,6 +13,9 @@ Object.assign(ACT,{
pzFinish:()=>{if(!pzOn())return;if(S.ar){arResults(false);return;}const e=pzEval();if(e.stars)pzResults(e,e.stars);},
pzRetry:()=>{if(!pzOn())return;if(S.ar){arBegin(arRun());return;}pzBegin(S.pz.id==='weekly'?pzWkDef():pzDef(S.pz.id));},
pzLeave:()=>{if(pzOn())pzLeave();},
// The sheet's next-fix line: bring the city, or the link a cut hurts most, into view (the zoom stays).
pzLook:({c,u})=>{if(!pzOn())return;let x,y;if(c&&isCity(c)){x=CITY[c].x;y=CITY[c].y;}else{const l=u&&S.links.find(q=>pzUnit(q)===u);if(!l)return;const A=CITY[l.a],B=CITY[l.b];x=A.x+wrapDx(A.x,B.x)/2;y=(A.y+B.y)/2;}
const sh=isPhone()&&CW<=CH?($('pzBox').offsetHeight||0):0;cam.x=x;cam.y=y+sh/2/cam.z;wrapCam();haptic(8);},
pzPop:({city})=>{if(!pzOn()||S.pops[city]||!['goal','via','off'].includes(pzKind(city)))return;pzSnap();S.pops[city]=pzNewPop(city);sfx('build');haptic(10);floater(CITY[city].x,CITY[city].y-30,tr('common.new_pop'),'#FF4F9A');pzAfter();},
pzRmPop:({city})=>{if(!pzOn()||!S.pops[city]||(S.ar&&city===S.ar.hq))return;pzSnap();if(S.ar)arSink([city],S.links.filter(l=>l.a===city||l.b===city));delete S.pops[city];S.links=S.links.filter(l=>l.a!==city&&l.b!==city);prunePairMet();sfx('click');UI.sel=null;pzAfter();},
pzLinkTo:({a,b})=>{if(!pzOn()||!S.pops[a]||a===b)return;pzLinkModal(a,b);},

View file

@ -13,7 +13,7 @@ function renderTabbar(){const tb=$('tabbar');if(!tb||(pressing&&UI.ticking))retu
function haptic(ms){if(UI.muted)return;try{navigator.vibrate&&navigator.vibrate(ms||12);}catch(e){}}
// Bottom sheets: drag the handle up to expand, down to shrink or close; tap it to toggle.
(function(){let g=null;
document.addEventListener('pointerdown',e=>{const h=e.target.closest('[data-grab]');if(!h||!isPhone())return;const el=h.parentElement;g={el,y:e.clientY,dy:0,id:e.pointerId,full:el.classList.contains('full')};try{h.setPointerCapture(e.pointerId);}catch(_){}el.style.transition='none';});
document.addEventListener('pointerdown',e=>{const h=e.target.closest('[data-grab]');if(!h||!isPhone()||e.target.closest('button,select,input'))return;const el=h.dataset.grab==='pz'?$('pzBox'):h.parentElement;g={el,y:e.clientY,dy:0,id:e.pointerId,full:el.classList.contains('full')};try{h.setPointerCapture(e.pointerId);}catch(_){}el.style.transition='none';});
document.addEventListener('pointermove',e=>{if(!g||e.pointerId!==g.id)return;g.dy=e.clientY-g.y;if(g.dy>0)g.el.style.transform=`translateY(${g.dy}px)`;});
const end=e=>{if(!g||e.pointerId!==g.id)return;const {el,dy,full}=g;g=null;el.style.transition='';el.style.transform='';
if(Math.abs(dy)<6){el.classList.toggle(el.id==='pzBox'?'mini':'full');return;}

View file

@ -13,24 +13,49 @@ function pzFlowRow(x){const f=x.f,ok=x.full&&x.fast,u=f.g?Math.min(1,x.g/f.g):0;
return `<div class="pzf${ok?' ok':''}"><div class="kv"><span>${f.t==='l2'?'🔗':'👀'} ${esc(pzFlowName(f))}${f.be?` <span class="tag st">${tr('puzzles.best_effort')}</span>`:''}</span><b>${fmtG(x.g)} / ${fmtG(f.g)}</b></div><div class="bar ${ok?'':u>=0.999?'warn':'bad'}"><i style="width:${(u*100).toFixed(1)}%"></i></div>${lat?`<div class="meta">${tr('puzzles.latency')}${lat}</div>`:''}${f.t==='l2'?pzRouteCtl(x.i):''}</div>`;}
// A circuit's path: the metrics, or the lowest latency.
function pzRouteCtl(i){const b=S.biz.find(x=>x.id===pzFlowId(i));if(!b)return '';return `<div class="seg pzrt">${['normal','fast'].map(m=>btn(RT[m],'pzRoute',{i,m},b.route===m?'pink sm':'ghost sm')).join('')}</div>`;}
// The three stars as three goals in plain words, in star order. The first one not met is the current one: it says what
// is wrong and what to do, and `look` is where "Show me" takes the map. mark: what the map rings in red (pzDrawMarks).
function pzGoals(e){const P=S.pz,cn=c=>esc(CITY[c].name),list=cs=>{const nm=cs.map(cn);try{return new Intl.ListFormat(LANG,{type:'conjunction'}).format(nm);}catch(e){return nm.join(', ');}};
const g1={done:e.goal,t:tr('puzzles.goal_deliver')},g2={done:e.goal&&e.cheap,t:tr('puzzles.goal_budget'),v:P.budget?tr('puzzles.goal_x_of_y',{x:fmt$(e.spend),y:fmt$(P.budget)}):''},g3={done:e.goal&&e.n1,t:tr('puzzles.goal_n1')};
const x=e.flows.slice().sort((a,b)=>(a.f.be?1:0)-(b.f.be?1:0)).find(x=>!(x.full&&x.fast));
if(x){const f=x.f,got=fmtG(x.g),g=fmtG(f.g),eye=f.t==='eye',nm=esc(pzFlowName(f));
g1.hint=eye?(x.g>0?tr('puzzles.hint_eye_short',{city:cn(f.a),got,g}):tr('puzzles.hint_eye_none',{city:cn(f.a)}))
:!x.full?(x.g>0?tr('puzzles.hint_l2_short',{name:nm,got,g}):tr('puzzles.hint_l2_none',{name:nm})):tr('puzzles.hint_l2_slow',{name:nm,ms:x.ms==null?'—':x.ms.toFixed(1),cap:f.ms});
g1.look={c:f.a};g1.mark={cities:eye?[f.a]:[f.a,f.b]};}
else{const t=e.tw.find(t=>!t.ok);if(t)g1.hint=`${pzTwistTxt(t)}.`;}
if(e.goal&&!e.cheap)g2.hint=tr('puzzles.hint_over',{x:fmt$(e.spend-P.budget)});
if(!P.budget)g2.v=tr('puzzles.free');
if(e.goal&&e.cheap&&!e.n1&&e.worst){const w=e.worst,cs=[...new Set(w.lost.flatMap(q=>{const f=P.dem[q.i];return f.t==='l2'?[f.a,f.b]:[f.a];}))],l=S.links.find(q=>pzUnit(q)===w.u);
g3.hint=tr('puzzles.hint_cut',{where:pzUnitName(w.u),list:list(cs),g:fmtG(w.g)});g3.look={u:w.u};g3.mark={cities:cs,link:l&&l.id};}
else if(e.goal&&!e.cheap&&!e.n1&&e.worst){const w=e.worst,l=S.links.find(q=>pzUnit(q)===w.u);g3.mark={cities:[],link:l&&l.id};}
const gs=[g1,g2,g3],cur=gs.findIndex(g=>!g.done);if(cur>=0)gs[cur].cur=true;return gs;}
// One goal row: ⭐ met (each goal is a star), 👉 the one to work on (with its hint and Show me), a number while it waits its turn.
function pzGoalRow(g,i){const ic=g.done?'⭐':g.cur?'👉':`<i>${i+1}</i>`;
return `<div class="pzgoal${g.done?' done':g.cur?' cur':''}"><div class="pzgl"><span class="pzgi">${ic}</span><b>${g.t}</b>${g.v?`<span class="pzgv">${g.v}</span>`:''}</div>`
+(g.cur&&g.hint?`<div class="pzgh">${g.hint}${g.look?' '+btn(tr('puzzles.show_me'),'pzLook',g.look,'sm pzshow'):''}</div>`:'')+`</div>`;}
// A delivered eyeball flow is a chip; anything still short, a circuit or a latency cap keeps its full row.
const pzChip=x=>`<span class="pzchip">👀 ${esc(CITY[x.f.a].name)} <b>${fmtG(x.f.g)}</b> ✓</span>`;
function pzRender(){const el=$('pzBox');if(!pzOn()){el.hidden=true;return;}el.hidden=false;el.classList.toggle('ar',!!S.ar);if(S.ar){arRender(el);return;}
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>`;
// A phone held upright starts each puzzle with the sheet down to its status bar, so the map has the room (swipe it up for the rest).
const pk2=P.id+'|'+(P.key||'');if(UI._pzPeek!==pk2){UI._pzPeek=pk2;el.classList.toggle('mini',isPhone()&&CW<=CH);}
const sp=fmt$(e.spend);
// The status bar stays at the top of the sheet, whatever scrolls: the puzzle, its stars, the money, undo and the menu.
let h=`<div class="pztop" data-grab="pz"><div class="grab" 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>`
+`<button class="b ghost sm" data-act="pzUndo" data-args="{}" aria-label="${esc(tr('puzzles.undo'))}" title="${esc(tr('puzzles.undo'))}"${UI.pzHist&&UI.pzHist.length?'':' disabled'}>↶</button>${btn('☰','puzzleMenu',{},'ghost sm')}</div>`;
const gs=pzGoals(e),cur=gs.find(g=>g.cur);UI.pzMark=!UI.pzMk&&cur&&cur.mark||null;
h+=`<div class="pzgoals">${gs.map(pzGoalRow).join('')}</div></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.delivered'))}${star(e.goal&&e.cheap,P.budget?tr('puzzles.budget'):tr('puzzles.free'))}${star(e.goal&&e.n1,'N-1')}</div>`;
if(P.src.length)h+=`<div class="pzsrc">🗄️ ${tr('puzzles.content_lives_in_list',{list:P.src.map(c=>esc(CITY[c].name)).join(', ')})}</div>`;
h+=`<div class="pzfl">${e.flows.map(pzFlowRow).join('')}</div>`;
const chip=x=>x.f.t==='eye'&&!x.f.ms&&!x.f.be&&x.full&&x.fast,rows=e.flows.filter(x=>!chip(x)).sort((a,b)=>(a.full&&a.fast?1:0)-(b.full&&b.fast?1:0)),chips=e.flows.filter(chip);
h+=`<div class="pzfl">${rows.map(pzFlowRow).join('')}${chips.length?`<div class="pzchips">${chips.map(pzChip).join('')}</div>`:''}</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>`;
const w=e.worst;
h+=!e.goal?`<div class="pzn1">🛡 ${tr('puzzles.n_1_deliver_everything_first')}</div>`:e.n1?`<div class="pzn1 on">🛡 ${tr('puzzles.survives_any_single_cut_under_load')}</div>`
:`<div class="pzn1 bad">⚠️ ${tr('puzzles.a_cut_on_where_drops_g',{where:pzUnitName(w.u),g:fmtG(w.g)})}<br><small>${w.lost.map(x=>esc(pzFlowName(P.dem[x.i]))).join(', ')}</small></div>`;
if(!P.budget)h+=`<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>`;
if(e.n1)h+=`<div class="pzn1 on">🛡 ${tr('puzzles.survives_any_single_cut_under_load')}</div>`;
if(UI.pzMk)h+=`<div class="btns">${btn('⏩ '+tr('puzzles.skip_the_monkey'),'pzMkSkip',{},'big')}</div>`;else if(e.goal)h+=`<div class="btns">${btn(tr('puzzles.let_the_chaos_monkey_loose'),'pzMonkey',{},'sm')}</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)}${(UI.pzTop||0)>0&&(UI.pzTop||0)<3?btn(tr('puzzles.finish_here'),'pzFinish',{},'sm'):''}${btn(UI.pzFrom==='game'?tr('puzzles.back_to_my_network'):tr('puzzles.back_to_the_title'),'pzLeave',{},'ghost sm')}</div>`;
// Undo sits in the status bar; leaving is in ☰ with the puzzle list.
h+=`<div class="btns pzfoot">${btn(tr('puzzles.reset'),'pzReset',{},'ghost sm',!S.links.length&&!Object.keys(S.pops).length)}${(UI.pzTop||0)>0&&(UI.pzTop||0)<3?btn(tr('puzzles.finish_here'),'pzFinish',{},'sm'):''}</div>`;
if(h!==UI._pzh){UI._pzh=h;morph(el,h);}}
// Trenches on a pair get numbers, cables their names, so parallel links say where they run.
function pzTrench(l){if(l.cable)return esc(CAB[l.cable].name);const us=[...new Set(pairLinks(l.a,l.b).filter(x=>!x.cable).map(pzUnit))];return tr('puzzles.trench_n',{n:us.indexOf(pzUnit(l))+1});}

View file

@ -76,7 +76,7 @@ function drawFrame(now){
// cities
UI.feed=null;if(UI.sel&&UI.sel.type==='link'){const sl=S.links.find(x=>x.id===UI.sel.id);const rec=sl&&R.ef[edgeKey(sl)];if(rec){UI.feed=new Set(Object.keys(rec.eg).map(k=>R.egDesc[k].city));UI.dest=new Set(Object.keys(rec.dst));}}
// Place labels: your POPs and the selected city first, then others; a label that would overlap moves above its city or hides.
const vis=[];for(const C of CITIES){if(C.off&&!cityOn(C.id))continue;if(arHide(C.id))continue;for(const k of ks){const [sx,sy]=toS(C.x,C.y,k);if(sx<-60||sx>CW+60||sy<-60||sy>CH+60)continue;vis.push({C,sx,sy});}}
const vis=[];for(const C of CITIES){if(C.off&&!cityOn(C.id))continue;if(pzHide(C.id))continue;for(const k of ks){const [sx,sy]=toS(C.x,C.y,k);if(sx<-60||sx>CW+60||sy<-60||sy>CH+60)continue;vis.push({C,sx,sy});}}
const prio=v=>(UI.sel&&UI.sel.type==='city'&&UI.sel.id===v.C.id?0:S.pops[v.C.id]?1:2);vis.sort((a,b)=>prio(a)-prio(b)||b.C.P-a.C.P);
const rects=[],labs=[],hit=(r)=>rects.some(q=>r.x<q.x+q.w&&q.x<r.x+r.w&&r.y<q.y+q.h&&q.y<r.y+r.h);
const farL=lodFar();
@ -85,6 +85,7 @@ function drawFrame(now){
CM.inc=new Set(S.inc.filter(i=>i.type!=='leak').map(i=>i.ref));CM.far=farL;
// Zoomed in, crowded small cities give way to bigger ones and become dots (75-city-size.js).
const csc=cityScale(sc);if(farL)for(const v of vis)v.dem=false;else cityRoom(vis,csc);
if(pzOn()&&!farL)for(const v of vis)if(pzQuiet(v.C.id))v.dem=true;
for(const v of vis){if(farL){const r=FAR_R[cTier(v.C.id)]+3;rects.push({x:v.sx-r,y:v.sy-r,w:2*r,h:2*r});continue;}
if(v.dem){rects.push({x:v.sx-5*csc,y:v.sy-5*csc,w:10*csc,h:10*csc});continue;}const h=cityTop(v.C.id,S.pops[v.C.id])*csc;rects.push({x:v.sx-v.r,y:v.sy-h,w:2*v.r,h:h+10*csc});}
for(const v of vis){const p=S.pops[v.C.id];ctx.font=`800 ${p?13:12}px "Baloo 2", sans-serif`;const tw=(LBLW[v.C.id+(p?1:0)]||(LBLW[v.C.id+(p?1:0)]=ctx.measureText(v.C.name).width+14));
@ -95,7 +96,7 @@ function drawFrame(now){
if(ly===null&&prio(v)===1)for(const y of [below,above]){const r={x:v.sx-tw/2,y:y-10,w:tw,h:21};if(!labs.some(q=>r.x<q.x+q.w&&q.x<r.x+r.w&&r.y<q.y+q.h&&q.y<r.y+r.h)){ly=y;rects.push(r);labs.push(r);break;}}
if(ly===null&&(prio(v)===0||(prio(v)===1&&(v.C.id===S.home||UI.hover===v.C.id)))){ly=below;const r={x:v.sx-tw/2,y:below-10,w:tw,h:21};rects.push(r);labs.push(r);}
v.ly=ly;}
if(pzOn()){for(const v of vis.slice().reverse())pzDrawCity(v,csc,now);}else for(const v of vis.slice().reverse())drawCity(v.C,v.sx,v.sy,csc,now,v.ly,v.dem);
if(pzOn()){for(const v of vis.slice().reverse())pzDrawCity(v,csc,now);pzDrawMarks(ks,now);}else for(const v of vis.slice().reverse())drawCity(v.C,v.sx,v.sy,csc,now,v.ly,v.dem);
// cable ships at sea (88-cable-ships.js), over the city labels so a ship leaving port stays in sight
drawShips(ks,now);
// Architect runs: what the tubes between two cities are (one trench, or separate paths), above the cities.

View file

@ -14,3 +14,14 @@ function pzDrawCity(v,sc,now){const k=pzKind(v.C.id);
// In a puzzle every line says what it is ("2×100G · 70%"), and a selected POP lights up every pair it has links on.
function pzLinkLab(grp,up,load,cap){if(S.ar)return groupLabel(grp,up)+(cap?` · ${Math.round(load/cap*100)}%`:'');return groupLabel(grp,up)+(cap?` · ${Math.round(load/cap*100)}%`:'');}
const pzLinkHot=grp=>!!(UI.sel&&UI.sel.type==='city'&&grp.some(x=>x.a===UI.sel.id||x.b===UI.sel.id));
// The goal being worked on, marked where it is: a red ring round each city it is about, and on a cut that would hurt,
// a pulsing ✂ on the link (pzGoals sets UI.pzMark; the monkey's own show has the map while it runs).
function pzDrawMarks(ks,now){const m=UI.pzMark;if(!m||UI.pzMk)return;const a=animOn()?.6+.4*Math.sin(now/260):1,sc=CM.far?.6:1;
ctx.save();ctx.lineWidth=3;ctx.strokeStyle=`rgba(255,77,94,${a})`;ctx.setLineDash([7,6]);ctx.lineDashOffset=animOn()?-now/45:0;
for(const c of m.cities||[]){const C=CITY[c];if(!C)continue;for(const k of ks){const [x,y]=toS(C.x,C.y,k);ctx.beginPath();ctx.arc(x,y-6*sc,46*sc,0,7);ctx.stroke();}}
ctx.setLineDash([]);const l=m.link&&S.links.find(q=>q.id===m.link);
if(l){const pts=linkGeom(l).pts,q=pts[Math.floor(pts.length/2)];
for(const k of ks){const [x,y]=toS(q[0],q[1],k);if(x<-30||x>CW+30||y<-30||y>CH+30)continue;const r=15+2*a;
ctx.fillStyle='#FF4D5E';ctx.strokeStyle='#1E2640';ctx.lineWidth=2.5;ctx.beginPath();ctx.arc(x,y,r,0,7);ctx.fill();ctx.stroke();
ctx.fillStyle='#fff';ctx.font='900 17px sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('✂',x,y+1);}}
ctx.restore();}

View file

@ -3448,9 +3448,20 @@
"puzzles.framed_n_stars_from_the_old":"Framed on the wall: {n} ⭐ from the old puzzles",
"puzzles.frankfurt_to_singapore_the_short_way":"Frankfurt to Singapore the short way. The long way is overland, and it shows.",
"puzzles.free":"Free",
"puzzles.goal_budget":"Stay under budget",
"puzzles.goal_city":"Goal city",
"puzzles.goal_deliver":"Get all the traffic there",
"puzzles.goal_n1":"Survive any one cut",
"puzzles.goal_x_of_y":"{x} of {y}",
"puzzles.grand_tour":"Grand Tour",
"puzzles.hello_world":"Hello, World",
"puzzles.hint_cut":"If {where} is cut, {g} is lost on the way to {list}. Give them a second way in.",
"puzzles.hint_eye_none":"Nothing reaches {city} yet. Connect it.",
"puzzles.hint_eye_short":"{city} gets {got} of {g}. Add capacity on the way there.",
"puzzles.hint_l2_none":"The {name} has no path yet. Connect both ends.",
"puzzles.hint_l2_short":"The {name} gets {got} of {g}. Add capacity on its path.",
"puzzles.hint_l2_slow":"The {name} takes {ms} ms; the limit is {cap} ms. Find a faster path.",
"puzzles.hint_over":"You are {x} over. Try smaller tubes or fewer links.",
"puzzles.hub_cap":"Hub Cap",
"puzzles.includes_a_new_pop_in_city":"Includes a new POP in {city} ({price} for a year).",
"puzzles.installed":"installed",
@ -3528,6 +3539,7 @@
"puzzles.sao_paulo_to_miami_before_the":"São Paulo to Miami before the caipirinha gets warm.",
"puzzles.sea_to_shining_sea":"Sea to Shining Sea",
"puzzles.share_line":"Series of Tubes puzzle {what} {stars} {spend} · seriesoftub.es",
"puzzles.show_me":"Show me",
"puzzles.six_cities_a_few_gigs_each":"Six cities, a few gigs each, and a router with eight ports. Count before you dig.",
"puzzles.size":"Size",
"puzzles.skip_the_monkey":"Skip",

View file

@ -21,6 +21,18 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
@keyframes pzglow{50%{box-shadow:0 0 0 4px rgba(34,196,122,.25)}}
#pzBox .btns{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
#pzBox .grab{display:none}
/* The status bar: name, stars, money and the one thing to fix next stay put while the rest scrolls. */
#pzBox .pztop{position:sticky;top:-10px;z-index:2;background:var(--paper);margin:-10px -14px 0;padding:10px 14px 4px}
#pzBox .pzh .b.sm{min-width:34px;padding:3px 8px;font-size:16px}#pzBox .pzh .grow{flex:1 1 auto;min-width:0}#pzBox .pzs span small{white-space:nowrap}
/* The three goals, one per star: ⭐ met, 👉 the one to work on (with what to do and Show me), a number while it waits. */
.pzgoals{margin:2px 0 4px}.pzgoal{padding:3px 2px}
.pzgl{display:flex;align-items:center;gap:8px;font-size:14px}.pzgl b{flex:1;min-width:0;font-weight:800}
.pzgi{width:24px;flex:none;text-align:center;font-size:16px}.pzgi i{font-style:normal;display:inline-block;width:20px;height:20px;border:2px solid var(--line);border-radius:50%;font:900 11px/16px var(--body);color:var(--ink2);box-sizing:border-box}
.pzgv{font-size:12.5px;font-weight:800;color:var(--ink2);white-space:nowrap}
.pzgoal.done b{font-weight:700;color:var(--ink2)}.pzgoal:not(.done):not(.cur){opacity:.6}
.pzgoal.cur{background:#FFF4D6;border:2px solid var(--warn);border-radius:12px;padding:6px 8px;margin:3px 0}
.pzgh{font-size:13px;line-height:1.4;margin:3px 0 1px 32px}#pzBox .pzgh .pzshow{margin:2px 0 0 2px;padding:2px 10px;min-height:0;vertical-align:middle}
.pzchips{display:flex;flex-wrap:wrap;gap:5px;margin:4px 0}.pzchip{font-size:12px;font-weight:800;border:2px solid var(--ok);border-radius:999px;padding:1px 9px;background:#fff;white-space:nowrap}.pzchip b{font-weight:900}
.pzprog{margin:6px 0 4px}.pzpack{font-size:17px;margin:14px 0 2px}.pzst{font-size:12px;letter-spacing:-1px;white-space:nowrap}
.scn.lock{opacity:.5}
.pzres{position:relative}.pzstars{display:flex;justify-content:center;gap:10px;margin:10px 0 2px}
@ -40,8 +52,12 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
#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}
#pzBox .pztop{top:0;margin:0 -12px;padding:0 12px 2px}
/* Peek: only the status bar, so the map keeps the screen while you build; tap or swipe it up for the rest. */
#pzBox.mini{max-height:none}#pzBox.mini>:not(.pztop){display:none}
#pzBox .pzh .eyebrow{display:none}#pzBox h3{font-size:17px}
#pzBox .pzgl{font-size:14.5px}#pzBox .pzgh{font-size:13.5px}#pzBox .pzgh .pzshow{min-height:32px}
body.pz:has(#pzBox.mini) #hint{bottom:calc(150px + env(safe-area-inset-bottom,0px)) !important}
body.pz.sheet-open #pzBox{display:none}
body.pz #panel{bottom:0 !important}
body.pz #hint{bottom:calc(min(46%,330px) + 8px) !important}

View file

@ -0,0 +1,95 @@
// The puzzle sheet on phones: a status bar that stays put, the one thing to fix next, delivered flows as chips, and a
// map that leaves out what the puzzle does not need (far cities gone, idle stepping stones as nameless dots).
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');
// Tour de Africa (2026-W45): content in Abidjan, eyeballs in Kinshasa, Accra and Dakar, Lagos as a stepping stone.
const W45 = fs.readFileSync(path.join(__dirname, '..', 'site', 'puzzles', 'weekly', '2026-W45.json'), 'utf8');
const begin = (ev) => ev(`pzBegin(pzWkValid(${W45},'2026-W45'));ACT.pzPop({city:'abj'})`);
const L = (ev, a, b) => ev(`ACT.pzLinkTo({a:'${a}',b:'${b}'});ACT.pzLink({tier:1});closeModal()`);
const tree = (ev) => { L(ev, 'abj', 'acc'); L(ev, 'acc', 'lag'); L(ev, 'lag', 'fih'); L(ev, 'abj', 'dkr'); ev('if(UI.pzMk)ACT.pzMkSkip();pzRender()'); };
const box = (dom) => dom.window.document.getElementById('pzBox');
test('the sheet is three goals in plain words, one per star, and the one to work on says what to do and shows where', () => {
const { ev, dom, errors } = load();
begin(ev);
const top = () => box(dom).querySelector('.pztop');
assert.ok(top().querySelector('[data-act="pzUndo"]') && top().querySelector('[data-act="puzzleMenu"]'), 'undo and the menu stay in the bar');
const goals = () => [...top().querySelectorAll('.pzgoal')];
const cur = () => top().querySelector('.pzgoal.cur');
assert.equal(goals().length, 3);
assert.match(goals()[1].textContent, /Stay under budget.*of \$1\.75M/, 'the budget goal carries spent of budget');
assert.match(cur().textContent, /Get all the traffic there.*Nothing reaches (Kinshasa|Accra|Dakar) yet/, 'first: what does not arrive');
assert.ok(JSON.parse(cur().querySelector('.pzshow').dataset.args).c, 'Show me points at that city');
assert.equal(ev('UI.pzMark.cities.length'), 1, 'and the map rings it');
tree(ev);
assert.equal(goals().filter((g) => g.classList.contains('done')).length, 2, 'delivered and within budget: two stars');
assert.match(cur().textContent, /Survive any one cut.*If .+ is cut, [\d.]+ Gbps is lost on the way to .*Kinshasa/, 'then the worst cut and who it hurts');
const look = JSON.parse(cur().querySelector('.pzshow').dataset.args);
assert.ok(look.u, 'Show me points at the cut');
assert.ok(ev('!!UI.pzMark.link&&UI.pzMark.cities.length>=1'), 'the map marks the link and rings the cities');
ev('cam.x=0;cam.y=0');
cur().querySelector('.pzshow').click();
assert.ok(ev('Math.abs(cam.x)>100'), 'a tap brings it into view');
ev('draw(0)');
ev("S.pz.budget=1000;UI.pzEv=null;pzRender()");
assert.match(cur().textContent, /Stay under budget.*You are .+ over/, 'the budget comes before the cut, in star order');
assert.equal(ev('UI.pzMark'), null, 'nothing to mark for money');
assert.deepEqual(errors, []);
});
test('delivered eyeballs are chips; Back to my network lives in the menu, not in the sheet', () => {
const { ev, dom, errors } = load();
begin(ev);
assert.equal(box(dom).querySelectorAll('.pzchip').length, 0, 'nothing delivered yet: full rows');
tree(ev);
assert.equal(box(dom).querySelectorAll('.pzchip').length, 3, 'all three delivered: three chips');
assert.equal(box(dom).querySelectorAll('.pzf').length, 0);
assert.equal(box(dom).querySelectorAll('[data-act="pzLeave"]').length, 0, 'no Back button in the sheet');
ev('ACT.puzzleMenu()');
assert.ok(dom.window.document.querySelector('#modal [data-act="pzLeave"]'), 'it is in ☰');
assert.deepEqual(errors, []);
});
test('on a phone held upright the sheet starts as its status bar, and the bar opens it', () => {
const { ev, dom, errors } = load();
ev("window.innerWidth=360;window.innerHeight=740;dispatchEvent(new Event('resize'))");
begin(ev);
assert.equal(box(dom).classList.contains('mini'), true, 'peek');
ev('ACT.pzRetry()');
assert.equal(box(dom).classList.contains('mini'), true, 'a fresh try of the same puzzle keeps the sheet as the player left it');
const { ev: ev2, dom: dom2 } = load();
ev2("window.innerWidth=1280;window.innerHeight=800;dispatchEvent(new Event('resize'))");
begin(ev2);
assert.equal(box(dom2).classList.contains('mini'), false, 'a desktop shows the whole card');
assert.deepEqual(errors, []);
});
test('the map leaves out far cities and quiets idle stepping stones, but not the puzzle\'s own or yours', () => {
const { ev, errors } = load();
begin(ev);
assert.equal(ev("pzKind('tip')"), null, 'Tripoli is far from the puzzle: not a city here');
assert.equal(ev("pzHide('tip')"), true, 'and not drawn');
assert.equal(ev("pzKind('dla')"), 'off', 'Douala is close: a stepping stone');
assert.equal(ev("pzQuiet('dla')"), true, 'a nameless dot while it has no part');
assert.equal(ev("pzQuiet('fih')||pzQuiet('abj')"), false, 'the puzzle\'s cities keep their names');
ev("UI.sel={type:'city',id:'dla'}");
assert.equal(ev("pzQuiet('dla')"), false, 'picked: named');
ev("UI.sel=null;ACT.pzPop({city:'dla'})");
assert.equal(ev("pzQuiet('dla')"), false, 'a POP there: named');
ev("ACT.pzUndo();cam.z=UI.pzZ0*2.5");
assert.equal(ev("pzQuiet('dla')"), false, 'zoomed in close: named');
ev('cam.z=UI.pzZ0;draw(0)');
assert.deepEqual(errors, []);
});
test('Architect runs keep hiding everything outside the run', () => {
const { ev, errors } = load();
ev("ACT.pzArStart({id:'euro'})");
assert.equal(ev("pzHide('lis')&&arHide('lis')"), true);
assert.equal(ev("pzHide('ams')||arHide('ams')"), false);
assert.deepEqual(errors, []);
});

View file

@ -112,7 +112,7 @@ test('stars come from traffic: capacity, latency caps, best effort and N-1 under
e = evalP(ev);
assert.ok(e.goal && !e.n1, 'still connected after a cut, but short');
assert.equal(Math.round(e.worst.g), 50, 'cutting the trench with two waves leaves 100G for 150G: 50G drop');
assert.match(ev("document.getElementById('pzBox').textContent"), /A cut on Frankfurt ⇄ Paris drops 50\.\d Gbps/);
assert.match(ev("document.getElementById('pzBox').textContent"), /If Frankfurt ⇄ Paris is cut, 50\.\d Gbps is lost on the way to Paris/);
build(ev, [['fra', 'par', 'land', 1, 2]]);
assert.ok(evalP(ev).n1, 'two waves in each trench: either one carries Paris alone');
// A latency cap: Grace Hopscotch is too slow for the traders; the eyeballs are best effort and may drop on a cut.