A build standard for the whole network, kept by the intern
One sheet sets the target state for every POP, port and fiber: router
model and count, a second building, a generator, LAG members (split over
both buildings), an exchange port wherever there is one, PNIs spread
over the cities that pay, the line system, the fastest optics that reach
and wave sizes. S.popStd keeps its name; an old {g,rt} standard loads
with the same meaning.
One read-only plan prices every job with the game's own cost helpers,
POPs busiest first, then ports, then fiber hottest first. The sheet's
summary, the MCP quote, "Bring everything up now" and the new "Keep to
the build standard" order all use it, so the quote is what the click
spends. The order works a few jobs a shift through the budget and the
cash floor: a second router before a swap on a busy POP, no generator
under a nogen covenant, no De-Kicks, a line system swap only where the
fiber is quiet or a parallel link carries it, one a shift. New POPs get
the POP part of the standard, and the template's kit no longer pays for
it twice. opsMoNow counts generators and second buildings.
This commit is contained in:
parent
647e302f1c
commit
2b48a6ad65
27 changed files with 1153 additions and 61 deletions
|
|
@ -38,6 +38,8 @@ const API_DOMAINS={
|
|||
opsKey:{table:'OPSK',kind:'key'},
|
||||
opsPopKind:{kind:'enum',values:()=>OPS_POP.slice()},
|
||||
opsTplKey:{kind:'enum',values:()=>OPS_TPL.slice()},
|
||||
// The build standard's targets (bstdSet).
|
||||
bstdKey:{kind:'enum',values:()=>BSTD.map(x=>x.k)},
|
||||
// The specialist's offers: a seat on a consortium cable, the charter, a vendor demo.
|
||||
seatPairs:{kind:'enum',values:()=>SEAT_N.slice()},
|
||||
callAmount:{kind:'enum',values:()=>CALL_AMTS.slice()},
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ const API_CMD={
|
|||
opsParam:{args:[['k','opsKey'],['p','string'],['v','string',false]],watch:['ops'],
|
||||
doc:'Step one of a standing order\'s settings to its next value (the provider to prefer, the port size to order, the load ceiling…). With v (a position in the list the sheet shows, 0 first) it picks that value instead, such as the model to standardize routers on.'},
|
||||
opsCap:{args:[['k','opsKey'],['v','string',false]],watch:['ops'],
|
||||
doc:'Step the monthly budget of an order that has one: 10k, 25k, 50k, 100k, 250k, no limit. With v (a position in that list, 0 first) it picks that one.'},
|
||||
doc:'Step the monthly budget of an order that has one: 10k, 50k, 250k, 1M, 5M, no limit (for caches, a cap on the rent it adds: 1k, 2.5k, 5k, 10k, 25k, no limit). With v (a position in that list, 0 first) it picks that one.'},
|
||||
opsFloor:{args:[['v','string',false]],watch:['ops'],
|
||||
doc:'Step the floor under your cash that the intern keeps clear when paying for jobs: 0, 50k, 250k, 1M, 5M. With v (a position in that list, 0 first) it picks that one.'},
|
||||
opsPop:{args:[['k','opsPopKind'],['city','cityId']],watch:['ops'],
|
||||
|
|
@ -376,11 +376,16 @@ const API_CMD={
|
|||
layShip:{args:[['id','entityId']],watch:['links.#id'],
|
||||
quote:a=>{const l=S.links.find(x=>x.id===a.id),q=l&&layQuote(l);return q?{setup:q.cost}:{};},
|
||||
doc:'Book a second lay ship on your own cable before laying starts: it lays from the other end and halves that part of the build.'},
|
||||
/* ---------- standard POPs ---------- */
|
||||
/* ---------- the build standard ---------- */
|
||||
popStdSet:{args:[['city','cityId']],watch:['popStd'],
|
||||
doc:'Make a POP\'s routers the standard: every new POP starts with that model and that number of routers while it is still empty.'},
|
||||
doc:'Make a POP\'s build the standard\'s POP part: its router model, router count, second building and generator. New POPs start with them at once; the other targets are kept.'},
|
||||
popStdClear:{args:[],watch:['popStd'],
|
||||
doc:'Stop setting a standard; new POPs go back to one basic router.'},
|
||||
doc:'Clear the whole build standard; new POPs go back to one basic router.'},
|
||||
bstdSet:{args:[['k','bstdKey'],['v','string',false]],watch:['popStd'],
|
||||
doc:'Set one target of the build standard: g router model, rt routers, site2 second building, gen generator, lag LAG members on transit, IX and PNI ports, split LAGs across both buildings, ix an IX port wherever the city has an exchange, pni PNIs per network in at least that many cities, sys line system, opt fastest optics, wv waves at least that size. Without v it steps to the next value; with v (a position in the list the sheet shows, 0 first, "keep" first) it picks that one.'},
|
||||
bstdApply:{args:[],watch:['pops','transit','pni','ixp','ixn','ixSite','links','spares'],
|
||||
quote:a=>{const q=bstdQuote(false);return {setup:q.cost,monthly:q.mo,blocked:q.held.map(w=>w.split('|').map(c=>CITY[c].name).join('–')+': its line system waits until the fiber is quiet or a parallel link can carry its load for the day it goes dark')};},
|
||||
doc:'Bring everything up to the build standard now, the busiest first, while cash lasts: routers, buildings, generators, LAG members, IX ports, PNIs, line systems, optics and waves. A line-system swap waits unless the fiber is quiet or a parallel link carries its load: such a fiber gets the best optics its line system takes, and the quote lists it under blocked. The quote is the whole bill.'},
|
||||
/* ---------- utilities ---------- */
|
||||
utilityRouteServers:{args:[['city','cityId',false]],watch:['rs'],
|
||||
doc:'Join the route server at every IX you have a port at. One call does what the button does.'},
|
||||
|
|
@ -507,6 +512,7 @@ const API_VIEW={
|
|||
keys:{args:[],doc:'Open the list of keyboard shortcuts (the ? key).'},
|
||||
routingOpen:{args:[],doc:'Open the Routing & DDoS window: the traceroute, backbone, Auto-TE and DDoS settings (the button at the top of the NOC tab).'},
|
||||
opsOpen:{args:[],doc:'Open the Ops sheet: the NOC intern\'s mood, weekly shift report and standing orders.'},
|
||||
bstdOpen:{args:[],doc:'Open the build standard sheet: every target, how many POPs, ports and links are below it, what bringing them up costs, and the intern\'s order that keeps them there.'},
|
||||
salesOpen:{args:[],doc:'Open the sales desk sheet: the three kinds of salesperson, who is at the desk and what they cost.'},
|
||||
opsCity:{args:[['v','cityId',false]],doc:'Show one POP\'s standing-order exceptions in the Ops sheet.'},
|
||||
utilities:{args:[['city','cityId',false]],doc:'Open the utilities sheet: route servers, the redundancy kit, caches and bulk peering, for one city or the whole network.'},
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ const API_STATE_DOC={
|
|||
ops:{type:'map',doc:'The NOC intern: who is hired, each standing order\'s on/off switch and settings (network work only: deals belong to the sales desk, slAuto), the monthly budget and what it spent, per-POP exceptions, the new-POP template and the weekly log.'},
|
||||
core:{type:'map',doc:'Your backbone technology: lv bought, the level it runs at, the interop lab.'},
|
||||
ddosAuto:{type:'map',doc:'The NOC\'s auto-mitigation switches: rtbh and scrub.'},
|
||||
popStd:{type:'map',doc:'The standard POP: router model and count new POPs start with, or null for none.'},
|
||||
popStd:{type:'map',doc:'The build standard, or null for none. g router model (an RG index), rt routers, then only the targets that are set: site2, gen (true), lag (2 or 4 members), split, ix (true), pni (2 or 3 cities per network), sys (roadm, cl), opt (fast), wv (an LT index). New POPs get g, rt, site2 and gen at once; the std standing order and bstdApply bring the rest up.'},
|
||||
demo:{type:'map',doc:'Vendor demo units on order, by "kind:id" → ready day.'},
|
||||
seatOff:{type:'map',doc:'The pending consortium-cable seat offer: landings, km, name, expiry day.'},
|
||||
monkey:{type:'map',doc:'The chaos monkey: next visit day, whether it is in your network now, days left, whether anyone noticed.'},
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ function apiControls(root,player){
|
|||
const o=b.dataset.act?{label:apiText(b,200).replace(/\n/g,' ')||b.getAttribute('aria-label')||b.dataset.act,act:b.dataset.act,args:apiParse(b.dataset.args),disabled:!!b.disabled}
|
||||
// A list the game acts on when its value changes (the change handler in 96-map/95-clicks.js): click it with a value.
|
||||
:{label:b.getAttribute('aria-label')||(b.closest('label')&&apiText(b.closest('label'),120).split('\n')[0])||b.dataset.chg,
|
||||
select:b.dataset.chg,value:b.value,options:[...b.options].map(o=>({value:o.value,label:o.textContent.trim()})),disabled:!!b.disabled};
|
||||
select:b.dataset.chg,args:apiParse(b.dataset.args),value:b.value,options:[...b.options].map(o=>({value:o.value,label:o.textContent.trim()})),disabled:!!b.disabled};
|
||||
if(player)o.player=true;
|
||||
out.push(o);}
|
||||
return out;}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,8 @@ function apiClick(n,value){
|
|||
if(!b)apiFail(`No button ${n} on the last screen. Call screen first.`);
|
||||
if(b.disabled)apiFail(`"${b.label}" is greyed out.`);
|
||||
if(b.player&&apiPlayerWin())apiFail(`"${b.label}" is in a window the player opened: it is theirs to press.`);
|
||||
const name=b.select||b.act,args=b.select?{v:value===undefined?undefined:String(value)}:b.args;
|
||||
// A list sends its own arguments with the value picked, as the page's change handler does (96-map/95-clicks.js).
|
||||
const name=b.select||b.act,args=b.select?{...(b.args||{}),v:value===undefined?undefined:String(value)}:b.args;
|
||||
if(b.select&&!b.options.some(o=>o.value===args.v))apiFail(`"${b.label}" is a list: click it with a value, one of ${b.options.map(o=>JSON.stringify(o.value)).join(', ')}.`);
|
||||
const kind=apiAllowed(name,`"${b.label}" runs ${name}, which is not an action.`);
|
||||
if(kind==='game'){const w=apiWaiting(name);if(w)return {clicked:b.label,...w};}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ const RCAGE=6,CAGE_MUL=1.5,CAGE_MO=2000;
|
|||
const routerCost=(g,rt)=>Math.round((ROUTER_COST+RG[g].cost*0.8)*((rt||1)>=RCAGE?CAGE_MUL:1)*hwMul('rt')*techMul(RG[g].lvl));
|
||||
const routerMo=g=>ROUTER_MO+RG[g].mo,cageMo=rt=>Math.max(0,(rt||1)-RCAGE)*CAGE_MO;
|
||||
// Old routers go on eBuy when you swap models or remove one (#82), like spare optics (#45). Chassis age faster.
|
||||
const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCost=(c,g)=>{const p=S.pops[c],rt=p.routers||1;return Math.max(0,Math.round(RG[g].cost*rt*hwMul('rt')*techMul(RG[g].lvl))-tradeIn(p.rgen||0,rt));};
|
||||
// swapCostOf: the same price for a POP on model old with rt routers (the build standard plans a few steps ahead).
|
||||
const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCostOf=(g,old,rt)=>Math.max(0,Math.round(RG[g].cost*rt*hwMul('rt')*techMul(RG[g].lvl))-tradeIn(old,rt)),swapCost=(c,g)=>{const p=S.pops[c];return swapCostOf(g,p.rgen||0,p.routers||1);};
|
||||
const RMAX=16;
|
||||
// The plain, badge-less model of each class is the default upgrade path; the others are side-grades.
|
||||
const mainRG=k=>RG.findIndex(r=>r.cls===k&&!r.badge);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ const OPS=[
|
|||
{k:'routers',i:'🧠',pop:1,cap:250000,t:N_('ops.o_routers'),d:N_('ops.o_routers_desc'),p:{at:{d:80,v:[60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'},how:{d:'auto',v:['auto','add','swap'],l:N_('ops.p_how'),f:v=>tr({auto:N_('ops.how_auto'),add:N_('ops.how_add'),swap:N_('ops.how_swap')}[v])},
|
||||
// A model to standardize on: every POP on a smaller one is swapped to it, busiest first, within the budget.
|
||||
model:{d:'next',ok:v=>v==='next'||(Number.isInteger(v)&&!!RG[v]),l:N_('ops.p_model'),f:v=>v==='next'?tr('ops.model_next'):RG[v].n}}},
|
||||
// The build standard (96-pop-standard.js): its targets are set in their own sheet, so here it has only the budget.
|
||||
{k:'std',i:'📐',pop:1,cap:250000,t:N_('ops.o_std'),d:N_('ops.o_std_d'),p:{}},
|
||||
{k:'caches',i:'📦',pop:1,cap:5000,mo:1,t:N_('ops.o_caches'),d:N_('ops.o_caches_d'),p:{g:{d:5,v:[1,5,10,25,50],l:N_('ops.p_g'),f:v=>fmtG(v)}}},
|
||||
{k:'ix',i:'🔀',t:N_('ops.o_ix'),d:N_('ops.o_ix_d'),p:{}},
|
||||
{k:'pni',i:'🤝',pop:1,cap:50000,t:N_('ops.o_pni'),d:N_('ops.o_pni_d'),p:{g:{d:25,v:[5,10,25,50,100],l:N_('ops.p_g'),f:v=>fmtG(v)},tier:{d:0,v:[0,1,2],l:N_('ops.p_tier'),f:v=>tr('ops.at_least_port',{port:PORT[v].n})},paid:{d:false,v:[false,true],l:N_('ops.p_paid'),f:v=>v?tr('common.on'):tr('common.off')}}},
|
||||
|
|
@ -31,7 +33,7 @@ const OPS=[
|
|||
const OPSK=Object.fromEntries(OPS.map(o=>[o.k,o])),OPS_POP=OPS.filter(o=>o.pop).map(o=>o.k);
|
||||
const OPS_TPL=['bb','transit','ix','kit'];
|
||||
// What the shift log can say. One line per day: "{name} did this, that and the other."
|
||||
const OPS_SAY={transit:N_('ops.l_transit'),ports:N_('ops.l_ports'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),optup:N_('ops.l_optup'),optswap:N_('ops.l_optswap'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')};
|
||||
const OPS_SAY={std:N_('ops.l_std'),transit:N_('ops.l_transit'),ports:N_('ops.l_ports'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),optup:N_('ops.l_optup'),optswap:N_('ops.l_optswap'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')};
|
||||
// Fat fingers: rare, visible, harmless. Only the LAG one costs anything, and only a little.
|
||||
const OPS_FF=[N_('ops.ff_desc'),N_('ops.ff_hostname'),N_('ops.ff_typo'),N_('ops.ff_lag'),N_('ops.ff_ping')];
|
||||
const OPS_FF_RATE={oncall:1/150,bgp:1/60};
|
||||
|
|
@ -103,7 +105,7 @@ const opsPaid=e=>e.up||e.mo?' '+tr('ops.l_paid',{cost:fmt$(e.up||0),mo:opsMo$(e.
|
|||
// What the network costs every month before traffic: what a job adds to the bill (ports, routers, rent, links, cache boxes).
|
||||
// PNIs count from the day they are ordered, at the size they are going to be.
|
||||
function opsMoNow(){let m=cachesMo();
|
||||
for(const c in S.pops){const p=S.pops[c],rt=p.routers||1;m+=(rt-1)*ROUTER_MO+cageMo(rt)+rt*RG[p.rgen||0].mo;}
|
||||
for(const c in S.pops){const p=S.pops[c],rt=p.routers||1;m+=(rt-1)*ROUTER_MO+cageMo(rt)+rt*RG[p.rgen||0].mo+(p.gen?GEN_MO:0)+(p.site2?SITE2_MO:0);}
|
||||
for(const l of S.links)m+=(l.mo||0)+(l.kind==='df'?(l.spares?Math.round(150+(l.ch||[]).length*80):0)+(l.regen|0)*REGEN_MO:0);
|
||||
for(const t of S.transit)m+=transitMo(t,0);
|
||||
for(const p of S.pni){const q=p.up||p,N=NET[p.net];m+=(q.g1?Math.round(PORT[0].pni/2):PORT[q.tier].pni)*(q.n||1)+(N.pol==='paid'&&!paidFree(N)?N.paidFee:0);}
|
||||
|
|
@ -137,6 +139,8 @@ const cheapestTransit=c=>NETS.filter(n=>sellsAt(n,c)&&opsTransitOk(n,c)).sort((a
|
|||
const opsProv=c=>{const pv=opsP('transit','prov'),n=isNet(pv)?NET[pv]:null;return n&&sellsAt(n,c)&&opsTransitOk(n,c)?n:cheapestTransit(c);};
|
||||
// The orders. Each takes the shift and does its jobs through the player's own actions.
|
||||
const OPS_RUN={
|
||||
// Bring POPs, ports and fiber up to the build standard: the busiest first, a few jobs a shift (96-pop-standard.js).
|
||||
std(X){bstdShift(X);},
|
||||
repair(X){purgeInc();for(const i of S.inc.slice())if(i.type!=='ddos'&&i.until>S.day&&i.cost>0&&!(i.slow&&i.rushed)&&X.can('repair',i.cost)&&X.pay('repair',()=>ACT.fixInc({id:i.id})))X.did('repair');},
|
||||
routers(X){const at=opsP('routers','at')/100,how=opsP('routers','how'),m=opsP('routers','model'),fix=m!=='next',
|
||||
load=c=>Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));
|
||||
|
|
@ -206,7 +210,9 @@ const OPS_RUN={
|
|||
// More of what is already lit, or else the most Gbps per dollar that reaches. Told to go big (#262), the intern
|
||||
// picks the most Gbps per channel it can afford for a new kind of optic, but never swaps what is already lit.
|
||||
const fit=Object.keys(OPT).filter(o=>!chWhy(l,o)),cheap=fit.slice().sort((a,b)=>gpd(b,l)-gpd(a,l)),
|
||||
o=fit.filter(o=>cnt[o]).sort((a,b)=>cnt[b]-cnt[a])[0]||(big&&fit.slice().sort((a,b)=>optG(b,l)-optG(a,l)||gpd(b,l)-gpd(a,l)).find(o=>X.can('optics',opticCountCost(l,o,1),0,true)))||cheap[0];if(!o)break;
|
||||
// A build standard that wants the fastest optics gets those first, so the two orders never undo each other.
|
||||
fast=bstdFast()&&fit.slice().sort((a,b)=>optG(b,l)-optG(a,l)||optCost(a)-optCost(b)).find(o=>X.can('optics',opticCountCost(l,o,1),0,true)),
|
||||
o=fast||fit.filter(o=>cnt[o]).sort((a,b)=>cnt[b]-cnt[a])[0]||(big&&fit.slice().sort((a,b)=>optG(b,l)-optG(a,l)||gpd(b,l)-gpd(a,l)).find(o=>X.can('optics',opticCountCost(l,o,1),0,true)))||cheap[0];if(!o)break;
|
||||
const n=(cnt[o]||0)+1,cost=opticCountCost(l,o,n),before=(l.ch||[]).length;if(!X.can('optics',cost))break;
|
||||
X.pay('optics',()=>{ACT.setChCount({id:l.id,o,n});return (l.ch||[]).length>before;});if((l.ch||[]).length<=before)break;
|
||||
cap+=optG(o,l);X.did('optics',l.a+'|'+l.b);}}},
|
||||
|
|
@ -253,15 +259,10 @@ const OPS_RUN={
|
|||
for(const q of b.orders.filter(q=>opsHere('pni',q.city)&&loc(q)>=g&&(paid||NET[q.net].pol!=='paid'||paidFree(NET[q.net]))).sort((a,b)=>loc(b)-loc(a))){
|
||||
if(!X.can('pni',q.cost))break;if(X.pay('pni',()=>{if(!spend(q.cost))return false;pniPlace(q);return true;}))X.did('pni',q.city+' '+q.net);}},
|
||||
// Hand back smaller waves once a bigger link between the same cities carries the pair with a quarter to spare (#102).
|
||||
decom(X){const keep=opsP('decom','keep'),by=new Map();for(const l of S.links)if(l.kind!=='vxc'){const k=edgeKey(l);(by.get(k)||by.set(k,[]).get(k)).push(l);}
|
||||
decom(X){const by=new Map();for(const l of S.links)if(l.kind!=='vxc'){const k=edgeKey(l);(by.get(k)||by.set(k,[]).get(k)).push(l);}
|
||||
// Loads must include what this shift already did (a customer just signed, a repair): recompute first, if anything could go.
|
||||
if(X.dirty&&[...by.values()].some(ls=>ls.length>1&&ls.some(l=>l.kind==='wave'))){compute();X.dirty=false;}
|
||||
for(const ls of by.values()){if(ls.length<2)continue;const live=ls.filter(l=>!linkDown(l)),big=live.reduce((a,l)=>!a||capOf(l)>capOf(a)?l:a,null);if(!big)continue;
|
||||
let cap=live.reduce((a,l)=>a+capOf(l),0);const load=ls.reduce((a,l)=>a+((R.load&&R.load[l.id])||0),0);
|
||||
const small=live.filter(l=>l!==big&&l.kind==='wave'&&!l.standby&&!l.premium&&capOf(l)<capOf(big)&&!S.biz.some(b=>b.link===l.id)).sort((a,b)=>capOf(b)-capOf(a));
|
||||
// The spare is there for when the big link's trench is cut, so it has to live in another trench.
|
||||
if(keep&&small.length){const tr=l=>l.trench||l.id,i=small.findIndex(l=>tr(l)!==tr(big));small.splice(Math.max(0,i),1);}
|
||||
for(const l of small.reverse()){if(cap-capOf(l)<load*1.25)break;if(!opsDecomSafe(l))continue;cap-=capOf(l);UI.confirm=l.id;X.pay('decom',()=>ACT.rmLink({id:l.id}));if(!S.links.includes(l))X.did('decom',l.a+'|'+l.b);}}},
|
||||
for(const ls of by.values())for(const l of opsDecomPick(ls)){UI.confirm=l.id;X.pay('decom',()=>ACT.rmLink({id:l.id}));if(!S.links.includes(l))X.did('decom',l.a+'|'+l.b);}},
|
||||
};
|
||||
// Line system swaps per shift, and how many fibers a shift may test for one: each test routes the whole network once,
|
||||
// so a shift costs at most one routing more, and only on a night with a fiber to try. A fiber that failed the test is not tested again for a week
|
||||
|
|
@ -276,11 +277,21 @@ function opsDarkOk(l,X){if(S.biz.some(b=>b.link===l.id)||!opsAround(l))return fa
|
|||
const R0=R,e0=l.eqDown,s0=R0.served,L0=R0.l2||{};
|
||||
try{l.eqDown=S.day+1;compute();return R.served>=s0-1e-6*Math.max(1,s0)&&Object.keys(L0).every(id=>(R.l2[id]||0)>=L0[id]-1e-6);}
|
||||
finally{if(e0===undefined)delete l.eqDown;else l.eqDown=e0;R=R0;}}
|
||||
// A wave can carry a promise: diverse paths, no subsea, a latency budget. Try the network without it first.
|
||||
function opsDecomSafe(l){const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>k==='diverse'||k==='sharks'||k==='lat')&&b.city2);if(!bz.length)return true;
|
||||
// The waves decom hands back on one city pair (ls: every link between them): the smaller ones the rest carry with 25% to
|
||||
// spare, smallest first, less the spare it keeps. cf: each link's capacity (the build standard asks with the sizes its
|
||||
// wave upgrades will give, so it never upgrades one that goes back).
|
||||
function opsDecomPick(ls,cf=capOf){if(!ls||ls.length<2)return [];const live=ls.filter(l=>!linkDown(l)),big=live.reduce((a,l)=>!a||cf(l)>cf(a)?l:a,null),out=[];if(!big)return out;
|
||||
let cap=live.reduce((a,l)=>a+cf(l),0);const load=ls.reduce((a,l)=>a+((R.load&&R.load[l.id])||0),0);
|
||||
const small=live.filter(l=>l!==big&&l.kind==='wave'&&!l.standby&&!l.premium&&cf(l)<cf(big)&&!S.biz.some(b=>b.link===l.id)).sort((a,b)=>cf(b)-cf(a));
|
||||
// The spare is there for when the big link's trench is cut, so it has to live in another trench.
|
||||
if(opsP('decom','keep')&&small.length){const tr=l=>l.trench||l.id,i=small.findIndex(l=>tr(l)!==tr(big));small.splice(Math.max(0,i),1);}
|
||||
for(const l of small.reverse()){if(cap-cf(l)<load*1.25)break;if(!opsDecomSafe(l,out))continue;cap-=cf(l);out.push(l);}
|
||||
return out;}
|
||||
// A wave can carry a promise: diverse paths, no subsea, a latency budget. Try the network without it (and gone) first.
|
||||
function opsDecomSafe(l,gone=[]){const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>k==='diverse'||k==='sharks'||k==='lat')&&b.city2);if(!bz.length)return true;
|
||||
const chk=b=>(b.reqs||[]).every(k=>k==='diverse'?diversePaths(b.city,b.city2):k==='sharks'?terrestrialPath(b.city,b.city2):k==='lat'?bestLat(b.city,b.city2)<=b.latMax:true);
|
||||
const was=bz.filter(chk),all=S.links;S.links=all.filter(x=>x!==l);try{return was.every(chk);}finally{S.links=all;}}
|
||||
const OPS_ORDER=['repair','routers','transit','ports','optup','optics','caches','ix','pni','decom'];
|
||||
const was=bz.filter(chk),all=S.links;S.links=all.filter(x=>x!==l&&!gone.includes(x));try{return was.every(chk);}finally{S.links=all;}}
|
||||
const OPS_ORDER=['repair','std','routers','transit','ports','optup','optics','caches','ix','pni','decom'];
|
||||
// The shift: once per game day from dayTick, after outages and events have had their turn.
|
||||
function opsDay(d){if(!opsHired())return;const O=S.ops,m=monthIdx(d);if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;O.addMo={};}
|
||||
// A new week: last week's tally becomes the shift report, and the one NOC notice of the week.
|
||||
|
|
@ -306,8 +317,9 @@ function opsTplQuote(c){if(!S||S.pops[c]||!cityOn(c)||(cnCity(c)&&!cnOk()))retur
|
|||
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.
|
||||
// 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};
|
||||
// The standard's building and generator too, so the kit only prices what the standard leaves out: nothing twice.
|
||||
const sq=popStdQuote();if(sq){cost+=sq.cost;parts.push(sq.site2||sq.gen?tr('ops.tpl_bstd'):tr('ops.tpl_std'));}
|
||||
S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:sq?sq.rt:1,gen:!!(sq&&sq.gen),rgen:sq?sq.g:0,...(sq&&sq.site2?{site2:true}:{})};
|
||||
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};}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,207 @@
|
|||
/* ---------- 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. */
|
||||
/* ---------- The build standard (#240, grown into a target state for every POP, port and fiber) ----------
|
||||
Big networks run one design everywhere. The standard says what every POP, port and fiber should have: the router
|
||||
model and count, a second building and a generator, LAGs, an exchange port, PNIs spread over cities, the line
|
||||
system, the optics and the waves. A new POP gets its POP part at once, while the box is still idle (no maintenance
|
||||
window). The rest is brought up by the intern's "Keep to the build standard" order, or in one tap from the sheet. */
|
||||
// Every target, with the values its list offers ("keep" first: no target) and its default. Saved sparse: a target left
|
||||
// at its default is not in the save, so an old {g, rt} standard is exactly the routers it always was.
|
||||
const BSTD=[
|
||||
{k:'g',grp:'pop',l:N_('bstd.l_model'),d:'keep',v:()=>['keep',...RG.map((r,i)=>i).sort((a,b)=>RG[a].cls-RG[b].cls||RG[a].cap-RG[b].cap||a-b)],ok:v=>v==='keep'||(Number.isInteger(v)&&!!RG[v])},
|
||||
{k:'rt',grp:'pop',l:N_('common.routers'),d:1,v:()=>[1,2,3,4,6,8,12,16],ok:v=>Number.isInteger(v)&&v>=1&&v<=RMAX},
|
||||
{k:'site2',grp:'pop',l:N_('bstd.l_site2'),d:false,v:()=>[false,true]},
|
||||
{k:'gen',grp:'pop',l:N_('common.backup_generator'),d:false,v:()=>[false,true]},
|
||||
{k:'lag',grp:'port',l:N_('bstd.l_lag'),d:1,v:()=>[1,2,4]},
|
||||
{k:'split',grp:'port',l:N_('bstd.l_split'),d:false,v:()=>[false,true]},
|
||||
{k:'ix',grp:'port',l:N_('bstd.l_ix'),d:false,v:()=>[false,true]},
|
||||
{k:'pni',grp:'port',l:N_('bstd.l_pni'),d:0,v:()=>[0,2,3]},
|
||||
{k:'sys',grp:'fiber',l:N_('common.line_system'),d:'keep',v:()=>['keep','roadm','cl']},
|
||||
{k:'opt',grp:'fiber',l:N_('common.optics'),d:'keep',v:()=>['keep','fast']},
|
||||
{k:'wv',grp:'fiber',l:N_('common.waves'),d:'keep',v:()=>['keep',...LT.map((x,i)=>i).filter(i=>i>0&&waveShown(i))],ok:v=>v==='keep'||(Number.isInteger(v)&&v>0&&!!LT[v])},
|
||||
];
|
||||
const BSTDK=Object.fromEntries(BSTD.map(x=>[x.k,x])),BSTD_MAX=16,BSTD_SYS={lite:0,roadm:1,cl:2};
|
||||
const bstdOk=(x,v)=>x.ok?x.ok(v):x.v().includes(v);
|
||||
// The whole standard, every target filled in. d: a saved one (untrusted: anything odd reads as "keep").
|
||||
function bstd(d=S&&S.popStd){const o={},ob=d&&typeof d==='object'&&!Array.isArray(d)?d:{};
|
||||
for(const x of BSTD){const v=ob[x.k];o[x.k]=x.k==='rt'?(own(ob,'rt')?int(v,1,RMAX,1):1):own(ob,x.k)&&bstdOk(x,v)?v:x.d;}return o;}
|
||||
// Back to the saved form: the model and router count, and any other target that is not "keep". Nothing set: null.
|
||||
function bstdPut(o){const d={};for(const x of BSTD)if(x.k==='rt'||o[x.k]!==x.d)d[x.k]=o[x.k];return Object.keys(d).length>1||d.rt>1?d:null;}
|
||||
function popStdSanitize(s){s.popStd=s.popStd&&typeof s.popStd==='object'&&!Array.isArray(s.popStd)?bstdPut(bstd(s.popStd)):null;}
|
||||
// A bank that forbids generators (Stormy Weather's covenant): the standard never installs one while that loan runs.
|
||||
const bstdNoGen=()=>(S.loans||[]).some(l=>(l.covs||[]).includes('nogen'));
|
||||
// The model a POP should get: the standard's if you can buy it, else the best main-line model that is unlocked and no
|
||||
// bigger. Never a step down, never one that does not fit, and never one that would drop a POP out of the backbone core.
|
||||
// c: an existing POP, or null for a new, empty one. -1: nothing to do. A vendor's demo unit (at its markup) only ever
|
||||
// goes into a new POP, as before: swapping every POP onto one is the player's call, not the intern's. A new POP takes the
|
||||
// model as chosen, even one smaller than the basic router (the Mikrowtik CCR has more ports): nothing is replaced there.
|
||||
function bstdModel(g,c){if(g==='keep'||!RG[g])return -1;const p=c&&S.pops[c],cur=p?p.rgen||0:0,core=!!p&&coreRun()>0&&inCore(c);
|
||||
const ok=i=>i>=0&&RG[i].cap<=RG[g].cap&&(!p||(RG[i].cap>RG[cur].cap&&!modelFits(c,i)&&(!core||rgCore(i,coreRun()))));
|
||||
if((p?rgOpen(g):techOk('rg',g,RG[g].lvl))&&ok(g))return g;let b=-1;
|
||||
for(let k=0;k<=4;k++){const i=mainRG(k);if(i!==g&&rgOpen(i)&&ok(i)&&(b<0||RG[i].cap>RG[b].cap))b=i;}return b;}
|
||||
// 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;}
|
||||
// A new POP's setup with the standard's routers, for every way a POP gets built (links, cables, seats).
|
||||
function popStdQuote(){if(!S||!S.popStd||pzOn())return null;const D=bstd(),m=bstdModel(D.g,null),g=m>0?m:0,rt=D.rt;
|
||||
let cost=g?swapCostOf(g,0,1):0;for(let n=1;n<rt;n++)cost+=routerCost(g,n);
|
||||
let mo=(rt-1)*ROUTER_MO+cageMo(rt)+rt*RG[g].mo-RG[0].mo;const site2=D.site2,gen=D.gen&&!bstdNoGen();
|
||||
if(site2){cost+=SITE2_COST;mo+=SITE2_MO;}if(gen){cost+=GEN_COST;mo+=GEN_MO;}
|
||||
return cost||mo?{cost,mo,g,rt,site2,gen}:null;}
|
||||
// A new POP's setup with the standard, for every way a POP gets built (links, cables, seats).
|
||||
function newPopCost(c){const q=popStdQuote();return popCost(c)+(q?q.cost:0);}
|
||||
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;}
|
||||
function popStdApply(city){const p=S.pops[city];if(!S.popStd||!p||pzOn())return;const D=bstd(),m=bstdModel(D.g,null),c0=S.cash;
|
||||
// Short of the model asked for (it is locked): the best that is unlocked goes in, and the toast says so.
|
||||
let miss=D.g!=='keep'&&RG[m>0?m:0].cap<RG[D.g].cap;
|
||||
if(m>0&&m!==(p.rgen||0)){if(S.cash>=swapCost(city,m)){spend(swapCost(city,m));p.rgen=m;}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;}
|
||||
if(D.site2&&!p.site2){if(S.cash>=SITE2_COST){spend(SITE2_COST);p.site2=true;p.site2Day=S.day;}else miss=true;}
|
||||
if(D.gen&&!p.gen&&!bstdNoGen()){if(S.cash>=GEN_COST){spend(GEN_COST);p.gen=true;}else miss=true;}
|
||||
if(c0===S.cash&&!miss)return;
|
||||
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>`;}
|
||||
// The line in a POP's router section: the standard, a button to edit it, and one to make this POP's build the standard.
|
||||
function popStdHtml(c){const p=S.pops[c];if(!p||pzOn())return '';const D=bstd(),on=!!S.popStd,mine=bstd(bstdPut({...D,g:p.rgen||0,rt:p.routers||1,site2:!!p.site2,gen:!!p.gen})),
|
||||
same=on&&BSTD.every(x=>D[x.k]===mine[x.k]);
|
||||
return `<div class="kv"><span>${tr('bstd.title')}</span><b>${on?esc(bstdLine(D)):tr('pop_std.none')}</b></div><div class="btns">${btn(tr('bstd.edit'),'bstdOpen',{},'sm')}${same?'':btn(tr('pop_std.make_this_the_standard'),'popStdSet',{city:c},'ghost sm')}${on?btn(tr('pop_std.clear'),'popStdClear',{},'ghost sm'):''}</div>`;}
|
||||
// "2 × Absolute Unit 3.2T, second building, generator": the POP part, what a new POP gets.
|
||||
function bstdPopParts(D){const a=[];if(D.g!=='keep'||D.rt>1)a.push(`${D.rt} × ${D.g==='keep'?tr('bstd.any_model'):RG[D.g].n}`);if(D.site2)a.push(tr('bstd.second_building'));if(D.gen)a.push(tr('bstd.generator'));return a;}
|
||||
// The POP part first, then how many other targets.
|
||||
function bstdLine(D){const a=bstdPopParts(D),n=['lag','split','ix','pni','sys','opt','wv'].filter(k=>D[k]!==BSTDK[k].d).length;if(n)a.push(trn('bstd.n_more_targets',n));return a.join(', ')||tr('pop_std.none');}
|
||||
|
||||
/* What the standard still asks for, as jobs in the order they get done: POPs busiest first, then ports hottest first,
|
||||
then fiber and waves hottest first. Pure: it reads S and R and changes nothing. Each job is priced with the game's
|
||||
own helpers on a running copy of the few numbers earlier jobs change (routers, spares), so the sum is what the clicks
|
||||
cost. Jobs that build on each other form a chain (ch: a POP's routers, a port, a fiber): when one cannot be done, the
|
||||
rest of that chain waits. A job that needs another chain's work first (optics only the new router model takes, a split
|
||||
that needs the second building) names that job in dep and waits for it too. Whether a fiber may go dark is settled
|
||||
here, not on the way, so the plan is what the button does and its sum is the quote.
|
||||
intern: only where the intern may work (per-POP exceptions). J.held: fibers whose line system has to wait. */
|
||||
function bstdPlan(intern){const J=[];J.held=[];if(!S||!S.popStd||pzOn())return J;const D=bstd(),here=c=>!intern||opsHere('std',c);
|
||||
const load=c=>Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));
|
||||
const cs=Object.keys(S.pops).filter(here),ld={};for(const c of cs)ld[c]=load(c);cs.sort((a,b)=>ld[b]-ld[a]||(a<b?-1:1));
|
||||
// Router ports: what the POP will have once its own jobs are done, less what pending PNI augments will take.
|
||||
const V={},rmn={},resv=c=>S.pni.reduce((a,p)=>p.up&&p.city===c?a+Math.max(0,PORT_SLOT(p.up.tier)*(p.up.n||1)-PORT_SLOT(p.tier)*(p.n||1)):a,0);
|
||||
const room=c=>rmn[c]??(rmn[c]=(V[c]?portsMax(c,V[c].g,V[c].rt)-portsUsed(c,V[c].g):portsMax(c)-portsUsed(c))-resv(c)+1e-9);
|
||||
const take=(c,n,dry)=>{if(n<=0)return true;if(room(c)<n)return false;if(!dry)rmn[c]-=n;return true;};
|
||||
const job=(grp,k,ch,w,cost,mo,go,x)=>{const j={grp,k,ch,w,cost,mo,go,...x};J.push(j);return j;};
|
||||
for(const c of cs){const p=S.pops[c],ch='p:'+c;let g=p.rgen||0,rt=p.routers||1,sw=null,s2=null;
|
||||
const add=()=>{const g0=g,r0=rt;job('pop','rt',ch,c+' +1',routerCost(g0,r0),routerMo(g0)+cageMo(r0+1)-cageMo(r0),()=>{const n=S.pops[c].routers||1;ACT.addRouter({city:c});return (S.pops[c].routers||1)>n;},{c});rt++;};
|
||||
const m=p.rupDay===S.day?-1:bstdModel(D.g,c);
|
||||
if(m>=0){
|
||||
// One router carrying traffic: a second goes in first, so the swap rolls through with no maintenance window.
|
||||
if(rt===1&&!popIdle(c))add();
|
||||
const old=g,r=rt;sw=job('pop','g',ch,c+' ⇧'+RG[m].pn,swapCostOf(m,old,r),r*(RG[m].mo-RG[old].mo),()=>{ACT.upRouter({city:c,g:m});return (S.pops[c].rgen||0)===m;},{c});g=m;}
|
||||
while(rt<D.rt&&rt<RMAX)add();
|
||||
// A building and a generator do not wait for the routers, nor for each other.
|
||||
if(D.site2&&!p.site2)s2=job('pop','site2','s:'+c,c,SITE2_COST,SITE2_MO,()=>{ACT.addSite({city:c});return !!S.pops[c].site2;},{c});
|
||||
if(D.gen&&!p.gen&&!bstdNoGen())job('pop','gen','e:'+c,c,GEN_COST,GEN_MO,()=>{if(bstdNoGen())return false;ACT.addGen({city:c});return !!S.pops[c].gen;},{c});
|
||||
V[c]={g,rt,site2:!!p.site2||D.site2,sw,s2};}
|
||||
// Ports: LAG members up to the standard, then the members split over both buildings.
|
||||
if(D.lag>1||D.split){const P=[];
|
||||
for(const t of S.transit)if(S.pops[t.city]&&here(t.city))P.push({k:'t',c:t.city,id:t.id,o:t,n:t.n||1,tier:t.tier,u:(R.useT[t.id]||0)/lagCap(PORT[t.tier].g,t.n)});
|
||||
for(const x of S.pni)if(S.pops[x.city]&&here(x.city)&&pniOn(x)&&!x.up)P.push({k:'p',c:x.city,id:x.id,o:x,n:x.n||1,tier:x.tier,u:(R.usePni[x.id]||0)/lagCap(pniG(x),x.n)});
|
||||
for(const x in S.ixp){const c=ixCity(x);if(!S.myIx[x]&&S.pops[c]&&here(c))P.push({k:'ix',c,id:x,n:(S.ixn||{})[x]||1,tier:S.ixp[x],u:(R.useIx[x]||0)/Math.max(1e-9,lagCap(PORT[S.ixp[x]].g,(S.ixn||{})[x]))});}
|
||||
P.sort((a,b)=>b.u-a.u||(a.id<b.id?-1:1));
|
||||
for(const o of P)bstdPort(o,D,V[o.c],take,job);}
|
||||
// An exchange port at every POP in a city with an exchange (not DE-KICKS: they want a sales call first).
|
||||
if(D.ix)for(const c of cs){if(hasIxAt(c))continue;const x=ixIdsIn(c).find(x=>!isDk(x)&&!S.myIx[x]&&!!ixName(x)&&S.ixp[x]===undefined);if(!x||!take(c,PORT_SLOT(0)))continue;
|
||||
const ch='i:'+x,pm=ixPortMo(x,0);job('port','ix',ch,x+' +'+PORT[0].n,pm,pm,()=>{ACT.buyIx({city:x,tier:0});return S.ixp[x]!==undefined;},{c});
|
||||
bstdPort({k:'ix',c,id:x,n:1,tier:0,fresh:true},D,V[c],take,job);}
|
||||
// PNIs spread out: every network you have a PNI with gets one in at least that many cities, where one is worth it.
|
||||
if(D.pni){const by={};for(const p of S.pni)(by[p.net]||(by[p.net]=new Set())).add(p.city);
|
||||
for(const net of Object.keys(by).sort()){let k=D.pni-by[net].size;if(k<=0||!isNet(net))continue;
|
||||
const opts=NET[net].pops.filter(c=>S.pops[c]&&here(c)&&!by[net].has(c)).map(c=>({c,v:pniVal(net,c)})).filter(o=>o.v.worth).sort((a,b)=>b.v.want-a.v.want||(a.c<b.c?-1:1));
|
||||
for(const {c,v} of opts){if(k<=0)break;let q=null;for(let t=Math.max(v.tier,pniMin(net));t>=pniMin(net)&&!q;t--){const x=pniQuote(c,net,t,resv(c));if(x&&!x.why)q=x;}
|
||||
if(!q||!take(c,q.slots))continue;const tier=q.tier;k--;
|
||||
job('port','pni','n:'+net+'@'+c,c+' '+net,q.cost,pniMo({net,tier,n:1},0),()=>{const x=pniQuote(c,net,tier,resv(c));if(!x||x.why||!spend(x.cost))return false;pniPlace(x);return true;},{c});}}}
|
||||
// Fiber and waves, hottest first. A POP excepted from the order keeps its links as they are too.
|
||||
if(D.sys!=='keep'||D.opt!=='keep'||D.wv!=='keep'){const sp={...(S.spares||{})},dk=new Map(),wv=new Map();
|
||||
const ls=S.links.filter(l=>(l.kind==='df'||l.kind==='wave')&&here(l.a)&&here(l.b)&&S.pops[l.a]&&S.pops[l.b]).map(l=>({l,u:(R.load[l.id]||0)/Math.max(1e-9,capOf(l))})).sort((a,b)=>b.u-a.u||(a.l.id<b.l.id?-1:1));
|
||||
// Waves: the size each goes up to. The decom order hands back the smaller waves a pair no longer needs, judged with
|
||||
// the sizes these upgrades give: never pay a month's rent on one it is about to return.
|
||||
if(D.wv!=='keep'){for(const {l} of ls)if(l.kind==='wave'&&l.tier<D.wv)for(let t=D.wv;t>l.tier;t--){if(subWaveWhy(t,l.km,l.sub)||soldOut(l.a,l.b,t,l.cable)||!waveOk(l.a,l.b,t))continue;wv.set(l,t);break;}
|
||||
if(wv.size&&opsHired()&&S.ops.on.decom){const by=new Map(),cf=x=>wv.has(x)?capOf(x)*LT[wv.get(x)].g/LT[x.tier].g:capOf(x);
|
||||
for(const x of S.links)if(x.kind!=='vxc'){const k=edgeKey(x);(by.get(k)||by.set(k,[]).get(k)).push(x);}
|
||||
for(const k of new Set([...wv.keys()].map(edgeKey)))for(const x of opsDecomPick(by.get(k),cf))wv.delete(x);}}
|
||||
for(const {l} of ls){const ch='l:'+l.id;
|
||||
if(l.kind==='wave'){const t=wv.get(l);if(t){const nm=Math.round(waveMo(l.km,l.sub,t)*(l.mult||1));job('fiber','wv',ch,l.a+'|'+l.b,nm,nm-(l.mo||0),()=>{ACT.upLink({id:l.id,tier:t});return l.tier===t;},{l});}continue;}
|
||||
if(l.eqDown>S.day)continue;
|
||||
let sys=l.sys;const lit=l.ready<=S.day,nx=D.sys!=='keep'&&BSTD_SYS[sys]<BSTD_SYS[D.sys]&&sysNext({sys});
|
||||
// A lit fiber goes dark for a day. Busy with nothing parallel to carry it: it keeps its line system for now, and
|
||||
// gets the best optics that one takes. A parallel fiber goes dark first in this plan: it waits for next time.
|
||||
if(nx&&techOk('sys',nx,DF_SYS[nx].lvl)){
|
||||
if(lit&&!bstdDarkOk(l))J.held.push(l);
|
||||
else if(lit&&!bstdDarkOk(l,dk)){J.held.push(l);continue;}
|
||||
else{const busy=lit&&bstdBusy(l);
|
||||
while(BSTD_SYS[sys]<BSTD_SYS[D.sys]){const to=sysNext({sys});if(!to||!techOk('sys',to,DF_SYS[to].lvl))break;
|
||||
const s0=sys;job('fiber','sys',ch,l.a+'|'+l.b,sysCost(to)*(to==='cl'&&l.own?Math.max(1,l.pairs|0):1),0,()=>{if(l.sys!==s0)return false;ACT.upSys({id:l.id});return l.sys===to;},{l,dark:lit,busy});sys=to;}
|
||||
if(lit)dk.set(l.id,busy);}}
|
||||
// Optics for the line system the fiber will have.
|
||||
if(D.opt==='fast'&&lit&&(l.ch||[]).length)J.push(...bstdOptJobs(l,sys,sp,V,take,ch));}}
|
||||
return J;}
|
||||
// One port's LAG members up to the standard, then split over both buildings. A PNI's new member is an augment that
|
||||
// lands later; it remembers to split when it does. o.fresh: a port the plan is buying (the IX job before it).
|
||||
function bstdPort(o,D,v,take,job){const {k,c,id}=o,ch=(o.fresh?'i:':'x:'+k+':')+id;let n=o.n;
|
||||
const site2=v?v.site2:!!(S.pops[c]&&S.pops[c].site2),split=D.split&&site2,
|
||||
// A second building still to buy is a job of its own: the split waits for it, or it would be tried every shift.
|
||||
sx={c,...(v&&v.s2&&!S.pops[c].site2?{dep:[v.s2]}:{})};
|
||||
if(k==='p'){const x=o.o;
|
||||
if(n<D.lag&&n<LAG_MAX&&!msfNope(x.net,c)&&take(c,PORT_SLOT(x.tier))){const n0=n,mo=x.g1?Math.round(PORT[0].pni/2):PORT[x.tier].pni;
|
||||
job('port','lag',ch,c+' +1×'+pniPN(x),1500+PORT[x.tier].setup/2,mo,()=>{if((x.n||1)!==n0||x.up)return false;ACT.lagP({id,d:1});return !!x.up||(x.n||1)>n0;},{c});n++;}
|
||||
if(split&&n>=2&&x.site!=='ab')job('port','split',ch,c,0,0,()=>{if(!S.pops[c].site2)return false;if(x.up){if(x.up.n<2)return false;x.up.site='ab';return true;}
|
||||
if((x.n||1)<2)return false;ACT.siteSet({k:'p',id,s:'ab'});return x.site==='ab';},sx);
|
||||
return;}
|
||||
const t=k==='t'?o.o:null,tier=o.tier,each=k==='t'?PORT[tier].setup:ixPortMo(id,tier);
|
||||
while(n<D.lag&&n<LAG_MAX&&(k!=='t'||portOk(c,tier))&&take(c,PORT_SLOT(tier))){const n0=n,mo=k==='t'?transitMo({...t,n:n0+1},0)-transitMo({...t,n:n0},0):each;
|
||||
job('port','lag',ch,(k==='t'?c:id)+' +1×'+PORT[tier].n,each,mo,k==='t'?()=>{if((t.n||1)!==n0)return false;ACT.lagT({id,d:1});return (t.n||1)>n0;}
|
||||
:()=>{const m=(S.ixn||{})[id]||1;if(m!==n0)return false;ACT.lagIx({city:id,d:1});return ((S.ixn||{})[id]||1)>m;},{c});n++;}
|
||||
const cur=k==='t'?t.site:(S.ixSite||{})[id];
|
||||
if(split&&n>=2&&cur!=='ab')job('port','split',ch,k==='t'?c:id,0,0,()=>{if(!S.pops[c].site2)return false;
|
||||
if(k==='t'){if((t.n||1)<2)return false;ACT.siteSet({k:'t',id,s:'ab'});return t.site==='ab';}
|
||||
if(((S.ixn||{})[id]||1)<2)return false;ACT.siteSet({k:'ix',id,s:'ab'});return (S.ixSite||{})[id]==='ab';},sx);}
|
||||
// Can it see the fastest optic that reaches, ignoring the free-slot check (a swap frees its own slot first)? rg: each
|
||||
// end's router model once the plan's swaps are in, so the optics a new model takes are part of the plan.
|
||||
const bstdOptFits=(l,o,sys,rg)=>{const O=OPT[o];return techOk('opt',o,O.lvl)&&(O.sys!=='roadm'||isRdm(sys))&&!!optMode(o,l)&&[l.a,l.b].every(c=>!S.pops[c]||RG[rg(c)].cls>=O.rg);};
|
||||
const bstdCnt=(l,o)=>(l.ch||[]).filter(k=>k===o).length;
|
||||
// Swap a fiber's slower optics for the fastest that reaches on it, one job per kind, slowest first: the old ones go on
|
||||
// the spares shelf (setChCount), the new ones come from the shelf first. sp: spares as earlier jobs leave them.
|
||||
function bstdOptJobs(l,sys,sp,V,take,ch){const rg=c=>V[c]?V[c].g:(S.pops[c].rgen||0),fits=Object.keys(OPT).filter(o=>bstdOptFits(l,o,sys,rg));if(!fits.length)return [];
|
||||
const best=fits.sort((a,b)=>optG(b,l)-optG(a,l)||optCost(a)-optCost(b))[0],bg=optG(best,l),g=c=>V[c]?V[c].g:undefined,out=[];
|
||||
// Optics only the new router model takes wait for its swap: until it is in, nothing is pulled.
|
||||
const low=c=>!!S.pops[c]&&RG[S.pops[c].rgen||0].cls<OPT[best].rg,dep=[l.a,l.b].filter(low).map(c=>V[c]&&V[c].sw).filter(Boolean);
|
||||
for(const o0 of [...new Set(l.ch||[])].filter(o=>OPT[o]&&optG(o,l)<bg).sort((a,b)=>optG(a,l)-optG(b,l)||(a<b?-1:1))){
|
||||
// A faster optic can take more router ports than the one it replaces: as many as both ends have room for.
|
||||
const per=c=>Math.max(0,chPorts(best,c,g(c))-chPorts(o0,c,g(c)));let k=bstdCnt(l,o0);
|
||||
while(k>0&&!(take(l.a,per(l.a)*k,true)&&take(l.b,per(l.b)*k,true)))k--;if(!k)continue;take(l.a,per(l.a)*k);take(l.b,per(l.b)*k);
|
||||
const r=REGEN_CH*(l.regen|0),c=optCost(best),s=Math.max(0,Math.min(k,sp[best]|0)),cost=s*Math.round(c*r)+(k-s)*Math.round(c*(1+r));
|
||||
sp[best]=(sp[best]|0)-s;sp[o0]=(sp[o0]|0)+k;
|
||||
// price: what it costs when it runs. The plan's price counts on the shelf as the jobs before it leave it; one of those
|
||||
// refused (budget, cash) leaves the shelf emptier, and the budget and the floor must see the real bill.
|
||||
out.push({grp:'fiber',k:'opt',ch,w:l.a+'|'+l.b,cost,mo:0,l,...(dep.length?{dep}:{}),price:()=>opticCountCost(l,best,bstdCnt(l,best)+k),
|
||||
go:()=>{const n0=bstdCnt(l,o0),h0=bstdCnt(l,best);if(n0<k||[l.a,l.b].some(low))return false;
|
||||
ACT.setChCount({id:l.id,o:o0,n:n0-k});if(bstdCnt(l,o0)!==n0-k)return false;ACT.setChCount({id:l.id,o:best,n:h0+k});if(bstdCnt(l,best)===h0+k)return true;
|
||||
// The new ones could not go in (ports, cash): the old optics go back in from the shelf.
|
||||
(l.ch=l.ch||[]).push(...Array(k).fill(o0));S.spares[o0]-=k;return false;}});}
|
||||
return out;}
|
||||
// A line-system swap darkens the fiber for a day: only while it carries little, or its parallel links can take its load.
|
||||
// ex: fibers already going dark today (id → whether they carry traffic): they carry nothing for this one, and one whose
|
||||
// traffic leans on its parallel links keeps them lit.
|
||||
const bstdBusy=l=>((R.load&&R.load[l.id])||0)>Math.max(1,capOf(l)*0.1);
|
||||
function bstdDarkOk(l,ex){const P=pairLinks(l.a,l.b).filter(x=>x!==l);if(ex&&P.some(x=>ex.get(x.id)))return false;if(!bstdBusy(l))return true;
|
||||
return P.filter(x=>!linkDown(x)&&!x.standby&&!(ex&&ex.has(x.id))).reduce((a,x)=>a+Math.max(0,capOf(x)-((R.load&&R.load[x.id])||0)),0)>=((R.load&&R.load[l.id])||0);}
|
||||
// Do the plan's jobs in order. can(j): may it be paid for (budget, floor, cash); pay(j): run it, true if it took.
|
||||
// one: at most one fiber goes dark (the intern's shift); max: at most that many jobs tried, done or failed, so a shift's
|
||||
// work stays bounded whatever goes wrong. Returns what was done.
|
||||
function bstdDo(J,can,pay,one,max=1e9){const stop=new Set(),done=new Set(),dark=new Map();let n=0;
|
||||
for(const j of J){if(n>=max)break;if(stop.has(j.ch))continue;if(j.dep&&!j.dep.every(d=>done.has(d))){stop.add(j.ch);continue;}
|
||||
if(j.dark&&!dark.has(j.l.id)&&((one&&dark.size)||!bstdDarkOk(j.l,dark))){stop.add(j.ch);continue;}
|
||||
if(!can(j)){stop.add(j.ch);continue;}n++;
|
||||
if(!pay(j)){stop.add(j.ch);continue;}
|
||||
if(j.dark)dark.set(j.l.id,!!j.busy);done.add(j);}
|
||||
return [...done];}
|
||||
// What a job costs as it runs (an optics swap is priced again then: see bstdOptJobs).
|
||||
const bstdPrice=j=>j.price?j.price():j.cost;
|
||||
// The sheet's summary and the MCP quote: how much is below the standard, and what bringing it all up costs. The plan is
|
||||
// what the button does, so its sum is the bill. held: the fibers whose line system waits ("fra|ams"); they are below it.
|
||||
function bstdQuote(intern){const J=bstdPlan(intern),P=new Set(),Q=new Set(),L=new Set(J.held.map(l=>l.id));let cost=0,mo=0;
|
||||
for(const j of J){cost+=j.cost;mo+=j.mo;if(j.grp==='pop')P.add(j.c);else if(j.grp==='port')Q.add(j.ch);else L.add(j.l.id);}
|
||||
return {cost:Math.round(cost),mo:Math.round(mo),pops:P.size,ports:Q.size,links:L.size,n:J.length,held:J.held.map(l=>l.a+'|'+l.b)};}
|
||||
// The optics order lights the standard's fastest optics while this order keeps to a standard that wants them.
|
||||
const bstdFast=()=>!!(S.popStd&&opsHired()&&S.ops.on.std&&bstd().opt==='fast');
|
||||
// The intern's shift: the same plan, every job through the budget and the cash floor at what it costs then, a few at a time.
|
||||
function bstdShift(X){bstdDo(bstdPlan(true),j=>X.can('std',bstdPrice(j),j.mo),j=>X.pay('std',()=>j.go())&&(X.did('std',j.w),true),true,BSTD_MAX);}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,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;}
|
||||
// The build standard (#240): a router model and how many, and since then every other target; odd values read as "keep".
|
||||
popStdSanitize(s);
|
||||
{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));
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@ 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();},
|
||||
// This POP's build becomes the standard's POP part: its model, routers, second building and generator.
|
||||
popStdSet:({city})=>{const p=S.pops[city];if(!p||pzOn())return;S.popStd=bstdPut({...bstd(),g:p.rgen||0,rt:p.routers||1,site2:!!p.site2,gen:!!p.gen});
|
||||
toast(tr('pop_std.new_pops_now_start_with_list',{list:esc(bstdPopParts(bstd()).join(', '))}),'good');sfx('click');after();if(bstdShown())bstdModal();},
|
||||
popStdClear:()=>{S.popStd=null;sfx('click');after();if(bstdShown())bstdModal();},
|
||||
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();},
|
||||
|
|
|
|||
14
src/game/90-actions/88-build-standard.js
Normal file
14
src/game/90-actions/88-build-standard.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// The build standard sheet (93-ui/59-build-standard.js): pick a target, or bring everything up to the standard in one go.
|
||||
Object.assign(ACT,{
|
||||
bstdOpen:()=>{if(S&&!pzOn())bstdModal();},
|
||||
// v: a position in the list the sheet shows; without v, the next value (the MCP tools step through a list).
|
||||
bstdSet:({k,v})=>{if(!S||pzOn()||!own(BSTDK,k))return;const D=bstd(),x=opsPick(bstdOpts(k),D[k],v);if(x===undefined||!bstdOk(BSTDK[k],x))return;
|
||||
D[k]=x;S.popStd=bstdPut(D);sfx('click');after();opsRedraw('bstdSet',{k},bstdModal);},
|
||||
// The same jobs, in the same order and through the same gates as the intern's order, while the cash lasts. One
|
||||
// recompute at the end, and one toast: what got done, and what still waits.
|
||||
bstdApply:()=>{if(!S||pzOn()||!S.popStd)return;const J=bstdPlan(false);if(!J.length)return;const c0=S.cash;let n=0;
|
||||
opsQuiet(()=>{n=bstdDo(J,j=>{const c=bstdPrice(j);return c<=0||S.cash>=c;},j=>!!j.go(),false).length;});
|
||||
after();const q=bstdQuote(false),left=q.pops+q.ports+q.links;
|
||||
toast((n?trn('bstd.applied',n,{cost:fmt$(c0-S.cash)}):tr('bstd.applied_none'))+(left?' '+trn('bstd.left',left):''),n?'good':'bad');sfx(n?'build':'err');
|
||||
if(bstdShown())bstdModal();},
|
||||
});
|
||||
|
|
@ -2,8 +2,10 @@
|
|||
const opsCycle=(a,v)=>a[(a.indexOf(v)+1)%a.length];
|
||||
// A pick from a list (v: its position, as the sheet's dropdown sends it), or without v the next value (the MCP tools step).
|
||||
const opsPick=(a,cur,v)=>{if(v===undefined)return opsCycle(a,cur);const i=Number(v);return Number.isInteger(i)&&i>=0&&i<a.length?a[i]:undefined;};
|
||||
// The sheet is drawn again after a pick: keep the keyboard on the list that was used.
|
||||
const opsRedraw=(act,args)=>{opsModal();const j=JSON.stringify(args);for(const el of $('modalCard').querySelectorAll(`[data-chg="${act}"]`))if(el.dataset.args===j){el.focus();break;}};
|
||||
// The sheet is drawn again after a pick: keep the keyboard on the list that was used. The build standard sheet shows the
|
||||
// std order's switch and budget too: a pick there stays there.
|
||||
const opsSheet=()=>(bstdShown()?bstdModal:opsModal)();
|
||||
const opsRedraw=(act,args,draw=opsSheet)=>{draw();const j=JSON.stringify(args);for(const el of $('modalCard').querySelectorAll(`[data-chg="${act}"]`))if(el.dataset.args===j){el.focus();break;}};
|
||||
Object.assign(ACT,{
|
||||
opsOpen:()=>{if(S)opsModal();},
|
||||
opsHire:({id})=>{if(!S||opsHired()||!own(INTERNS,id)||!opsCanHire()||!rule('clock'))return;if(!spend(INTERN_MO))return;const O=opsO(),m=monthIdx(S.day);O.intern=id;O.hired=S.day;O.wk=null;
|
||||
|
|
@ -12,7 +14,7 @@ Object.assign(ACT,{
|
|||
O.log.unshift({d:S.day,i:id,r:[]});toast(esc(tr('ops.hired',{name:opsName(true)})),'good',[{l:tr('ops.ops'),act:'opsOpen',args:{}}]);after();opsModal();},
|
||||
opsFire:()=>{if(!opsHired())return;if(UI.confirm!=='opsFire'){UI.confirm='opsFire';opsModal();return;}UI.confirm=null;const nm=opsName();S.ops.intern=null;
|
||||
toast(esc(tr('ops.fired',{name:nm})),'');after();opsModal();},
|
||||
opsToggle:({k})=>{if(!opsHired()||!own(OPSK,k))return;S.ops.on[k]=!S.ops.on[k];sfx('click');after();opsModal();},
|
||||
opsToggle:({k})=>{if(!opsHired()||!own(OPSK,k))return;S.ops.on[k]=!S.ops.on[k];sfx('click');after();opsSheet();},
|
||||
opsParam:({k,p,v})=>{if(!opsHired()||!own(OPSK,k)||!own(OPSK[k].p,p))return;const P=OPSK[k].p[p],x=opsPick(opsOpts(k,p),opsP(k,p),v);if(x===undefined||!(P.ok?P.ok(x):P.v.includes(x)))return;
|
||||
(S.ops.p[k]||(S.ops.p[k]={}))[p]=x;sfx('click');after();opsRedraw('opsParam',{k,p});},
|
||||
opsCap:({k,v})=>{if(!opsHired()||!own(OPSK,k)||!OPSK[k].cap)return;const x=opsPick(opsCaps(k),opsCap(k),v);if(x===undefined)return;S.ops.cap[k]=x;sfx('click');after();opsRedraw('opsCap',{k});},
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ Object.assign(ACT,{
|
|||
<div class="menu-list">
|
||||
${btn(tr('common.back_to_the_map'),'closeModal',{},'pink big')}${saveFailing()?btn(tr('common.export_save'),'exportSave',{},'pink'):''}${saveFailing()&&UI.saveFail.full&&slotOthers().length?btn(tr('slots.free_up_space'),'slotSpace',{},'pink'):''}
|
||||
</div>
|
||||
<div class="menu-tiles">${[['🗂️',tr('slots.your_networks'),'toTitle'],['🧩',tr('puzzles.puzzles'),'puzzleMenu'],['🏆',tr('common.scenarios'),'scenarios'],['🧑💻',tr('ops.standing_orders'),'opsOpen'],['📸',tr('common.share'),'share'],['⚙️',tr('common.settings'),'settings']].map(([i,l,a])=>`<button class="mtile" data-act="${a}"><i aria-hidden="true">${i}</i><span>${l}</span></button>`).join('')}</div>
|
||||
<div class="menu-tiles">${[['🗂️',tr('slots.your_networks'),'toTitle'],['🧩',tr('puzzles.puzzles'),'puzzleMenu'],['🏆',tr('common.scenarios'),'scenarios'],['🧑💻',tr('ops.standing_orders'),'opsOpen'],['📐',tr('bstd.title'),'bstdOpen'],['📸',tr('common.share'),'share'],['⚙️',tr('common.settings'),'settings']].map(([i,l,a])=>`<button class="mtile" data-act="${a}"><i aria-hidden="true">${i}</i><span>${l}</span></button>`).join('')}</div>
|
||||
<p class="menu-links">${[saveFailing()?null:[tr('common.export_save'),'exportSave'],[tr('common.import_a_save'),'importPick'],[tr('common.how_to_play'),'help'],RELEASE_NOTES.length?[tr('common.what_s_new_in_v',{v:esc(APP_VERSION)}),'whatsNewShow']:null,[tr('common.start_a_new_network'),'resetAsk']].filter(Boolean).map(([l,a])=>`<button class="lnk" data-act="${a}">${l}</button>`).join(' · ')}</p>
|
||||
</div><div class="menu-plugs"><a class="mplug" href="${SIGNAL}" target="_blank" rel="noopener">💬 ${tr('modal_and_names.join_the_noc_chat')} →</a><a class="mplug" href="${ISSUES}" target="_blank" rel="noopener">🐛 ${tr('modal_and_names.found_a_bug_or_have_an')} →</a></div>`);},
|
||||
settings:()=>{UI.setOpen=true;openModal(settingsHtml());},
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ function bbCost(c){return 15000+CITY[c].P*20;}
|
|||
/* A click that changes nothing routing reads (the log, offers, cash, names, settings…) keeps the routing it has:
|
||||
compute() gives the same R again for the same state (tests/compute-idempotent), so it is skipped. The key is the save
|
||||
without the fields routing never reads (tests/route-skip checks each one); any other change routes again. */
|
||||
const RK_SKIP=new Set(['name','log','offers','usedNames','stats','cash','seen','tut','ach','achP','won','loanOffers','loanStrikes','uiSpeed','cam','richTold','demo','nextEvent','nextFail','done','confReg','auNews','calV','solWon','seatOff','chartSet','t1Now','ltv','capDeal','auV','pdeskRep','sv']);
|
||||
const RK_SKIP=new Set(['name','log','offers','usedNames','stats','cash','seen','tut','ach','achP','won','loanOffers','loanStrikes','uiSpeed','cam','richTold','demo','nextEvent','nextFail','done','confReg','auNews','calV','solWon','seatOff','chartSet','t1Now','ltv','capDeal','auV','pdeskRep','sv','popStd']);
|
||||
function routeKey(){const o={};for(const k in S)if(!RK_SKIP.has(k))o[k]=S[k];return JSON.stringify(o);}
|
||||
function routeIfChanged(){const k=S&&!pzOn()?routeKey():null;if(k&&k===UI.rk&&R===UI.rkR)return false;compute();UI.rk=k;UI.rkR=R;return true;}
|
||||
function after(){if(pzOn()){pzAfter();return;}NOC.dirty=true;if(S)purgeInc();routeIfChanged();checkGoals();renderAll();if(S&&!$('dash').hidden)renderDash();save();}
|
||||
|
|
|
|||
|
|
@ -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>`:''}${(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())}
|
||||
${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">${q.site2||q.gen?tr('pop_std.includes_the_build_standard',{list:esc(bstdPopParts({g:q.g,rt:q.rt,site2:q.site2,gen:q.gen}).join(', ')),cost:fmt$(q.cost),mo:fmt$(q.mo)}):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));
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ const opsCapName=(k,v)=>v?tr('common.price_mo',{price:(OPSK[k].mo?'+':'')+fmt$(v
|
|||
function opsOrderHtml(d){const k=d.k,on=S.ops.on[k],cap=d.cap?opsCap(k):0,sp=S.ops.spent[k]||0,am=Math.round(S.ops.addMo[k]||0);
|
||||
return `<div class="ops-o${on?' on':''}"><div class="ops-h"><span class="ops-i" aria-hidden="true">${d.i}</span><div class="grow"><div class="nm">${tr(d.t)}</div><div class="meta">${tr(d.d)}${k==='caches'?' '+tr('ops.caches_rent',{price:fmt$(CACHE_MO),big:fmt$(CACHE_BIG_MO)}):''}</div></div>
|
||||
<button class="b sm ${on?'green':'ghost'}" data-act="opsToggle" data-args='{"k":"${k}"}' aria-pressed="${on}" aria-label="${esc(tr(d.t))}">${on?tr('common.on'):tr('ops.paused')}</button></div>
|
||||
${k==='std'?`<div class="meta">${tr('bstd.now_line',{list:S.popStd?esc(bstdLine(bstd())):tr('pop_std.none')})}</div><div class="btns">${btn(tr('bstd.edit'),'bstdOpen',{},'ghost sm')}</div>`:''}
|
||||
${on?`<div class="ops-p">${Object.keys(d.p).map(p=>opsSel(tr(d.p[p].l),'opsParam',{k,p},opsOpts(k,p),opsP(k,p),v=>opsVal(k,p,v))).join('')}
|
||||
${d.cap?opsSel(d.mo?tr('ops.budget_running'):tr('ops.budget'),'opsCap',{k},opsCaps(k),cap,v=>opsCapName(k,v)):''}</div>
|
||||
${sp||am?`<div class="meta">${tr('ops.spent_and_mo',{price:fmt$(sp),mo:opsMo$(am)})}</div>`:''}
|
||||
|
|
@ -41,7 +42,8 @@ function opsReportHtml(){const O=S.ops,w=Math.floor(S.day/7),cur=O.wk&&O.wk.w===
|
|||
const row=(t,x)=>`<div class="ops-rep"><div class="eyebrow">${t}</div><div>${esc(opsWeekLine(x))}</div></div>`;
|
||||
return (rep?row(tr('ops.report_last'),rep):'')+(cur?row(tr('ops.report_now'),cur):'');}
|
||||
// The big one-off batches (#181, #192) live here now, next to the orders that run them every week.
|
||||
const opsOnceHtml=()=>`<section><h3>${tr('ops.by_hand')}</h3><p class="meta">${tr('ops.by_hand_note')}</p><div class="btns">${btn(tr('utilities.title'),'utilities',{},'sm')}${btn(tr('pni_all.peer_all_networks'),'pniAllOpen',{net:null},'sm')}</div></section>`;
|
||||
// The build standard too: its sheet works with or without an intern (targets, new POPs, everything up in one tap).
|
||||
const opsOnceHtml=()=>`<section><h3>${tr('ops.by_hand')}</h3><p class="meta">${tr('ops.by_hand_note')}</p><div class="btns">${btn(tr('utilities.title'),'utilities',{},'sm')}${btn(tr('pni_all.peer_all_networks'),'pniAllOpen',{net:null},'sm')}${pzOn()?'':btn(tr('bstd.title'),'bstdOpen',{},'sm')}</div></section>`;
|
||||
// On a city without a POP: open it from the template in one tap.
|
||||
function opsTplHtml(c){if(!opsHired())return '';const q=opsTplQuote(c);if(!q)return '';
|
||||
return `<section><h3>${tr('ops.template')}</h3><p class="meta">${esc(tr('ops.tpl_offer',{name:opsName(),list:[tr('ops.tpl_pop'),...q.parts].join(', ')}))}</p><div class="btns">${btn(tr('ops.tpl_open',{cost:fmt$(q.cost)}),'opsNewPop',{city:c},'pink',S.cash<q.cost)}</div></section>`;}
|
||||
|
|
|
|||
38
src/game/93-ui/59-build-standard.js
Normal file
38
src/game/93-ui/59-build-standard.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* The build standard sheet: every target as a list (two to a row on a phone), grouped POP / ports and peering / fiber;
|
||||
what is below the standard and what bringing it up costs, priced without changing anything; one tap to do it now;
|
||||
and the intern's order that keeps it there. A bottom sheet on phones, like the Ops sheet it sits next to. */
|
||||
const BSTD_GRP=[['pop',N_('common.pops')],['port',N_('bstd.g_port')],['fiber',N_('bstd.g_fiber')]];
|
||||
// Every value a target can take, in the order its list shows them; the current one is always on the list.
|
||||
function bstdOpts(k){const L=BSTDK[k].v(),cur=bstd()[k];if(!L.includes(cur))L.push(cur);return L;}
|
||||
function bstdVal(k,v){if(v===BSTDK[k].d&&k!=='rt')return tr('bstd.keep');
|
||||
switch(k){case 'g':return RG[v].n+(rgOpen(v)?'':' '+tr('bstd.from_level',{lv:RG[v].lvl}));
|
||||
case 'rt':return v>1?tr('bstd.at_least_n',{n:v}):tr('bstd.keep');
|
||||
case 'site2':case 'gen':return tr('bstd.at_every_pop');
|
||||
case 'lag':return tr('bstd.at_least_n',{n:v});
|
||||
case 'split':return tr('bstd.both_buildings');
|
||||
case 'ix':return tr('bstd.every_exchange');
|
||||
case 'pni':return tr('bstd.in_n_cities',{n:v});
|
||||
case 'sys':return tr('bstd.or_better',{x:DF_SYS[v].n});
|
||||
case 'opt':return tr('bstd.fastest');
|
||||
case 'wv':return tr('bstd.or_better',{x:LT[v].n});}
|
||||
return String(v);}
|
||||
const bstdShown=()=>!!$('modal')&&!$('modal').hidden&&!!$('modalCard').querySelector('[data-sheet="bstd"]');
|
||||
function bstdModal(){if(!S||pzOn())return;const D=bstd(),q=bstdQuote(false),hired=opsHired(),on=hired&&S.ops.on.std;
|
||||
let h=`<div data-sheet="bstd" style="display:flex;align-items:center"><div><div class="eyebrow">${tr('ops.ops')}</div><h2 style="font-size:26px">${tr('bstd.title')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>
|
||||
<p class="tagline">${tr('bstd.tagline')}</p>`;
|
||||
for(const [g,lab] of BSTD_GRP)h+=`<section><h3>${tr(lab)}</h3><div class="ops-p">${BSTD.filter(x=>x.grp===g).map(x=>opsSel(tr(x.l),'bstdSet',{k:x.k},bstdOpts(x.k),D[x.k],v=>bstdVal(x.k,v))).join('')}</div>
|
||||
<p class="note">${g==='pop'?tr('bstd.new_pops_note'):g==='port'?tr('bstd.port_note'):tr('bstd.fiber_note')}</p></section>`;
|
||||
// What is below it today, and what bringing it all up costs: a quote, nothing changes until the button. A fiber whose
|
||||
// line system has to wait is below it too, but not on the bill.
|
||||
const n={pop:q.pops,port:q.ports,fiber:q.links},w=q.held.length;
|
||||
h+=`<section><h3>${tr('bstd.below')}</h3>${q.n||w?BSTD_GRP.map(([g,lab])=>`<div class="kv"><span>${tr(lab)}</span><b>${n[g]}</b></div>`).join('')
|
||||
+`<div class="kv"><span>${tr('bstd.cost_now')}</span><b>${fmt$(q.cost)}</b></div><div class="kv"><span>${tr('bstd.cost_mo')}</span><b>${tr('common.price_mo',{price:opsMo$(q.mo)})}</b></div>`
|
||||
+(w?`<p class="meta">${trn('bstd.held',w)}</p>`:'')
|
||||
:`<p class="meta">${S.popStd?tr('bstd.all_up'):tr('bstd.none_set')}</p>`}</section>`;
|
||||
// The intern keeps it there: the order's switch and budget, or a word on hiring one.
|
||||
h+=`<section><h3>${tr('ops.o_std')}</h3>${hired?`<div class="ops-o${on?' on':''}"><div class="ops-h"><span class="ops-i" aria-hidden="true">${INTERNS[S.ops.intern].i}</span><div class="grow"><div class="nm">${esc(tr('bstd.intern_keeps',{name:opsName()}))}</div><div class="meta">${tr('ops.o_std_d')}</div></div>
|
||||
<button class="b sm ${on?'green':'ghost'}" data-act="opsToggle" data-args='{"k":"std"}' aria-pressed="${on}" aria-label="${esc(tr('ops.o_std'))}">${on?tr('common.on'):tr('ops.paused')}</button></div>
|
||||
${on?`<div class="ops-p">${opsSel(tr('ops.budget'),'opsCap',{k:'std'},opsCaps('std'),opsCap('std'),v=>opsCapName('std',v))}</div>`:''}</div>`
|
||||
:`<p class="meta">${tr('bstd.hire_note')}</p><div class="btns">${btn(tr('ops.hire_an_intern'),'opsOpen',{},'ghost sm',!opsCanHire()||!rule('clock'))}</div>`}</section>`;
|
||||
h+=`<div class="btns cta">${btn(q.n?tr('bstd.apply_now',{cost:fmt$(q.cost)}):w?tr('bstd.apply_wait'):tr('bstd.apply_nothing'),'bstdApply',{},'pink',!q.n)}</div>`;
|
||||
openModal(h,'ops');}
|
||||
|
|
@ -396,6 +396,48 @@
|
|||
"broker.win_text":"{name} (AS{asn}) laid its own cables onto {n} continents and sells {mo} a month of capacity to other carriers, in {days} days. The oceans are your trench now.",
|
||||
"broker.won_on_date":"Won on {date}: your own cables span the oceans, and carriers pay you to use them.",
|
||||
"broker.your_glass_gear_is_already_yours":"As a Cable broker, every fiber, line system, optic, subsea cable and the routers to light them are yours already, whatever the level says.",
|
||||
"bstd.all_up":"Everything meets the standard.",
|
||||
"bstd.any_model":"any model",
|
||||
"bstd.applied":{"one":"One job done for the build standard, {cost}.","other":"{n} jobs done for the build standard, {cost}."},
|
||||
"bstd.applied_none":"Nothing could be done for the build standard right now.",
|
||||
"bstd.apply_nothing":"Nothing below the standard",
|
||||
"bstd.apply_now":"Bring everything up now · {cost}",
|
||||
"bstd.apply_wait":"Nothing to do until those fibers are free",
|
||||
"bstd.at_every_pop":"At every POP",
|
||||
"bstd.at_least_n":"At least {n}",
|
||||
"bstd.below":"Below the standard today",
|
||||
"bstd.both_buildings":"Across both buildings",
|
||||
"bstd.cost_mo":"Running costs",
|
||||
"bstd.cost_now":"To bring it all up now",
|
||||
"bstd.edit":"Edit the build standard",
|
||||
"bstd.every_exchange":"Wherever there is an IX",
|
||||
"bstd.fastest":"Fastest that reaches",
|
||||
"bstd.fiber_note":"A line system swap takes the fiber dark for a day: only on a quiet fiber, or where a parallel link carries its load.",
|
||||
"bstd.from_level":"(level {lv})",
|
||||
"bstd.g_fiber":"Fiber and waves",
|
||||
"bstd.g_port":"Ports and peering",
|
||||
"bstd.generator":"generator",
|
||||
"bstd.held":{"one":"One fiber keeps its line system for now, until it is quiet or a parallel link can carry its load for the day it goes dark. Until then it gets the fastest optics its line system takes.","other":"{n} fibers keep their line system for now, until they are quiet or a parallel link can carry their load for the day they go dark. Until then they get the fastest optics their line system takes."},
|
||||
"bstd.hire_note":"Hire a NOC intern in Ops and they keep every POP, port and fiber to the standard: a few jobs a day, the busiest first, within a monthly budget and only with money to spare.",
|
||||
"bstd.in_n_cities":"In at least {n} cities",
|
||||
"bstd.intern_keeps":"{name} keeps the network to it",
|
||||
"bstd.keep":"Keep as is",
|
||||
"bstd.l_ix":"Exchange port",
|
||||
"bstd.l_lag":"LAG members",
|
||||
"bstd.l_model":"Router model",
|
||||
"bstd.l_pni":"PNIs per network",
|
||||
"bstd.l_site2":"Second building",
|
||||
"bstd.l_split":"Split LAGs",
|
||||
"bstd.left":{"one":"One thing is still below it, waiting for cash, a quiet fiber or an augment to land.","other":"{n} things are still below it, waiting for cash, a quiet fiber or an augment to land."},
|
||||
"bstd.n_more_targets":{"one":"{n} more target","other":"{n} more targets"},
|
||||
"bstd.new_pops_note":"A new POP gets these at once, while it is still empty: no maintenance window. Short on cash, it gets what fits. A model you have not unlocked yet means the best unlocked one below it.",
|
||||
"bstd.none_set":"No standard yet: every target says Keep as is.",
|
||||
"bstd.now_line":"Standard: {list}",
|
||||
"bstd.or_better":"{x} or better",
|
||||
"bstd.port_note":"LAGs and splits apply to transit, IX and PNI ports. A new PNI member is an augment and lands weeks later.",
|
||||
"bstd.second_building":"second building",
|
||||
"bstd.tagline":"One design for the whole network: what every POP, port and fiber should have. New POPs get the POP part the day they open; your intern, or the button below, brings the rest up to it.",
|
||||
"bstd.title":"Build standard",
|
||||
"businesses.a_free_pni_with_voda_phony":"A free PNI with Voda-Phony. Gear: Absolute Unit 3.2T routers, 3.2T ports and 12.8T waves.",
|
||||
"businesses.agi_lab_allegedly":"AGI lab (allegedly)",
|
||||
"businesses.agi_labs_allegedly_wanting_ai_wans":"AGI labs (allegedly) wanting AI WANs of 12.8 to 25.6 Tbps, and free PNIs with Du-opoly and Ooh-redoo. Gear: Mikrowtik CCR 3.2T routers.",
|
||||
|
|
@ -3236,6 +3278,7 @@
|
|||
"ops.l_routers":{"one":"upgraded routers in {where}","other":"upgraded routers in {n} places ({where})"},
|
||||
"ops.l_rs":{"one":"joined a route server","other":"joined {n} route servers"},
|
||||
"ops.l_snag":{"one":"got stuck on {where} and paused it until you have a look","other":"got stuck on {n} orders ({where}) and paused them until you have a look"},
|
||||
"ops.l_std":{"one":"brought {where} up to the build standard","other":"did {n} jobs for the build standard ({where})"},
|
||||
"ops.l_transit":{"one":"topped up transit in {where}","other":"topped up transit {n} times ({where})"},
|
||||
"ops.locked":"The NOC hires interns from customer level {lv}.",
|
||||
"ops.model_next":"Next generation, when busy",
|
||||
|
|
@ -3269,6 +3312,8 @@
|
|||
"ops.o_repair_d":"Pay for the rush repair on every outage that has one, while the budget lasts.",
|
||||
"ops.o_routers":"Keep routers ahead",
|
||||
"ops.o_routers_desc":"Add a router, or swap to the next generation where a second router carries the traffic, when load or ports pass a level. Pick a model, and every POP on a smaller one is swapped to it, the busiest first, within the budget.",
|
||||
"ops.o_std":"Keep to the build standard",
|
||||
"ops.o_std_d":"Bring POPs, ports and fiber up to your build standard, the busiest first, a few jobs a shift. A second router goes in before a swap, and a line system only changes on a quiet fiber.",
|
||||
"ops.o_transit":"Keep transit headroom",
|
||||
"ops.o_transit_d":"Keep transit at each POP above a multiple of its 30-day peak: add a LAG member, or move up a port size.",
|
||||
"ops.ops":"Ops",
|
||||
|
|
@ -3301,6 +3346,7 @@
|
|||
"ops.template":"New POP from template",
|
||||
"ops.template_note":"Pick what {name} sets up when you open a city from the template. The standing orders take it from there.",
|
||||
"ops.tpl_bb":"Broadband",
|
||||
"ops.tpl_bstd":"build standard",
|
||||
"ops.tpl_done":"{name} opened {city}: {list}.",
|
||||
"ops.tpl_ix":"IX port",
|
||||
"ops.tpl_just_pop":"just the POP",
|
||||
|
|
@ -3799,12 +3845,12 @@
|
|||
"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_cost":"{city} gets the standard: {n} × {model} for {cost}.",
|
||||
"pop_std.clear":"Clear",
|
||||
"pop_std.includes_the_build_standard":"Includes your build standard: {list}, {cost} + {mo}/mo. Short on cash, the POP gets what fits.",
|
||||
"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.new_pops_now_start_with_list":"New POPs now start with {list}.",
|
||||
"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.",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue