Subsea cable designs, fixed against today's main (#65, #78)

- Upgrades take effect: the optic speed cache from #89 is now kept per cable
  state (subsea, terminals in service, engineering in service), so a cable
  no longer stays at 400G after both upgrades are commissioned.
- Refunds: a cable remembers what was paid for it, design and upgrades
  included. Calling off a 7x low-latency cable returned 10% of its price.
  'Unusable' now means no optic lights it even with both upgrades.
- Length limit: #88 counts the shortest design and both upgrades. The order
  screen says which upgrade a route needs and will not order without it;
  the order action checks the same. New York to Sydney needs terminals.
  No leased-wave payback hint where no leased wave reaches.
- Choices start fresh when you open the own-cable view and after ordering.
- The 'consider terminals or engineering' hint only on cables you own.
- Low-latency builds take 1.7x as long (London-New York ~2.9 years), not
  3.5x; optimized 1.3x. Each design is one tappable card.
- The low-latency factor is worked out once per route instead of on every
  latency lookup. 'Number.isFinite' alone, no repeated guard in seaQuote,
  the express factor folded into seaLatencyFactor, '+{n} days' as one
  translatable string.
- Portuguese and French for the new strings; one CHANGELOG bullet (#65).

Big network vs main: no slowdowns, identical routing.
This commit is contained in:
Frederic Jung 2026-10-26 16:07:08 +01:00
parent e76d68fc90
commit 6ddbc6ec7d
No known key found for this signature in database
7 changed files with 120 additions and 25 deletions

View file

@ -1058,7 +1058,11 @@ test('#104 declining a loan offer clears the bank badge while paused', () => {
test('#88 no subsea cable longer than any optic can light, and a refund for calling one off', () => {
const { ev, errors } = load();
ev("ACT.start({});S.cash=1e10;S.lvl=13;S.won=true;for(const g of GOALS)S.done[g.id]=0");
assert.match(ev("ownCabWhy('nyc','syd')"), /more than any optic can light/);
// New York to Sydney is too long for plain optics; since #78 premium terminals light it, so the order screen asks
// for them instead of refusing. Only a length beyond even both upgrades is refused.
assert.equal(ev("ownCabWhy('nyc','syd')"), '');
assert.deepEqual(JSON.parse(ev("JSON.stringify(subNeed(ownCabKm('nyc','syd')))")), ['terminal']);
assert.equal(ev('subNeed(26000)'), null, 'nothing lights 26,000 km');
assert.equal(ev("ownCabWhy('lax','syd')"), '', 'Los Angeles to Sydney still works');
assert.ok(ev("subCarrier(ownCabKm('lax','syd'))") > 0);
// half-way through laying it: most of the unlaid part comes back
@ -1071,7 +1075,9 @@ test('#88 no subsea cable longer than any optic can light, and a refund for call
assert.equal(ev('S.cash') - c0, want);
// a finished cable that works is yours for good; one nothing can light (old saves) goes back in full
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:ownCabKm('lax','syd'),ready:0})"), 0);
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:18387,ready:0})"), ev('ownCabCost(18387)'));
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:26000,ready:0})"), ev('ownCabCost(26000)'));
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:26000,ready:0,paid:5e8})"), 5e8, 'what was really paid');
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:18387,ready:0})"), 0, 'a finished cable upgrades can light is yours for good');
assert.deepEqual(errors, []);
});