Subsea hurry costs a cable ship: charters for builds, the repair-ship queue for cuts

Speeding up an own subsea cable charters another cable ship ($3M plus $500/km per 30 days saved), and a rush repair on a subsea cut costs $1M plus $200/km. Land crews and trench repairs keep their prices.
This commit is contained in:
Frederic Jung 2026-11-01 10:25:32 +00:00
parent bd6ba6bfd7
commit 38fdf9b4d8
No known key found for this signature in database
14 changed files with 104 additions and 13 deletions

View file

@ -0,0 +1,60 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
// Hurrying anything at sea takes a cable ship: a charter for a build, a place in the repair queue for a cut. Both cost
// millions, while the same hurry on land stays cheap.
const start = "ACT.start({});S.cash=1e9;S.lvl=13;S.day=200;for(const g of GOALS)S.done[g.id]=0;";
test('more crews on a subsea build means chartering a cable ship, for millions', () => {
const { ev, dom, errors } = load();
ev(start + "S.links=[{id:'sea',a:'lag',b:'bde',kind:'df',own:true,sub:true,sys:'roadm',km:6000,ch:[],day:200,ready:800,cut:0,mo:1},"
+ "{id:'land',a:'fra',b:'ams',kind:'df',own:true,sys:'roadm',km:400,ch:[],day:200,ready:500,cut:0,mo:1}]");
assert.equal(ev("crewCost(S.links[0])"), 3000000 + 6000 * 500, 'mobilising a ship plus its time at sea');
assert.ok(ev("crewCost(S.links[1])") < 50000, 'land crews stay cheap');
const cash = ev('S.cash');
ev("ACT.crews({id:'sea'})");
assert.equal(cash - ev('S.cash'), 6000000);
assert.equal(ev('S.links[0].ready'), 770);
assert.match(dom.window.document.body.innerHTML, /Another cable ship joins the lay/);
ev("UI.sel={type:'link',id:'sea'};renderPanel()");
const panel = () => dom.window.document.querySelector('#panelBody').textContent;
assert.match(panel(), /Charter another cable ship/);
assert.match(panel(), /Only a few dozen cable ships exist/);
assert.doesNotMatch(panel(), /Hire extra crews/);
ev("UI.sel={type:'link',id:'land'};renderPanel()");
assert.match(panel(), /Hire extra crews/);
assert.doesNotMatch(panel(), /cable ship/);
// The whole lay in one go is the charter times every 30 days left.
ev("S.cash=1e9;UI.sel={type:'link',id:'sea'};renderPanel()");
assert.equal(ev("crewSteps(S.links[0])*crewCost(S.links[0])"), 19 * 6000000);
assert.deepEqual(errors, []);
});
test('a rush repair on a subsea cut, even on a leased wave, costs a cable ship, a trench cut stays cheap', () => {
const { ev, errors } = load();
ev(start + "S.links=[{id:'sea',a:'lag',b:'bde',kind:'wave',sub:true,tier:0,km:6000,cut:0,mo:1000}];S.inc=[];fireFailure('cut')");
const sea = JSON.parse(ev("JSON.stringify(S.inc.find(i=>i.type==='cut'))"));
assert.equal(sea.cost, 1000000 + 6000 * 200);
assert.equal(sea.fix, 'Jump the cable-ship queue');
ev("S.links=[{id:'land',a:'fra',b:'ams',kind:'wave',tier:0,km:400,cut:0,mo:1000}];S.inc=[];fireFailure('cut')");
const land = JSON.parse(ev("JSON.stringify(S.inc.find(i=>i.type==='cut'))"));
assert.equal(land.cost, 4000);
assert.equal(land.fix, undefined);
// Paying it brings the cable back at once, like any rush repair.
ev("S.links=[{id:'sea',a:'lag',b:'bde',kind:'wave',sub:true,tier:0,km:6000,cut:0,mo:1000}];S.inc=[];fireFailure('cut')");
const id = ev("S.inc.find(i=>i.type==='cut').id"), cash = ev('S.cash');
ev(`ACT.fixInc({id:'${id}'})`);
assert.equal(cash - ev('S.cash'), 2200000);
assert.equal(ev("linkDown(S.links[0])"), false);
assert.deepEqual(errors, []);
});
test('the chaos monkey snipping a subsea cable prices the rush the same way', () => {
const { ev, errors } = load();
ev(start + "S.links=[{id:'sea',a:'lag',b:'bde',kind:'wave',sub:true,tier:0,km:3000,cut:0,mo:1000}];S.inc=[];"
+ "S.monkey={n:0,hurt:0,until:S.day+100};mkSnip()");
const i = JSON.parse(ev("JSON.stringify(S.inc.find(i=>i.type==='cut'))"));
assert.equal(i.cost, 1000000 + 3000 * 200);
assert.deepEqual(errors, []);
});

View file

@ -129,11 +129,11 @@ test('one-click completion costs the same as repeated crew hires and advances pe
const button = [...dom.window.document.querySelectorAll('#panelBody [data-act=crews]')].find(b => JSON.parse(b.dataset.args).all);
assert.ok(button && !button.disabled, 'one-click option is available');
const cash = ev('S.cash');
assert.ok(button.textContent.includes(ev('fmt$(30*Math.round(15000+15000*6))')), 'full price is shown before purchase');
assert.ok(button.textContent.includes(ev('fmt$(30*Math.round(3000000+15000*500))')), 'full price is shown before purchase');
button.click();
const bulkDates = dates(ev), bulkCash = ev('S.cash');
assert.deepEqual(bulkDates, [101, 131, 281]);
assert.equal(cash - bulkCash, 30 * 105000);
assert.equal(cash - bulkCash, 30 * 10500000);
const after = [...dom.window.document.querySelectorAll('#panelBody [data-act=crews]')];
assert.ok(after.every(b => b.disabled), 'both options stop at one day');
ev("ACT.crews({id:'cable',all:1})");
@ -150,18 +150,18 @@ test('one-click completion is atomic when unaffordable and handles short or comp
const { ev, dom } = load();
try {
setup(ev);
ev("S.cash=30*105000-1;UI.sel={type:'link',id:'cable'};renderPanel()");
ev("S.cash=30*10500000-1;UI.sel={type:'link',id:'cable'};renderPanel()");
const bulk = [...dom.window.document.querySelectorAll('#panelBody [data-act=crews]')].find(b => JSON.parse(b.dataset.args).all);
assert.equal(bulk.disabled, true);
ev("ACT.crews({id:'cable',all:1})");
assert.equal(ev('S.cash'), 30 * 105000 - 1);
assert.equal(ev('S.cash'), 30 * 10500000 - 1);
assert.equal(ev('S.links[0].ready'), 1000, 'no partial purchase');
ev("S.cash=105000;S.links[0].ready=102;ACT.crews({id:'cable',all:1})");
ev("S.cash=10500000;S.links[0].ready=102;ACT.crews({id:'cable',all:1})");
assert.equal(ev('S.cash'), 0);
assert.equal(ev('S.links[0].ready'), 101, 'two days remaining costs one normal hire');
assert.match(dom.window.document.body.textContent, /Construction is 1 day ahead\./);
ev("S.cash=105000;S.day=101;ACT.crews({id:'cable',all:1})");
assert.equal(ev('S.cash'), 105000, 'completed construction cannot be rushed');
assert.match(dom.window.document.body.textContent, /The cable is 1 day ahead\./);
ev("S.cash=10500000;S.day=101;ACT.crews({id:'cable',all:1})");
assert.equal(ev('S.cash'), 10500000, 'completed construction cannot be rushed');
ev("S.day=100;S.links[0].ready=1000;S.links[0].own=false;ACT.crews({id:'cable',all:1})");
assert.equal(ev('S.links[0].ready'), 1000, 'leased handovers cannot buy construction crews');
} finally { dom.window.close(); }