From da1a4e2f3c9f7fac12c94eefb8d35bd6b1e4ae16 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Mon, 2 Nov 2026 21:45:30 +0100 Subject: [PATCH] Give POPs built by links, fiber, cables and seats the standard routers (#261) Only Build POP applied the standard. A wave, dark fiber, own subsea cable or consortium seat to a new city now applies it too, and their offers quote newPopCost() (the site plus the standard's routers). --- CHANGELOG.md | 2 +- src/game/60-features/36-specialist.js | 2 +- src/game/60-features/96-pop-standard.js | 2 ++ src/game/90-actions/60-links.js | 2 +- src/game/90-actions/86-specialist.js | 2 +- src/game/90-actions/87-fiber-and-hardware.js | 4 ++-- src/game/95-modals/70-link-modal.js | 4 ++-- tests/pop-standard.test.js | 24 ++++++++++++++++++++ 8 files changed, 34 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a000684..ee68ffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] -- The Build POP button now shows the whole price of a new POP, including the routers of your standard POP (#261). Before, it showed only the site, although the standard routers were paid for on top; a note under the button now lists them, and the intern's one-tap template prices them in as well. +- The Build POP button now shows the whole price of a new POP, including the routers of your standard POP (#261). Before, it showed only the site, although the standard routers were paid for on top; a note under the button now lists them, and the intern's one-tap template prices them in as well. POPs that come with a new wave, dark fiber, your own subsea cable or a consortium seat now get the standard routers too, and those offers show the price with them. ## [2.5.0] — 2026-11-02 diff --git a/src/game/60-features/36-specialist.js b/src/game/60-features/36-specialist.js index 855834f..37e7039 100644 --- a/src/game/60-features/36-specialist.js +++ b/src/game/60-features/36-specialist.js @@ -58,7 +58,7 @@ const seatRoute=name=>Object.values(SEAT_ROUTES).flat().find(r=>r[2]===name); function seatOffer(c,d){const rs=(c?SEAT_ROUTES[c]||[]:Object.values(SEAT_ROUTES).flat()).filter(r=>isCity(r[0])&&isCity(r[1])&&(c||S.pops[r[0]]||S.pops[r[1]])&&!S.links.some(l=>l.seat&&l.cname===r[2])); if(!rs.length)return null;const r=rs[hstr(S.asn+'|seat|'+d)%rs.length];return {a:r[0],b:r[1],name:r[2],km:seatKm(r[0],r[1]),exp:d+SEAT_EXP};} function seatConf(c){if(S.seatOff||lvl()!S.pops[c]).reduce((x,c)=>x+popCost(c),0); +function seatSection(){const o=S.seatOff;if(!o||o.exp<=S.day)return '';const pop=[o.a,o.b].filter(c=>!S.pops[c]).reduce((x,c)=>x+newPopCost(c),0); return `
🚢 ${tr('specialist.consortium_seat_name',{name:esc(o.name)})}
${tr('specialist.a_b_km_km_ready_in',{a:CITY[o.a].name,b:CITY[o.b].name,km:o.km.toLocaleString(),n:seatDays(o.km),ms:linkLat({kind:'df',own:true,sub:true,km:o.km,seaDesign:'standard'}).toFixed(1)})} · ${tr('ui.n_d_left',{n:o.exp-S.day})}
${tr('specialist.your_own_fiber_pairs_on_a')}${pop?' '+tr('specialist.includes_pops_at_the_landings_price',{price:fmt$(pop)}):''}
${SEAT_N.map(n=>{const c=seatCost(o.km,n)+pop;return btn(`${trn('specialist.n_fiber_pairs',n)} ${fmt$(c)} · ${tr('common.price_mo',{price:fmt$(seatMo(o.km,n))})}`,'seatBuy',{n},'sm',S.cash
`;} diff --git a/src/game/60-features/96-pop-standard.js b/src/game/60-features/96-pop-standard.js index 6c78a14..dad4b00 100644 --- a/src/game/60-features/96-pop-standard.js +++ b/src/game/60-features/96-pop-standard.js @@ -5,6 +5,8 @@ function popStdQuote(){const d=S.popStd;if(!d||pzOn())return null;const g=techOk('rg',d.g,RG[d.g].lvl)?d.g:0; let cost=g?Math.max(0,Math.round(RG[g].cost*hwMul('rt')*techMul(RG[g].lvl))-tradeIn(0,1)):0;for(let n=1;n=swapCost(city,d.g)){spend(swapCost(city,d.g));p.rgen=d.g;}else miss=true;} while((p.routers||1){const it=demoItem(k,id);if(!it||!demoCan(it.lvl)||demoAt(k,id)!==null)return;S.demo=S.demo||{};const at=S.day+leadDays(DEMO_DAYS);S.demo[k+':'+id]=at; toast(tr('specialist.the_vendor_ships_a_demo_name',{name:esc(it.n),n:at-S.day,p:Math.round((DEMO_MUL-1)*100)}),'good');after();}, seatBuy:({n})=>{const o=S.seatOff;n=+n;if(!o||o.exp<=S.day||!SEAT_N.includes(n))return;const miss=[o.a,o.b].filter(c=>!S.pops[c]),cost=seatCost(o.km,n)+miss.reduce((x,c)=>x+popCost(c),0);if(!spend(cost))return; - for(const c of miss)S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0}; + for(const c of miss){S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(c);} const id=uid(),days=seatDays(o.km);S.links.push({id,a:o.a,b:o.b,kind:'df',own:true,sub:true,seat:true,seaDesign:'standard',sys:'roadm',ch:[],km:o.km,cable:null,cname:o.name,mo:seatMo(o.km,n),trench:'seat:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:n,paid:seatCost(o.km,n)}); S.seatOff=null;S.stats.seats=(S.stats.seats||0)+1;UI.sel={type:'link',id}; toast(tr('specialist.you_own_n_fiber_pairs_on',{n,name:esc(o.name),a:CITY[o.a].name,b:CITY[o.b].name,d:days}),'goal');sfx('build');after();}, diff --git a/src/game/90-actions/87-fiber-and-hardware.js b/src/game/90-actions/87-fiber-and-hardware.js index 3351b63..9befa30 100644 --- a/src/game/90-actions/87-fiber-and-hardware.js +++ b/src/game/90-actions/87-fiber-and-hardware.js @@ -8,7 +8,7 @@ Object.assign(ACT,{ dfSrc:({v})=>{UI.dfSrc=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);}, dfSys:({v})=>{UI.dfSys=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);}, orderCable:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(ownCabWhy(a,b))return;const design=own(SEA_DESIGNS,UI.seaDesign)?UI.seaDesign:'standard',up=seaUps(seaQuote(a,b,design).km),q=seaQuote(a,b,design,up),km=q.km,cost=q.cost+(S.pops[b]?0:popCost(b));if(seaLack(km,up).length||!spend(cost))return; - if(!S.pops[b])S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0}; + if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);} const used=new Set(S.links.map(l=>l.cname).filter(Boolean)),cname=OWNCAB_NAMES.find(n=>!used.has(n))||`${pick(OWNCAB_NAMES)} ${used.size+1}`,id=uid(),ship=layName({id}),days=q.days; S.links.push({id,a,b,kind:'df',own:true,sub:true,seaDesign:design,seaPath:q.pts.map(p=>p.slice()),sys:'roadm',ch:[],km,cable:null,cname,mo:Math.round(km*OWNCAB_OM),trench:'own:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:1}); const laid=S.links[S.links.length-1];laid.paid=q.cost;for(const k of Object.keys(SUB_UPGRADES))if(up[k])laid['sub'+k]=laid.ready;UI.seaDesign='standard';UI.seaterminal=UI.seaengineering=false; @@ -17,7 +17,7 @@ Object.assign(ACT,{ orderDf:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(!dfAllowed(a,b))return;const sc=isSub(a,b)?subDfCable(a,b):null,km=sc?sc.km:kmBetween(a,b); const own=UI.dfSrc==='build'&&!sc,sys=DF_SYS[UI.dfSys]&&techOk('sys',UI.dfSys,DF_SYS[UI.dfSys].lvl)?UI.dfSys:'lite';if(lvl()<2)return; const up=(own?digCost(km):0)+sysCost(sys)+ampCount(km)*AMP_COST+(S.pops[b]?0:popCost(b));if(!spend(up))return; - if(!S.pops[b])S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0}; + if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);} const sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'),id=uid(); const l={id,a,b,kind:'df',own,sys,ch:[],km,sub:!!sc,cable:sc?sc.cid:null,mo:own?Math.round(km*0.15):dfLeaseMo(km),trench:sc?'cab:'+sc.cid:id,cut:0,day:S.day,ready:S.day+(own?dfBuildDays(km):leadDays(IRU_DAYS)),spares:false}; S.links.push(l);closeModal();UI.sel={type:'link',id}; diff --git a/src/game/95-modals/70-link-modal.js b/src/game/95-modals/70-link-modal.js index 876de5a..b21f39e 100644 --- a/src/game/95-modals/70-link-modal.js +++ b/src/game/95-modals/70-link-modal.js @@ -1,7 +1,7 @@ function openLinkModal(a,b){ if([a,b].includes('kyv')&&[a,b].includes('mos')){openModal(`

${tr('common.not_happening')}

${tr('link_modal.nobody_sells_capacity_between_kyiv')}

`);return;} if((cnCity(a)||cnCity(b))&&!cnOk()){openModal(`

${tr('link_modal.not_without_a_license')}

${tr('link_modal.building_into_mainland_china_needs_a',{city:CITY[cnCity(a)?a:b].name})}

`);return;} - let route='';UI.pending={a,b};const km=kmBetween(a,b),sub=isSub(a,b),pop=S.pops[b]?0:popCost(b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'); + let route='';UI.pending={a,b};const km=kmBetween(a,b),sub=isSub(a,b),pop=S.pops[b]?0:newPopCost(b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'); if(!sib.length)UI.route='diverse';const border=cnCity(a)!==cnCity(b),jn=sib.length?routeJoin(a,b):null,ts=landTrenches(a,b),mult=(sib.length&&!(jn&&jn.k===(ts[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1); if(border)route+=`

${tr('link_modal.cross_border_circuits_into_mainland')}

${a==='hkg'||b==='hkg'?`
${btn(tr('common.regular_crossing'),'cnPrem',{v:0},!UI.cnPrem?'pink':'ghost')}${btn(tr('link_modal.premium_crossing_60_3_loss'),'cnPrem',{v:1},UI.cnPrem?'pink':'ghost')}
`:`

${tr('link_modal.premium_crossings_are_only_sold_in')}

`}`; if(sib.length&&!(isSub(a,b)&&cablesFor(a,b).length)&&!(UI.via&&UI.via!=='land'&&cablesFor(a,b).some(c=>c.cid===UI.via))){route+=`

${trn('link_modal.you_already_have_n_link_here',sib.length,{list:sib.map(l=>capName(l)).join(', ')})}

@@ -16,6 +16,6 @@ function openLinkModal(a,b){ const wr=waveRoute(a,b,mult,border); openModal(`${head}

${tr('link_modal.waves_are_leased_at_a_flat')}

- ${pop?`

${tr('link_modal.includes_a_new_pop_in_city',{city:CITY[b].name,price:fmt$(popCost(b)),extra:ruCity(b)?', '+tr('link_modal.government_box_included'):CITY[b].uae?', '+tr('link_modal.free_zone_license_included'):CITY[b].saudi?', '+tr('link_modal.local_telecom_licence_included'):''})}

`:''}${route}${viaSeg(a,b)} + ${pop?`

${tr('link_modal.includes_a_new_pop_in_city',{city:CITY[b].name,price:fmt$(pop),extra:ruCity(b)?', '+tr('link_modal.government_box_included'):CITY[b].uae?', '+tr('link_modal.free_zone_license_included'):CITY[b].saudi?', '+tr('link_modal.local_telecom_licence_included'):''})}

`:''}${route}${viaSeg(a,b)}
${LT.map((T,i)=>{const lc=Math.round(waveMo(wr.km,wr.sub,i)*wr.wm),c=lc+pop,sw=subWaveWhy(i,wr.km,wr.sub),so=!sw&&soldOut(a,b,i,wr.cab),ok=waveOk(a,b,i)&&!sw&&!so;return !waveShown(i)?'':``;}).join('')}
`); } diff --git a/tests/pop-standard.test.js b/tests/pop-standard.test.js index 61f90eb..f6e53cd 100644 --- a/tests/pop-standard.test.js +++ b/tests/pop-standard.test.js @@ -61,3 +61,27 @@ test('the price of a new POP includes the standard routers, on the button and in assert.equal(ev('popStdQuote()'), null); assert.deepEqual(errors, []); }); + +test('POPs built by a link, dark fiber or a consortium seat get the standard too, at the quoted price (#261)', () => { + const { ev, errors } = load(); + const A = g('Arrrhipster 7280R'), Ai = ev(A); + ev(start + `;S.lvl=4;S.pops.fra.rgen=${A};S.pops.fra.routers=2;ACT.popStdSet({city:'fra'})`); + const std = ev('popStdQuote().cost'); + assert.equal(ev("newPopCost('ams')"), ev("popCost('ams')") + std); + // A wave to a city without a POP. + ev("UI.pending={a:'fra',b:'ams'};UI.lmode='wave';ACT.buildLink({tier:0})"); + assert.ok(ev('!!S.pops.ams'), 'the wave built the POP'); + assert.equal(ev('S.pops.ams.rgen'), Ai); + assert.equal(ev('S.pops.ams.routers'), 2); + // Dark fiber to a city without a POP. + ev("UI.pending={a:'fra',b:'par'};UI.lmode='df';UI.dfSys='lite';ACT.orderDf()"); + assert.equal(ev('S.pops.par.rgen'), Ai); + assert.equal(ev('S.pops.par.routers'), 2); + // A consortium seat with a landing that has no POP yet; its offer is priced with the standard. + ev("S.seatOff={a:'fra',b:'lis',name:'Test',km:seatKm('fra','lis'),exp:S.day+30};UI.tab='links'"); + assert.ok(ev("seatSection()").includes(ev("fmt$(newPopCost('lis'))"))); + ev('ACT.seatBuy({n:1})'); + assert.equal(ev('S.pops.lis.rgen'), Ai); + assert.equal(ev('S.pops.lis.routers'), 2); + assert.deepEqual(errors, []); +});