diff --git a/CHANGELOG.md b/CHANGELOG.md index 2014114..3a2e61a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Cities on the map now show how big they are: zoomed out, bigger cities are bigger dots and megacities glow; zoomed in, a city's skyline grows from a hut to a megacity's towers. When cities crowd together, the smaller ones step back to a dot until you zoom in, so the map stays readable, and exchanges you haven't joined are quieter tags. ## [2.1.0] — 2026-10-31 - Your backbone now runs a technology you choose: plain IGP, LDP/MPLS, RSVP-TE, SR-MPLS or SRv6. Each step up costs plenty and uses less router CPU: label switching makes traffic that only passes through a POP cheaper for its router, and Auto-TE and RouteScript now need RSVP-TE or higher. Routers only run what they support, so a POP with an older router stays outside the backbone, and mixing vendors at the very top of what their routers can do brings interop failures. Networks that already have Auto-TE keep it exactly as it is. diff --git a/src/game/96-map/60-draw.js b/src/game/96-map/60-draw.js index d6370ae..67b4452 100644 --- a/src/game/96-map/60-draw.js +++ b/src/game/96-map/60-draw.js @@ -78,19 +78,22 @@ function drawFrame(now){ 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=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; + // 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); + 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)); - if(farL&&prio(v)>1&&UI.hover!==v.C.id){v.ly=null;continue;} - const h=farL?6:12+Math.sqrt(v.C.P)*0.75;const below=farL?v.sy+15:v.sy+16*sc+8,above=farL?v.sy-15:v.sy-h*sc-17*sc;let ly=null; + if((farL&&prio(v)>1&&UI.hover!==v.C.id)||v.dem){v.ly=null;continue;} + const h=farL?6:cityTop(v.C.id,p);const below=farL?v.sy+15:v.sy+16*csc+8,above=farL?v.sy-15:v.sy-h*csc-17*csc;let ly=null; for(const y of [below,above]){const r={x:v.sx-tw/2-2,y:y-10,w:tw+4,h:21};if(!hit(r)){ly=y;rects.push(r);labs.push(r);break;}} // Your POPs may sit over a city icon, but not over another name: that one waits until you zoom in. 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=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); + 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); // 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);} // the chaos monkey (woken here after a reload, wherever it last snipped) diff --git a/src/game/96-map/75-city-size.js b/src/game/96-map/75-city-size.js new file mode 100644 index 0000000..2f3c953 --- /dev/null +++ b/src/game/96-map/75-city-size.js @@ -0,0 +1,36 @@ +/* City size: a city's icon says how many eyeballs live there, in five steps from an outpost to a megacity. + P is the city's eyeball demand (about 40G per million people), so it stands in for population. + Zoomed out the dots grow with it; zoomed in the skyline does. Crowded cities give way to bigger ones. */ +const CTIER_AT=[15,100,350,800],ctier=P=>{let t=0;while(t<4&&P>=CTIER_AT[t])t++;return t;}; +const CTIER=new Map(CITIES.map(C=>[C.id,ctier(C.P)])),cTier=id=>{const t=CTIER.get(id);return t===undefined?ctier((CITY[id]||{}).P||0):t;}; +// Near view: each tier's skyline, one [x, height, colour] per 10 px wide building, and a gentle extra scale on top. +const SKY=[ + [[-5,7,'#FFFFFF']], + [[-10,9,'#FFFFFF'],[0,12,'#FFE7A1']], + [[-15,11,'#FFFFFF'],[-5,16,'#FFE7A1'],[5,9,'#BDE8FF']], + [[-20,13,'#BDE8FF'],[-10,20,'#FFFFFF'],[0,16,'#FFE7A1'],[10,10,'#FFFFFF']], + [[-25,15,'#BDE8FF'],[-15,22,'#FFFFFF'],[-5,31,'#FFE7A1'],[5,20,'#BDE8FF'],[15,13,'#FFFFFF']], +]; +const SKY_H=SKY.map(b=>Math.max(...b.map(x=>x[1]))),SKY_W=SKY.map(b=>b.length*10),CSC=[0.8,0.88,0.95,1.03,1.1]; +// Far view: the dot's radius per tier. Megacities also glow a little. +const FAR_R=[1.7,2.3,3.1,4.3,6]; +// How tall a city's icon stands above its spot, in icon units (×iconScale on screen). +const cityTop=(id,p)=>p?24:SKY_H[cTier(id)]*CSC[cTier(id)]+6; +// Phones show cities a little smaller: the screen is narrow and every city would touch the next (taps stay as big). +const cityScale=sc=>sc*(innerWidth<=760?0.82:1); +// An exchange you have not joined is a quiet tag, and on outposts and towns only once you zoom in close. +const ixQuiet=id=>!S.myIx[id]&&!hasIxAt(id),ixShown=(id,p)=>!!ixName(id)&&(p||!ixQuiet(id)||cTier(id)>=2||cam.z>=1.5); +/* Room on the map (near view only). Cities claim space in order: the selected or hovered city, your POPs, cities with + an offer, an outage or a part in the puzzle, then the biggest. A city whose skyline would sit on one already placed + becomes a small dot (v.dem): still there and still tappable, just quiet. */ +function cityRoom(vis,sc){ + const sel=UI.sel&&UI.sel.type==='city'?UI.sel.id:null,pz=pzOn(); + const pr=v=>{const id=v.C.id;return id===sel||UI.hover===id?0:S.pops[id]?1:CM.off.has(id)||CM.inc.has(id)||(pz&&pzKind(id)&&pzKind(id)!=='off')?2:3;}; + for(const v of vis)v.pr=pr(v); + const ord=vis.slice().sort((a,b)=>a.pr-b.pr||b.C.P-a.C.P),cell=64,grid=new Map(),at=(i,j)=>i*8192+j; + for(const v of ord){const t=cTier(v.C.id),p=S.pops[v.C.id],r=(p?22:(SKY_W[t]/2+3+(ixShown(v.C.id,p)?7:0))*CSC[t])*sc;v.r=r;v.dem=false; + const i0=Math.floor(v.sx/cell),j0=Math.floor(v.sy/cell);let clash=false; + if(v.pr>2)for(let i=i0-2;i<=i0+2&&!clash;i++)for(let j=j0-2;j<=j0+2&&!clash;j++){const L=grid.get(at(i,j));if(L)for(const q of L)if(Math.hypot(q.sx-v.sx,q.sy-v.sy)=2){ctx.fillStyle=down?'#6E7590':'#D63B7F';rr(-6,-7,15,10,4);ctx.fill();ctx.stroke();} ctx.fillStyle=col;rr(-8,-5,16,10,4);ctx.fill();ctx.stroke(); - }else{ctx.fillStyle=hasIxAt(C.id)?'#FFD23F':'#FFFFFF';ctx.lineWidth=1.5;ctx.beginPath();ctx.arc(0,0,hov?4.5:3.4,0,7);ctx.fill();ctx.stroke();} + }else{// The dot grows with the city's eyeballs; a megacity glows a little (75-city-size.js). + const t=cTier(C.id),r=FAR_R[t]*(hov?1.3:1);if(t===4){ctx.fillStyle='rgba(255,255,255,.55)';ctx.beginPath();ctx.arc(0,0,r+4.5,0,7);ctx.fill();} + ctx.fillStyle=hasIxAt(C.id)?'#FFD23F':'#FFFFFF';ctx.lineWidth=t>=3?1.6:1.3;ctx.beginPath();ctx.arc(0,0,r,0,7);ctx.fill();ctx.stroke();} if(CM.off.has(C.id)){ctx.fillStyle='#16A866';ctx.lineWidth=1.2;ctx.beginPath();ctx.arc(p?9:5,p?-7:-5,3,0,7);ctx.fill();ctx.stroke();} if(CM.inc.has(C.id)){ctx.fillStyle='#FF4D5E';ctx.lineWidth=1.2;ctx.beginPath();ctx.arc(p?-9:-5,p?-7:-5,3.4,0,7);ctx.fill();ctx.stroke();} ctx.restore(); @@ -19,20 +21,25 @@ function drawCityFar(C,sx,sy,sc,now,lyOverride){ ctx.fillStyle=p?'#FF4F9A':'#FFFFFF';ctx.strokeStyle='#1E2640';ctx.lineWidth=1.6;rr(sx-tw/2,ly-8,tw,16,8);ctx.fill();ctx.stroke(); ctx.fillStyle=p?'#FFFFFF':'#1E2640';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(t,sx,ly+1);} } -function drawCity(C,sx,sy,sc,now,lyOverride){ +function drawCity(C,sx,sy,sc,now,lyOverride,dem){ if(CM.far)return drawCityFar(C,sx,sy,sc,now,lyOverride); const hot=(UI.hotMap||{})[C.id]; const p=S.pops[C.id],down=p&&p.down>S.day,sel=UI.sel&&UI.sel.type==='city'&&UI.sel.id===C.id,hov=UI.hover===C.id||(UI.snap&&UI.snap.id===C.id); + // No room for its skyline here: a quiet dot, a little bigger for bigger cities, until you zoom in (cityRoom). + if(dem&&!p&&!sel&&!hov){const r=(2.6+cTier(C.id)*0.35)*sc;ctx.fillStyle=hasIxAt(C.id)?'#FFD23F':'#FFFFFF';ctx.strokeStyle='#1E2640';ctx.lineWidth=1.6;ctx.beginPath();ctx.arc(sx,sy+2*sc,r,0,7);ctx.fill();ctx.stroke();return;} + const t=cTier(C.id),cs=p?1:CSC[t]; const k=sc*(hov?1.15:1); ctx.save();ctx.translate(sx,sy); if(UI.feed&&UI.feed.has(C.id)){ctx.strokeStyle='#FF8A3D';ctx.lineWidth=4;ctx.setLineDash([3,5]);ctx.beginPath();ctx.arc(0,-6*k,36*k,0,7);ctx.stroke();ctx.setLineDash([]);} if(sel){ctx.strokeStyle='#FF4F9A';ctx.lineWidth=3;ctx.setLineDash([6,6]);ctx.lineDashOffset=-now/40;ctx.beginPath();ctx.arc(0,-6*k,30*k,0,7);ctx.stroke();ctx.setLineDash([]);} if(p&&!down&&R.cityDem[C.id]>0&&sfOf(R,C.id)<0.9){const a=.35+.25*Math.sin(now/200);ctx.fillStyle=`rgba(255,77,94,${a})`;ctx.beginPath();ctx.arc(0,-6*k,26*k,0,7);ctx.fill();} - ctx.scale(k,k); - ctx.fillStyle='rgba(30,38,64,.2)';ctx.beginPath();ctx.ellipse(0,9,20,5,0,0,7);ctx.fill(); - const h=p?18:12+Math.sqrt(C.P)*0.75; + ctx.scale(k*cs,k*cs); + ctx.fillStyle='rgba(30,38,64,.2)';ctx.beginPath();ctx.ellipse(0,9,p?20:SKY_W[t]/2+5,5,0,0,7);ctx.fill(); + const h=p?18:SKY_H[t]; ctx.strokeStyle='#1E2640';ctx.lineWidth=2.2; - if(!p){const bl=[[-15,h*.65,'#FFFFFF'],[-5,h,'#FFE7A1'],[5,h*.5,'#BDE8FF']]; + // The skyline says how big the city is: a hut for an outpost, up to five towers for a megacity. + if(!p){const bl=SKY[t]; + if(t===4){ctx.lineWidth=2;ctx.beginPath();ctx.moveTo(0,8-h);ctx.lineTo(0,1-h);ctx.stroke();ctx.fillStyle='#FF4D5E';ctx.beginPath();ctx.arc(0,-h,2.2,0,7);ctx.fill();ctx.stroke();ctx.lineWidth=2.2;} for(const [x,hh,col] of bl){ctx.fillStyle=col;rr(x,8-hh,10,hh,2);ctx.fill();ctx.stroke();} ctx.fillStyle='rgba(30,38,64,.35)';ctx.beginPath();for(const [x,hh] of bl)for(let yy=8-hh+4;yy<5;yy+=5){ctx.rect(x+2.5,yy,2,2);ctx.rect(x+5.5,yy,2,2);}ctx.fill();} if(p){ @@ -56,8 +63,10 @@ function drawCity(C,sx,sy,sc,now,lyOverride){ ctx.translate(0,-2); } const ixn=ixName(C.id); - if(ixn){const mine=!!S.myIx[C.id],joined=hasIxAt(C.id);const ixHot=hot&&hot.ix;ctx.fillStyle=ixHot?(Math.sin(now/180)>0?'#FF4D5E':'#FF8A3D'):mine?'#FF4F9A':joined?'#FFD23F':'#FFFFFF';ctx.beginPath();for(let i=0;i<6;i++){const a=Math.PI/3*i+Math.PI/6;ctx.lineTo(19+8.5*Math.cos(a),-h+2+8.5*Math.sin(a));}ctx.closePath();ctx.fill();ctx.lineWidth=2;ctx.stroke(); - ctx.fillStyle=mine||ixHot?'#fff':'#1E2640';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('IX',19,-h+2.5);} + // The IX badge sits at the skyline's top right, whatever its width. + if(ixn&&(ixShown(C.id,p)||(hot&&hot.ix)||sel||hov)){const mine=!!S.myIx[C.id],joined=hasIxAt(C.id),ixHot=hot&&hot.ix,q=!p&&!ixHot&&ixQuiet(C.id),R=q?6.5:8.5,ix=p?19:SKY_W[t]/2+(q?2:4); + ctx.fillStyle=ixHot?(Math.sin(now/180)>0?'#FF4D5E':'#FF8A3D'):mine?'#FF4F9A':joined?'#FFD23F':'#FFFFFF';ctx.beginPath();for(let i=0;i<6;i++){const a=Math.PI/3*i+Math.PI/6;ctx.lineTo(ix+R*Math.cos(a),-h+2+R*Math.sin(a));}ctx.closePath();ctx.fill();ctx.lineWidth=q?1.4:2;ctx.stroke(); + ctx.fillStyle=mine||ixHot?'#fff':'#1E2640';ctx.font=`900 ${q?6.5:8}px Nunito, sans-serif`;ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('IX',ix,-h+2.5);} if(hot&&p){let y=-14;const pulse=.75+.25*Math.sin(now/200);for(const k of ['r','t','p','c']){if(!hot[k])continue;ctx.globalAlpha=pulse;ctx.fillStyle='#FF4D5E';ctx.beginPath();ctx.arc(-29,y,6.5,0,7);ctx.fill();ctx.globalAlpha=1;ctx.lineWidth=2;ctx.strokeStyle='#1E2640';ctx.stroke();ctx.fillStyle='#fff';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(HOTL[k],-29,y+0.5);y+=14;}} const off=CM.off.has(C.id); if(off){const by=-h-16+Math.sin(now/250)*3;ctx.fillStyle='#fff';ctx.lineWidth=2.2;ctx.beginPath();ctx.ellipse(-2,by,11,9,0,0,7);ctx.fill();ctx.stroke();ctx.beginPath();ctx.moveTo(-5,by+8);ctx.lineTo(-7,by+14);ctx.lineTo(0,by+8);ctx.fillStyle='#fff';ctx.fill();const big=CM.big.has(C.id);ctx.fillStyle=big?'#FF4F9A':'#16A866';ctx.font='900 13px "Baloo 2", sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(big?'$$':'$',-2,by+1);} diff --git a/src/game/96-map/85-puzzle-cities.js b/src/game/96-map/85-puzzle-cities.js index baddeb7..be64a9f 100644 --- a/src/game/96-map/85-puzzle-cities.js +++ b/src/game/96-map/85-puzzle-cities.js @@ -3,13 +3,13 @@ build in but not emphasised. */ function pzBadge(c){const P=S.pz;if(S.ar)return c===S.ar.hq?'🏠':S.ar.gold.includes(c)?'🚨':'';return P.src.includes(c)?'🗄️':P.dem.some(f=>f.t==='eye'&&f.a===c)?'👀':P.dem.some(f=>f.t==='l2'&&(f.a===c||f.b===c))?'🔗':'';} function pzDrawCity(v,sc,now){const k=pzKind(v.C.id); - if(!k||k==='off'){drawCity(v.C,v.sx,v.sy,sc,now,v.ly===null?undefined:v.ly);return;} + if(!k||k==='off'){drawCity(v.C,v.sx,v.sy,sc,now,v.ly===null?undefined:v.ly,v.dem);return;} const r=(CM.far?16:34)*sc,y=v.sy-(CM.far?0:6*sc),p=S.pops[v.C.id]; ctx.save();ctx.lineWidth=3; if(k==='avoid'){ctx.strokeStyle='#FF4D5E';ctx.beginPath();ctx.arc(v.sx,y,r,0,7);ctx.moveTo(v.sx-r*.7,y-r*.7);ctx.lineTo(v.sx+r*.7,y+r*.7);ctx.stroke();} else{const a=animOn()?.55+.35*Math.sin(now/300):.8,gold=S.ar&&S.ar.gold.includes(v.C.id),dk=S.ar&&arDarkNow(v.C.id);ctx.strokeStyle=dk?`rgba(255,77,94,${a})`:gold?`rgba(224,160,0,${p?1:a})`:k==='goal'?`rgba(255,79,154,${p?1:a})`:'rgba(30,38,64,.7)';if(gold||dk)ctx.lineWidth=5;if(k==='via')ctx.setLineDash([5,5]); ctx.fillStyle=k==='goal'&&!p?'rgba(255,210,63,.35)':'rgba(255,255,255,.25)';ctx.beginPath();ctx.arc(v.sx,y,r,0,7);ctx.fill();ctx.stroke();ctx.setLineDash([]);} - ctx.restore();drawCity(v.C,v.sx,v.sy,sc,now,v.ly===null?undefined:v.ly); + ctx.restore();drawCity(v.C,v.sx,v.sy,sc,now,v.ly===null?undefined:v.ly,v.dem); const b=k==='goal'&&!CM.far?pzBadge(v.C.id):'';if(b){ctx.font=`${Math.round(15*sc)}px sans-serif`;ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(b,v.sx-r*.75,y-r*.75);}} // top left: the IX badge has the top right // 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)}%`:'');} diff --git a/tests/city-size.test.js b/tests/city-size.test.js new file mode 100644 index 0000000..8c16fcd --- /dev/null +++ b/tests/city-size.test.js @@ -0,0 +1,81 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +// A game with three POPs around Europe, and a hook that keeps the cities cityRoom() saw on the last frame. +function game(t) { + const h = load(); + t.after(() => h.dom.window.close()); + h.ev("ACT.start({});S.lvl=6;S.cash=1e9;for(const c of ['ams','lon','par'])ACT.buildPop({city:c});UI.speed=0;compute()"); + h.ev("window.__v=null;const o=cityRoom;cityRoom=(v,s)=>{o(v,s);window.__v=v;}"); + return h; +} +// Draw one frame at a zoom and return what each visible city got: tier, room, dot or not, label or not. +const frame = (ev, z, x = 1040, y = 300) => { + ev(`window.__v=null;cam.x=${x};cam.y=${y};cam.z=${z};draw(0)`); + return JSON.parse(ev("JSON.stringify((window.__v||[]).map(v=>({id:v.C.id,P:v.C.P,t:cTier(v.C.id),sx:v.sx,sy:v.sy,r:v.r,dem:v.dem,pr:v.pr,ly:v.ly})))")); +}; +const near = (a, b) => Math.hypot(a.sx - b.sx, a.sy - b.sy) < a.r + b.r - 1e-6; + +test('five city sizes from eyeballs: megacities are rare, outposts are huts', t => { + const { ev, errors } = game(t); + assert.equal(ev("cTier('sha')"), 4, 'Shanghai'); + assert.equal(ev("cTier('nyc')"), 4, 'New York'); + assert.equal(ev("cTier('dks')"), 0, 'Dikson'); + const n = JSON.parse(ev("JSON.stringify([0,1,2,3,4].map(t=>CITIES.filter(C=>cTier(C.id)===t).length))")); + assert.ok(n.every(x => x > 0), `every size is used: ${n}`); + assert.ok(n[4] <= 20, `megacities stay rare: ${n[4]}`); + // bigger cities draw bigger, near and far + assert.equal(ev("[1,2,3,4].every(t=>SKY_H[t]>SKY_H[t-1]&&SKY_W[t]>SKY_W[t-1]&&FAR_R[t]>FAR_R[t-1])"), true); + assert.deepEqual(errors, []); +}); + +test('crowded small cities give way to bigger ones as dots; your POPs and the selected city never do', t => { + const { ev, errors } = game(t); + ev("UI.sel={type:'city',id:'bru'}"); + const v = frame(ev, 1.05); + assert.ok(v.length > 50 && v.some(x => x.dem), 'a crowded view has dots'); + for (const x of v.filter(x => x.pr <= 2)) assert.equal(x.dem, false, `${x.id} keeps its icon`); + assert.equal(v.find(x => x.id === 'bru').dem, false, 'the selected city'); + for (const id of ['ams', 'lon', 'par']) assert.equal(v.find(x => x.id === id).dem, false, `POP ${id}`); + const full = v.filter(x => !x.dem); + // two ordinary cities with full icons never sit on each other + for (const a of full) for (const b of full) if (a !== b && a.pr === 3 && b.pr === 3) assert.ok(!near(a, b), `${a.id} and ${b.id} overlap`); + // a city only gives way to one that is more important or at least as big + for (const d of v.filter(x => x.dem)) assert.ok(full.some(b => near(d, b) && (b.pr < d.pr || b.P >= d.P)), `${d.id} gave way to nothing bigger`); + // and a dot gets no label + for (const d of v.filter(x => x.dem)) assert.equal(d.ly, null, `${d.id} has no label`); + assert.deepEqual(errors, []); +}); + +test('zooming in gives every city its skyline back; zoomed out the map is dots sized by eyeballs', t => { + const { ev, errors } = game(t); + const dots = z => frame(ev, z).filter(x => x.dem).length; + const a = dots(1.05), b = dots(1.7), c = dots(3.2); + assert.ok(a > b && b > c, `fewer dots as you zoom in: ${a}, ${b}, ${c}`); + assert.equal(c, 0, 'close in, every city in view has its skyline'); + // far view: no room to share, every city is a dot drawn by size (cityRoom is not needed) + assert.equal(frame(ev, 0.5).length, 0); + assert.equal(ev('CM.far'), true); + assert.deepEqual(errors, []); +}); + +test('a city shown as a dot is still there to tap', t => { + const { ev, errors } = game(t); + const v = frame(ev, 1.05); + const lone = v.filter(x => x.dem).find(d => v.every(o => o === d || Math.hypot(o.sx - d.sx, o.sy - d.sy) > 24)); + assert.ok(lone, 'a dot with nothing right next to it'); + assert.equal(ev(`(pickCity(${lone.sx},${lone.sy + 2})||{}).id`), lone.id); + assert.deepEqual(errors, []); +}); + +test('phones draw cities a little smaller, so more of them keep their skyline', t => { + const { ev, errors } = game(t); + const desk = frame(ev, 1.05).filter(x => x.dem).length; + ev("Object.defineProperty(window,'innerWidth',{value:390,configurable:true})"); + assert.equal(ev('cityScale(1)'), 0.82); + const v = frame(ev, 1.3); + assert.ok(v.length > 0 && v.filter(x => !x.dem).every(x => x.r <= 40), 'small enough for a narrow screen'); + assert.ok(desk > 0); + assert.deepEqual(errors, []); +});