From 7e3ea0cefe17c0f7ce8d5e659d18379107805799 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sun, 25 Oct 2026 21:49:51 +0100 Subject: [PATCH 1/2] Router trade-ins, one swap a day, and speed-based requirements (#82) Swaps and removals sell the old chassis for 30% (optics get 40%, #45), and buttons show the net price. A POP accepts one model swap per game day so a double click cannot chain two upgrades. Optic and wave requirements name the port speed, since side-grades qualify too. --- CHANGELOG.md | 1 + site/i18n/it.js | 10 ++++++++-- site/index.html | 22 ++++++++++++---------- tests/issues.test.js | 24 ++++++++++++++++++++++++ tests/levels.test.js | 4 ++-- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d42626..2792768 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Swapping router models now sells the old ones on eBuy for 30% of their price, and removing a router does too (#82). A POP takes one swap a day, so a double click no longer buys two upgrades, and optics and waves now say which port speed they need instead of naming one model. - Hamburg and Munich join the map, with the Moin-IX and the Brezn-IX. Stuttgart and Frankfurt are back where they belong on the map, with Stuttgart between Frankfurt and Zurich instead of halfway to Prague. ## [1.28.0] — 2026-10-25 diff --git a/site/i18n/it.js b/site/i18n/it.js index cf44262..0b4de07 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -1252,7 +1252,6 @@ "Too late: the event has already started.":"Troppo tardi: l’evento è già iniziato.", "Signed!":"Firmato!", "The event is already running.
The organisers will not let you walk out now.":"L’evento è già in corso.
Gli organizzatori non ti lasciano andare via adesso.", -"A {wave} wave needs {need} routers at both ends.":"Una wave {wave} richiede router {need} a entrambi i capi.", "Power-cycled.
The router in {city} is booting again. It will be up tomorrow, the {chip} willing.":"Riavviato.
Il router di {city} sta ripartendo. Sarà su domani, {chip} permettendo.", "Fixed. {what} resolved early.":"Sistemato. {what}: risolto in anticipo.", "A {fab} fabric unlocks at customer level {lv}.":"Un fabric {fab} si sblocca al livello clienti {lv}.", @@ -1321,7 +1320,6 @@ "Too far even at its slowest setting: an optical span here is {span} km and it reaches {max} km. Add a regen site (Line system).":"Troppo lontano anche alla velocità più bassa: qui una tratta ottica è di {span} km e l’ottica arriva a {max} km. Aggiungi un sito di rigenerazione (Sistema di linea).", "{sys} is full ({max} channels, {sold} sold to customers).":"{sys} è pieno ({max} canali, {sold} venduti ai clienti).", "{sys} is full ({max} channels).":"{sys} è pieno ({max} canali).", -"Needs {model} routers at both ends ({city}).":"Servono router {model} a entrambi i capi ({city}).", "Save exported.
{file} is in your downloads. Open it on another device with “Import a save”.":"Salvataggio esportato.
{file} è nei tuoi download. Aprilo su un altro dispositivo con “Importa un salvataggio”.", "That file is not valid JSON.":"Quel file non è un JSON valido.", "That does not look like a Series of Tubes save.":"Non sembra un salvataggio di Series of Tubes.", @@ -2424,4 +2422,12 @@ "A wind-farm service vessel dropped anchor on your {a}–{b} cable. It was there to fix a turbine.":"Una nave di servizio di un parco eolico ha gettato l'ancora sul tuo cavo {a}–{b}. Era lì per riparare una turbina.", "Germany’s port city. Everyone says “Moin”, at any time of day, and the rain comes in sideways off the Elbe.":"La città portuale della Germania. Tutti dicono «Moin» a qualsiasi ora del giorno, e la pioggia arriva di traverso dall'Elba.", "Bavaria’s capital: cars, insurers and a two-week beer festival that sends mobile traffic through the roof every autumn. Racks must be finished before noon, like the sausages.":"La capitale della Baviera: auto, assicurazioni e una festa della birra di due settimane che ogni autunno fa schizzare il traffico mobile alle stelle. I rack vanno finiti prima di mezzogiorno, come le salsicce.", +"{pn} routers":"router da {pn}", +"A {wave} wave needs {need} at both ends.":"Una wave da {wave} richiede {need} a entrambe le estremità.", +"Sold a {model} on eBuy.
{price} back.":"Venduto un {model} su eBuy.
{price} recuperati.", +"The new routers in {city} are still being racked.
One swap a day: try again tomorrow.":"I nuovi router a {city} li stanno ancora montando nel rack.
Un cambio al giorno: riprova domani.", +"Sold the old {model} on eBuy.
{price} back toward the new gear.":"Venduto il vecchio {model} su eBuy.
{price} recuperati per il nuovo hardware.", +"Needs routers with {pn} ports or bigger at both ends ({city}).":"Servono router con porte da {pn} o più grandi a entrambe le estremità ({city}).", +"Prices include {p} back for the old routers on eBuy.":"I prezzi includono {p} recuperati vendendo i vecchi router su eBuy.", +"New routers went in today. The next swap can wait until tomorrow.":"I nuovi router sono stati montati oggi. Il prossimo cambio può aspettare domani.", }; diff --git a/site/index.html b/site/index.html index 22a044c..b326679 100644 --- a/site/index.html +++ b/site/index.html @@ -652,6 +652,8 @@ const SLOW_BOOT=[tr('is oinking through the self-test of every PacketOinker on e function slowBoot(c){const p=S.pops[c];if(!p)return false;const g=p.rgen||0;return hstr(c+'|boot|'+g+'|'+S.asn)%100Math.round(ROUTER_COST+RG[g].cost*0.8); +// Old routers go on eBuy when you swap models or remove one (#82), like spare optics (#45). Chassis age faster. +const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCost=(c,g)=>{const p=S.pops[c],rt=p.routers||1;return Math.max(0,RG[g].cost*rt-tradeIn(p.rgen||0,rt));}; const RMAX=6; // The plain, badge-less model of each class is the default upgrade path; the others are side-grades. const mainRG=k=>RG.findIndex(r=>r.cls===k&&!r.badge); @@ -1901,7 +1903,7 @@ function sanitize(s){ s.priceMul=num(s.priceMul,1);s.nextFail=num(s.nextFail,s.day+45);s.nextEvent=num(s.nextEvent,s.day+40);s.lvl=int(s.lvl,1,LEVELS.length,1);s.neg=int(s.neg,0,1e7,0);s.loanStrikes=int(s.loanStrikes,0,1e3,0); for(const k of Object.keys(s.stats)){const v=s.stats[k];if(k==='by'||k==='f'){if(!v||typeof v!=='object')s.stats[k]={};else for(const j of Object.keys(v))v[j]=num(v[j],0);}else if(typeof v!=='boolean')s.stats[k]=num(v,0);} for(const k of ['survived','incidents','peak'])s.stats[k]=num(s.stats[k],0); - for(const c of Object.keys(s.pops)){const p=s.pops[c];if(!isCity(c)||!p||typeof p!=='object'){delete s.pops[c];continue;}p.routers=int(p.routers,1,RMAX,1);if(p.rgen!==undefined)p.rgen=int(p.rgen,0,RG.length-1,0);p.down=num(p.down,0);if(p.bb&&typeof p.bb==='object')p.bb.d=num(p.bb.d,0);else p.bb=null;} + for(const c of Object.keys(s.pops)){const p=s.pops[c];if(!isCity(c)||!p||typeof p!=='object'){delete s.pops[c];continue;}p.routers=int(p.routers,1,RMAX,1);if(p.rupDay!==undefined)p.rupDay=num(p.rupDay,-1);if(p.rgen!==undefined)p.rgen=int(p.rgen,0,RG.length-1,0);p.down=num(p.down,0);if(p.bb&&typeof p.bb==='object')p.bb.d=num(p.bb.d,0);else p.bb=null;} if(!isCity(s.home))s.home=Object.keys(s.pops)[0]||'fra'; const tier=v=>int(v,0,PORT.length-1,0),lag=v=>int(v,1,LAG_MAX,1),sid=v=>String(v==null?uid():v).slice(0,40); s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&!own(CAB,l.cable))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);if(l.metric&&!own(MET,l.metric))l.metric='normal';return l;}); @@ -2083,10 +2085,10 @@ const onSite=(site,s)=>(site||'a')===s||site==='ab'; function siteCtl(k,id,c,cur){const p=S.pops[c];if(!p||!p.site2)return '';cur=cur||'a';const n=k==='t'?(S.transit.find(x=>x.id===id)||{}).n:k==='p'?(S.pni.find(x=>x.id===id)||{}).n:(S.ixn||{})[id];return `
${tr('Site:')}${['a','b'].map(x=>btn(`${x.toUpperCase()} ${esc(siteName(c,x))}`,'siteSet',{k,id,s:x},cur===x?'pink sm':'ghost sm')).join('')}${btn((n||1)<2?tr('Both adds a LAG member'):tr('Both split the LAG'),'siteSet',{k,id,s:'ab'},cur==='ab'?'pink sm':'ghost sm')}
`;} function portOk(c,i){const p=S.pops[c];return i<=RG[p?(p.rgen||0):0].maxP;} function waveOk(a,b,i){return [a,b].every(c=>i<=RG[S.pops[c]?(S.pops[c].rgen||0):0].maxLT);} -function waveNeed(i){const g=RG.find(r=>r.maxLT>=i);return g?g.n:'?';} +function waveNeed(i){const g=RG.find(r=>r.maxLT>=i);return g?tr('{pn} routers',{pn:g.pn}):'?';} function routerModels(c){const p=S.pops[c],g=p.rgen||0,rt=p.routers||1; return `
${RG.map((M,i)=>{if(i===g)return '';const why=modelFits(c,i),lk=M.lvl>lvl(); - return `
${esc(M.n)} ${M.pn} · ${tr('{n} ports',{n:M.ports})} · ${fmtG(M.cap)} · ${tr('boots in ~{n} min',{n:M.boot})}${M.flaky?' · '+tr('crashes more'):''}
${esc(M.blurb)}
${why?`
${esc(why)}
`:''}
${btn(lk?tr('Level {n}',{n:M.lvl}):tr('Swap {cost} + {mo}/mo',{cost:fmt$(M.cost*rt),mo:fmt$(M.mo*rt)}),'upRouter',{city:c,g:i},'sm',lk||!!why||S.cash`;}).join('')}
`;} + return `
${esc(M.n)} ${M.pn} · ${tr('{n} ports',{n:M.ports})} · ${fmtG(M.cap)} · ${tr('boots in ~{n} min',{n:M.boot})}${M.flaky?' · '+tr('crashes more'):''}
${esc(M.blurb)}
${why?`
${esc(why)}
`:''}
${btn(lk?tr('Level {n}',{n:M.lvl}):tr('Swap {cost} + {mo}/mo',{cost:fmt$(swapCost(c,i)),mo:fmt$(M.mo*rt)}),'upRouter',{city:c,g:i},'sm',lk||!!why||S.cash`;}).join('')}
`;} function portNote(c){const p=S.pops[c];if(!p)return '';const g=p.rgen||0;return RG[g].maxP${tr('Your {model} here tops out at {pn} ports. Bigger ports need a router upgrade (Infra tab).',{model:esc(RG[g].n),pn:RG[g].pn})}

`:'';} function sfOf(r,c){const d=r.cityDem[c]||0;return d<=1e-6?1:clamp(r.citySrv[c]/d,0,1);} @@ -2678,7 +2680,7 @@ const ACT={ floater(CITY[o.city].x,CITY[o.city].y-30,tr('Signed!'),'#16A866');sfx('coin');after();}, 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;{const w=subWaveWhy(tier,l.km,l.sub);if(w){toast(tr('No {wave} waves on this cable.
{why}',{wave:LT[tier].n,why:esc(w)}),'bad');sfx('err');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();}, + 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;{const w=subWaveWhy(tier,l.km,l.sub);if(w){toast(tr('No {wave} waves on this cable.
{why}',{wave:LT[tier].n,why:esc(w)}),'bad');sfx('err');return;}}if(!waveOk(l.a,l.b,tier)){toast(tr('A {wave} wave needs {need} 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();}, @@ -2690,7 +2692,7 @@ const ACT={ S.myIx[city]={name:nm,members:[],next:S.day+4};S.ixp[city]=2;toast(tr('You founded {ix}!
Networks will join over time and pay you for ports. Open members peer with you for free.',{ix:esc(nm)}),'goal');after();}, buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p)return;const {a,b}=p;const km=kmBetween(a,b),sub=isSub(a,b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'),jn=sib.length?routeJoin(a,b):null,same=!!jn,border=cnCity(a)!==cnCity(b),mult=(sib.length&&!(jn&&jn.k===(landTrenches(a,b)[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1); if((cnCity(a)||cnCity(b))&&!cnOk())return; - if(!waveOk(a,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;} + if(!waveOk(a,b,tier)){toast(tr('A {wave} wave needs {need} at both ends.',{wave:LT[tier].n,need:esc(waveNeed(tier))}),'bad');sfx('err');return;} const wr=waveRoute(a,b,mult,border);if(!wr){toast(tr('No cable available for that route right now.'),'bad');sfx('err');return;}{const w=subWaveWhy(tier,wr.km,wr.sub);if(w){toast(tr('No {wave} waves on this cable.
{why}',{wave:LT[tier].n,why:esc(w)}),'bad');sfx('err');return;}}const base=Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm),cost=base+(S.pops[b]?0:popCost(b)); if(!portGate(a,1)||!portGate(b,1))return;if(!spend(cost))return;if(!S.pops[b])S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false}; const id=uid();const l={id,a,b,kind:'wave',border,premium:border&&!!UI.cnPrem&&(a==='hkg'||b==='hkg'),tier,km:wr.km,sub:wr.sub,cable:wr.cab,mo:base,mult:wr.wm,trench:wr.cab?'cab:'+wr.cab:(jn?jn.k:id),cut:0,day:S.day};S.links.push(l);closeModal(); @@ -2745,9 +2747,9 @@ const ACT={ addParallel:({id})=>{const l=S.links.find(x=>x.id===id);if(l)openLinkModal(l.a,l.b);}, addRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)>=RMAX)return;if(!spend(routerCost(p.rgen||0)))return;p.routers=(p.routers||1)+1;floater(CITY[city].x,CITY[city].y-30,tr('Router added'),'#FF4F9A');after();}, models:()=>{UI.models=!UI.models;renderPanel();}, - rmRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)<=1)return;if(portsUsed(city)>portsMax(city,undefined,p.routers-1)){toast(tr('Unplug something first.
{used} ports are in use, and one router fewer only has {max}.',{used:fmtPorts(portsUsed(city)),max:portsMax(city,undefined,p.routers-1)}),'bad');sfx('err');return;}p.routers--;after();}, + rmRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)<=1)return;if(portsUsed(city)>portsMax(city,undefined,p.routers-1)){toast(tr('Unplug something first.
{used} ports are in use, and one router fewer only has {max}.',{used:fmtPorts(portsUsed(city)),max:portsMax(city,undefined,p.routers-1)}),'bad');sfx('err');return;}p.routers--;{const back=tradeIn(p.rgen||0,1);if(back>0){S.cash+=back;toast(tr('Sold a {model} on eBuy.
{price} back.',{model:esc(RG[p.rgen||0].n),price:fmt$(back)}),'good');}}after();}, upRouter:({city,g})=>{const p=S.pops[city];if(!p)return;g=g===undefined?mainRG(RG[p.rgen||0].cls+1):+g;if(!RG[g]||g===(p.rgen||0))return;{const why=modelFits(city,g);if(why){toast(tr("The {model} won't fit.
{why}",{model:esc(RG[g].n),why:esc(why)}),'bad');sfx('err');return;}}if(RG[g].lvl>lvl()){toast(tr('{model} unlocks at customer level {lv}.',{model:esc(RG[g].n),lv:RG[g].lvl}),'bad');sfx('err');return;} - const rt=p.routers||1;if(!spend(RG[g].cost*rt))return;p.rgen=g; + const rt=p.routers||1,old=p.rgen||0;if(p.rupDay===S.day){toast(tr('The new routers in {city} are still being racked.
One swap a day: try again tomorrow.',{city:CITY[city].name}),'bad');sfx('err');return;}const back=tradeIn(old,rt);if(!spend(swapCost(city,g)))return;p.rgen=g;p.rupDay=S.day;if(back>0)toast(tr('Sold the old {model} on eBuy.
{price} back toward the new gear.',{model:esc(RG[old].n),price:fmt$(back)}),'good'); if(rt===1){const sl=slowBoot(city),dd=sl?3:1;p.down=Math.max(p.down||0,S.day+dd);addInc({type:'maint',ref:city,until:S.day+dd,msg:sl?tr('Swapping the only router in {city} for a {model}. The new one {how}. Back in {n} days.',{city:CITY[city].name,model:RG[g].n,how:pick(SLOW_BOOT),n:dd}):tr('Swapping the only router in {city} for a {model}. Maintenance window: back tomorrow.',{city:CITY[city].name,model:RG[g].n}),cost:0});toast(`${tr('Maintenance window in {city}',{city:CITY[city].name})}
${sl?tr('One router, and this one takes forever to boot. Back in {n} days.',{n:dd}):tr('One router means downtime during the swap. Back tomorrow.')}`,'bad');} else toast(tr('Rolling upgrade in {city}
{n} × {model}, swapped one at a time. Zero downtime.',{city:CITY[city].name,n:rt,model:esc(RG[g].n)}),'good'); floater(CITY[city].x,CITY[city].y-30,RG[g].n+'!','#FF4F9A');after();}, @@ -2836,7 +2838,7 @@ function pairBtn(l){if(!l.own||!isRdm(l.sys)||l.ready>S.day)return '';const n=Ma const full=(l.ch||[]).length+soldSlots(l)>=chMax(l),c=pairCost(l);return btn(l.sub?tr('Light fiber pair {n} {price}',{n:n+1,price:fmt$(c)}):tr('Light fiber pair {n} {price} + {mo}/mo',{n:n+1,price:fmt$(c),mo:fmt$(ampCount(l.km)*AMP_MO)}),'addPair',{id:l.id},full?'pink sm':'ghost sm',!full||S.cashlvl())return tr('Unlocks at customer level {n}.',{n:O.lvl});if(O.sys==='roadm'&&!isRdm(l.sys))return tr('Needs a ROADMaster 9000 line system.');if(!optMode(o,l)){const mx=reachOn((O.modes||[[0,O.reach]]).at(-1)[1],l.sub);return tr('Too far even at its slowest setting: an optical span here is {span} km and it reaches {max} km. Add a regen site (Line system).',{span:spanKm(l).toLocaleString(),max:mx.toLocaleString()});} if((l.ch||[]).length+soldSlots(l)>=chMax(l))return soldSlots(l)?tr('{sys} is full ({max} channels, {sold} sold to customers).',{sys:DF_SYS[l.sys].n,max:chMax(l),sold:soldSlots(l)}):tr('{sys} is full ({max} channels).',{sys:DF_SYS[l.sys].n,max:chMax(l)}); - for(const c of [l.a,l.b]){const p=S.pops[c];if(p&&RG[p.rgen||0].clsinnerWidth>760&&innerWidth<=1200; @@ -3092,9 +3094,9 @@ function cityPanel(c){
${tr('Forwarding chip')}${esc(G.chip)}
${tr('Boot time')}${slowBoot(c)?`${tr('~{n} min · a slow one',{n:bootMin(c)})}`:tr('~{n} min',{n:bootMin(c)})}
${slowBoot(c)?`

${tr('This chassis takes forever to boot: crashes last longer, and swapping the only router here takes 3 days. A second router hides it.')}

`:''}
${tr('Forwarding load')}${fmtG(nl)} / ${fmtG(nc)}
${nl>=nc*0.95?`

${tr('Maxed out. Traffic here is being dropped.')}

`:''} -
${N?btn(N.lvl>lvl()?tr('{model} level {lv}',{model:esc(N.n),lv:N.lvl}):tr('Upgrade to {model} {cost} + {mo}/mo',{model:esc(N.n),cost:fmt$(N.cost*rt),mo:fmt$(N.mo*rt)}),'upRouter',{city:c,g:Ni},'pink',N.lvl>lvl()||S.cash{cost} + {mo}/mo',{cost:fmt$(routerCost(g)),mo:fmt$(ROUTER_MO+G.mo)}),'addRouter',{city:c},'',S.cash1?btn(tr('Remove one'),'rmRouter',{city:c},'ghost sm'):''}
+
${N?btn(N.lvl>lvl()?tr('{model} level {lv}',{model:esc(N.n),lv:N.lvl}):tr('Upgrade to {model} {cost} + {mo}/mo',{model:esc(N.n),cost:fmt$(swapCost(c,Ni)),mo:fmt$(N.mo*rt)}),'upRouter',{city:c,g:Ni},'pink',N.lvl>lvl()||S.cash{cost} + {mo}/mo',{cost:fmt$(routerCost(g)),mo:fmt$(ROUTER_MO+G.mo)}),'addRouter',{city:c},'',S.cash1?btn(tr('Remove one'),'rmRouter',{city:c},'ghost sm'):''}
${UI.models?routerModels(c):''} - ${N||UI.models?`

${rt>1?tr('Rolling upgrade: one router at a time, no downtime.'):tr('With one router, the upgrade needs a maintenance window: this POP goes dark for a day.')}

`:''} + ${N||UI.models?`

${(p.rgen||0)>0?tr('Prices include {p} back for the old routers on eBuy.',{p:fmt$(tradeIn(p.rgen||0,rt))})+' ':''}${p.rupDay===S.day?tr('New routers went in today. The next swap can wait until tomorrow.')+' ':''}${rt>1?tr('Rolling upgrade: one router at a time, no downtime.'):tr('With one router, the upgrade needs a maintenance window: this POP goes dark for a day.')}

`:''}

${rt>=2?tr('A crash here only costs one router’s capacity for a few days.'):tr('One router is a single point of failure.')}

${tr('Metro diversity')}

${p.site2?(()=>{const up=s=>[...S.transit.filter(t=>t.city===c&&onSite(t.site,s)).map(t=>tr('{net} transit',{net:NET[t.net].name})+(t.site==='ab'?' '+tr('(split)'):'')),...S.pni.filter(x=>x.city===c&&onSite(x.site,s)).map(x=>'PNI '+NET[x.net].name+(x.site==='ab'?' '+tr('(split)'):'')),...ixIdsIn(c).filter(x=>S.ixp[x]!==undefined&&!S.myIx[x]&&onSite((S.ixSite||{})[x],s)).map(x=>tr('{port} port',{port:ixName(x)})+((S.ixSite||{})[x]==='ab'?' '+tr('(split)'):'')),...S.caches.filter(x=>x.city===c&&(x.site==='b'?'b':'a')===s).map(x=>NET[x.net].cache.name)]; const row=s=>{const dn=siteDown(c,s),u=up(s);return `
${esc(siteName(c,s))}${dn?' DOWN':''}
${u.length?esc(u.join(', ')):tr('Nothing plugged in here yet')}
`;}; diff --git a/tests/issues.test.js b/tests/issues.test.js index 2d4d27b..f390c8d 100644 --- a/tests/issues.test.js +++ b/tests/issues.test.js @@ -991,3 +991,27 @@ test('#63 incidents you can fix with one click sit above hot ports in the NOC', assert.ok(t.indexOf('DDoS scrubbing') > fix, 'status lines come after the incidents'); assert.deepEqual(errors, []); }); + +test('#82 router swaps trade in the old gear, one swap a day, and requirements name the speed', () => { + 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'});S.pops.fra.rgen=1;S.pops.fra.routers=2"); + const c0 = ev('S.cash'), back = ev('tradeIn(1,2)'); + assert.equal(back, Math.round(ev('RG[1].cost') * 2 * 0.3)); + ev("ACT.upRouter({city:'fra',g:2})"); + assert.equal(ev('S.pops.fra.rgen'), 2); + assert.equal(c0 - ev('S.cash'), ev('RG[2].cost') * 2 - back, 'you pay the new routers minus the old ones sold on eBuy'); + // a double click does not chain a second upgrade + ev("ACT.upRouter({city:'fra',g:3})"); + assert.equal(ev('S.pops.fra.rgen'), 2, 'one swap a day'); + ev("S.day++;ACT.upRouter({city:'fra',g:3})"); + assert.equal(ev('S.pops.fra.rgen'), 3); + // removing a router sells it too + const c1 = ev('S.cash'); + ev("ACT.rmRouter({city:'fra'})"); + assert.equal(ev('S.cash') - c1, ev('tradeIn(3,1)')); + // requirements say the speed, not one model + ev("ACT.buildPop({city:'ams'});S.pops.ams.rgen=0;S.links.push({id:'df',a:'fra',b:'ams',kind:'df',km:450,sys:'roadm',ch:[],ready:0,mo:1,day:0,cut:0});compute()"); + assert.match(ev("chWhy(S.links.find(l=>l.id==='df'),'tp16')"), /routers with 800G ports or bigger/); + assert.equal(ev('waveNeed(4)'), '1.6T routers'); + assert.deepEqual(errors, []); +}); diff --git a/tests/levels.test.js b/tests/levels.test.js index 41fdf4d..150efe3 100644 --- a/tests/levels.test.js +++ b/tests/levels.test.js @@ -53,9 +53,9 @@ test('new routers: the 3.2T main line, side-grades, and 3.2T ports only once unl assert.equal(ev('waveShown(6)'), true); ev("S.pops.fra.rgen=3;S.pops.fra.routers=1;ACT.upRouter({city:'fra'})"); assert.equal(ev("RG[S.pops.fra.rgen].n"), 'Absolute Unit 3.2T'); - ev("const g=RG.findIndex(r=>r.lvl===13);ACT.upRouter({city:'fra',g})"); + ev("S.day++;const g=RG.findIndex(r=>r.lvl===13);ACT.upRouter({city:'fra',g})"); assert.equal(ev("RG[S.pops.fra.rgen].n"), 'Absolute Unit 3.2T', 'the Router at the End of the Universe waits for level 13'); - ev("S.lvl=13;ACT.upRouter({city:'fra',g:RG.findIndex(r=>r.lvl===13)})"); + ev("S.lvl=13;S.day++;ACT.upRouter({city:'fra',g:RG.findIndex(r=>r.lvl===13)})"); assert.equal(ev("RG[S.pops.fra.rgen].ports"), 256); // every model's numbers make sense for its class assert.equal(ev("RG.every(r=>PORT[r.maxP]&<[r.maxLT]&&r.pn===PORT[r.maxP].n&&r.lvl>=1&&r.lvl<=LEVELS.length)"), true); From 388b12d9014a5faf96e5ab6fd5e7d39b5657f713 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sun, 25 Oct 2026 21:56:21 +0100 Subject: [PATCH 2/2] Gentler bends for links between nearby cities The curve that dodges other cities wanted 24 map units of clearance and picked the most distant of up to 3.8x curves when nothing cleared, so short links in dense regions looped wide. Clearance now scales with link length, offsets are capped at about a third of it, and a modest curve wins over a giant one when nothing clears. --- CHANGELOG.md | 1 + site/index.html | 11 +++++++---- tests/issues.test.js | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2792768..6c8f16f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Fiber between nearby cities bends gently again instead of looping wide around the neighbourhood, so dense regions like Toronto, Ottawa and Montreal stay readable. - Swapping router models now sells the old ones on eBuy for 30% of their price, and removing a router does too (#82). A POP takes one swap a day, so a double click no longer buys two upgrades, and optics and waves now say which port speed they need instead of naming one model. - Hamburg and Munich join the map, with the Moin-IX and the Brezn-IX. Stuttgart and Frankfurt are back where they belong on the map, with Stuttgart between Frankfurt and Zurich instead of halfway to Prague. ## [1.28.0] — 2026-10-25 diff --git a/site/index.html b/site/index.html index b326679..5f7ab75 100644 --- a/site/index.html +++ b/site/index.html @@ -3792,14 +3792,17 @@ 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(10,Math.min(len*0.13,110)),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); + 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); const mx=(A.x+bx)/2,my=(A.y+by)/2; const obs=CITIES.filter(c=>c.id!==l.a&&c.id!==l.b).map(c=>[mx+wrapDx(mx,c.x),c.y]); const clear=(cx,cy)=>{let m=Infinity;const g={ax:A.x,ay:A.y,bx,by,cx,cy};for(let t=0.08;t<0.93;t+=0.06){const [px,py]=qpt(g,t);for(const [ox,oy] of obs){const d=Math.hypot(px-ox,py-oy);if(dsg*mag*k).concat([1,1.5,2.1,2.9,3.8].map(k=>-sg*Math.max(mag,base)*k)); - let best=null,bc=-1; - for(const off of cand){const cx=mx+nx*off,cy=my+ny*off,c=clear(cx,cy);if(c>=24){best=[cx,cy];break;}if(c>bc){bc=c;best=[cx,cy];}} + // Bend around cities in the way, but gently: short links need less room, no curve bows out more than about a + // third of its length, and when nothing clears, a modest curve beats a giant loop around the neighbourhood. + const need=Math.min(24,Math.max(7,len*0.2)),cap=Math.max(mag,len*0.32),lim=o=>Math.sign(o)*Math.min(Math.abs(o),cap); + const cand=[1,1.5,2.1,2.9,3.8].map(k=>lim(sg*mag*k)).concat([1,1.5,2.1,2.9,3.8].map(k=>lim(-sg*Math.max(mag,base)*k))); + let best=null,bs=-Infinity; + for(const off of cand){const cx=mx+nx*off,cy=my+ny*off,c=clear(cx,cy);if(c>=need){best=[cx,cy];break;}const sc=Math.min(c,need)-Math.abs(off)*0.35;if(sc>bs){bs=sc;best=[cx,cy];}} 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'; diff --git a/tests/issues.test.js b/tests/issues.test.js index f390c8d..bdc84a8 100644 --- a/tests/issues.test.js +++ b/tests/issues.test.js @@ -1015,3 +1015,12 @@ test('#82 router swaps trade in the old gear, one swap a day, and requirements n assert.equal(ev('waveNeed(4)'), '1.6T routers'); assert.deepEqual(errors, []); }); + +test('fiber between nearby cities bends gently instead of looping around the neighbourhood', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e9;for(const g of GOALS)S.done[g.id]=0;for(const x of ['tor','ott','mtl','nyc','ash'])if(!S.pops[x])ACT.buildPop({city:x})"); + ev("const L=(a,b)=>{UI.via=null;UI.lmode='wave';UI.route='diverse';openLinkModal(a,b);ACT.buildLink({tier:1});closeModal();};L('tor','ott');L('ott','mtl');L('tor','nyc');L('tor','mtl');L('mtl','nyc');L('tor','ash');L('ash','nyc');GEO.clear()"); + const worst = ev("Math.max(...S.links.map(l=>{const g=linkGeom(l),A=CITY[l.a],B=CITY[l.b],L=Math.hypot(B.x-A.x,B.y-A.y);return Math.max(...g.pts.map(p=>segDist(p[0],p[1],[A.x,A.y],[B.x,B.y])))/L;}))"); + assert.ok(worst < 0.3, `worst bend is ${worst.toFixed(2)}× its length`); + assert.deepEqual(errors, []); +});