A standard POP: new POPs get the standard router model and count at once (closes #240)
This commit is contained in:
parent
5d7b626519
commit
533532ba32
14 changed files with 97 additions and 2 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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":"<b>40 % Rabatt auf {ix} für 6 Monate.</b><br>Dein Account Manager ist erleichtert. Das Kleingedruckte liest du später.",
|
||||
"pops_transit_ix.after_consulting_with_management_the":"<b>„Nach Rücksprache mit dem Management …“</b><br>Der Preis ist gestiegen. Das Management wurde konsultiert.",
|
||||
|
|
|
|||
|
|
@ -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":"<b>40 % de descuento en {ix} durante 6 meses.</b><br>Tu gestor de cuenta está aliviado. Lee la letra pequeña más tarde.",
|
||||
"pops_transit_ix.after_consulting_with_management_the":"<b>«Tras consultar con la dirección…»</b><br>El precio subió. Se consultó a la dirección.",
|
||||
|
|
|
|||
|
|
@ -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":"<b>40 % de remise sur {ix} pendant 6 mois.</b><br>Ton account manager est soulagé. Lis les petites lignes plus tard.",
|
||||
"pops_transit_ix.after_consulting_with_management_the":"<b>« Après consultation de la direction… »</b><br>Le prix a augmenté. La direction a été consultée.",
|
||||
|
|
|
|||
|
|
@ -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":"<b>40% di sconto su {ix} per 6 mesi.</b><br>Il tuo account manager tira un sospiro di sollievo. Le clausole in piccolo leggile dopo.",
|
||||
"pops_transit_ix.after_consulting_with_management_the":"<b>“Dopo un confronto con il management…”</b><br>Il prezzo è salito. Il management è stato consultato.",
|
||||
|
|
|
|||
|
|
@ -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":"<b>40% de desconto no {ix} por 6 meses.</b><br>Seu account manager respirou aliviado. Leia as letras miúdas depois.",
|
||||
"pops_transit_ix.after_consulting_with_management_the":"<b>“Depois de consultar a diretoria…”</b><br>O preço subiu. A diretoria foi consultada.",
|
||||
|
|
|
|||
|
|
@ -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}};
|
||||
}
|
||||
|
||||
|
|
|
|||
10
src/game/60-features/96-pop-standard.js
Normal file
10
src/game/60-features/96-pop-standard.js
Normal file
|
|
@ -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)<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');}
|
||||
// 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>`;}
|
||||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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();},
|
||||
|
|
|
|||
|
|
@ -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();},
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ function cityPanel(c){
|
|||
${nl>=nc*0.95?`<p class="why">${tr('city_panel.maxed_out_traffic_here_is_being')}</p>`:''}
|
||||
<div class="btns">${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<swapCost(c,Ni)||p.rupDay===S.day)):''}${btn(UI.models?tr('city_panel.hide_other_models'):tr('common.other_models'),'models',{},'ghost sm')}${rt<RMAX?btn(tr('city_panel.add_router_cost_mo_mo',{cost:fmt$(routerCost(g,rt)),mo:fmt$(routerMo(g)+(rt>=RCAGE?CAGE_MO:0))}),'addRouter',{city:c},'',S.cash<routerCost(g,rt)):''}${rt>1?btn(tr('common.remove_one'),'rmRouter',{city:c},'ghost sm'):''}</div>
|
||||
${rt>=RCAGE&&rt<RMAX?`<p class="note">${tr('city_panel.the_standard_cage_holds_n_routers',{n:RCAGE,mo:fmt$(CAGE_MO)})}</p>`:''}${rt>=RMAX?`<p class="note">${tr('city_panel.this_pop_has_the_most_routers',{n:RMAX})}</p>`:''}${rt>RCAGE?`<div class="kv"><span>${tr('city_panel.cage_extension')}</span><b>${fmt$(cageMo(rt))}/mo</b></div>`:''}
|
||||
${popStdHtml(c)}
|
||||
${UI.models?routerModels(c):''}
|
||||
${N||UI.models?`<p class="note">${(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')}</p>`:''}
|
||||
<p class="note">${rt>=2?tr('city_panel.a_crash_here_only_costs_one'):tr('city_panel.one_router_is_a_single_point')}</p></section>
|
||||
|
|
|
|||
|
|
@ -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":"<b>40% off {ix} for 6 months.</b><br>Your account manager is relieved. Read the small print later.",
|
||||
"pops_transit_ix.after_consulting_with_management_the":"<b>\"After consulting with management…\"</b><br>The price went up. Management was consulted.",
|
||||
|
|
|
|||
37
tests/pop-standard.test.js
Normal file
37
tests/pop-standard.test.js
Normal file
|
|
@ -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, []);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue