Show the standard POP's routers in the price of a new POP (#261)

The Build POP button quoted only the site, though popStdApply then paid
for the standard routers on top. popStdQuote() prices the standard the
way it is paid; the button, a note under it and the intern's one-tap
template now include it, and the toast says what the routers cost.
This commit is contained in:
Frederic Jung 2026-11-02 21:40:14 +01:00
parent 15dc5741d4
commit 1a4a62d0f2
No known key found for this signature in database
11 changed files with 56 additions and 10 deletions

View file

@ -6,6 +6,8 @@ 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.
## [2.5.0] — 2026-11-02
**Mostly a performance release.** Big networks route their traffic on about half the processor time, days no longer freeze the game, and clicks that change nothing about your traffic answer at once, so phones last longer. Same routes, same results, just faster.

View file

@ -2945,6 +2945,7 @@
"ops.tpl_offer":"{name} kann diese Stadt in einem Rutsch eröffnen: {list}.",
"ops.tpl_open":"Aus Vorlage eröffnen · {cost}",
"ops.tpl_pop":"POP",
"ops.tpl_std":"Standard-Router",
"ops.tpl_transit":"10G Transit",
"ops.tracy":"Tracy",
"ops.tracy_d":"Verfolgt jedes Paket Hop für Hop. Kommt am Ende an, mit ein, zwei Sternchen unterwegs.",
@ -3083,8 +3084,9 @@
"pnis.their_peering_team_says_us_east":"Ihr Peering-Team sagt, US East sei „kapazitätsbeschränkt“, was in Cloud-Sprache „nein“ heißt.",
"pnis.their_team_quotes_m_months":"Ihr Team nennt {m} Monate",
"pnis.us_east_is_sold_out_until":"US East ist bis auf Weiteres ausverkauft. „Bis auf Weiteres“ ist auch ausverkauft.",
"pop_std.city_gets_the_standard_n":"{city} bekommt den Standard: {n} × {model}.",
"pop_std.city_gets_the_standard_cost":"{city} bekommt den Standard: {n} × {model} für {cost}.",
"pop_std.clear":"Entfernen",
"pop_std.includes_the_standard_n_model":"Inklusive deiner Standard-Router: {n} × {model}, {cost} + {mo}/Monat. Reicht das Geld nicht, bekommt der POP, was passt.",
"pop_std.make_this_the_standard":"Zum Standard machen",
"pop_std.new_pops_now_start_with":"Neue POPs starten jetzt mit {n} × {model}.",
"pop_std.none":"Keiner",

View file

@ -2943,6 +2943,7 @@
"ops.tpl_offer":"{name} puede abrir esta ciudad de una vez: {list}.",
"ops.tpl_open":"Abrir desde plantilla · {cost}",
"ops.tpl_pop":"POP",
"ops.tpl_std":"routers estándar",
"ops.tpl_transit":"Tránsito de 10G",
"ops.tracy":"Tracy",
"ops.tracy_d":"Sigue cada paquete salto a salto. Al final llega, con alguna estrellita por el camino.",
@ -3081,8 +3082,9 @@
"pnis.their_peering_team_says_us_east":"Su equipo de peering dice que US East tiene «capacidad limitada», que en lenguaje de nube significa «no».",
"pnis.their_team_quotes_m_months":"Su equipo da {m} meses",
"pnis.us_east_is_sold_out_until":"US East está agotado hasta nuevo aviso. El nuevo aviso también está agotado.",
"pop_std.city_gets_the_standard_n":"{city} recibe el estándar: {n} × {model}.",
"pop_std.city_gets_the_standard_cost":"{city} recibe el estándar: {n} × {model} por {cost}.",
"pop_std.clear":"Quitar",
"pop_std.includes_the_standard_n_model":"Incluye tus routers estándar: {n} × {model}, {cost} + {mo}/mes. Si falta dinero, el POP recibe lo que alcance.",
"pop_std.make_this_the_standard":"Convertir en estándar",
"pop_std.new_pops_now_start_with":"Los nuevos POP empiezan ahora con {n} × {model}.",
"pop_std.none":"Ninguno",

View file

@ -2943,6 +2943,7 @@
"ops.tpl_offer":"{name} peut ouvrir cette ville d'un coup : {list}.",
"ops.tpl_open":"Ouvrir depuis le modèle · {cost}",
"ops.tpl_pop":"POP",
"ops.tpl_std":"routeurs standard",
"ops.tpl_transit":"Transit 10G",
"ops.tracy":"Tracy",
"ops.tracy_d":"Suit chaque paquet saut par saut. Arrive au bout, avec une ou deux étoiles en chemin.",
@ -3081,8 +3082,9 @@
"pnis.their_peering_team_says_us_east":"Leur équipe de peering dit qu’US East est « capacity constrained », ce qui veut dire « non » en langage cloud.",
"pnis.their_team_quotes_m_months":"Leur équipe annonce {m} mois",
"pnis.us_east_is_sold_out_until":"US East est complet jusqu’à nouvel ordre. Le nouvel ordre est complet aussi.",
"pop_std.city_gets_the_standard_n":"{city} reçoit le standard : {n} × {model}.",
"pop_std.city_gets_the_standard_cost":"{city} reçoit le standard : {n} × {model} pour {cost}.",
"pop_std.clear":"Effacer",
"pop_std.includes_the_standard_n_model":"Inclut tes routeurs standard : {n} × {model}, {cost} + {mo}/mois. Si l’argent manque, le POP reçoit ce qui rentre.",
"pop_std.make_this_the_standard":"En faire le standard",
"pop_std.new_pops_now_start_with":"Les nouveaux POP démarrent désormais avec {n} × {model}.",
"pop_std.none":"Aucun",

View file

@ -2943,6 +2943,7 @@
"ops.tpl_offer":"{name} può aprire questa città in un colpo solo: {list}.",
"ops.tpl_open":"Apri da modello · {cost}",
"ops.tpl_pop":"POP",
"ops.tpl_std":"router standard",
"ops.tpl_transit":"Transit 10G",
"ops.tracy":"Tracy",
"ops.tracy_d":"Segue ogni pacchetto hop per hop. Alla fine arriva, con qualche asterisco per strada.",
@ -3081,8 +3082,9 @@
"pnis.their_peering_team_says_us_east":"Il loro team di peering dice che US East è “capacity constrained”, che in linguaggio cloud vuol dire “no”.",
"pnis.their_team_quotes_m_months":"Il loro team parla di {m} mesi",
"pnis.us_east_is_sold_out_until":"US East è esaurito fino a nuovo avviso. Anche il nuovo avviso è esaurito.",
"pop_std.city_gets_the_standard_n":"{city} riceve lo standard: {n} × {model}.",
"pop_std.city_gets_the_standard_cost":"{city} riceve lo standard: {n} × {model} per {cost}.",
"pop_std.clear":"Rimuovi",
"pop_std.includes_the_standard_n_model":"Include i tuoi router standard: {n} × {model}, {cost} + {mo}/mese. Se mancano i soldi, il POP riceve quello che ci sta.",
"pop_std.make_this_the_standard":"Rendilo lo standard",
"pop_std.new_pops_now_start_with":"I nuovi POP ora partono con {n} × {model}.",
"pop_std.none":"Nessuno",

View file

@ -2943,6 +2943,7 @@
"ops.tpl_offer":"{name} pode abrir esta cidade de uma vez: {list}.",
"ops.tpl_open":"Abrir pelo modelo · {cost}",
"ops.tpl_pop":"POP",
"ops.tpl_std":"roteadores padrão",
"ops.tpl_transit":"Trânsito de 10G",
"ops.tracy":"Tracy",
"ops.tracy_d":"Segue cada pacote salto a salto. Chega no fim, com uma ou duas estrelinhas no caminho.",
@ -3081,8 +3082,9 @@
"pnis.their_peering_team_says_us_east":"O time de peering deles diz que US East está “capacity constrained”, que na língua da nuvem quer dizer “não”.",
"pnis.their_team_quotes_m_months":"A equipe deles fala em {m} meses",
"pnis.us_east_is_sold_out_until":"US East está esgotado até segunda ordem. A segunda ordem também esgotou.",
"pop_std.city_gets_the_standard_n":"{city} recebe o padrão: {n} × {model}.",
"pop_std.city_gets_the_standard_cost":"{city} recebe o padrão: {n} × {model} por {cost}.",
"pop_std.clear":"Limpar",
"pop_std.includes_the_standard_n_model":"Inclui seus roteadores padrão: {n} × {model}, {cost} + {mo}/mês. Se faltar dinheiro, o POP recebe o que couber.",
"pop_std.make_this_the_standard":"Tornar este o padrão",
"pop_std.new_pops_now_start_with":"Novos POPs agora começam com {n} × {model}.",
"pop_std.none":"Nenhum",

View file

@ -219,7 +219,9 @@ function opsTplQuote(c){if(!S||S.pops[c]||!cityOn(c)||(cnCity(c)&&!cnOk()))retur
if(T.bb){cost+=bbCost(c);parts.push(tr('ops.tpl_bb'));}
if(T.transit&&!scnRule('noTransit')){net=opsProv(c);if(net){cost+=PORT[0].setup;parts.push(tr('ops.tpl_transit'));}}
// Priced as if the POP were already there (an IX port is dearer from afar). DE-KICKS wants a sales call first, so not those.
S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};
// The standard routers go in first (#261), so they are in the price and the kit is priced for them.
const sq=popStdQuote();if(sq){cost+=sq.cost;parts.push(tr('ops.tpl_std'));}
S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:sq?sq.rt:1,gen:false,rgen:sq?sq.g:0};
try{if(T.ix&&CITY[c].ix&&!isDk(c)&&S.ixp[c]===undefined){ix=c;cost+=ixPortMo(c,0);parts.push(tr('ops.tpl_ix'));}
if(T.kit){kit=utilityKit(c);if(kit&&kit.cost){cost+=kit.cost;parts.push(tr('ops.tpl_kit'));}}}finally{delete S.pops[c];}
return {cost,net:net&&net.id,ix,kit:!!(kit&&kit.cost),parts};}

View file

@ -1,10 +1,14 @@
/* ---------- The standard POP (#240) ----------
Big networks run one design everywhere. A new POP gets the standard routers at once, while the box is still idle
(no maintenance window): the model if it is unlocked and affordable, then the extra routers as cash allows. */
function popStdApply(city){const d=S.popStd,p=S.pops[city];if(!d||!p||pzOn())return;let miss=false;
// What the standard adds to a fresh POP, priced the way popStdApply pays for it, so it can be on the button (#261).
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<d.rt;n++)cost+=routerCost(g,n);
const mo=(d.rt-1)*ROUTER_MO+cageMo(d.rt)+d.rt*RG[g].mo-RG[0].mo;return cost||mo?{cost,mo,g,rt:d.rt}:null;}
function popStdApply(city){const d=S.popStd,p=S.pops[city];if(!d||!p||pzOn())return;let miss=false;const c0=S.cash;
if(d.g!==(p.rgen||0)){if(techOk('rg',d.g,RG[d.g].lvl)&&S.cash>=swapCost(city,d.g)){spend(swapCost(city,d.g));p.rgen=d.g;}else miss=true;}
while((p.routers||1)<d.rt){const k=routerCost(p.rgen||0,p.routers||1);if(S.cash<k){miss=true;break;}spend(k);p.routers=(p.routers||1)+1;}
toast(miss?tr('pop_std.not_all_of_the_standard',{city:CITY[city].name}):tr('pop_std.city_gets_the_standard_n',{city:CITY[city].name,n:p.routers||1,model:esc(RG[p.rgen||0].n)}),miss?'bad':'good');}
toast(miss?tr('pop_std.not_all_of_the_standard',{city:CITY[city].name}):tr('pop_std.city_gets_the_standard_cost',{city:CITY[city].name,n:p.routers||1,model:esc(RG[p.rgen||0].n),cost:fmt$(c0-S.cash)}),miss?'bad':'good');}
// The line in a POP's router section: the standard, and a button to make this POP's routers the standard.
function popStdHtml(c){const p=S.pops[c];if(!p||pzOn())return '';const d=S.popStd,same=d&&d.g===(p.rgen||0)&&d.rt===(p.routers||1);
return `<div class="kv"><span>${tr('pop_std.standard_for_new_pops')}</span><b>${d?`${d.rt} × ${esc(RG[d.g].n)}`:tr('pop_std.none')}</b></div><div class="btns">${same?'':btn(tr('pop_std.make_this_the_standard'),'popStdSet',{city:c},'ghost sm')}${d?btn(tr('pop_std.clear'),'popStdClear',{},'ghost sm'):''}</div>`;}

View file

@ -8,7 +8,7 @@ function cityPanel(c){
if(!p){
h+=`<div class="scroll">${C.note?`<p class="note" style="margin-top:0">${esc(C.note)}</p>`:''}
${C.cn?chinaSection(c):''}${C.cn&&!cnOk()?'':`<section><h3>${tr('city_panel.open_a_pop_here')}</h3><p class="lead">${tr('city_panel.a_pop_point_of_presence_is')}</p>
${C.ru?`<p class="why">${tr('city_panel.includes_the_mandatory_government',{cost:fmt$(RU_BOX),mo:fmt$(RU_BOX_MO)})}</p>`:''}${btn(tr('city_panel.build_pop_cost_mo_mo',{cost:fmt$(popCost(c)),mo:fmt$(popMo(c))}),'buildPop',{city:c},'pink big',S.cash<popCost(c))}
${C.ru?`<p class="why">${tr('city_panel.includes_the_mandatory_government',{cost:fmt$(RU_BOX),mo:fmt$(RU_BOX_MO)})}</p>`:''}${(q=>btn(tr('city_panel.build_pop_cost_mo_mo',{cost:fmt$(popCost(c)+(q?q.cost:0)),mo:fmt$(popMo(c)+(q?q.mo:0))}),'buildPop',{city:c},'pink big',S.cash<popCost(c))+(q?`<p class="note">${tr('pop_std.includes_the_standard_n_model',{n:q.rt,model:esc(RG[q.g].n),cost:fmt$(q.cost),mo:fmt$(q.mo)})}</p>`:''))(popStdQuote())}
<p class="note">${tr('city_panel.or_drag_from_one_of_your')}</p></section>${opsTplHtml(c)}`}`;
h+=offersHere(c);
const trs=NETS.filter(n=>sellsAt(n,c));

View file

@ -2944,6 +2944,7 @@
"ops.tpl_offer":"{name} can open this city in one go: {list}.",
"ops.tpl_open":"Open from template · {cost}",
"ops.tpl_pop":"POP",
"ops.tpl_std":"standard routers",
"ops.tpl_transit":"10G transit",
"ops.tracy":"Tracy",
"ops.tracy_d":"Follows every packet hop by hop. Gets there in the end, with a star or two on the way.",
@ -3082,8 +3083,9 @@
"pnis.their_peering_team_says_us_east":"Their peering team says US East is “capacity constrained”, which is cloud for “no”.",
"pnis.their_team_quotes_m_months":"Their team quotes {m} months",
"pnis.us_east_is_sold_out_until":"US East is sold out until further notice. Further notice is also sold out.",
"pop_std.city_gets_the_standard_n":"{city} gets the standard: {n} × {model}.",
"pop_std.city_gets_the_standard_cost":"{city} gets the standard: {n} × {model} for {cost}.",
"pop_std.clear":"Clear",
"pop_std.includes_the_standard_n_model":"Includes your standard routers: {n} × {model}, {cost} + {mo}/mo. Short on cash, the POP gets what fits.",
"pop_std.make_this_the_standard":"Make this the standard",
"pop_std.new_pops_now_start_with":"New POPs now start with {n} × {model}.",
"pop_std.none":"None",

View file

@ -35,3 +35,29 @@ test('without the cash or the level, a new POP gets what fits; clearing and save
assert.equal(ev('S.popStd'), null, 'old saves have none');
assert.deepEqual(errors, []);
});
test('the price of a new POP includes the standard routers, on the button and in the template (#261)', () => {
const { ev, dom, errors } = load();
const U = g('The Router at the End of the Universe');
ev(start + `;S.pops.fra.rgen=${U};S.pops.fra.routers=4;ACT.popStdSet({city:'fra'})`);
const q = JSON.parse(ev('JSON.stringify(popStdQuote())'));
assert.equal(q.rt, 4);
assert.ok(q.cost > 5e6, 'four of the biggest routers cost millions, not thousands');
ev("selectCity('ams');renderPanel()");
const btnText = dom.window.document.querySelector('[data-act="buildPop"]').textContent;
assert.ok(btnText.includes(ev(`fmt$(popCost('ams')+${q.cost})`)), 'the button shows the whole price: ' + btnText);
assert.match(dom.window.document.getElementById('panelBody').textContent, /Includes your standard routers: 4 ×/);
const cash = ev('S.cash');
ev("ACT.buildPop({city:'ams'})");
assert.equal(cash - ev('S.cash'), ev("popCost('ams')") + q.cost, 'and that is exactly what it costs');
// The one-tap template prices the standard too, so it is all or nothing.
ev("S.ops.hired=true;S.ops.tpl={};");
const t = JSON.parse(ev("JSON.stringify(opsTplQuote('par'))"));
assert.equal(t.cost, ev("popCost('par')") + q.cost);
// A locked model is not quoted: what fits is the plain routers.
ev('S.lvl=1');
assert.equal(ev('popStdQuote().g'), 0);
ev('S.popStd=null');
assert.equal(ev('popStdQuote()'), null);
assert.deepEqual(errors, []);
});