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);