From 533532ba32919a2547005ce89394899e1ae5c868 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sun, 1 Nov 2026 11:06:46 +0100 Subject: [PATCH] A standard POP: new POPs get the standard router model and count at once (closes #240) --- CHANGELOG.md | 1 + site/i18n/de.js | 7 ++++ site/i18n/es.js | 7 ++++ site/i18n/fr.js | 7 ++++ site/i18n/it.js | 7 ++++ site/i18n/pt.js | 7 ++++ src/game/60-features/80-new-game.js | 2 +- src/game/60-features/96-pop-standard.js | 10 +++++ src/game/80-simulation/50-sanitize.js | 2 + src/game/90-actions/20-pops-transit-ix.js | 2 +- src/game/90-actions/85-routing-and-routers.js | 2 + src/game/93-ui/50-city-panel.js | 1 + src/i18n/en.js | 7 ++++ tests/pop-standard.test.js | 37 +++++++++++++++++++ 14 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 src/game/60-features/96-pop-standard.js create mode 100644 tests/pop-standard.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index a134493..af3ac28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Pick a standard POP: in any POP's Infra tab, make its routers the standard, and every new POP gets that model and number of routers right away, while it is still empty (#240). - Clarovision now peers only over paid PNIs, like the real carrier, and free only with networks at customer level 11 or above (#213). A PNI you already have with it starts paying the fee. - Cache boxes now share router ports through an aggregation switch: one port carries as many 100G boxes as its speed holds, so 32 fit on a 3.2T port (#252). Each site gets its own. - Opening a link from a list now moves the map to it, zoomed so the whole line fits beside the open panel. diff --git a/site/i18n/de.js b/site/i18n/de.js index 5038308..8b31022 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -3066,6 +3066,13 @@ "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.clear":"Entfernen", +"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", +"pop_std.not_all_of_the_standard":"Nicht genug Geld oder Level für den ganzen Standard in {city}: Er bekam, was passte.", +"pop_std.standard_for_new_pops":"Standard für neue POPs", "pops_transit_ix.40_off_for_6_months":"40 % Rabatt für 6 Monate", "pops_transit_ix.40_off_ix_for_6_months":"40 % Rabatt auf {ix} für 6 Monate.
Dein Account Manager ist erleichtert. Das Kleingedruckte liest du später.", "pops_transit_ix.after_consulting_with_management_the":"„Nach Rücksprache mit dem Management …“
Der Preis ist gestiegen. Das Management wurde konsultiert.", diff --git a/site/i18n/es.js b/site/i18n/es.js index f44e735..dfaf397 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -3064,6 +3064,13 @@ "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.clear":"Quitar", +"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", +"pop_std.not_all_of_the_standard":"No hay dinero o nivel para todo el estándar en {city}: recibió lo que cupo.", +"pop_std.standard_for_new_pops":"Estándar para nuevos POP", "pops_transit_ix.40_off_for_6_months":"40 % de descuento durante 6 meses", "pops_transit_ix.40_off_ix_for_6_months":"40 % de descuento en {ix} durante 6 meses.
Tu gestor de cuenta está aliviado. Lee la letra pequeña más tarde.", "pops_transit_ix.after_consulting_with_management_the":"«Tras consultar con la dirección…»
El precio subió. Se consultó a la dirección.", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index b4899e8..2515714 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -3064,6 +3064,13 @@ "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.clear":"Effacer", +"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", +"pop_std.not_all_of_the_standard":"Pas assez d'argent ou de niveau pour tout le standard à {city} : il a reçu ce qui passait.", +"pop_std.standard_for_new_pops":"Standard des nouveaux POP", "pops_transit_ix.40_off_for_6_months":"40 % de remise pendant 6 mois", "pops_transit_ix.40_off_ix_for_6_months":"40 % de remise sur {ix} pendant 6 mois.
Ton account manager est soulagé. Lis les petites lignes plus tard.", "pops_transit_ix.after_consulting_with_management_the":"« Après consultation de la direction… »
Le prix a augmenté. La direction a été consultée.", diff --git a/site/i18n/it.js b/site/i18n/it.js index 804e05a..592238d 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -3064,6 +3064,13 @@ "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.clear":"Rimuovi", +"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", +"pop_std.not_all_of_the_standard":"Non bastano soldi o livello per tutto lo standard a {city}: ha avuto quello che si poteva.", +"pop_std.standard_for_new_pops":"Standard per i nuovi POP", "pops_transit_ix.40_off_for_6_months":"40% di sconto per 6 mesi", "pops_transit_ix.40_off_ix_for_6_months":"40% di sconto su {ix} per 6 mesi.
Il tuo account manager tira un sospiro di sollievo. Le clausole in piccolo leggile dopo.", "pops_transit_ix.after_consulting_with_management_the":"“Dopo un confronto con il management…”
Il prezzo è salito. Il management è stato consultato.", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 48a611f..9601f86 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -3064,6 +3064,13 @@ "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.clear":"Limpar", +"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", +"pop_std.not_all_of_the_standard":"Sem dinheiro ou nível para todo o padrão em {city}: recebeu o que coube.", +"pop_std.standard_for_new_pops":"Padrão para novos POPs", "pops_transit_ix.40_off_for_6_months":"40% de desconto por 6 meses", "pops_transit_ix.40_off_ix_for_6_months":"40% de desconto no {ix} por 6 meses.
Seu account manager respirou aliviado. Leia as letras miúdas depois.", "pops_transit_ix.after_consulting_with_management_the":"“Depois de consultar a diretoria…”
O preço subiu. A diretoria foi consultada.", diff --git a/src/game/60-features/80-new-game.js b/src/game/60-features/80-new-game.js index 21d322e..84ebf7e 100644 --- a/src/game/60-features/80-new-game.js +++ b/src/game/60-features/80-new-game.js @@ -1,6 +1,6 @@ function newGame(name,home){ S={v:1,name,asn:200000+Math.floor(_rand()*15000),home,day:0,cash:START_CASH, ltv:2,t1v:3,auV:1,ops:opsNew(),achP:{},seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{},pairMet:{}, - done:{},inc:[],ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',ddosAuto:{rtbh:false,scrub:true},capDeal:null,core:{lv:0,run:0},won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,ppol:'open',pdesk:null,pdeskRep:null,hw:{},rules:makeRules('oncall'),charter:'global',chartSet:false,demo:{},seatOff:null,solWon:0,monkey:{next:null,on:0}}; + done:{},inc:[],ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',ddosAuto:{rtbh:false,scrub:true},capDeal:null,core:{lv:0,run:0},popStd:null,won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,ppol:'open',pdesk:null,pdeskRep:null,hw:{},rules:makeRules('oncall'),charter:'global',chartSet:false,demo:{},seatOff:null,solWon:0,monkey:{next:null,on:0}}; } diff --git a/src/game/60-features/96-pop-standard.js b/src/game/60-features/96-pop-standard.js new file mode 100644 index 0000000..4f60bb6 --- /dev/null +++ b/src/game/60-features/96-pop-standard.js @@ -0,0 +1,10 @@ +/* ---------- 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; + 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)${tr('pop_std.standard_for_new_pops')}${d?`${d.rt} × ${esc(RG[d.g].n)}`:tr('pop_std.none')}
${same?'':btn(tr('pop_std.make_this_the_standard'),'popStdSet',{city:c},'ghost sm')}${d?btn(tr('pop_std.clear'),'popStdClear',{},'ghost sm'):''}
`;} diff --git a/src/game/80-simulation/50-sanitize.js b/src/game/80-simulation/50-sanitize.js index 860ec0c..d79ff4a 100644 --- a/src/game/80-simulation/50-sanitize.js +++ b/src/game/80-simulation/50-sanitize.js @@ -57,6 +57,8 @@ function sanitize(s){ for(const k of Object.keys(s.confReg))s.confReg[k]=s.confReg[k]==='sp'?'sp':!!s.confReg[k]; if(s.conf){const c=s.conf;if(typeof c!=='object'||!own(REG,c.reg))s.conf=null;else s.conf={until:num(c.until,0),reg:c.reg,name:String(c.name||'').slice(0,40),sp:!!c.sp};} // The backbone's technology: a save from before it with Auto-TE bought keeps the old rules on RSVP-TE (legacy). + // The standard POP build (#240): a router model and how many. + {const d=s.popStd;s.popStd=d&&typeof d==='object'&&Number.isInteger(d.g)&&RG[d.g]?{g:d.g,rt:int(d.rt,1,RMAX,1)}:null;} {const c=s.core&&typeof s.core==='object'?s.core:null,lv=c?int(c.lv,0,4,0):(s.te?2:0);s.core={lv,run:c?int(c.run,0,lv,lv):lv};if(c?c.legacy===true:!!s.te)s.core.legacy=true;if(c&&c.lab===true)s.core.lab=true;if(c&&c.since!==undefined)s.core.since=num(c.since,0);} s.capDeal=s.capDeal&&typeof s.capDeal==='object'&&own(CAP_ROUTES,s.capDeal.c)?{at:num(s.capDeal.at,0),c:s.capDeal.c}:null; s.inc=s.inc.filter(i=>i&&typeof i.type==='string').map(i=>(i.type==='maxpfx'&&(i.type='ixloop'),i.id=sid(i.id),i.until=num(i.until,s.day),i.cost=num(i.cost,0),i.msg=String(i.msg||'').slice(0,400),i.fix=i.fix==null?undefined:String(i.fix).slice(0,60),i)); diff --git a/src/game/90-actions/20-pops-transit-ix.js b/src/game/90-actions/20-pops-transit-ix.js index 28a0d31..7dca4e9 100644 --- a/src/game/90-actions/20-pops-transit-ix.js +++ b/src/game/90-actions/20-pops-transit-ix.js @@ -1,5 +1,5 @@ Object.assign(ACT,{ - buildPop:({city})=>{if(S.pops[city]||!cityOn(city))return;const flipNote=CITY[city]&&CITY[city].au;if(cnCity(city)&&!cnOk()){toast(tr('pops_transit_ix.you_need_a_license_first_foreign'),'bad');sfx('err');return;}if(!spend(popCost(city)))return;S.pops[city]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};floater(CITY[city].x,CITY[city].y-30,tr('common.new_pop'),'#FF4F9A');if(flipNote)toast(pick([tr('pops_transit_ix.router_installed_in_city_upside_down',{city:CITY[city].name}),tr('pops_transit_ix.router_installed_in_city_the_vendor',{city:CITY[city].name})]),'good',[],{a:'city',v:city});UI.tab='cust';after();}, + buildPop:({city})=>{if(S.pops[city]||!cityOn(city))return;const flipNote=CITY[city]&&CITY[city].au;if(cnCity(city)&&!cnOk()){toast(tr('pops_transit_ix.you_need_a_license_first_foreign'),'bad');sfx('err');return;}if(!spend(popCost(city)))return;S.pops[city]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};popStdApply(city);floater(CITY[city].x,CITY[city].y-30,tr('common.new_pop'),'#FF4F9A');if(flipNote)toast(pick([tr('pops_transit_ix.router_installed_in_city_upside_down',{city:CITY[city].name}),tr('pops_transit_ix.router_installed_in_city_the_vendor',{city:CITY[city].name})]),'good',[],{a:'city',v:city});UI.tab='cust';after();}, launchBB:({city})=>{const p=S.pops[city];if(!p||p.bb)return;const C=CITY[city];if(!spend(bbCost(city)))return;p.bb={d:bbStart(city)};floater(C.x,C.y-30,tr('common.eyeballs_online'),'#16A866');after();}, ad:({city})=>{const p=S.pops[city];if(!p||!p.bb)return;if(!spend(8000))return;p.boost=S.day+30;floater(CITY[city].x,CITY[city].y-30,tr('common.ad_campaign'),'#FF8A3D');after();}, buyTransit:({city,net,tier})=>{tier=+tier;if(scnRule('noTransit')){toast(tr('pops_transit_ix.no_transit_in_this_scenario_peering'),'bad');sfx('err');return;}if(!S.pops[city]||!NET[net]||!sellsAt(NET[net],city)||!PORT[tier])return;if(!portOk(city,tier)){toast(tr('actions.your_router_can_t_take_a',{port:PORT[tier].n}),'bad');sfx('err');return;}const ex=S.transit.find(t=>t.city===city&&t.net===net);if(ex&&tier<=ex.tier)return;if(!portGate(city,ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(tier)))return;if(!spend(PORT[tier].setup*(ex&&ex.n||1)))return;if(ex)ex.tier=tier;else S.transit.push({id:uid(),city,net,tier,down:0,...(premOnlyAt(NET[net],city)?{premium:true}:{})});toast(tr('pops_transit_ix.net_transit_is_live_in_city',{net:esc(NET[net].name),city:CITY[city].name}),'good');after();}, diff --git a/src/game/90-actions/85-routing-and-routers.js b/src/game/90-actions/85-routing-and-routers.js index 4e77ad9..995c150 100644 --- a/src/game/90-actions/85-routing-and-routers.js +++ b/src/game/90-actions/85-routing-and-routers.js @@ -11,6 +11,8 @@ Object.assign(ACT,{ setRoute:({id,m})=>{if(!own(RT,m))return;const b=S.biz.find(x=>x.id===id);if(b){b.route=m;sfx('click');after();}}, route:({r})=>{UI.route=r;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);}, addParallel:({id})=>{const l=S.links.find(x=>x.id===id);if(l)openLinkModal(l.a,l.b);}, + popStdSet:({city})=>{const p=S.pops[city];if(!p||pzOn())return;S.popStd={g:p.rgen||0,rt:p.routers||1};toast(tr('pop_std.new_pops_now_start_with',{n:S.popStd.rt,model:esc(RG[S.popStd.g].n)}),'good');sfx('click');after();}, + popStdClear:()=>{S.popStd=null;sfx('click');after();}, addRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)>=RMAX)return;if(!spend(routerCost(p.rgen||0,p.routers||1)))return;p.routers=(p.routers||1)+1;floater(CITY[city].x,CITY[city].y-30,tr('common.router_added'),'#FF4F9A');after();}, models:()=>{UI.models=!UI.models;renderPanel();}, rmRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)<=1)return;if(portsUsed(city)>portsMax(city,undefined,p.routers-1)){toast(tr('routing_and_routers.unplug_something_first_used_ports',{used:fmtPorts(portsUsed(city)),max:portsMax(city,undefined,p.routers-1)}),'bad');sfx('err');return;}p.routers--;{const back=tradeIn(p.rgen||0,1);if(back>0){S.cash+=back;toast(tr('routing_and_routers.sold_a_model_on_ebuy_price',{model:esc(RG[p.rgen||0].n),price:fmt$(back)}),'good');}}after();}, diff --git a/src/game/93-ui/50-city-panel.js b/src/game/93-ui/50-city-panel.js index b9c4d1e..dc9c8cd 100644 --- a/src/game/93-ui/50-city-panel.js +++ b/src/game/93-ui/50-city-panel.js @@ -75,6 +75,7 @@ function cityPanel(c){ ${nl>=nc*0.95?`

${tr('city_panel.maxed_out_traffic_here_is_being')}

`:''}
${N?(!techOk('rg',Ni,N.lvl)?demoBtn('rg',Ni,N.lvl,tr('city_panel.model_level_lv',{model:esc(N.n),lv:N.lvl}),'pink'):btn(tr('city_panel.upgrade_to_model_cost_mo_mo',{model:esc(N.n),cost:fmt$(swapCost(c,Ni)),mo:fmt$(N.mo*rt)}),'upRouter',{city:c,g:Ni},'pink',S.cash=RCAGE?CAGE_MO:0))}),'addRouter',{city:c},'',S.cash1?btn(tr('common.remove_one'),'rmRouter',{city:c},'ghost sm'):''}
${rt>=RCAGE&&rt${tr('city_panel.the_standard_cage_holds_n_routers',{n:RCAGE,mo:fmt$(CAGE_MO)})}

`:''}${rt>=RMAX?`

${tr('city_panel.this_pop_has_the_most_routers',{n:RMAX})}

`:''}${rt>RCAGE?`
${tr('city_panel.cage_extension')}${fmt$(cageMo(rt))}/mo
`:''} + ${popStdHtml(c)} ${UI.models?routerModels(c):''} ${N||UI.models?`

${(p.rgen||0)>0?tr('city_panel.prices_include_p_back_for_the',{p:fmt$(tradeIn(p.rgen||0,rt))})+' ':''}${p.rupDay===S.day?tr('city_panel.new_routers_went_in_today_the')+' ':''}${rt>1?tr('city_panel.rolling_upgrade_one_router_at_a'):tr('city_panel.with_one_router_the_upgrade_needs')}

`:''}

${rt>=2?tr('city_panel.a_crash_here_only_costs_one'):tr('city_panel.one_router_is_a_single_point')}

diff --git a/src/i18n/en.js b/src/i18n/en.js index 4efd0fd..2c54fb9 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -3065,6 +3065,13 @@ "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.clear":"Clear", +"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", +"pop_std.not_all_of_the_standard":"Not enough cash or level for the whole standard in {city}: it got what fit.", +"pop_std.standard_for_new_pops":"Standard for new POPs", "pops_transit_ix.40_off_for_6_months":"40% off for 6 months", "pops_transit_ix.40_off_ix_for_6_months":"40% off {ix} for 6 months.
Your account manager is relieved. Read the small print later.", "pops_transit_ix.after_consulting_with_management_the":"\"After consulting with management…\"
The price went up. Management was consulted.", diff --git a/tests/pop-standard.test.js b/tests/pop-standard.test.js new file mode 100644 index 0000000..8ba7621 --- /dev/null +++ b/tests/pop-standard.test.js @@ -0,0 +1,37 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const g = n => `RG.findIndex(r=>r.n===${JSON.stringify(n)})`; +const start = "ACT.start({});S.cash=1e8;S.lvl=13;S.nextFail=1e9;S.nextEvent=1e9"; + +test('a standard POP: new POPs get its router model and count at once, without downtime (#240)', () => { + const { ev, dom, errors } = load(); + ev(start + `;S.pops.fra.rgen=${g('Arrrhipster 7280R')};S.pops.fra.routers=2;selectCity('fra');UI.tab='links';renderPanel()`); + assert.match(dom.window.document.getElementById('panelBody').textContent, /Make this the standard/); + ev("ACT.popStdSet({city:'fra'})"); + assert.deepEqual(JSON.parse(ev('JSON.stringify(S.popStd)')), { g: ev(g('Arrrhipster 7280R')), rt: 2 }); + const cash = ev('S.cash'); + ev("ACT.buildPop({city:'ams'})"); + assert.equal(ev('S.pops.ams.rgen'), ev(g('Arrrhipster 7280R'))); + assert.equal(ev('S.pops.ams.routers'), 2); + assert.ok(ev('S.cash') < cash - ev("popCost('ams')"), 'the routers are paid for'); + assert.equal(ev("S.inc.some(i=>i.type==='maint'&&i.ref==='ams')"), false, 'no maintenance window on an empty POP'); + assert.deepEqual(errors, []); +}); + +test('without the cash or the level, a new POP gets what fits; clearing and saves', () => { + const { ev, errors } = load(); + ev(start + `;S.popStd={g:${g('The Router at the End of the Universe')},rt:3};S.lvl=1;S.cash=1e6`); + ev("ACT.buildPop({city:'ams'})"); + assert.equal(ev('S.pops.ams.rgen||0'), 0, 'the model is locked at level 1'); + ev("ACT.popStdClear()"); + assert.equal(ev('S.popStd'), null); + ev(`S.popStd={g:${g('Disco 8K')},rt:99};S=sanitize(JSON.parse(JSON.stringify(S)))`); + assert.equal(ev('S.popStd.rt'), ev('RMAX'), 'counts are clamped'); + ev("S.popStd={g:999};S=sanitize(JSON.parse(JSON.stringify(S)))"); + assert.equal(ev('S.popStd'), null, 'garbage is dropped'); + ev("delete S.popStd;S=sanitize(JSON.parse(JSON.stringify(S)))"); + assert.equal(ev('S.popStd'), null, 'old saves have none'); + assert.deepEqual(errors, []); +});