diff --git a/CHANGELOG.md b/CHANGELOG.md index f0bd968..ff379be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,22 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +## [1.15.0] — 2026-10-25 + +- The map gets cleaner as you zoom out (#37): cities turn into dots, your POPs + into small router pills, links get thinner, and only your own cities keep + their labels. Up close, a POP shows your router instead of the skyline, + and a city with a second building shows a small router B on its metro + ring, so dual-site POPs stand out. +- Parallel waves on the same cable or in the same trench draw as one line + with a combined label, like "8×6.4T · 7/8 up" (#19). +- Decommission POPs, one at a time or several at once, from the Infra tab. + Everything in them goes, and customers who depended on them are let go + with three months of their contract as an early-termination penalty. +- Dark fiber panels now list the other links between the two cities and can + add a parallel link, like waves already could. +- NLNOG Day joins the conference calendar, in Amsterdam every September (#32). + ## [1.14.0] — 2026-10-24 - More of Britain and Norway: Manchester, Edinburgh, the cable town of Bude diff --git a/package-lock.json b/package-lock.json index bd17618..b815b7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "seriesoftubes", - "version": "1.14.0", + "version": "1.15.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "seriesoftubes", - "version": "1.14.0", + "version": "1.15.0", "devDependencies": { "jsdom": "24.1.3" }, diff --git a/package.json b/package.json index 5fd7141..c6dab3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seriesoftubes", - "version": "1.14.0", + "version": "1.15.0", "description": "A cartoon browser game about building the internet.", "private": true, "homepage": "https://seriesoftub.es/", diff --git a/site/i18n/it.js b/site/i18n/it.js index 87801e3..f7bc3e1 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -1971,4 +1971,28 @@ "Football, films and a router that looks like a spaceship.":"Calcio, film e un router che sembra un’astronave.", "Cable broadband for half of Britain. Fast on a good day.":"Banda larga via cavo per mezza Gran Bretagna. Veloce nelle giornate buone.", "Norway’s incumbent. Neither yes nor no, until you send enough traffic.":"L’incumbent norvegese. Né sì né no, finché non mandi abbastanza traffico.", +"Decommission":"Dismetti", +"Shut this POP down: its links, ports and caches go with it, and every customer that depends on it is let go, with an early-termination penalty.":"Chiudi questo POP: link, porte e cache spariscono con lui, e ogni cliente che ne dipende viene lasciato andare, con una penale di recesso anticipato.", +"Decommission {city}…":"Dismetti {city}…", +"Decommission several POPs…":"Dismetti più POP…", +"home":"casa", +"{n} link":"{n} link", +"{n} links":"{n} link", +"{n} customer":"{n} cliente", +"{n} customers":"{n} clienti", +"Decommission POPs":"Dismetti POP", +"Pick the POPs to shut down. Everything in them goes: routers, ports, caches, exchange ports and every link that touches them.":"Scegli i POP da chiudere. Se ne va tutto: router, porte, cache, porte agli exchange e ogni link che li tocca.", +"Links removed":"Link rimossi", +"Eyeballs you stop serving":"Eyeball che smetti di servire", +"{n} customer let go":"{n} cliente lasciato andare", +"{n} customers let go":"{n} clienti lasciati andare", +"Keep at least one POP.":"Tieni almeno un POP.", +"Decommission {n} POP · pay {fee}":"Dismetti {n} POP · paga {fee}", +"Decommission {n} POPs · pay {fee}":"Dismetti {n} POP · paga {fee}", +"Pick a POP":"Scegli un POP", +"Keep them":"Tienili", +"{n} POP decommissioned.
{fee} in early-termination penalties to {m} customers.":"{n} POP dismesso.
{fee} di penali di recesso anticipato a {m} clienti.", +"{n} POPs decommissioned.
{fee} in early-termination penalties to {m} customers.":"{n} POP dismessi.
{fee} di penali di recesso anticipato a {m} clienti.", +"Other links between these cities:":"Altri link tra queste città:", +"up":"attivi", }; diff --git a/site/index.html b/site/index.html index f58714c..7318376 100644 --- a/site/index.html +++ b/site/index.html @@ -1257,7 +1257,7 @@ function beginGame(nm,city,o={}){newGame(nm,city);S.mode=o.mode||'normal'; toast(S.scn?`${esc(S.scn.name)}
${esc(o.scn.goal||tr('Serve as much traffic as you can in one year.'))} ${tr('You have {n} days.',{n:S.scn.days})}`:S.mode==='sandbox'?tr('Sandbox mode
A billion dollars, every unlock, and nothing ever breaks. Build the internet you always wanted.'):tr('Welcome, {name}!
The RIPE NCC assigned you AS{asn}. Your first router is humming in {city}.',{name:esc(nm),asn:S.asn,city:CITY[city].name}),'goal'); renderAll();save();if(!S.scn&&S.mode!=='sandbox')tutorialStart();} /* ---------- conference season ---------- */ -const CONFS=[{n:'NANOG',c:'chi',m:1},{n:'APRICOT',c:'sin',m:1},{n:'Peering Days',c:'waw',m:2},{n:'UKNOF',c:'lon',m:3},{n:'MENOG',c:'dxb',m:3},{n:'NZNOG',c:'akl',m:3},{n:'RIPE',c:'ams',m:4},{n:'NANOG',c:'sea',m:5},{n:'IX Forum',c:'tok',m:6},{n:'AfPIF',c:'nbo',m:7},{n:'AusNOG',c:'syd',m:8},{n:'LACNOG',c:'sao',m:9},{n:'NANOG',c:'ash',m:9},{n:'DENOG',c:'fra',m:10},{n:'RIPE',c:'ber',m:10},{n:'PTT Forum',c:'sao',m:11}]; +const CONFS=[{n:'NANOG',c:'chi',m:1},{n:'APRICOT',c:'sin',m:1},{n:'Peering Days',c:'waw',m:2},{n:'UKNOF',c:'lon',m:3},{n:'MENOG',c:'dxb',m:3},{n:'NZNOG',c:'akl',m:3},{n:'RIPE',c:'ams',m:4},{n:'NANOG',c:'sea',m:5},{n:'IX Forum',c:'tok',m:6},{n:'AfPIF',c:'nbo',m:7},{n:'AusNOG',c:'syd',m:8},{n:'NLNOG Day',c:'ams',m:8},{n:'LACNOG',c:'sao',m:9},{n:'NANOG',c:'ash',m:9},{n:'DENOG',c:'fra',m:10},{n:'RIPE',c:'ber',m:10},{n:'PTT Forum',c:'sao',m:11}]; const CONF_COST=8000,CONF_DAYS=45; const confDay=(cf,y)=>y*360+cf.m*30+9; function confKey(cf,y){return cf.n+'@'+cf.c+'@'+y;} @@ -2357,6 +2357,9 @@ const ACT={ decline:({id})=>{S.offers=S.offers.filter(x=>x.id!==id);after();}, dropBiz:({id})=>{const b0=S.biz.find(x=>x.id===id);if(!b0)return;if(BIZ_T[b0.type].event&&S.day>=b0.start){toast(tr('The event is already running.
The organisers will not let you walk out now.'),'bad');sfx('err');return;}if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.biz=S.biz.filter(b=>b.id!==id);UI.confirm=null;after();}, upLink:({id,tier})=>{tier=+tier;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='wave'||!LT[tier]||tier<=l.tier)return;if(!waveOk(l.a,l.b,tier)){toast(tr('A {wave} wave needs {need} routers at both ends.',{wave:LT[tier].n,need:esc(waveNeed(tier))}),'bad');sfx('err');return;}const nm=Math.round(waveMo(l.km,l.sub,tier)*(l.mult||1));if(!spend(nm))return;l.mo=nm;l.tier=tier;after();}, + decomOpen:({city})=>{UI.decom=new Set(city&&S.pops[city]?[city]:[]);decomModal();}, + decomToggle:({city})=>{if(!S.pops[city])return;UI.decom=UI.decom||new Set();if(UI.decom.has(city))UI.decom.delete(city);else UI.decom.add(city);decomModal();}, + decomGo:()=>{const sel=[...(UI.decom||[])].filter(c=>S.pops[c]);if(!sel.length||sel.length>=Object.keys(S.pops).length)return;closeModal();UI.decom=null;UI.sel=null;decommission(sel);sfx('alert');after();}, rmLink:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.links=S.links.filter(l=>l.id!==id);UI.sel=null;UI.confirm=null;after();}, fixInc:({id})=>{const i=S.inc.find(x=>x.id===id);if(!i||!(i.cost>0))return;if(i.slow&&i.rushed)return;if(!spend(i.cost))return; if(i.slow&&i.until>S.day+1){i.rushed=true;i.cost=0;i.until=S.day+1;const p=S.pops[i.ref];if(p)p.down=Math.min(p.down,S.day+1);toast(tr('Power-cycled.
The router in {city} is booting again. It will be up tomorrow, the {chip} willing.',{city:esc(CITY[i.ref].name),chip:esc(RG[(p&&p.rgen)||0].chip)}),'good');after();return;}clearInc(i);toast(tr('Fixed. {what} resolved early.',{what:incTitle(i.type)}),'good');after();}, @@ -2710,9 +2713,32 @@ function cityPanel(c){ for(const l of ls){const o=l.a===c?l.b:l.a,u=capOf(l)?(R.load[l.id]||0)/capOf(l):0,cut=linkDown(l); h+=`
→ ${CITY[o].name}${l.mult>1?' · '+tr('diverse'):''} ${cut?''+tr('CUT')+'':''}
${capName(l)} · ${l.km.toLocaleString()} km ${l.kind==='vxc'?tr('virtual circuit via {fab}',{fab:esc(FAB[l.prov].name)}):l.kind==='df'?(l.own?tr('own dark fiber'):tr('dark fiber IRU'))+(l.ready>S.day?` · ${tr('ready in {n}d',{n:l.ready-S.day})}`:''):l.sub?tr('subsea'):tr('terrestrial')} · ${tr('{price}/mo',{price:fmt$(l.mo)})}
${btn(tr('Open'),'selLink',{id:l.id},'ghost sm')}
`;} h+=``; + if(Object.keys(S.pops).length>1)h+=`

${tr('Decommission')}

${tr('Shut this POP down: its links, ports and caches go with it, and every customer that depends on it is let go, with an early-termination penalty.')}

${btn(tr('Decommission {city}…',{city:C.name}),'decomOpen',{city:c},'ghost sm')}${btn(tr('Decommission several POPs…'),'decomOpen',{},'ghost sm')}
`; } return h+``; } +/* Decommissioning POPs. Customers that touch a decommissioned city, or ride a removed link, are let go + with an early-termination penalty of three months of their contract. */ +const DECOM_MONTHS=3; +function decomImpact(cities){const set=new Set(cities),links=S.links.filter(l=>set.has(l.a)||set.has(l.b)),lids=new Set(links.map(l=>l.id)); + const biz=S.biz.filter(b=>bCities(b).some(c=>set.has(c))||(b.link&&lids.has(b.link))); + const pen=b=>Math.max(2000,Math.round(b.fee?b.fee*0.5:b.bw*b.rate*DECOM_MONTHS)); + return {links,biz,pen,fee:biz.reduce((a,b)=>a+pen(b),0),eye:cities.reduce((a,c)=>a+(R.cityEye[c]||0),0)};} +function decomModal(){const sel=[...(UI.decom||[])],im=decomImpact(sel),all=Object.keys(S.pops),left=all.length-sel.length; + const rows=all.map(c=>``).join(''); + openModal(`

${tr('Decommission POPs')}

+

${tr('Pick the POPs to shut down. Everything in them goes: routers, ports, caches, exchange ports and every link that touches them.')}

${rows} + ${sel.length?`
${tr('Links removed')}${im.links.length}
${tr('Eyeballs you stop serving')}${fmtG(im.eye)}
${trn('{n} customer let go','{n} customers let go',im.biz.length)}${fmt$(im.fee)}
${im.biz.length?`

${im.biz.map(b=>esc(b.name)+' '+fmt$(im.pen(b))).join(' · ')}

`:''}`:''} + ${left<1?`

${tr('Keep at least one POP.')}

`:''} +
${btn(sel.length?trn('Decommission {n} POP · pay {fee}','Decommission {n} POPs · pay {fee}',sel.length,{fee:fmt$(im.fee)}):tr('Pick a POP'),'decomGo',{},'red',!sel.length||left<1)}${btn(tr('Keep them'),'closeModal',{},'ghost')}
`);} +function decommission(cities){const set=new Set(cities),im=decomImpact(cities),lids=new Set(im.links.map(l=>l.id)),bids=new Set(im.biz.map(b=>b.id)); + S.links=S.links.filter(l=>!lids.has(l.id));S.biz=S.biz.filter(b=>!bids.has(b.id));S.offers=S.offers.filter(o=>!bCities(o).some(c=>set.has(c))); + S.transit=S.transit.filter(t=>!set.has(t.city));S.pni=S.pni.filter(x=>!set.has(x.city));S.caches=S.caches.filter(x=>!set.has(x.city));S.nni=(S.nni||[]).filter(x=>!set.has(x.city)); + for(const c of cities){for(const x of ixIdsIn(c)){delete S.ixp[x];delete S.rs[x];if(S.ixn)delete S.ixn[x];if(S.ixSite)delete S.ixSite[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}delete S.myIx[c];if(S.scrubAt===c)S.scrubAt=null;delete S.pops[c];} + const rem=remoteCities();for(const x in S.ixp){const c=ixCity(x);if(!S.pops[c]&&!rem.includes(c)){delete S.ixp[x];delete S.rs[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}} + if(set.has(S.home))S.home=Object.keys(S.pops)[0]; + purgeInc();S.cash-=im.fee;S.stats.decom=(S.stats.decom||0)+cities.length; + toast(trn('{n} POP decommissioned.
{fee} in early-termination penalties to {m} customers.','{n} POPs decommissioned.
{fee} in early-termination penalties to {m} customers.',cities.length,{fee:fmt$(im.fee),m:im.biz.length}),'bad');} const portMo=v=>v?tr('{price}/mo',{price:fmt$(v)}):tr('free'); function ixSection(c){const ids=ixIdsIn(c);if(ids.length<2)return ixBlock(c,false); let h=`

${tr('Internet Exchanges')}

${tr('{n} exchanges compete in {city}. Members overlap, but not completely, and the challengers undercut the incumbent. Small networks often sit on just one of them.',{n:ids.length,city:esc(CITY[c].name)})}

`; @@ -2790,6 +2816,7 @@ function dfPanel(l){ const rg=l.regen|0,rgAdd=REGEN_COST+Math.round((l.ch||[]).reduce((a,c)=>a+optCost(c),0)*REGEN_CH); h+=`

${tr('Line system')}

${esc(sysD.n)}${tr('{n} amplifiers',{n:amps})}
${tr('Regen sites')}${rg?tr('{n} · optical spans of {km} km',{n:rg,km:spanKm(l).toLocaleString()}):tr('none')}

${tr('A regen site turns the light back into bits halfway and sends it on fresh, so optics only have to reach the next site. Each needs a regen card for every lit channel. {price}/mo per site for the hut.',{price:fmt$(REGEN_MO)})}

${rg{price}',{price:fmt$(rgAdd)}),'regen',{id:l.id,d:1},'sm',S.cash

${esc(sysD.blurb)}

${l.sys!=='roadm'?btn(lvl()>=3?tr('Upgrade to ROADMaster 9000 {price}',{price:fmt$(DF_SYS.roadm.cost)}):tr('ROADMaster 9000 level 3'),'upSys',{id:l.id},'sm',lvl()<3||S.cash{price}/mo',{price:fmt$(Math.round(150+(l.ch||[]).length*80))}),'spares',{id:l.id},l.spares?'green sm':'sm')}

${tr('Spare optics and amplifier cards on the shelf turn multi-day hardware failures into one-day swaps.')}

`; + {const sib=pairLinks(l.a,l.b).filter(x=>x!==l&&x.kind!=='vxc');h+=`

${tr('Redundancy')}

${sib.length?tr('Other links between these cities:'):tr('This is the only link between these cities. Add a parallel one, or a path through another city.')}

${sib.map(x=>`
${esc(capName(x))} ${linkDown(x)?''+tr('CUT')+'':''}
${(x.trench||x.id)===(l.trench||l.id)?tr('same trench'):tr('diverse route')}
${btn(tr('Open'),'selLink',{id:x.id},'ghost sm')}
`).join('')}
${btn(tr('Add parallel link'),'addParallel',{id:l.id},'pink sm')}
`;} h+=`${trafficSection(l)}${metricSection(l)}
${btn(UI.confirm===l.id?tr('Really give it up?'):(l.own?tr('Abandon the fiber'):tr('Cancel the IRU')),'rmLink',{id:l.id},'ghost sm')}
`; return h; } @@ -3058,10 +3085,16 @@ function animOn(){const m=UI.anim||'auto';if(m==='on')return true;if(m==='off')r function applyAnim(){const r=document.documentElement;r.classList.toggle('no-anim',UI.anim==='off');r.classList.toggle('anim-force',UI.anim==='on');if(!animOn())FLOATS.length=0;} const toS=(wx,wy,k=0)=>[(wx+k*W-cam.x)*cam.z+CW/2,(wy-cam.y)*cam.z+CH/2]; const iconScale=()=>clamp(Math.sqrt(cam.z),0.7,1.35); +/* Level of detail (#37): zoomed out the map turns into a network map, with dots for cities, small + router pills for your POPs and thinner links. Phones switch a little earlier, the screen is small. */ +const lodFar=()=>cam.z<(innerWidth<=760?0.95:0.72); function rr(x,y,w,h,r){ctx.beginPath();ctx.moveTo(x+r,y);ctx.arcTo(x+w,y,x+w,y+h,r);ctx.arcTo(x+w,y+h,x,y+h,r);ctx.arcTo(x,y+h,x,y,r);ctx.arcTo(x,y,x+w,y,r);ctx.closePath();} // Enough world copies to cover any screen width at any zoom (the map wraps horizontally). function visibleKs(){const ks=[];for(let k=-5;k<=5;k++){const a=toS(0,0,k)[0],b=toS(W,0,k)[0];if(b>-200&&ax.tier===t),tot=grp.reduce((a,x)=>a+LT[x.tier].g,0);return (same?`${grp.length}×${LT[t].n}`:`${grp.length} × ${fmtCap(tot)}`)+(up.lengthp.slice());const same=pairLinks(l.a,l.b).filter(x=>x.cable===l.cable).indexOf(l);if(same>0)for(let j=1;jday,cut=!bld&&linkDown(l)&&!(df&&!(l.ch||[]).length),dark=df&&!bld&&!(l.ch||[]).length,vx=l.kind==='vxc'; - const sel=UI.sel&&UI.sel.type==='link'&&UI.sel.id===l.id; - const w=(vx?2.2:(2.5+tierW(l)*1.8))*sc; + for(const grp of linkGroups()){const l=grp[0],many=grp.length>1,up=many?grp.filter(x=>!linkDown(x)):null; + const gm=linkGeom(l),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'; + const sel=UI.sel&&UI.sel.type==='link'&&grp.some(x=>x.id===UI.sel.id); + const far=lodFar(),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); for(const k of ks){ const sp=gm.pts.map(p=>toS(p[0],p[1],k));let mn=Infinity,mx=-Infinity;for(const q of sp){if(q[0]mx)mx=q[0];} if(mx<-40||mn>CW+40)continue; @@ -3128,13 +3161,13 @@ function draw(now){ ctx.strokeStyle=bld?'#C9B27C':dark?'#5D6788':cut?'#FF4D5E':vx?FAB[l.prov].col:l.sub?(u>0.001?utilCol(u):'#7FD8EE'):utilCol(u);ctx.lineWidth=w;ctx.stroke();ctx.setLineDash([]); if(df&&!bld&&!dark){ctx.strokeStyle='rgba(255,255,255,.75)';ctx.lineWidth=Math.max(1,w*0.25);ctx.setLineDash([1,6]);path();ctx.stroke();ctx.setLineDash([]);} const at=t=>polyAt(sp,gm.cum,t); - if(!cut&&load>0.01){const n=clamp(Math.round(2+u*10),2,12),len=gm.len*z,spd=90; - ctx.fillStyle='#fff';ctx.strokeStyle='#1E2640';ctx.lineWidth=1.5; - const rr2=Math.max(2.2,w*.42),base=now/1000*spd/Math.max(len,40);ctx.beginPath();for(let i=0;i0.01){const n=clamp(Math.round(2+u*10),2,12)>>(far?1:0)||1,len=gm.len*z,spd=90; + ctx.fillStyle='#fff';ctx.strokeStyle='#1E2640';ctx.lineWidth=far?1:1.5; + 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;i0.9||sel){const t=capName(l);ctx.font='800 11px "Baloo 2", sans-serif';const 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);} + if(bld){if(far){ctx.fillStyle='#FF8A3D';ctx.strokeStyle='#1E2640';ctx.lineWidth=1.5;ctx.beginPath();ctx.arc(mxx,my,4,0,7);ctx.fill();ctx.stroke();}else drawCone(mxx,my,now);} + else if(cut&&!vx){if(far){ctx.fillStyle='#FF4D5E';ctx.strokeStyle='#1E2640';ctx.lineWidth=1.5;ctx.beginPath();ctx.arc(mxx,my,5,0,7);ctx.fill();ctx.stroke();ctx.fillStyle='#fff';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('!',mxx,my+0.5);}else drawBackhoe(mxx,my,now,l.sub);} + else if(z>0.9||sel){const t=many?groupLabel(grp,up):capName(l);ctx.font='800 11px "Baloo 2", sans-serif';const 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);} } } // drag preview @@ -3156,9 +3189,11 @@ function draw(now){ const vis=[];for(const C of CITIES)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=[],hit=(r)=>rects.some(q=>r.x1&&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; 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);break;}} if(ly===null&&prio(v)<2){ly=below;rects.push({x:v.sx-tw/2,y:below-10,w:tw,h:21});} v.ly=ly;} @@ -3202,7 +3237,26 @@ function drawBackhoe(x,y,now,sub){ } const LBLW={}; try{document.fonts&&document.fonts.ready.then(()=>{for(const k in LBLW)delete LBLW[k];});}catch(e){} +function drawCityFar(C,sx,sy,sc,now,lyOverride){ + 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); + ctx.save();ctx.translate(sx,sy);ctx.strokeStyle='#1E2640'; + if(sel){ctx.strokeStyle='#FF4F9A';ctx.lineWidth=2.5;ctx.setLineDash([4,4]);ctx.lineDashOffset=-now/40;ctx.beginPath();ctx.arc(0,0,p?14:9,0,7);ctx.stroke();ctx.setLineDash([]);ctx.strokeStyle='#1E2640';} + if(p){ + if(!down&&R.cityDem[C.id]>0&&sfOf(R,C.id)<0.9){ctx.fillStyle=`rgba(255,77,94,${.35+.25*Math.sin(now/200)})`;ctx.beginPath();ctx.arc(0,0,12,0,7);ctx.fill();} + const col=down?'#8A91A8':'#FF4F9A';ctx.lineWidth=1.8; + if(p.site2){ctx.setLineDash([2,2]);ctx.beginPath();ctx.moveTo(0,0);ctx.lineTo(9,6);ctx.stroke();ctx.setLineDash([]);ctx.fillStyle=col;rr(5,3,9,7,3);ctx.fill();ctx.stroke();} + if((p.routers||1)>=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();} + if(S.offers.some(o=>bCities(o).includes(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(S.inc.some(i=>i.ref===C.id&&i.type!=='leak')){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(); + if(lyOverride!==null&&(p||sel||hov)){ctx.font=`800 ${p?12:11}px "Baloo 2", sans-serif`;const t=C.name,tw=ctx.measureText(t).width+12,ly=lyOverride==null?sy+15: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){ + if(lodFar())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); const k=sc*(hov?1.15:1); @@ -3212,12 +3266,15 @@ function drawCity(C,sx,sy,sc,now,lyOverride){ 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=12+Math.sqrt(C.P)*0.75; - const bl=[[-15,h*.65,'#FFFFFF'],[-5,h,'#FFE7A1'],[5,h*.5,'#BDE8FF']]; + const h=p?18:12+Math.sqrt(C.P)*0.75; ctx.strokeStyle='#1E2640';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){const bl=[[-15,h*.65,'#FFFFFF'],[-5,h,'#FFE7A1'],[5,h*.5,'#BDE8FF']]; + 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){ + // Second building: a small router B on the metro ring, so dual-site POPs stand out. + if(p.site2){const dB=siteDown(C.id,'b'),cut=p.ringcut>S.day;ctx.save();ctx.lineWidth=2.2;ctx.setLineDash(cut?[3,4]:[]);ctx.strokeStyle=cut?'#FF4D5E':'#1E2640';ctx.beginPath();ctx.moveTo(10,6);ctx.quadraticCurveTo(22,14,26,7);ctx.stroke();ctx.setLineDash([]);ctx.strokeStyle='#1E2640'; + ctx.fillStyle=dB?'#8A91A8':'#FF4F9A';rr(20,-1,18,12,4);ctx.fill();ctx.stroke();ctx.fillStyle='#fff';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('B',29,5.5);ctx.restore();} ctx.translate(0,2); ctx.lineWidth=2.4;ctx.beginPath();ctx.moveTo(-10,-6);ctx.lineTo(-13,-17);ctx.moveTo(10,-6);ctx.lineTo(13,-17);ctx.stroke(); ctx.fillStyle=down?'#FF4D5E':'#FFD23F';ctx.beginPath();ctx.arc(-13,-18,2.6,0,7);ctx.arc(13,-18,2.6,0,7);ctx.fill();ctx.stroke(); @@ -3250,7 +3307,7 @@ function drawCity(C,sx,sy,sc,now,lyOverride){ /* ---------- hit tests & input ---------- */ function hitCity(x,y,r=28){let best=null,bd=r*iconScale();const KS=visibleKs();for(const C of CITIES)for(const k of KS){const [sx,sy]=toS(C.x,C.y,k);const d=Math.hypot(sx-x,sy+4-y);if(d{audioInit();cv.setPointerCapture(e.pointerId);ptrs.set(e.pointerId,{x:e.clientX,y:e.clientY}); diff --git a/tests/issues.test.js b/tests/issues.test.js index 00b4366..eec93ef 100644 --- a/tests/issues.test.js +++ b/tests/issues.test.js @@ -285,3 +285,39 @@ test('an optical control plane meltdown darkens every leased wave in a region, n assert.equal(ev("S.links.filter(l=>l.kind==='wave').some(l=>linkDown(l))"), false, 'escalating brings them back'); assert.deepEqual(errors, []); }); + +test('decommissioning POPs, one or several, removes what is there and charges for the customers', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e8;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'})"); + ev("for(const c of ['ams','par','lon'])ACT.buildPop({city:c});const L=(a,b)=>{UI.via=null;openLinkModal(a,b);ACT.buildLink({tier:1});closeModal();};L('fra','ams');L('fra','par');L('ams','lon');ACT.buyTransit({city:'ams',net:'cog',tier:1});ACT.buyIx({city:'ams',tier:1});ACT.peerAll({city:'ams'});compute()"); + ev("S.biz.push({id:'b1',type:'l2vpn',name:'Tulip Bank',city:'ams',city2:'fra',bw:10,rate:300,reqs:[],mood:100,start:S.day},{id:'b2',type:'l2vpn',name:'Croissant Co',city:'par',city2:'fra',bw:5,rate:200,reqs:[],mood:100,start:S.day})"); + ev("selectCity('ams');ACT.tab({t:'infra'})"); + assert.match(ev("document.getElementById('panelBody').textContent"), /Decommission/); + ev("ACT.decomOpen({city:'ams'})"); + assert.match(ev("document.getElementById('modalCard').textContent"), /Tulip Bank/); + const cash = ev('S.cash'); + ev("ACT.decomToggle({city:'lon'});ACT.decomGo();compute()"); + assert.equal(ev("!!S.pops.ams||!!S.pops.lon"), false, 'both gone'); + assert.equal(ev("S.links.some(l=>[l.a,l.b].some(c=>c==='ams'||c==='lon'))"), false); + assert.equal(ev("S.transit.length+Object.keys(S.ixp).length"), 0, 'ports and exchange go with them'); + assert.equal(ev("S.biz.map(b=>b.id).join()"), 'b2', 'only the Amsterdam customer is let go'); + assert.equal(cash - ev('S.cash'), 10 * 300 * 3, 'three months of the contract'); + // never the last one + ev("ACT.decomOpen({});for(const c of Object.keys(S.pops))ACT.decomToggle({city:c});ACT.decomGo()"); + assert.ok(ev("Object.keys(S.pops).length") >= 1); + assert.deepEqual(errors, []); +}); + +test('#19 parallel waves draw as one line, dark fiber can add parallel links, NLNOG Day exists', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buildPop({city:'nyc'});ACT.buildPop({city:'lon'})"); + ev("for(let i=0;i<4;i++){UI.via='grace';UI.route='same';openLinkModal('nyc','lon');ACT.buildLink({tier:1});closeModal();}compute()"); + assert.equal(ev("S.links.length"), 4); + assert.equal(ev("linkGroups().length"), 1, 'four waves on one cable are one line'); + assert.match(ev("groupLabel(linkGroups()[0],linkGroups()[0])"), /^4×/); + ev("S.links.push({id:'dfp',a:'fra',b:'lon',kind:'df',km:640,sys:'lite',ch:['zr4'],ready:0,mo:500,day:0,cut:0});ACT.selLink({id:'dfp'})"); + assert.match(ev("document.getElementById('panelBody').textContent"), /Add parallel link/); + assert.ok(ev("CONFS.some(c=>c.n==='NLNOG Day'&&c.c==='ams')")); + ev("cam.z=0.4;draw(0);cam.z=2;draw(0)"); + assert.deepEqual(errors, []); +});