The build standard owns the router model and the line system; one owner per fiber

The routers order reads its model from the build standard (bstd().g, 'keep'
is the old next-model-up rule) and the optical upgrade order its line system
(bstd().sys). The Ops sheet shows "From the build standard: X" with a button
to the sheet. Old saves move a model or line system from an order that was
running into the standard when it has none of its own; a paused order's or
an unhired intern's setting is dropped. opsParam refuses model/sys and points
at bstdSet.

The build standard's order is a generator now: every first job that takes a
fiber dark goes through the optical order's routing test (opsDark, in the
route worker in play), under one shared budget of dark swaps a night (two for
Kevin) and the week-long memory for a failed fiber. A fiber one order worked
on is the other's no more that shift, and decom keeps waves the standard just
upgraded. The plan is checked at every job, since the shift rests between
them: a POP gone or changed by hand meanwhile is skipped. The button still
runs the whole plan at once on the page.
This commit is contained in:
jvanvik 2026-11-07 06:55:01 +01:00
parent 032470f486
commit fbae6fc3ed
22 changed files with 573 additions and 138 deletions

276
tests/bstd-owner.test.js Normal file
View file

@ -0,0 +1,276 @@
// One owner per fiber: the build standard's order (std) and the optical order (optup) take fibers dark with the same
// test (a routing without the fiber, in the route worker in play), share one budget of dark swaps a night, and never both
// work on one fiber in a shift; the decom order leaves a wave the standard just upgraded. Change Freeze, no failures.
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
const { lit } = require('../scripts/lib/js-literal');
// Frankfurt (broadband, 100G Cogentle transit), Amsterdam and Paris with broadband, everyone on four Chonk 800s, level 7.
const BASE = "Date.now=()=>1.7e12;ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=7;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');" +
"ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});for(const c of ['ams','par','lon'])ACT.buildPop({city:c});" +
"for(const c of ['fra','ams','par','lon']){S.pops[c].rgen=RG.findIndex(r=>r.n==='Chonk 800');S.pops[c].routers=4;}ACT.launchBB({city:'ams'});ACT.launchBB({city:'par'});compute()";
function game(t, extra = '', opts = {}) {
const h = load(opts);
t.after(() => h.dom.window.close());
h.ev(BASE);
if (extra) h.ev(extra);
return h;
}
const hire = (ev, id) => ev(`ACT.opsHire({id:'${id}'});S.ops.floor=0;S.ops.cap={std:0,optup:0};S.ops.on.std=true;closeModal()`);
const std = (ev, d) => ev(`S.popStd=bstdPut({...bstd(),...${lit(d)}})`);
// A leased dark fiber, built and lit with these optics; a wave.
const fiber = (ev, a, b, ch, sys = 'lite') => ev(`(()=>{const id=uid();S.links.push({id,a:'${a}',b:'${b}',kind:'df',own:false,sys:'${sys}',ch:${lit(ch)},km:Math.round(kmBetween('${a}','${b}')),sub:false,cable:null,mo:1000,trench:id,cut:0,day:S.day,ready:S.day,spares:false});return id;})()`);
const wave = (ev, a, b, tier) => ev(`(()=>{const id=uid();S.links.push({id,a:'${a}',b:'${b}',kind:'wave',tier:${tier},km:Math.round(kmBetween('${a}','${b}')),cut:0,mo:1,trench:id,day:S.day});return id;})()`);
const L = (ev, id) => JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(id)})||null)`));
const said = ev => JSON.parse(ev('JSON.stringify((S.ops.log[0]&&S.ops.log[0].d===S.day?S.ops.log[0].r:[]).map(x=>[x[0],x[1]]))'));
// Count the fiber tests that route (opsDarkTrial()), on the page here: tests never use the worker.
const COUNT = "window.__tr=0;const _t=opsDarkTrial;opsDarkTrial=function(){__tr++;return _t.apply(this,arguments);};";
test('both orders share one budget of dark swaps a night: one for Annie, two for Kevin, whoever does them', t => {
for (const [id, want] of [['annie', 1], ['kevin', 2]]) {
// Nobody on the far ends: the fibers really are quiet, whenever the shift routes again.
const { ev, errors } = game(t, 'S.pops.ams.bb=null;S.pops.par.bb=null');
const ids = ['ams', 'par', 'lon'].map(c => fiber(ev, 'fra', c, ['zr4', 'zr4']));
ev('compute();for(const l of S.links)R.load[l.id]=0');
hire(ev, id);
std(ev, { sys: 'roadm' });
ev('S.ops.on.optup=true;opsDay(S.day)');
assert.equal(ids.filter(x => L(ev, x).sys === 'roadm').length, want, id + ': fibers swapped tonight');
assert.deepEqual(said(ev), [['std', want]], id + ': the build standard went first, the optical order found no room left');
// Alone, the optical order has the same budget (the line system from the standard).
ev('S.ops.on.std=false;S.day+=2;compute();for(const l of S.links)R.load[l.id]=0;opsDay(S.day)');
assert.equal(ids.filter(x => L(ev, x).sys === 'roadm').length, Math.min(3, 2 * want), id);
assert.deepEqual(said(ev), [['optup', Math.min(want, 3 - want)]]);
assert.deepEqual(errors, []);
}
});
test('a fiber the build standard worked on tonight is its own: the optical order takes it the next night', t => {
// A full Rainbow-in-a-Box fiber to Amsterdam, running hot, and a big wave beside it for the day it goes dark.
const { ev, errors } = game(t);
const f = fiber(ev, 'fra', 'ams', Array(16).fill('zr4'));
wave(ev, 'fra', 'ams', 3);
const hot = `compute();R.load[${lit(f)}]=1e5;`;
hire(ev, 'annie');
std(ev, { opt: 'fast' });
ev(`S.ops.on.optup=true;${hot}opsDay(S.day)`);
assert.deepEqual([L(ev, f).sys, [...new Set(L(ev, f).ch)]], ['lite', ['zr8']], 'the standard swapped its optics; its line system stays tonight');
assert.deepEqual(said(ev), [['std', 1]], 'the optical order left it alone');
ev(`S.day++;${hot}opsDay(S.day)`);
assert.equal(L(ev, f).sys, 'roadm', 'the next night, with nothing left for the standard there, the optical order moves it up');
assert.deepEqual(said(ev), [['optup', 1]]);
assert.deepEqual(errors, []);
});
test("the standard's order takes a fiber dark on the optical order's test: a way around, not just a parallel link, and never a little traffic with none", t => {
// Amsterdam's broadband rides Frankfurt–Amsterdam; Paris closes a ring of fibers with room.
const { ev, errors } = game(t);
const a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']), b = fiber(ev, 'ams', 'par', ['zr4', 'zr4']), c = fiber(ev, 'par', 'fra', ['zr4', 'zr4']);
ev(COUNT);
hire(ev, 'annie');
std(ev, { sys: 'roadm' });
// Busy by the plan's own measure, and nothing parallel: the button waits for it, the intern routes and finds the ring.
const busy = `compute();R.load[${lit(a)}]=capOf(S.links.find(l=>l.id===${lit(a)}))*0.9;`;
ev(busy);
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(false).held)')), ['fra|ams'], 'the button: busy, nothing parallel');
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(true).held)')), [], 'the intern: a routing decides');
const served = ev('R.served');
ev('opsDay(S.day)');
assert.equal(ev('__tr'), 1, 'one routing without the fiber');
assert.deepEqual([L(ev, a).sys, L(ev, b).sys, L(ev, c).sys], ['roadm', 'lite', 'lite'], 'the busy one first, one a night');
ev('compute()');
assert.ok(ev('R.served') >= served - 1e-6, 'and every gigabit still gets through, round the ring');
// A little traffic (well under the plan's "quiet") and no way around: the old test let it go dark; this one never.
const g = game(t);
const x = fiber(g.ev, 'fra', 'ams', ['zr4', 'zr4']);
g.ev('compute()');
assert.ok(g.ev(`R.load[${lit(x)}]`) > 1 && !g.ev(`bstdBusy(S.links.find(l=>l.id===${lit(x)}))`), 'Amsterdam\'s broadband, under 10% of the fiber');
hire(g.ev, 'kevin');
std(g.ev, { sys: 'roadm', opt: 'fast' });
g.ev(COUNT + 'opsDay(S.day)');
assert.deepEqual([L(g.ev, x).sys, L(g.ev, x).eqDown], ['lite', undefined], 'Amsterdam is never cut off for a day');
assert.deepEqual(L(g.ev, x).ch, ['zr8', 'zr8'], 'it gets the fastest optics its line system takes');
assert.equal(g.ev('__tr'), 0, 'known without routing');
assert.deepEqual(errors, []);
assert.deepEqual(g.errors, []);
});
test('with two swaps a night, the second fiber is judged on the routing with the first one dark, not on the loads from before', t => {
// The ring again, Kevin on shift. Once Frankfurt–Amsterdam is dark, Amsterdam's traffic rides Amsterdam–Paris, which
// carried nothing before: its "nothing rides it" is asked again after the shift routes, and is no longer true.
const { ev, errors } = game(t);
const a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']), b = fiber(ev, 'ams', 'par', ['zr4', 'zr4']), c = fiber(ev, 'par', 'fra', ['zr4', 'zr4']);
hire(ev, 'kevin');
std(ev, { sys: 'roadm' });
ev(`compute();R.load[${lit(a)}]=capOf(S.links.find(l=>l.id===${lit(a)}))*0.9;`);
assert.equal(ev(`R.load[${lit(b)}]||0`), 0, 'Amsterdam–Paris is idle today');
const served = ev('R.served');
ev('opsDay(S.day)');
assert.deepEqual([L(ev, a).sys, L(ev, b).sys, L(ev, c).sys], ['roadm', 'lite', 'lite'], 'Amsterdam keeps one way in');
ev('compute()');
assert.ok(ev('R.served') >= served - 1e-6, 'and every gigabit still gets through');
assert.deepEqual(errors, []);
});
test('two busy fibers side by side: one goes dark tonight, its twin carries it, and the twin goes the next night', t => {
// Amsterdam's broadband split over two Frankfurt–Amsterdam fibers, a few gigabits each: busy, though under the
// button's "quiet". Kevin has room for two swaps, but the twin waits rather than fail the test and wait a week.
const { ev, errors } = game(t);
const a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']), b = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']);
hire(ev, 'kevin');
std(ev, { sys: 'roadm' });
ev('compute()');
assert.ok(ev(`R.load[${lit(a)}]`) > 1 && ev(`R.load[${lit(b)}]`) > 1, 'both carry Amsterdam');
ev('opsDay(S.day)');
assert.deepEqual([[L(ev, a).sys, L(ev, b).sys].sort(), ev('OPTUP_NO.size')], [['lite', 'roadm'], 0], 'one tonight, and no fiber failed');
ev('S.day++;compute();opsDay(S.day)');
assert.deepEqual([L(ev, a).sys, L(ev, b).sys], ['roadm', 'roadm'], 'the twin the next night');
assert.deepEqual(errors, []);
});
test('a fiber that fails the test waits a week, for both orders, and gets the optics its line system takes meanwhile', t => {
// The ring back from Amsterdam is two 10G waves: too thin for Amsterdam's broadband.
const { ev, errors } = game(t);
const a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']);
wave(ev, 'ams', 'par', 0); wave(ev, 'par', 'fra', 0);
ev('compute()');
assert.ok(ev(`R.load[${lit(a)}]`) > 10, 'more than the ring carries');
ev(COUNT);
hire(ev, 'annie');
std(ev, { sys: 'roadm', opt: 'fast' });
ev('S.ops.on.optup=true;opsDay(S.day)');
assert.equal(ev('__tr'), 1, 'tested once');
assert.deepEqual([L(ev, a).sys, L(ev, a).ch], ['lite', ['zr4', 'zr4']], 'no swap, and no optics for a line system it did not get');
assert.equal(ev(`OPTUP_NO.get(${lit(a)})`), ev('S.day+OPTUP_WAIT'));
for (let d = 1; d < 7; d++) ev('S.day++;compute();opsDay(S.day)');
assert.equal(ev('__tr'), 1, 'not tested again that week, by either order');
assert.deepEqual([L(ev, a).sys, L(ev, a).ch], ['lite', ['zr8', 'zr8']], 'the fastest optics the old line system takes');
assert.deepEqual(errors, []);
});
test('an express riding the fiber goes dark with it in the test: its traffic has to get around too', t => {
// Frankfurt–Brussels–Paris as an express over two bare ROADM fibers; Paris reaches its transit over it.
const { ev, errors } = game(t, "ACT.buildPop({city:'bru'});S.pops.bru.rgen=S.pops.fra.rgen;S.lvl=8;" +
"window.df=(a,b)=>{const id=uid();S.links.push({id,a,b,kind:'df',own:true,sys:'roadm',ch:[],km:kmBetween(a,b),sub:false,cable:null,mo:100,trench:id,cut:0,day:S.day,ready:S.day,spares:false,pairs:1});return id;};" +
"window.s1=df('fra','bru');window.s2=df('bru','par');compute();ACT.xpBuild({a:'fra',b:'par',via:s1+','+s2,o:'zr4'});window.x=S.links.find(l=>l.kind==='xp').id;compute()");
const [s1, s2, x] = ['s1', 's2', 'x'].map(k => ev(k));
assert.ok(ev('R.load[x]') > 1 && !ev('(R.load[s1]||0)+(R.load[s2]||0)'), 'the express carries Paris; the fibers carry nothing of their own');
ev(COUNT + "window.__xd=[];const _c=compute;compute=function(){if(S.links.find(l=>l.id===s1).eqDown>S.day||S.links.find(l=>l.id===s2).eqDown>S.day)__xd.push(xpDown(S.links.find(l=>l.id===x)));return _c.apply(this,arguments);}");
hire(ev, 'annie');
std(ev, { sys: 'cl' });
const sys = () => [L(ev, s1).sys, L(ev, s2).sys];
// No way around either fiber: known without routing.
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(true).held)')).sort(), ['bru|par', 'fra|bru']);
ev('opsDay(S.day)');
assert.deepEqual([sys(), ev('__tr')], [['roadm', 'roadm'], 0]);
// A wave beside the first fiber: it has a way around now, but Paris has none without the express.
wave(ev, 'fra', 'bru', 1);
ev('S.day++;compute();opsDay(S.day)');
assert.equal(ev('__tr'), 1, 'one routing without the fiber');
assert.deepEqual(JSON.parse(ev('JSON.stringify(__xd)')), [true], 'the express was dark in it');
assert.deepEqual(sys(), ['roadm', 'roadm'], 'Paris would be cut off: no swap');
// A wave to Paris carries it round: the swap goes ahead, with the express dark for the day.
wave(ev, 'fra', 'par', 3);
ev('OPTUP_NO.clear();S.day++;compute();opsDay(S.day)');
assert.deepEqual(sys().sort(), ['cl', 'roadm'], 'one of them, one a night');
assert.equal(ev('xpDown(S.links.find(l=>l.id===x))'), true);
ev('compute()');
assert.ok(ev('R.load[x]||0') === 0 && ev('R.served') > 0);
assert.deepEqual(errors, []);
});
test('the decom order never hands back a wave the build standard upgraded that same shift', t => {
const { ev, errors } = game(t);
// A 800G wave and two 100G waves between Frankfurt and Amsterdam, in three trenches.
const big = wave(ev, 'fra', 'ams', 3), w1 = wave(ev, 'fra', 'ams', 1), w2 = wave(ev, 'fra', 'ams', 1);
hire(ev, 'annie');
ev("S.ops.on.decom=true;S.ops.p.decom={keep:false}");
std(ev, { wv: 2 });
// The plan sees a pair that needs all three once the small ones are 400G; the routing after the shift's jobs, which
// decom reads, sees almost nothing on them.
ev(`compute();R.load[${lit(big)}]=700;R.load[${lit(w1)}]=150;R.load[${lit(w2)}]=150`);
assert.equal(ev('bstdQuote(true).n'), 2, 'both small waves go up');
ev('opsDay(S.day)');
const tiers = () => JSON.parse(ev("JSON.stringify(S.links.filter(l=>l.kind==='wave').map(l=>l.tier))"));
assert.deepEqual(tiers(), [3, 2, 2], 'both upgraded, both kept today');
assert.deepEqual(said(ev), [['std', 2]]);
// Tomorrow they are the decom order's to judge again.
ev('S.day++;compute();opsDay(S.day)');
assert.deepEqual(tiers(), [3]);
assert.deepEqual(said(ev), [['decom', 2]]);
assert.deepEqual(errors, []);
});
// In play the test is routed in the route worker. jsdom has no Worker: a second page plays it (rwServe() there), as in
// tests/day-steps.test.js. The day is the day dayTick() plays, and the page itself never routes.
test("in play, the standard's fiber test is routed by the route worker, and the day is the day dayTick() plays", t => {
// The ring of fibers, Amsterdam's and Paris's broadband on it.
const RING = "for(const [a,b] of [['fra','ams'],['ams','par'],['par','fra']]){const id=uid();S.links.push({id,a,b,kind:'df',own:false,sys:'lite',ch:['zr4','zr4'],km:Math.round(kmBetween(a,b)),sub:false,cable:null,mo:1000,trench:id,cut:0,day:S.day,ready:S.day,spares:false});}compute();" +
"ACT.opsHire({id:'annie'});S.ops.floor=0;S.ops.cap={};S.ops.on.std=true;closeModal();S.popStd=bstdPut({...bstd(),sys:'roadm'});__reseed(4242);";
const open = seed => { const h = load({ seed }); t.after(() => h.dom.window.close()); h.dom.window.structuredClone = globalThis.structuredClone; return h; };
const ref = open(777), page = open(777), wk = open(1);
for (const h of [ref, page]) { h.ev(BASE); h.ev(RING); }
page.ev('window.__q=[];window.__later=[];RW.budget=0;RW.later=f=>__later.push(f);rwOn=()=>!RW.dead;rwStart=()=>RW.w||(RW.w={postMessage:m=>__q.push(structuredClone(m)),terminate(){__q.length=0;}});');
page.ev('window.__pc=0;const _c=compute;compute=function(){__pc++;return _c.apply(this,arguments);};');
wk.ev('window.__out=null;window.postMessage=(m,tr)=>{__out=structuredClone(m,{transfer:tr});};');
let trials = 0;
const pump = () => { for (;;) {
if (page.ev('__later.length')) { page.ev('__later.shift()()'); continue; }
if (!page.ev('__q.length')) break;
if (page.ev('!!(__q[0].trial&&__q[0].trial.dark)')) trials++;
wk.dom.window.__m = page.ev('__q.shift()'); wk.ev('rwServe(__m)'); page.dom.window.__a = wk.ev('__out'); page.ev('rwDone(__a)'); } };
ref.ev('dayTick()');
page.ev('rwDay()'); pump();
assert.equal(trials, 1, 'the fiber test went to the worker');
assert.equal(page.ev('__pc'), 0, 'no routing on the page');
assert.equal(page.ev("S.links.filter(l=>l.sys==='roadm').length"), 1, 'and it passed: the rest of the ring carries its traffic');
const STATE = 'JSON.stringify({S,served:R.served,load:R.load})';
assert.equal(page.ev(STATE), ref.ev(STATE), 'the same day as dayTick()');
assert.deepEqual([...ref.errors, ...page.errors, ...wk.errors], []);
});
// In play the shift rests between the standard's jobs (DAY_REST, rwRest()), and the player can tap meanwhile: every job
// is checked again against the game as it is then, not as the plan found it at the start of the shift.
test('the player acts while the shift rests: nothing past the standard, nothing paid twice, nothing claimed, and no snag for a POP gone', t => {
// Every POP on one router. std: the standard; act: what the player does at the first rest after a job of the shift.
const play = (std, act, setup = '') => {
const { ev, errors } = game(t, "for(const c of ['fra','ams','par','lon'])S.pops[c].routers=1;compute()");
hire(ev, 'annie');
ev(`S.popStd=${std};${setup};window.__later=[];RW.budget=0;RW.later=f=>__later.push(f)`);
ev('rwDay()');
let spent = null;
while (ev('__later.length')) {
if (spent === null && ev('S.ops.spent.std>0')) { spent = ev('S.ops.spent.std'); ev(act); }
ev('__later.shift()()');
}
assert.ok(spent > 0, 'the shift rested after a job');
return { ev, errors, spent };
};
const routers = ev => JSON.parse(ev('JSON.stringify(Object.fromEntries(Object.entries(S.pops).map(([c,p])=>[c,p.routers])))'));
// The button brings every POP up to the standard while the shift rests after its first job.
let { ev, errors, spent } = play('{rt:3}', 'ACT.bstdApply()');
assert.deepEqual(routers(ev), { fra: 3, ams: 3, par: 3, lon: 3 }, 'three routers each, as the standard says');
assert.equal(ev('S.ops.spent.std'), spent, 'the shift paid for nothing after the button');
assert.deepEqual(said(ev), [['std', 1]]);
assert.deepEqual(errors, []);
// The same with a model: the swaps the button did are not the shift's.
({ ev, errors, spent } = play("{g:RG.findIndex(r=>r.n==='Absolute Unit 1.6T'),rt:2}", 'ACT.bstdApply()', "for(const c in S.pops)S.pops[c].routers=2"));
assert.deepEqual(JSON.parse(ev('JSON.stringify([...new Set(Object.values(S.pops).map(p=>RG[p.rgen].n))])')), ['Absolute Unit 1.6T']);
assert.equal(ev('S.ops.spent.std'), spent);
assert.deepEqual(said(ev), [['std', 1]], 'one swap, not four');
assert.deepEqual(errors, []);
// A PNI the player orders by hand meanwhile, smaller than the plan's: the shift does not order it again as an upgrade.
const net = "NETS.find(n=>n.pops.includes('fra')&&n.pops.includes('ams')&&pniMin(n.id)===0&&peerOk(n.id,'pni','ams').ok&&peerOk(n.id,'pni','fra').ok).id";
({ ev, errors, spent } = play('{rt:2,pni:2}', `pniPlace(pniQuote('ams',${net},0))`,
`S.rules.pnis='instant';window.__net=${net};S.pni.push({id:'P1',city:'fra',net:__net,tier:1,ready:S.day});compute();const _v=pniVal;pniVal=(id,c)=>id===__net&&c==='ams'?{..._v(id,c),worth:true,want:40,tier:1}:_v(id,c)`));
assert.deepEqual(JSON.parse(ev("JSON.stringify(S.pni.filter(x=>x.city==='ams').map(x=>[x.tier,!!x.up]))")), [[0, false]], 'the player\'s own, as ordered');
assert.deepEqual(said(ev), [['std', 4]], 'the routers only');
assert.deepEqual(errors, []);
// Amsterdam decommissioned meanwhile: its jobs are left out, the order runs on, the other POPs get theirs.
({ ev, errors } = play('{rt:3}', "decommission(['ams'])"));
assert.equal(ev('S.ops.on.std'), true, 'the order is still on');
assert.deepEqual(said(ev), [['std', 6]], 'no snag');
assert.deepEqual(routers(ev), { fra: 3, par: 3, lon: 3 });
assert.deepEqual(errors, []);
});

View file

@ -12,7 +12,8 @@ const { lit } = require('../scripts/lib/js-literal');
const BASE = "ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=7;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');S.rules.pnis='instant';" +
"ACT.launchBB({city:'fra'});S.pops.fra.rgen=1;ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buildPop({city:'ams'});compute()";
const AU = "RG.findIndex(r=>r.n==='Absolute Unit 3.2T')";
const hire = ev => ev("ACT.opsHire({id:'kevin'});S.ops.floor=0;S.ops.cap.std=0;S.ops.on.std=true;closeModal()");
// Kevin by default; a fiber test that counts swaps a night hires Annie (Kevin does two: tests/bstd-owner.test.js).
const hire = (ev, id = 'kevin') => ev(`ACT.opsHire({id:'${id}'});S.ops.floor=0;S.ops.cap.std=0;S.ops.on.std=true;closeModal()`);
const shift = ev => ev('opsDay(S.day)');
function game(t, extra = '') {
const h = load();
@ -144,9 +145,9 @@ test('ports: LAG members up to the standard, split over both buildings; PNIs spr
assert.deepEqual(errors, []);
});
test('fiber: the line system only on a quiet fiber or with a parallel link, one a shift; faster optics, old ones on the shelf; bigger waves', t => {
test('fiber: the line system only on a quiet fiber or with a way around, one a shift; faster optics, old ones on the shelf; bigger waves', t => {
const { ev, errors } = game(t);
hire(ev);
hire(ev, 'annie');
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`ACT.buildPop({city:'par'});for(const c of ['fra','ams','par']){S.pops[c].rgen=${chonk};S.pops[c].routers=4;}`);
const a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']), b = fiber(ev, 'fra', 'par', ['zr4']);
@ -189,7 +190,7 @@ test('fiber: the line system only on a quiet fiber or with a parallel link, one
test('quiet fibers take their line system one a shift and buy nothing in between: the intern spends what the quote said', t => {
const { ev, errors } = game(t);
hire(ev);
hire(ev, 'annie');
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`ACT.buildPop({city:'par'});ACT.buildPop({city:'lon'});for(const c of ['fra','ams','par','lon']){S.pops[c].rgen=${chonk};S.pops[c].routers=4;}`);
const ids = ['ams', 'par', 'lon'].map(c => fiber(ev, 'fra', c, ['zr4', 'zr4']));

View file

@ -1,5 +1,6 @@
// The intern upgrades optical transport: line systems up a size (only where the traffic gets around the day-long swap and
// no customer rides the fiber), optics traded for bigger ones on full, hot fiber, or every fiber up to a chosen line system.
// no customer rides the fiber), optics traded for bigger ones on full, hot fiber, or every fiber up to the build standard's
// line system.
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
@ -21,6 +22,8 @@ function game(t, extra) {
return h;
}
const order = (ev, p) => ev(`S.ops.on.optup=true;S.ops.p.optup=${JSON.stringify(p)}`);
// The line system every fiber should have: the build standard's.
const goal = (ev, sys) => ev(`S.popStd=bstdPut({...bstd(),sys:${JSON.stringify(sys)}})`);
// The fiber runs at 90% of what it carries.
const heat = ev => ev("R.load.f=dfCap(S.links[0])*0.9");
const fiber = ev => JSON.parse(ev("JSON.stringify({sys:S.links[0].sys,ch:S.links[0].ch.join(),down:S.links[0].eqDown>S.day})"));
@ -69,10 +72,11 @@ test('no way around, or a customer on the fiber: no swap; bigger optics instead,
assert.deepEqual(errors, []);
});
test('a chosen line system: every fiber below it is moved up, two steps in one night if need be, one fiber a night', t => {
test("the build standard's line system: every fiber below it is moved up, two steps in one night if need be, one fiber a night", t => {
const { ev, errors } = game(t, "S.links[0].ch=['zr4'];" +
"for(const [i,a,b] of [[2,'fra','par'],[3,'par','ams']])S.links.push({id:'g'+i,a,b,kind:'df',own:true,sys:'lite',ch:['zr4'],km:450,trench:'t'+i,ready:0,cut:0,mo:1,pairs:1});compute()");
order(ev, { sys: 'cl', at: 90 });
order(ev, { at: 90 });
goal(ev, 'cl');
const want = ev("sysCost('roadm')+sysCost('cl')");
const sys = () => JSON.parse(ev("JSON.stringify(S.links.filter(l=>l.kind==='df').map(l=>l.sys))"));
const c0 = ev('S.cash');
@ -82,10 +86,12 @@ test('a chosen line system: every fiber below it is moved up, two steps in one n
for (let n = 0; n < 6 && sys().some(s => s !== 'cl'); n++) ev('S.day+=2;compute();opsDay(S.day)');
assert.deepEqual(sys(), ['cl', 'cl', 'cl', 'cl'].slice(0, sys().length), 'the rest on the nights after');
// Nothing is ever moved down.
ev("S.ops.p.optup.sys='roadm';S.day+=2;compute();opsDay(S.day)");
goal(ev, 'roadm');
ev('S.day+=2;compute();opsDay(S.day)');
assert.ok(sys().every(s => s === 'cl'));
// A fiber with no way around is tested once, then left alone for a week: no routing every night for nothing.
ev("S.links=S.links.filter(l=>l.id==='f');S.links[0].sys='lite';S.ops.p.optup.sys='cl';S.day+=2;compute()");
goal(ev, 'cl');
ev("S.links=S.links.filter(l=>l.id==='f');S.links[0].sys='lite';S.day+=2;compute()");
const runs = () => ev('window.__runs||0');
ev("window.__runs=0;const c0=compute;compute=function(){window.__runs++;return c0.apply(this,arguments);};opsDay(S.day)");
assert.equal(sys()[0], 'lite');
@ -98,7 +104,7 @@ test('a chosen line system: every fiber below it is moved up, two steps in one n
assert.deepEqual(errors, []);
});
test('the budget holds, the setting is saved, and the sheet shows it as lists', t => {
test("the budget holds, the settings are saved, and the sheet shows them as lists and the line system as the standard's", t => {
const { ev, dom, errors } = game(t);
order(ev, { at: 80 });
ev('S.ops.cap.optup=10000');
@ -107,16 +113,22 @@ test('the budget holds, the setting is saved, and the sheet shows it as lists',
assert.equal(fiber(ev).sys, 'lite', 'a $10k budget does not buy a line system');
assert.ok(ev("S.ops.log[0].r.some(x=>x[0]==='broke')"));
const back = v => ev(`(()=>{const s=JSON.parse(JSON.stringify(S));s.ops.p.optup=${v};sanitize(s);return JSON.stringify(s.ops.p.optup);})()`);
assert.deepEqual(JSON.parse(back("{sys:'cl',swap:false,at:70}")), { at: 70, sys: 'cl', swap: false });
assert.deepEqual(JSON.parse(back("{sys:'lite',swap:'yes'}")), {});
assert.deepEqual(JSON.parse(back("{swap:false,at:70}")), { at: 70, swap: false });
assert.deepEqual(JSON.parse(back("{at:55,swap:'yes'}")), {});
assert.deepEqual(JSON.parse(back('undefined')), {}, 'an old save without the order');
ev("const s=JSON.parse(JSON.stringify(S));delete s.ops.on.optup;sanitize(s);window.__off=s.ops.on.optup");
assert.equal(ev('__off'), false, 'off in an old save');
dom.window.innerWidth = 360;
ev("ACT.phoneTab({t:'noc'})");
dom.window.document.querySelector('#leftBody [data-act="opsOpen"]').click();
const sel = [...dom.window.document.querySelectorAll('#modalCard select[data-chg="opsParam"]')].find(s => s.dataset.args === '{"k":"optup","p":"sys"}');
assert.deepEqual([...sel.options].map(o => o.textContent), ['Next one, when full', 'ROADMaster 9000', 'ROADMaster 9000 C+L']);
assert.match(dom.window.document.getElementById('modalCard').textContent, /Upgrade optical transport/);
const doc = dom.window.document, card = () => [...doc.querySelectorAll('#modalCard .ops-o.on')].find(o => o.querySelector('.nm').textContent === 'Upgrade optical transport');
assert.deepEqual([...card().querySelectorAll('select[data-chg="opsParam"]')].map(s => JSON.parse(s.dataset.args).p), ['at', 'swap'], 'no line system list of its own');
// The line system is the build standard's: what it says, and the way to the sheet.
assert.match(card().querySelector('.ops-from').textContent, /^Line systemFrom the build standard: Next one, when full/);
goal(ev, 'cl');
ev('ACT.opsOpen()');
assert.equal(card().querySelector('.ops-from b').textContent, 'From the build standard: ROADMaster 9000 C+L');
card().querySelector('.ops-from [data-act="bstdOpen"]').click();
assert.ok(ev('bstdShown()'), 'the button opens the build standard');
assert.deepEqual(errors, []);
});

View file

@ -57,7 +57,7 @@ test('Kevin swaps two line systems a night, the others one', t => {
"S.links=[['f1','fra','ams'],['f2','ams','par'],['f3','par','fra'],['f4','fra','ams']].map(([id,a,b])=>({id,a,b,kind:'df',own:true,sys:'lite',ch:['zr4'],km:450,trench:id,ready:0,cut:0,mo:1,pairs:1}));compute()";
for (const [id, want] of [['kevin', 2], ['annie', 1], ['tracy', 1]]) {
const { ev, errors } = game(t, id, fibers);
ev("S.ops.on.optup=true;S.ops.p.optup={sys:'roadm'};opsDay(S.day)");
ev("S.ops.on.optup=true;S.popStd=bstdPut({...bstd(),sys:'roadm'});opsDay(S.day)");
assert.equal(ev("S.links.filter(l=>l.sys==='roadm').length"), want, id);
assert.deepEqual(errors, []);
}

View file

@ -1,4 +1,5 @@
// The intern standardizes routers on a chosen model within the budget, and every setting in the Ops sheet is a list.
// The intern standardizes routers on the build standard's model within the budget; the Ops sheet says where the model
// comes from and leads to the sheet that sets it, and every other setting there is a list.
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
@ -17,12 +18,15 @@ function game(t) {
return h;
}
const gens = ev => JSON.parse(ev("JSON.stringify(['fra','ams','par'].map(c=>S.pops[c].rgen))"));
// The build standard's router model (the standard's other targets stay as they are).
const model = (ev, g) => ev(`S.popStd=bstdPut({...bstd(),g:${g}})`);
test('a chosen model: every POP on a smaller one is swapped to it, at the price of the swap, never as an outage', t => {
test("the build standard's model: every POP on a smaller one is swapped to it, at the price of the swap, never as an outage", t => {
const { ev, errors } = game(t);
const m = ev(MODEL);
assert.ok(m > 0 && ev(`rgOpen(${m})`), 'the model is unlocked at level 3');
ev(`S.ops.on.routers=true;S.ops.p.routers={at:90,how:'auto',model:${m}};S.ops.cap.routers=0;compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0`);
model(ev, m);
ev("S.ops.on.routers=true;S.ops.p.routers={at:90,how:'auto'};S.ops.cap.routers=0;compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0");
const want = ev(`swapCost('ams',${m})+swapCost('par',${m})`), c0 = ev('S.cash');
ev('opsDay(S.day)');
assert.deepEqual(gens(ev), [1, m, m], 'Amsterdam (a second router) and Paris (no traffic yet) are swapped; Frankfurt has one busy router, so no');
@ -32,18 +36,19 @@ test('a chosen model: every POP on a smaller one is swapped to it, at the price
// Frankfurt gets its turn once it has a second router.
ev('S.pops.fra.routers=2;S.day++;compute();opsDay(S.day)');
assert.deepEqual(gens(ev), [m, m, m]);
// Busy POPs on the chosen model get more routers, never a swap to another one.
// Busy POPs on the standard's model get more routers, never a swap to another one.
ev("S.ops.p.routers.how='swap';S.day++;compute();R.nodeLoad.ams=R.nodeCap.ams*0.95;opsDay(S.day)");
assert.equal(ev('S.pops.ams.rgen'), m, 'no swap away from the chosen model');
assert.equal(ev('S.pops.ams.rgen'), m, 'no swap away from the standard\'s model');
ev("S.ops.p.routers.how='add';S.day++;compute();R.nodeLoad.ams=R.nodeCap.ams*0.95;opsDay(S.day)");
assert.equal(ev('S.pops.ams.routers'), 3, 'a busy POP gets a third router');
assert.deepEqual(errors, []);
});
test('the budget decides how far it gets, the busiest POP first; a smaller model is never a downgrade', t => {
test('the budget decides how far it gets, the busiest POP first; a smaller model is never a downgrade; a locked one means the best unlocked below it', t => {
const { ev, errors } = game(t);
const m = ev(MODEL);
ev(`S.ops.on.routers=true;S.ops.p.routers={at:90,how:'auto',model:${m}};compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0;R.nodeLoad.par=R.nodeCap.par*0.5`);
model(ev, m);
ev("S.ops.on.routers=true;S.ops.p.routers={at:90,how:'auto'};compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0;R.nodeLoad.par=R.nodeCap.par*0.5");
// A budget for one swap: Paris is the busier, so it goes first and Amsterdam waits for next month.
const one = ev(`swapCost('par',${m})`);
ev(`S.ops.cap.routers=OPS_CAPS.filter(c=>c>=${one}).sort((a,b)=>a-b)[0]`);
@ -54,24 +59,70 @@ test('the budget decides how far it gets, the busiest POP first; a smaller model
// Next month, a new budget: Amsterdam.
ev('{const m0=monthIdx(S.day);while(monthIdx(S.day)===m0)S.day++;}compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0;opsDay(S.day)');
assert.deepEqual(gens(ev), [1, m, m]);
// Choosing a smaller model swaps nothing back.
ev("S.ops.cap.routers=0;S.ops.p.routers.model=RG.findIndex(r=>r.n==='Edge Lord 400');S.day++;compute();opsDay(S.day)");
// A smaller model in the standard swaps nothing back.
ev("S.ops.cap.routers=0;S.day++;compute()");
model(ev, "RG.findIndex(r=>r.n==='Edge Lord 400')");
ev('opsDay(S.day)');
assert.deepEqual(gens(ev), [1, m, m]);
// A model above the level: the best main-line model unlocked below it, as the standard means for a new POP.
const big = ev("RG.findIndex(r=>r.n==='Arrrhipster 7800R5')");
assert.equal(ev(`rgOpen(${big})`), false);
model(ev, big);
ev('S.pops.fra.routers=2');
const best = ev(`bstdModel(${big},'fra')`);
ev('S.day++;compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0;opsDay(S.day)');
assert.equal(ev('S.pops.fra.rgen'), best);
assert.ok(ev('S.pops.fra.rgen') > 1 && ev(`RG[S.pops.fra.rgen].cap<RG[${big}].cap`), 'up, but no further than what is unlocked');
assert.deepEqual(errors, []);
});
test('the setting is saved; an unknown model falls back to the next generation', t => {
test('saves: an old model or line system setting moves into the standard when it names none; its own wins; neither stays neither', t => {
const { ev, errors } = game(t);
const back = v => ev(`(()=>{const s=JSON.parse(JSON.stringify(S));s.ops.p.routers=${v};sanitize(s);return JSON.stringify(s.ops.p.routers);})()`);
assert.deepEqual(JSON.parse(back(`{model:${ev(MODEL)}}`)), { model: ev(MODEL) });
assert.deepEqual(JSON.parse(back('{model:999}')), {});
assert.deepEqual(JSON.parse(back("{model:'7'}")), {});
assert.deepEqual(JSON.parse(back('undefined')), {}, 'an old save without it');
assert.equal(ev("opsP('routers','model')"), 'next');
const m = ev(MODEL), el = ev("RG.findIndex(r=>r.n==='Edge Lord 400')");
// An old save: the routers order's model and the optical order's line system, with or without a standard. x: what
// else the save says (by default both orders ran, with Kevin hired).
const ON = 's.ops.on.routers=true;s.ops.on.optup=true';
const back = (p, std, x = ON) => JSON.parse(ev(`(()=>{const s=JSON.parse(JSON.stringify(S));s.ops.p=${p};s.popStd=${std};${x};sanitize(s);return JSON.stringify({p:s.ops.p,std:s.popStd});})()`));
let r = back(`{routers:{model:${m},at:70},optup:{sys:'cl',swap:false}}`, 'null');
assert.deepEqual(r.std, { g: m, rt: 1, sys: 'cl' }, 'no standard: both move into a new one');
assert.deepEqual(r.p.routers, { at: 70 }, 'the old setting is gone, the others stay');
assert.deepEqual(r.p.optup, { swap: false });
// Only what an order that ran used: a paused order's setting, or one with nobody hired, did nothing, and goes.
r = back(`{routers:{model:${m},at:70},optup:{sys:'cl'}}`, 'null', 's.ops.on.routers=false');
assert.deepEqual([r.std, r.p.routers, r.p.optup], [null, { at: 70 }, {}], 'both paused: no standard');
r = back(`{routers:{model:${m}},optup:{sys:'cl'}}`, 'null', 's.ops.on.routers=true');
assert.deepEqual(r.std, { g: m, rt: 1 }, 'the routers order ran, the optical order was paused');
r = back(`{routers:{model:${m}},optup:{sys:'cl'}}`, '{rt:2}', ON + ';s.ops.intern=null');
assert.deepEqual([r.std, r.p.routers, r.p.optup], [{ rt: 2 }, {}, {}], 'nobody hired: the standard stays as it was');
r = back(`{routers:{model:${m}},optup:{sys:'roadm'}}`, `{g:${el},rt:2,sys:'cl',gen:true}`);
assert.deepEqual(r.std, { g: el, rt: 2, gen: true, sys: 'cl' }, 'a standard that names its own keeps them');
assert.deepEqual([r.p.routers, r.p.optup], [{}, {}]);
r = back(`{routers:{model:${m}},optup:{sys:'roadm'}}`, '{rt:3,lag:2}');
assert.deepEqual(r.std, { g: m, rt: 3, lag: 2, sys: 'roadm' }, 'one without them takes them and keeps the rest');
r = back("{routers:{model:'next'},optup:{sys:'next'}}", 'null');
assert.deepEqual([r.std, r.p.routers, r.p.optup], [null, {}, {}], "'next' was no choice: nothing moves");
r = back("{routers:{model:999},optup:{sys:'warp'}}", 'null');
assert.deepEqual([r.std, r.p.routers, r.p.optup], [null, {}, {}], 'junk moves nowhere');
r = back("{routers:{model:'7'}}", `{g:${el}}`);
assert.deepEqual(r.std, { g: el, rt: 1 });
r = back('undefined', 'undefined');
assert.deepEqual([r.std, r.p.routers, r.p.optup], [null, {}, {}], 'an old save with neither');
// The order reads the standard: none set, it is the next generation when busy.
assert.equal(ev('bstd().g'), 'keep');
// A loaded save whose model sat in a paused order, the intern since fired: new POPs cost what they did.
const lon = ev("popCost('lon')");
ev(`S.ops.p.routers={model:${m}};S.ops.on.routers=false;S.ops.intern=null;S=migrate(JSON.parse(JSON.stringify(S)))`);
assert.deepEqual([ev('S.popStd'), ev("newPopCost('lon')"), ev("JSON.stringify(S.ops.p.routers)")], [null, lon, '{}']);
ev("ACT.buildPop({city:'lon'})");
assert.equal(ev('S.pops.lon.rgen||0'), 0, 'and get the basic router');
// A loaded save that had a model in a running order plays with it: the shift swaps to it.
ev(`ACT.opsHire({id:'kevin'});S.ops.floor=0;closeModal();S.ops.p.routers={model:${m}};S.ops.on.routers=true;S=migrate(JSON.parse(JSON.stringify(S)));compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0;opsDay(S.day)`);
assert.equal(ev('S.popStd.g'), m);
assert.equal(ev('S.pops.ams.rgen'), m);
assert.deepEqual(errors, []);
});
test('every setting in the Ops sheet is a list to pick from, on a phone too', t => {
test('the Ops sheet: the model comes from the build standard, one line and a way there; every other setting is a list, on a phone too', t => {
const { ev, dom, errors } = game(t);
dom.window.innerWidth = 360;
const doc = dom.window.document;
@ -88,24 +139,29 @@ test('every setting in the Ops sheet is a list to pick from, on a phone too', t
// Every setting of every order, every budget and the floor.
const n = ev('OPS.reduce((a,d)=>a+Object.keys(d.p).length+(d.cap?1:0),0)+1');
assert.equal(doc.querySelectorAll('#modalCard .ops-p select').length, n);
// The model list: the next generation, then the models you can buy, smallest first.
const model = sel('opsParam', { k: 'routers', p: 'model' });
assert.ok(model, 'the routers order has a model list');
assert.equal(model.options[0].textContent, 'Next generation, when busy');
assert.ok([...model.options].some(o => o.textContent === 'Arrrhipster 7800R'));
assert.ok(![...model.options].some(o => o.textContent === 'Absolute Unit 3.2T'), 'only models unlocked at your level');
pick(model, 'Arrrhipster 7800R');
assert.equal(ev("opsP('routers','model')"), ev(MODEL));
assert.equal(doc.activeElement && doc.activeElement.dataset.args, JSON.stringify({ k: 'routers', p: 'model' }), 'the keyboard stays on the list');
assert.equal(sel('opsParam', { k: 'routers', p: 'model' }), undefined, 'no model list of its own');
// The routers order: where its model comes from, and the button to the sheet that sets it.
const routers = [...doc.querySelectorAll('#modalCard .ops-o.on')].find(o => o.querySelector('.nm').textContent === 'Keep routers ahead');
assert.ok(routers.querySelector('.ops-from'), 'a line in the routers order');
assert.match(routers.querySelector('.ops-from').textContent, /^ModelFrom the build standard: Next generation, when busy/);
routers.querySelector('.ops-from [data-act="bstdOpen"]').click();
assert.ok(ev('bstdShown()'), 'the button opens the build standard');
// Set there, it is what the line says.
pick([...doc.querySelectorAll('#modalCard select[data-chg="bstdSet"]')].find(s => JSON.parse(s.dataset.args).k === 'g'), 'Arrrhipster 7800R');
assert.equal(ev('bstd().g'), ev(MODEL));
ev('ACT.opsOpen()');
const r2 = [...doc.querySelectorAll('#modalCard .ops-o.on')].find(o => o.querySelector('.nm').textContent === 'Keep routers ahead');
assert.match(r2.querySelector('.ops-from b').textContent, /^From the build standard: Arrrhipster 7800R$/);
// The rest are still lists.
pick(sel('opsParam', { k: 'transit', p: 'prov' }), 'Already connected');
assert.equal(ev("opsP('transit','prov')"), 'have');
pick(sel('opsCap', { k: 'routers' }), 'no limit');
assert.equal(ev("opsCap('routers')"), 0);
pick(sel('opsFloor', {}), ev('fmt$(1e6)'));
assert.equal(ev('S.ops.floor'), 1e6);
// A value from nowhere changes nothing; the MCP tools still step without a value.
ev("ACT.opsParam({k:'routers',p:'model',v:'99'});ACT.opsCap({k:'routers',v:'-1'});ACT.opsFloor({v:'x'})");
assert.deepEqual([ev("opsP('routers','model')"), ev("opsCap('routers')"), ev('S.ops.floor')], [ev(MODEL), 0, 1e6]);
// A value from nowhere changes nothing; the retired setting is nothing either; the MCP tools still step without a value.
ev("ACT.opsParam({k:'routers',p:'model',v:'1'});ACT.opsCap({k:'routers',v:'-1'});ACT.opsFloor({v:'x'})");
assert.deepEqual([ev('bstd().g'), ev("opsCap('routers')"), ev('S.ops.floor'), ev("JSON.stringify(S.ops.p.routers||{})")], [ev(MODEL), 0, 1e6, '{}']);
ev("ACT.opsParam({k:'routers',p:'how'})");
assert.equal(ev("opsP('routers','how')"), 'add');
assert.deepEqual(errors, []);

View file

@ -343,6 +343,33 @@ test('a list in a sheet sends its own arguments with the value picked: the build
assert.deepEqual(s.errors(), []);
});
test('the router model and the line system are set in the build standard only: the orders\' old settings point there', () => {
const { s, T, ev } = sandbox({ pops: [] });
act(T, 'opsHire', { id: 'annie' });
ev('closeModal()');
for (const k of ['routers', 'optup']) act(T, 'opsToggle', { k });
ev('closeModal()');
assert.throws(() => act(T, 'opsParam', { k: 'routers', p: 'model', v: '1' }), /routers order takes its router model from the build standard: set it with bstdSet \(k "g"\)/);
assert.throws(() => act(T, 'opsParam', { k: 'optup', p: 'sys' }), /optup order takes its line system from the build standard: set it with bstdSet \(k "sys"\)/);
assert.equal(ev("JSON.stringify([S.ops.p.routers||{},S.ops.p.optup||{},S.popStd])"), '[{},{},null]', 'nothing changed');
act(T, 'opsParam', { k: 'routers', p: 'how' });
assert.equal(ev("opsP('routers','how')"), 'add', 'its other settings still step');
ev('closeModal()');
// The catalog of orders has no such settings; the docs say where they went.
const O = T('catalog', { name: 'OPSK' });
const ps = JSON.stringify(O);
assert.doesNotMatch(ps, /"model"|"sys"/);
assert.match(T('schema', { section: 'commands' }).opsParam.doc, /bstdSet k "g" and k "sys"/);
// Set there, both orders use it; the Ops sheet says so, with the way to the sheet.
act(T, 'bstdSet', { k: 'sys', v: '2' });
assert.equal(ev('bstd().sys'), 'cl');
act(T, 'opsOpen');
const sc = T('screen');
assert.match(sc.text, /From the build standard: ROADMaster 9000 C\+L/);
assert.ok(sc.buttons.some((b) => b.act === 'bstdOpen'), 'a button to the build standard');
assert.deepEqual(s.errors(), []);
});
test('new_game takes your own ASN and the sandbox chaos dial', () => {
const s = createSession(), T = tools(s), ev = (x) => s.game.ev(x);
assert.equal(T('new_game', { city: 'ams', asn: 213337, seed: 2 }).asn, 213337);