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

@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- DE-Kicks ports stop getting dearer once they cost four times the list price. Before, the yearly price harmonisation kept compounding, so a long game ended up paying $100k a month for one port at Frankfurt or Mumbai.
- Every capital in Africa is on the map, which puts every capital of the world in the game: 33 new cities from Porto-Novo, Bamako and Niamey to Khartoum, Juba, Mogadishu, Brazzaville, Tripoli, Rabat and Pretoria. Each country brings its real telcos, Nigeria gets its wholesale backbone up to Abuja, and the island capitals of the Comoros, São Tomé and Equatorial Guinea sit on their real cables.
- Every capital in South, East and Southeast Asia and the Pacific is on the map: Thimphu, Kathmandu, Bandar Seri Begawan, Phnom Penh, Vientiane, Ulaanbaatar, Naypyidaw, Pyongyang, Dili, Hanoi and Wellington, with the island capitals Tarawa, Palikir, Yaren, Funafuti and Port Vila. Each country brings its real telcos, North Korea reaches the world only through China and Russia, and the islands hang on their real cables.
- Every capital in the Middle East, the Caucasus and Central Asia is on the map, from Yerevan and Baku to Kabul, Tehran, Baghdad, Jerusalem, Amman, Kuwait City, Beirut, Damascus, Sanaa and Manama, with Ankara and Islamabad. Each country brings its real telcos, and Bahrain is an island on the Gulf's cables.

View file

@ -5,7 +5,11 @@ const DK_CITIES=['fra','mad','mrs','dxb','bom','nyc'];
const isDk=c=>(DK_CITIES.includes(c)||scnRule('dkAll'))&&!!CITY[c]&&!!CITY[c].ix&&!S.myIx[c];
const DK_ADDONS=[['Blackholing Plus™',tr('de_kicks.like_blackholing_but_with_a_plus')],['Route Server Gold',tr('de_kicks.the_same_route_server_in_a')],['Premium Port LEDs',tr('de_kicks.your_port_light_now_blinks_in')],['Strategic Peering Insights',tr('de_kicks.a_monthly_pdf_of_your_own')],['GlobePeer Ready™',tr('de_kicks.makes_your_port_ready_for_a')],['Cloud Exchange Readiness Fee',tr('de_kicks.a_fee_for_being_ready_for')],['Account Manager Lunch Fund',tr('de_kicks.your_account_manager_is_hungry')]];
const DK_STALL=[tr('de_kicks.your_account_manager_would_love_to'),tr('de_kicks.pricing_is_reviewed_by_the_global'),tr('de_kicks.they_sent_a_14_page_nda'),tr('de_kicks.your_account_manager_is_at_a')];
function dkMult(c){if(!S||!isDk(c)||!S.dk||!S.dk.m[c])return 1;const ret=S.dk.ret[c];return S.dk.m[c]*(ret&&ret>S.day?0.6:1);}
// Harmonisation and ended promos raise the personal price, but only up to this multiple of the list price: uncapped, 8-15% a
// year turned a 60-year game into $100k ports. (ponytail: a guess at the ceiling; the maintainer can tune it.)
const DK_MAX=4;
function dkMult(c){if(!S||!isDk(c)||!S.dk||!S.dk.m[c])return 1;const ret=S.dk.ret[c];return Math.min(S.dk.m[c],DK_MAX)*(ret&&ret>S.day?0.6:1);}
function dkRaise(c,f){const dk=S.dk,was=Math.min(dk.m[c],DK_MAX);dk.m[c]=Math.min(DK_MAX,+(dk.m[c]*f).toFixed(3));return dk.m[c]>was;}
function dkAddonMo(c){return S.dk&&S.dk.add[c]?S.dk.add[c].reduce((a,x)=>a+x.mo,0):0;}
function dkState(){S.dk=S.dk||{m:{},add:{},ret:{},retUsed:{},stall:0,q:null};return S.dk;}
function dkQuoteMult(){const pops=Object.keys(S.pops).length,big=Math.min(1.2,pops*0.04+(R.served||0)/20000);return +(0.95+Math.random()*0.45+big).toFixed(2);}
@ -19,8 +23,8 @@ function dkQuoteModal(){const q=S.dk.q,c=q.city,mo=Math.round(PORT[q.tier].ix*(S
<div class="btns">${btn(tr('de_kicks.sign_price_mo',{price:fmt$(mo)}),'dkAccept',{},'pink',S.cash<mo)}${btn(tr('common.haggle'),'dkHaggle',{},'',q.h>=3)}${btn(tr('common.walk_away'),'dkWalk',{},'ghost')}</div>`);}
function dkTick(d){if(!S.dk)return;const dk=S.dk;
for(const c in S.ixp){if(!isDk(c))continue;
if(dk.ret[c]&&dk.ret[c]===d){dk.m[c]=+(dk.m[c]*1.1).toFixed(3);toast(tr('de_kicks.your_ix_promo_ended_price_is',{ix:esc(ixName(c))}),'bad');}
if(dk.m[c]&&(d+hstr(c)%90)%365===0){const f=1.08+Math.random()*0.07;dk.m[c]=+(dk.m[c]*f).toFixed(3);toast(tr('de_kicks.de_kicks_has_harmonised_its_prices',{ix:esc(ixName(c)),p:Math.round((f-1)*100)}),'bad');}
if(dk.ret[c]&&dk.ret[c]===d){dkRaise(c,1.1);toast(tr('de_kicks.your_ix_promo_ended_price_is',{ix:esc(ixName(c))}),'bad');}
if(dk.m[c]&&(d+hstr(c)%90)%365===0){const f=1.08+Math.random()*0.07;if(dkRaise(c,f))toast(tr('de_kicks.de_kicks_has_harmonised_its_prices',{ix:esc(ixName(c)),p:Math.round((f-1)*100)}),'bad');}
const add=dk.add[c]=dk.add[c]||[];
if(add.length<3&&Math.random()<1/150){const a=DK_ADDONS.filter(x=>!add.some(y=>y.n===x[0]));if(a.length){const [n,blurb]=pick(a),mo=Math.round((300+Math.random()*1200)/50)*50;add.push({n,blurb,mo,day:d});
toast(tr('de_kicks.good_news_you_ve_been_enrolled',{addon:esc(n),blurb:esc(blurb),price:fmt$(mo),ix:esc(ixName(c))}),'bad');}}}

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, []);
});