Dark fiber leases cost half as much again (#203)

A leased pair was $400 + $1/km a month, so a single 400G wave on the
same route cost two to three times the whole fiber. It is now $600 +
$1.50/km (amplifiers as before): a lease pays off at a couple of 400G
waves, as dark fiber does. Leases already signed keep their price (l.mo).
Alien-wave rent follows, since it is priced against the fiber.

The differential route fuzz now also compares link prices, so a
deliberate price change compares this checkout with itself, as a change
to the world already does.
This commit is contained in:
Frederic Jung 2026-11-05 08:19:05 +00:00
parent 8841fdacb9
commit b9860edc77
No known key found for this signature in database
4 changed files with 23 additions and 5 deletions

View file

@ -65,3 +65,17 @@ test('#203 a dark fiber, cable or wave cannot be ordered to a city the map does
assert.equal(ev(`S.links.some(l=>l.b==='${off}'||l.a==='${off}')`), false);
assert.deepEqual(errors, []);
});
test('#203 a dark fiber lease costs more, and a lease already signed keeps its price', () => {
const { ev, errors } = load();
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;S.lvl=4;for(const c of ['fra','ams'])if(!S.pops[c])ACT.buildPop({city:c})");
assert.equal(ev('dfLeaseMo(1000)'), 2100);
ev("UI.pending={a:'fra',b:'ams'};UI.dfSrc='lease';UI.dfSys='lite';ACT.orderDf()");
const km = ev("S.links.find(l=>l.kind==='df').km");
assert.equal(ev("S.links.find(l=>l.kind==='df').mo"), Math.round(600 + km * 1.5));
// An old save's lease, signed at the old price, keeps it.
const old = Math.round(400 + km);
ev(`S.links.find(l=>l.kind==='df').mo=${old};S=migrate(JSON.parse(JSON.stringify(S)))`);
assert.equal(ev("S.links.find(l=>l.kind==='df').mo"), old);
assert.deepEqual(errors, []);
});

View file

@ -16,10 +16,11 @@ function pages() {
let base = head;
try { const b = path.join(os.tmpdir(), `tubes-fuzz-test-${process.pid}-base.html`); fs.writeFileSync(b, page.assembleRef('origin/main')); base = b; } catch (e) {}
let P = { base: openPage(base, 'base'), head: openPage(head, 'head') };
// A change to the world itself (cities, networks, cables) cannot route like main: there is no same game to compare.
// Then the base is this checkout too, and the cache on/off check still runs; equivalence with main resumes once it lands.
const world = (p) => p.ev("JSON.stringify([CITIES.map(c=>[c.id,c.land,c.P]),NETS.map(n=>[n.id,n.pops,n.ix,n.share,n.price,n.up]),CABLES.map(c=>[c.id,c.pairs.map(q=>[q[0],q[1]])])])");
if (base !== head && world(P.base) !== world(P.head)) { console.log('# route fuzz: the world differs from main, so both pages are this checkout'); P = { base: openPage(head, 'base'), head: P.head }; }
// A change to the world itself (cities, networks, cables) or to what links cost cannot route like main: there is no
// same game to compare. Then the base is this checkout too, and the cache on/off check still runs; equivalence with
// main resumes once it lands.
const world = (p) => p.ev("JSON.stringify([CITIES.map(c=>[c.id,c.land,c.P]),NETS.map(n=>[n.id,n.pops,n.ix,n.share,n.price,n.up]),CABLES.map(c=>[c.id,c.pairs.map(q=>[q[0],q[1]])]),[1,300,3000].map(k=>[dfLeaseMo(k),waveMo(k,false,2),dfBuildCost(k)])])");
if (base !== head && world(P.base) !== world(P.head)) { console.log('# route fuzz: the world or its prices differ from main, so both pages are this checkout'); P = { base: openPage(head, 'base'), head: P.head }; }
return P;
}