innerWidth>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 `${s.toUpperCase()}${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);