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.
This commit is contained in:
Frederic Jung 2026-10-25 21:49:51 +01:00
parent 6c2d5da5b8
commit 7e3ea0cefe
No known key found for this signature in database
5 changed files with 47 additions and 14 deletions

View file

@ -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, []);
});

View file

@ -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]&&LT[r.maxLT]&&r.pn===PORT[r.maxP].n&&r.lvl>=1&&r.lvl<=LEVELS.length)"), true);