Pay to hurry the permits and factory of your own subsea cable (closes #258)

Before laying starts, seaRush buys 30 days a step (or all of them at once)
at $500k plus $60 a km, with the market's build prices. The floor is the
factory: 60 days plus a day per ~80 km from the order (prepMin, through
leadDays), then the lay ships still need their time at sea, which a second
ship still halves. 6,000 km: from 600 days of prep to 132 for about $13M.
This commit is contained in:
Frederic Jung 2026-11-03 10:35:16 +00:00
parent 4d609d996f
commit 823e4188be
No known key found for this signature in database
13 changed files with 89 additions and 1 deletions

View file

@ -225,7 +225,7 @@ test('a dry run prices every command that has a price, and changes nothing', ()
crews: { id: df }, addCh: { id: df, o: 'zr4' }, addPair: { id: df }, upSys: { id: df }, regen: { id: df, d: 1 }, buySpare: { o: 'zr4' }, sellSpare: { o: 'zr4' },
setChCount: { id: df, o: 'zr4', n: 2 }, repayLoan: { id: 'none' }, buildScrub: { city: 'ams', tier: 1 }, scrubUp: { city: 'fra', tier: 1 },
fixInc: { id: 'none' }, confGo: { key: T('catalog', { name: 'conferences' })[0].key }, confSponsor: { key: T('catalog', { name: 'conferences' })[0].key },
opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df },
opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df }, seaRush: { id: df },
utilityKit: { city: 'fra' }, utilityCaches: { city: 'fra' }, teDeploy: { script: 'spill at 85%' }, upLinkX: {},
};
const missing = quoted.filter((n) => !sample[n] && T('schema', { section: 'commands' })[n].args.some((a) => a.required));

51
tests/sea-rush.test.js Normal file
View file

@ -0,0 +1,51 @@
// #258: money hurries the survey, permits and factory of your own subsea cable, 30 days a step, but never below what the
// factory needs to make the cable (two months plus a day per 80 km); the lay ships still sail after that.
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
const start = "ACT.start({});S.cash=1e9;S.lvl=13;S.day=200;S.nextFail=S.nextEvent=1e8;for(const g of GOALS)S.done[g.id]=0;";
const own = (km, ready) => `S.links=[{id:'own',a:'lag',b:'bde',kind:'df',own:true,sub:true,sys:'roadm',km:${km},ch:[],day:200,ready:${ready},cut:0,mo:1}];`;
test('#258 paying hurries the permits and the factory, 30 days a step, down to what the factory needs', () => {
const { ev, dom, errors } = load();
ev(start + own(6000, 800));
// 6000 km: 60 + 72 days to make it, then 40 days at sea.
assert.equal(ev('prepMin(S.links[0])'), 132);
assert.equal(ev('prepFloor(S.links[0])'), 200 + 132 + 40);
assert.equal(ev('prepSteps(S.links[0])'), 15);
ev("UI.sel={type:'link',id:'own'};renderPanel()");
const panel = () => dom.window.document.querySelector('#panelBody').textContent;
assert.match(panel(), /Hurry the permits and the factory/);
assert.match(panel(), /As fast as money goes/);
assert.match(panel(), /132 days from the order at the soonest/);
const step = ev('prepCost(S.links[0])'), cash = ev('S.cash');
ev("ACT.seaRush({id:'own'})");
assert.equal(ev('S.links[0].ready'), 770, 'one step: 30 days sooner');
assert.equal(cash - ev('S.cash'), step);
ev("ACT.seaRush({id:'own',all:1})");
assert.equal(ev('S.links[0].ready'), 372, 'all the way: the factory floor, then the ships');
assert.equal(cash - ev('S.cash'), 15 * step);
assert.equal(ev('layStart(S.links[0])'), 332);
assert.equal(ev('prepSteps(S.links[0])'), 0, 'no faster than that');
ev("ACT.seaRush({id:'own'})");
assert.equal(cash - ev('S.cash'), 15 * step, 'and nothing more is charged');
// The second lay ship still halves the time at sea on top.
ev("ACT.layShip({id:'own'})");
assert.equal(ev('S.links[0].ready'), 352);
assert.deepEqual(errors, []);
});
test('#258 a short cable is quick; once the ships sail, money buys no more paperwork', () => {
const { ev, errors } = load();
ev(start + own(800, 600));
assert.equal(ev('prepMin(S.links[0])'), 70, 'a short hop: a couple of months');
ev("ACT.seaRush({id:'own',all:1})");
assert.equal(ev('S.links[0].ready'), 200 + 70 + 6);
ev(start + own(6000, 800) + 'S.day=770');
assert.equal(ev('prepSteps(S.links[0])'), 0, 'laying has started');
const cash = ev('S.cash');
ev("ACT.seaRush({id:'own'})");
assert.equal(ev('S.cash'), cash);
assert.deepEqual(errors, []);
});