fix(peering): cap the DE-Kicks personal price multiplier

DE-Kicks ports stop getting dearer once they cost four times the list price. The yearly harmonisation kept compounding, so a long game paid $100k a month for one port.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lambro-codes 2026-11-04 04:32:16 +01:00
parent b2366ed260
commit 81e4fbd215
3 changed files with 39 additions and 3 deletions

View file

@ -0,0 +1,31 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
const start = "ACT.start({});S.cash=1e12;S.nextFail=1e9;S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buyIx({city:'fra',tier:1,signed:1});S.dk=S.dk||dkState();S.dk.m.fra=2";
test('DE-Kicks harmonisation raises the price for years, then stops at a ceiling', () => {
const { ev, errors } = load();
ev(start);
assert.equal(ev("S.ixp.fra"), 1, 'joined the DE-Kicks exchange');
const base = ev("PORT[1].ix*ixMul('fra')");
ev("for(let d=1;d<=360*10;d++)dkTick(d)");
const tenYears = ev("dkMult('fra')");
assert.ok(tenYears > 2 && tenYears <= ev("DK_MAX"), 'it still climbs at first');
ev("for(let d=360*10;d<=360*70;d++)dkTick(d)");
assert.equal(ev("dkMult('fra')"), ev("DK_MAX"), 'sixty more years stay at the ceiling');
assert.equal(ev("ixPortMo('fra',1)"), Math.round(base * ev("DK_MAX")), 'so the port costs a few times list, never a hundred');
assert.deepEqual(errors, []);
});
test('a save that already ran away reads as the ceiling, and a capped price stops announcing rises', () => {
const { ev, errors } = load();
ev(start);
ev("S.dk.m.fra=40");
assert.equal(ev("dkMult('fra')"), ev("DK_MAX"));
ev("S.inc=[];S.dk.add.fra=[]");
const day = ev("(()=>{for(let d=1;d<400;d++)if((d+hstr('fra')%90)%365===0)return d;})()");
ev(`Math.random=()=>0.9;toast=(...a)=>{(window.__t=window.__t||[]).push(a[0])};dkTick(${day})`);
assert.equal(ev("(window.__t||[]).filter(t=>/harmonised/i.test(t)).length"), 0, 'no "prices up" toast at the ceiling');
assert.deepEqual(errors, []);
});