From cbcb242d904a4abde024147012212a45c1d7c83c Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Fri, 30 Oct 2026 11:52:54 +0100 Subject: [PATCH] Architect runs: show whether tubes share a trench or take separate paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tubes in one trench are drawn as strands of one bundle with an orange '2× one trench' pill; separate paths bow well apart with a green '2 paths' pill. Cut tubes no longer show the backhoe: the monkey does the snipping. --- site/i18n/de.js | 2 ++ site/i18n/es.js | 2 ++ site/i18n/fr.js | 2 ++ site/i18n/it.js | 2 ++ site/i18n/pt.js | 2 ++ src/game/96-map/50-link-geometry.js | 7 +++++-- src/game/96-map/60-draw.js | 10 ++++++++-- src/i18n/en.js | 2 ++ tests/architect.test.js | 12 ++++++++++++ 9 files changed, 37 insertions(+), 4 deletions(-) diff --git a/site/i18n/de.js b/site/i18n/de.js index 5a95062..f4418f0 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -59,7 +59,9 @@ "architect.line_3":"Auf Par oder besser. Der Chaos-Affe ist gelangweilt heimgegangen.", "architect.move_out_of_city":"Zieh zuerst aus {city} aus.", "architect.n_briefs":"{n} Aufträge", +"architect.n_in_one_trench":"{n}× ein Graben", "architect.n_over_plan":"{n} über Plan", +"architect.n_paths":"{n} Wege", "architect.new":"Neu", "architect.next_brief":"Nächster Auftrag", "architect.next_brief_waiting":"Der nächste Auftrag wartet.", diff --git a/site/i18n/es.js b/site/i18n/es.js index 481f2a2..5868996 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -57,7 +57,9 @@ "architect.line_3":"En par o mejor. El mono del caos se fue a casa aburrido.", "architect.move_out_of_city":"Primero sal de {city}.", "architect.n_briefs":"{n} encargos", +"architect.n_in_one_trench":"{n}× una zanja", "architect.n_over_plan":"{n} por encima del plan", +"architect.n_paths":"{n} rutas", "architect.new":"Nuevo", "architect.next_brief":"Siguiente encargo", "architect.next_brief_waiting":"El siguiente encargo te espera.", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index b84ff22..16b29fd 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -57,7 +57,9 @@ "architect.line_3":"Au par ou mieux. Le singe du chaos est rentré s’ennuyer chez lui.", "architect.move_out_of_city":"Quitte d’abord {city}.", "architect.n_briefs":"{n} briefs", +"architect.n_in_one_trench":"{n}× une tranchée", "architect.n_over_plan":"{n} au-delà du plan", +"architect.n_paths":"{n} chemins", "architect.new":"Nouveau", "architect.next_brief":"Brief suivant", "architect.next_brief_waiting":"Le brief suivant t’attend.", diff --git a/site/i18n/it.js b/site/i18n/it.js index de9a748..221be11 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -57,7 +57,9 @@ "architect.line_3":"In par o meglio. La scimmia del caos è tornata a casa annoiata.", "architect.move_out_of_city":"Prima lascia {city}.", "architect.n_briefs":"{n} incarichi", +"architect.n_in_one_trench":"{n}× una trincea", "architect.n_over_plan":"{n} oltre il piano", +"architect.n_paths":"{n} percorsi", "architect.new":"Nuovo", "architect.next_brief":"Prossimo incarico", "architect.next_brief_waiting":"Il prossimo incarico ti aspetta.", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index df7ae8f..61b222b 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -57,7 +57,9 @@ "architect.line_3":"No par ou melhor. O macaco do caos foi para casa entediado.", "architect.move_out_of_city":"Saia de {city} primeiro.", "architect.n_briefs":"{n} pedidos", +"architect.n_in_one_trench":"{n}× uma vala", "architect.n_over_plan":"{n} acima do plano", +"architect.n_paths":"{n} rotas", "architect.new":"Novo", "architect.next_brief":"Próximo pedido", "architect.next_brief_waiting":"O próximo pedido está esperando.", diff --git a/src/game/96-map/50-link-geometry.js b/src/game/96-map/50-link-geometry.js index 2f6b4ea..adb0642 100644 --- a/src/game/96-map/50-link-geometry.js +++ b/src/game/96-map/50-link-geometry.js @@ -37,7 +37,8 @@ function drawCables(ks){const z=cam.z,selC=UI.drag&&UI.drag.mode==='link'?UI.dra ctx.globalAlpha=1;}}} function bezGeom(l,at){const A=CITY[l.a],B=CITY[l.b];const i=at!==undefined?at:lineIdx(l);const key=l.id+'|b'+i;const hit=GEO.get(key);if(hit)return hit; const bx=A.x+wrapDx(A.x,B.x),by=B.y;const dx=bx-A.x,dy=by-A.y,len=Math.hypot(dx,dy)||1;let nx=-dy/len,ny=dx/len;if(ny>0){nx=-nx;ny=-ny;} - const base=Math.max(4,Math.min(len*0.1,90)),step=Math.min(16,len*.06),off0=i<=0?base:(i%2?-1:1)*(base*(i%2?0.2:1)+Math.ceil(i/2)*step); + // Architect runs bow diverse paths well apart, so two routes never read as one. + const wide=S&&S.ar&&pzOn(),base=Math.max(4,Math.min(len*0.1,90)),step=wide?Math.min(30,len*.14):Math.min(16,len*.06),off0=i<=0?base:(i%2?-1:1)*(base*(i%2?(wide?0.9:0.2):1)+Math.ceil(i/2)*step); const mx=(A.x+bx)/2,my=(A.y+by)/2; const sg=Math.sign(off0)||1,mag=Math.abs(off0); // Bend around cities in the way, but gently: short links need less room, no curve bows out more than about a @@ -56,4 +57,6 @@ function bezGeom(l,at){const A=CITY[l.a],B=CITY[l.b];const i=at!==undefined?at:l const g={ax:A.x,ay:A.y,bx,by,cx:best[0],cy:best[1],len};GEO.set(key,g);return g;} const qpt=(g,t)=>[(1-t)*(1-t)*g.ax+2*(1-t)*t*g.cx+t*t*g.bx,(1-t)*(1-t)*g.ay+2*(1-t)*t*g.cy+t*t*g.by]; const utilCol=u=>u<=0.001?'#AFC0D6':u<0.65?'#22C47A':u<0.9?'#FFAA1F':'#FF4D5E'; - +// How many separate paths (trenches or cables) join this tube's two cities. +const arPaths=l=>new Set(pairLinks(l.a,l.b).map(gKey)).size; +const AR_PILLS=[]; // filled while the links are drawn, painted after the cities diff --git a/src/game/96-map/60-draw.js b/src/game/96-map/60-draw.js index 4874205..649f933 100644 --- a/src/game/96-map/60-draw.js +++ b/src/game/96-map/60-draw.js @@ -25,10 +25,11 @@ function drawFrame(now){ // cable systems drawCables(ks); // links + AR_PILLS.length=0; const far=lodFar(),PI=pairIdx(),LG=linkGroups(),GM=LG.map(g=>linkGeom(g[0],PI.get(edgeKey(g[0])))),busy=linesOnScreen(GM,ks)>MAP_BUSY; for(let gi=0;gi1,up=many?grp.filter(x=>!linkDown(x)):null; const gm=GM[gi],cap=many?up.reduce((a,x)=>a+capOf(x),0):capOf(l),load=many?grp.reduce((a,x)=>a+(R.load[x.id]||0),0):(R.load[l.id]||0),u=cap?load/cap:0,df=l.kind==='df',bld=df&&l.ready>day,cut=!bld&&(many?!up.length:linkDown(l))&&!(df&&!(l.ch||[]).length),dark=df&&!bld&&!(l.ch||[]).length,vx=l.kind==='vxc',idle=!cut&&!bld&&load<1e-3&&(many?up.length>0&&up.every(x=>x.standby):!!l.standby); - const pz=pzOn(),sel=(UI.sel&&UI.sel.type==='link'&&grp.some(x=>x.id===UI.sel.id))||(pz&&pzLinkHot(grp));let lab=null; + const pz=pzOn(),arPz=pz&&!!S.ar,sel=(UI.sel&&UI.sel.type==='link'&&grp.some(x=>x.id===UI.sel.id))||(pz&&pzLinkHot(grp));let lab=null; const w=(vx?2.2:(2.5+Math.max(...grp.map(tierW))*1.8+(many?Math.min(1.5,(grp.length-1)*0.5):0)))*sc*(far?0.5:1),np=gm.pts.length; if(SX.length0.001?utilCol(u):'#7FD8EE'):utilCol(u);ctx.lineWidth=w;ctx.stroke();ctx.setLineDash([]); + // Architect runs: tubes sharing one trench are drawn as strands of one bundle (one snip takes them all). + if(arPz&&many&&!far){ctx.strokeStyle='#1E2640';ctx.lineWidth=1.3;for(let j=1;jpolyAtXY(SX,SY,gm.cum,t); @@ -49,7 +52,8 @@ function drawFrame(now){ const rr2=far?1.6:Math.max(2.2,w*.42),base=now/1000*spd/Math.max(len,40);ctx.beginPath();for(let i=0;i1)){const k=arPaths(l);if(many||lineIdx(l,PI.get(edgeKey(l)))===0){AR_PILLS.push([mxx,my,many?tr('architect.n_in_one_trench',{n:grp.length}):'✓ '+tr('architect.n_paths',{n:k}),many]);}} else if(sel||(pz?!S.ar:z>0.9&&!busy)){const t=lab||(lab=pz?pzLinkLab(grp,up||[l],load,cap):many?groupLabel(grp,up):capName(l));ctx.font='800 11px "Baloo 2", sans-serif';let tw=LINKW.get(t);if(tw===undefined)LINKW.set(t,tw=ctx.measureText(t).width+10);ctx.fillStyle='#fff';ctx.strokeStyle='#1E2640';ctx.lineWidth=2;rr(mxx-tw/2,my-9,tw,17,8);ctx.fill();ctx.stroke();ctx.fillStyle='#1E2640';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(t,mxx,my+1);} } } @@ -86,6 +90,8 @@ function drawFrame(now){ CM.off=new Set();CM.big=new Set();for(const o of S.offers){const big=BIZ_T[o.type].lv>=3||BIZ_T[o.type].event;for(const c of bCities(o)){CM.off.add(c);if(big)CM.big.add(c);}} CM.inc=new Set(S.inc.filter(i=>i.type!=='leak').map(i=>i.ref));CM.far=farL; if(pzOn()){for(const v of vis.slice().reverse())pzDrawCity(v,sc,now);}else for(const v of vis.slice().reverse())drawCity(v.C,v.sx,v.sy,sc,now,v.ly); + // Architect runs: what the tubes between two cities are (one trench, or separate paths), above the cities. + for(const [x,y,t,one] of AR_PILLS){ctx.font='800 11px "Baloo 2", sans-serif';const tw=ctx.measureText(t).width+12;ctx.fillStyle=one?'#FFE3C2':'#DDF7E7';ctx.strokeStyle=one?'#FF8A3D':'#16A866';ctx.lineWidth=2;rr(x-tw/2,y-9,tw,17,8);ctx.fill();ctx.stroke();ctx.fillStyle='#1E2640';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(t,x,y+1);} if(UI.mk)mkDraw(ks); // floaters for(let i=FLOATS.length-1;i>=0;i--){const f=FLOATS[i],a=(now-f.t)/1600;if(a>1){FLOATS.splice(i,1);continue;} diff --git a/src/i18n/en.js b/src/i18n/en.js index f33be0d..14f163c 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -58,7 +58,9 @@ "architect.line_3":"At par or better. The chaos monkey went home bored.", "architect.move_out_of_city":"Move out of {city} first.", "architect.n_briefs":"{n} briefs", +"architect.n_in_one_trench":"{n}× one trench", "architect.n_over_plan":"{n} over plan", +"architect.n_paths":"{n} paths", "architect.new":"New", "architect.next_brief":"Next brief", "architect.next_brief_waiting":"The next brief is waiting.", diff --git a/tests/architect.test.js b/tests/architect.test.js index 322bcbc..a245070 100644 --- a/tests/architect.test.js +++ b/tests/architect.test.js @@ -151,3 +151,15 @@ test('architect runs: a bigger tube brings a bigger router, and changing an old assert.equal(ev("(S.pops.ams.rgen||0)===0&&S.ar.sunk===" + sunk), true, 'undo puts it all back'); assert.deepEqual(errors, []); }); + +test('architect runs: the map tells two tubes in one trench from two separate paths', () => { + const { ev, errors } = load(); + ev("ACT.pzArStart({id:'euro'});ACT.pzArAll();S.cash=1e9"); + lay(ev, 'ams', 'fra', 'land', 1); lay(ev, 'ams', 'fra', 'land', 0); + lay(ev, 'ams', 'par', 'land', 1); lay(ev, 'ams', 'par', 'land', 1); + assert.equal(ev("arPaths(S.links.find(l=>l.b==='fra'||l.a==='fra'))"), 1, 'same trench: one path'); + assert.equal(ev("arPaths(S.links.find(l=>l.b==='par'||l.a==='par'))"), 2, 'diverse: two paths'); + ev("cam.x=CITY.ams.x;cam.y=CITY.ams.y;cam.z=2.4;drawFrame(performance.now())"); + assert.deepEqual(JSON.parse(ev("JSON.stringify(AR_PILLS.map(p=>p[2]).sort())")), ['2× one trench', '✓ 2 paths']); + assert.deepEqual(errors, []); +});