The intern standardizes routers on a chosen model; Ops settings are lists
Some checks are pending
CI / test 1/4 (push) Waiting to run
CI / test 2/4 (push) Waiting to run
CI / test 3/4 (push) Waiting to run
CI / test 4/4 (push) Waiting to run
CI / build (push) Waiting to run
CI / test (push) Blocked by required conditions
CI / translations (push) Waiting to run
Some checks are pending
CI / test 1/4 (push) Waiting to run
CI / test 2/4 (push) Waiting to run
CI / test 3/4 (push) Waiting to run
CI / test 4/4 (push) Waiting to run
CI / build (push) Waiting to run
CI / test (push) Blocked by required conditions
CI / translations (push) Waiting to run
Keep routers ahead gets a Model setting: the next generation when busy (as before), or a model to standardize on. With a model, every POP on a smaller one is swapped to it, the busiest first, within the monthly budget, through the same upRouter click: never a step down, only unlocked models that fit, and only where a second router carries the traffic or nothing runs yet. Busy POPs on it only get more routers. Every setting in the Standing orders sheet (each order's dials, budgets, the cash floor) is a dropdown instead of a button that steps through the values. The change handler passes a select's data-args, the actions take the picked position (v) and still step without one for the MCP tools, which now declare v as optional.
This commit is contained in:
parent
9d64aa0144
commit
1e7638c4b9
16 changed files with 188 additions and 33 deletions
|
|
@ -6,6 +6,8 @@ All notable changes to this project are documented here. The project follows
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- Your intern can standardize your routers on a model you choose: pick it in Keep routers ahead, and every POP on a smaller model is swapped to it, the busiest first, within the monthly budget. Every setting in the Standing orders sheet is now a list to pick from instead of a button to tap through.
|
||||
|
||||
## [3.0.0] — 2026-11-06
|
||||
|
||||
**Series of Tubes 3.0: Pie in the Sky.** You have wired up the planet with fiber, cables and routers. Now take your network to orbit: start your own rocket company, fill the sky with satellites (we call them pies) and sell internet to everyone your cables will never reach.
|
||||
|
|
|
|||
|
|
@ -3237,6 +3237,7 @@
|
|||
"ops.l_snag":{"one":"ist bei {where} hängen geblieben und hat den Auftrag pausiert, bis du draufschaust","other":"ist bei {n} Aufträgen hängen geblieben ({where}) und hat sie pausiert, bis du draufschaust"},
|
||||
"ops.l_transit":{"one":"hat Transit in {where} aufgestockt","other":"hat {n}-mal Transit aufgestockt ({where})"},
|
||||
"ops.locked":"Das NOC stellt ab Kundenlevel {lv} Praktikanten ein.",
|
||||
"ops.model_next":"Nächste Generation, wenn ausgelastet",
|
||||
"ops.mood_annie":"Annie hat drei Fragen beantwortet, bevor du sie gestellt hast, vom nächstgelegenen Schreibtisch aus.",
|
||||
"ops.mood_broke":"{name} hat schon eine Einkaufsliste für das Budget des nächsten Monats.",
|
||||
"ops.mood_busy":"{name} hatte eine volle Woche und ist beim dritten Energydrink.",
|
||||
|
|
@ -3264,7 +3265,7 @@
|
|||
"ops.o_repair":"Reparaturen beschleunigen",
|
||||
"ops.o_repair_d":"Für jeden Ausfall mit Eil-Reparatur zahlen, solange das Budget reicht.",
|
||||
"ops.o_routers":"Router voraus halten",
|
||||
"ops.o_routers_d":"Einen Router dazustellen oder auf die nächste Generation tauschen, wo ein zweiter Router den Traffic trägt, sobald Last oder Ports eine Grenze überschreiten.",
|
||||
"ops.o_routers_desc":"Einen Router dazustellen oder auf die nächste Generation tauschen, wo ein zweiter Router den Traffic trägt, sobald Last oder Ports eine Grenze überschreiten. Wähl ein Modell, und jeder POP mit einem kleineren wird darauf getauscht, der am meisten ausgelastete zuerst, im Rahmen des Budgets.",
|
||||
"ops.o_transit":"Transit-Reserve halten",
|
||||
"ops.o_transit_d":"Transit an jedem POP über einem Vielfachen seiner 30-Tage-Spitze halten: ein LAG-Member dazu oder eine Portgröße hoch.",
|
||||
"ops.ops":"Ops",
|
||||
|
|
@ -3273,6 +3274,7 @@
|
|||
"ops.p_g":"Ab",
|
||||
"ops.p_how":"Wie",
|
||||
"ops.p_keep":"Einen in Reserve",
|
||||
"ops.p_model":"Modell",
|
||||
"ops.p_paid":"Paid Peering",
|
||||
"ops.p_pick":"Optiken",
|
||||
"ops.p_prov":"Anbieter",
|
||||
|
|
|
|||
|
|
@ -3235,6 +3235,7 @@
|
|||
"ops.l_snag":{"one":"se atascó con {where} y la pausó hasta que le eches un vistazo","other":"se atascó con {n} órdenes ({where}) y las pausó hasta que les eches un vistazo"},
|
||||
"ops.l_transit":{"one":"amplió el tránsito en {where}","other":"amplió el tránsito {n} veces ({where})"},
|
||||
"ops.locked":"El NOC contrata becarios a partir del nivel de clientes {lv}.",
|
||||
"ops.model_next":"Siguiente generación, si va lleno",
|
||||
"ops.mood_annie":"Annie respondió tres preguntas antes de que las hicieras, desde la mesa más cercana.",
|
||||
"ops.mood_broke":"{name} ya tiene la lista de la compra para cuando llegue el presupuesto del mes que viene.",
|
||||
"ops.mood_busy":"{name} ha tenido una semana movida y va por la tercera bebida energética.",
|
||||
|
|
@ -3262,7 +3263,7 @@
|
|||
"ops.o_repair":"Acelerar reparaciones",
|
||||
"ops.o_repair_d":"Pagar la reparación urgente de cada caída que la tenga, mientras dure el presupuesto.",
|
||||
"ops.o_routers":"Routers por delante",
|
||||
"ops.o_routers_d":"Añadir un router, o pasar a la siguiente generación donde un segundo router lleve el tráfico, cuando la carga o los puertos pasen de un nivel.",
|
||||
"ops.o_routers_desc":"Añadir un router, o pasar a la siguiente generación donde un segundo router lleve el tráfico, cuando la carga o los puertos pasen de un nivel. Elige un modelo y cada POP con uno más pequeño se cambia a ese, primero el más cargado, dentro del presupuesto.",
|
||||
"ops.o_transit":"Margen de tránsito",
|
||||
"ops.o_transit_d":"Mantener el tránsito de cada POP por encima de un múltiplo de su pico de 30 días: un miembro LAG más o un tamaño de puerto mayor.",
|
||||
"ops.ops":"Ops",
|
||||
|
|
@ -3271,6 +3272,7 @@
|
|||
"ops.p_g":"Desde",
|
||||
"ops.p_how":"Cómo",
|
||||
"ops.p_keep":"Dejar uno de reserva",
|
||||
"ops.p_model":"Modelo",
|
||||
"ops.p_paid":"Peering de pago",
|
||||
"ops.p_pick":"Ópticas",
|
||||
"ops.p_prov":"Proveedor",
|
||||
|
|
|
|||
|
|
@ -3235,6 +3235,7 @@
|
|||
"ops.l_snag":{"one":"a calé sur {where} et l'a mis en pause en attendant que tu jettes un œil","other":"a calé sur {n} ordres ({where}) et les a mis en pause en attendant que tu jettes un œil"},
|
||||
"ops.l_transit":{"one":"a renforcé le transit à {where}","other":"a renforcé le transit {n} fois ({where})"},
|
||||
"ops.locked":"Le NOC recrute des stagiaires à partir du niveau clients {lv}.",
|
||||
"ops.model_next":"Génération suivante, si chargé",
|
||||
"ops.mood_annie":"Annie a répondu à trois questions avant que tu les poses, depuis le bureau le plus proche.",
|
||||
"ops.mood_broke":"{name} a déjà sa liste de courses pour le budget du mois prochain.",
|
||||
"ops.mood_busy":"{name} a eu une semaine chargée et en est à sa troisième boisson énergisante.",
|
||||
|
|
@ -3262,7 +3263,7 @@
|
|||
"ops.o_repair":"Accélérer les réparations",
|
||||
"ops.o_repair_d":"Payer la réparation express de chaque panne qui en a une, tant que le budget suit.",
|
||||
"ops.o_routers":"Garder les routeurs en avance",
|
||||
"ops.o_routers_d":"Ajouter un routeur, ou passer à la génération suivante là où un second routeur porte le trafic, quand la charge ou les ports dépassent un seuil.",
|
||||
"ops.o_routers_desc":"Ajouter un routeur, ou passer à la génération suivante là où un second routeur porte le trafic, quand la charge ou les ports dépassent un seuil. Choisissez un modèle, et chaque POP équipé d’un plus petit passe à celui-ci, le plus chargé d’abord, dans la limite du budget.",
|
||||
"ops.o_transit":"Garder de la marge de transit",
|
||||
"ops.o_transit_d":"Garder le transit de chaque POP au-dessus d'un multiple de son pic sur 30 jours : un membre LAG de plus, ou une taille de port au-dessus.",
|
||||
"ops.ops":"Ops",
|
||||
|
|
@ -3271,6 +3272,7 @@
|
|||
"ops.p_g":"À partir de",
|
||||
"ops.p_how":"Comment",
|
||||
"ops.p_keep":"En garder un de secours",
|
||||
"ops.p_model":"Modèle",
|
||||
"ops.p_paid":"Peering payant",
|
||||
"ops.p_pick":"Optiques",
|
||||
"ops.p_prov":"Fournisseur",
|
||||
|
|
|
|||
|
|
@ -3235,6 +3235,7 @@
|
|||
"ops.l_snag":{"one":"si è bloccato su {where} e l'ha messo in pausa finché non dai un'occhiata","other":"si è bloccato su {n} ordini ({where}) e li ha messi in pausa finché non dai un'occhiata"},
|
||||
"ops.l_transit":{"one":"ha aumentato il transit a {where}","other":"ha aumentato il transit {n} volte ({where})"},
|
||||
"ops.locked":"Il NOC assume stagisti dal livello clienti {lv}.",
|
||||
"ops.model_next":"Generazione successiva, se carico",
|
||||
"ops.mood_annie":"Annie ha risposto a tre domande prima che tu le facessi, dalla scrivania più vicina.",
|
||||
"ops.mood_broke":"{name} ha già la lista della spesa per quando arriva il budget del mese prossimo.",
|
||||
"ops.mood_busy":"{name} ha avuto una settimana piena ed è alla terza bevanda energetica.",
|
||||
|
|
@ -3262,7 +3263,7 @@
|
|||
"ops.o_repair":"Accelera le riparazioni",
|
||||
"ops.o_repair_d":"Paga la riparazione urgente di ogni guasto che ce l'ha, finché il budget regge.",
|
||||
"ops.o_routers":"Router sempre avanti",
|
||||
"ops.o_routers_d":"Aggiungi un router, o passa alla generazione successiva dove un secondo router regge il traffico, quando carico o porte superano una soglia.",
|
||||
"ops.o_routers_desc":"Aggiungi un router, o passa alla generazione successiva dove un secondo router regge il traffico, quando carico o porte superano una soglia. Scegli un modello e ogni POP con uno più piccolo passa a quello, prima il più carico, nei limiti del budget.",
|
||||
"ops.o_transit":"Margine di transit",
|
||||
"ops.o_transit_d":"Tieni il transit di ogni POP sopra un multiplo del suo picco a 30 giorni: un membro LAG in più, o una porta più grande.",
|
||||
"ops.ops":"Ops",
|
||||
|
|
@ -3271,6 +3272,7 @@
|
|||
"ops.p_g":"Da",
|
||||
"ops.p_how":"Come",
|
||||
"ops.p_keep":"Tienine uno di scorta",
|
||||
"ops.p_model":"Modello",
|
||||
"ops.p_paid":"Peering a pagamento",
|
||||
"ops.p_pick":"Ottiche",
|
||||
"ops.p_prov":"Fornitore",
|
||||
|
|
|
|||
|
|
@ -3235,6 +3235,7 @@
|
|||
"ops.l_snag":{"one":"travou em {where} e pausou a ordem até você dar uma olhada","other":"travou em {n} ordens ({where}) e pausou-as até você dar uma olhada"},
|
||||
"ops.l_transit":{"one":"reforçou o trânsito em {where}","other":"reforçou o trânsito {n} vezes ({where})"},
|
||||
"ops.locked":"O NOC contrata estagiários a partir do nível de clientes {lv}.",
|
||||
"ops.model_next":"Próxima geração, quando lotado",
|
||||
"ops.mood_annie":"Annie respondeu três perguntas antes de você fazê-las, da mesa mais próxima.",
|
||||
"ops.mood_broke":"{name} já tem a lista de compras para quando chegar o orçamento do mês que vem.",
|
||||
"ops.mood_busy":"{name} teve uma semana cheia e está na terceira bebida energética.",
|
||||
|
|
@ -3262,7 +3263,7 @@
|
|||
"ops.o_repair":"Acelerar reparos",
|
||||
"ops.o_repair_d":"Pagar o reparo urgente de cada queda que tenha um, enquanto o orçamento durar.",
|
||||
"ops.o_routers":"Roteadores à frente",
|
||||
"ops.o_routers_d":"Adicionar um roteador, ou trocar para a próxima geração onde um segundo roteador segura o tráfego, quando a carga ou as portas passarem de um nível.",
|
||||
"ops.o_routers_desc":"Adicionar um roteador, ou trocar para a próxima geração onde um segundo roteador segura o tráfego, quando a carga ou as portas passarem de um nível. Escolha um modelo e cada POP com um menor é trocado para ele, o mais carregado primeiro, dentro do orçamento.",
|
||||
"ops.o_transit":"Folga de trânsito",
|
||||
"ops.o_transit_d":"Manter o trânsito de cada POP acima de um múltiplo do seu pico de 30 dias: mais um membro LAG, ou um tamanho de porta acima.",
|
||||
"ops.ops":"Ops",
|
||||
|
|
@ -3271,6 +3272,7 @@
|
|||
"ops.p_g":"A partir de",
|
||||
"ops.p_how":"Como",
|
||||
"ops.p_keep":"Manter um de reserva",
|
||||
"ops.p_model":"Modelo",
|
||||
"ops.p_paid":"Peering pago",
|
||||
"ops.p_pick":"Ópticas",
|
||||
"ops.p_prov":"Provedor",
|
||||
|
|
|
|||
|
|
@ -324,12 +324,12 @@ const API_CMD={
|
|||
doc:'Let the intern go. The standing orders stop; the rest of the month\'s salary is lost.'},
|
||||
opsToggle:{args:[['k','opsKey']],watch:['ops'],
|
||||
doc:'Pause or resume one standing order. Keys come from catalog(\'OPSK\'); the sheet in the game shows what each one does.'},
|
||||
opsParam:{args:[['k','opsKey'],['p','string']],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…). The sheet steps the same way.'},
|
||||
opsCap:{args:[['k','opsKey']],watch:['ops'],
|
||||
doc:'Step the monthly budget of an order that has one: 10k, 25k, 50k, 100k, 250k, no limit.'},
|
||||
opsFloor:{args:[],watch:['ops'],
|
||||
doc:'Step the floor under your cash that the intern keeps clear when paying for jobs: 0, 50k, 250k, 1M, 5M.'},
|
||||
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.'},
|
||||
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'],
|
||||
doc:'Add or remove one POP as an exception to an order: the intern never touches the POPs you except.'},
|
||||
opsTpl:{args:[['k','opsTplKey']],watch:['ops'],
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ const INTERNS={
|
|||
const OPS=[
|
||||
{k:'transit',i:'📈',pop:1,cap:50000,t:N_('ops.o_transit'),d:N_('ops.o_transit_d'),p:{x:{d:1.5,v:[1.25,1.5,2,3],l:N_('ops.p_x'),f:v=>v+'×'},prov:{d:'cheap',ok:v=>v==='cheap'||v==='have'||(isNet(v)&&!!NET[v].price),l:N_('ops.p_prov')}}},
|
||||
{k:'ports',i:'🔌',pop:1,cap:50000,t:N_('ops.o_ports'),d:N_('ops.o_ports_d'),p:{x:{d:1.5,v:[1.25,1.5,2,3],l:N_('ops.p_x'),f:v=>v+'×'}}},
|
||||
{k:'routers',i:'🧠',pop:1,cap:250000,t:N_('ops.o_routers'),d:N_('ops.o_routers_d'),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])}}},
|
||||
{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}}},
|
||||
{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')}}},
|
||||
|
|
@ -35,6 +37,11 @@ const opsHired=()=>!!(S&&S.ops&&S.ops.intern&&own(INTERNS,S.ops.intern));
|
|||
const opsCanHire=()=>lvl()>=2;
|
||||
const opsName=(long)=>{const I=INTERNS[S.ops.intern];return I?tr(long?I.n:I.s):'';};
|
||||
function opsP(k,p){const P=OPSK[k].p[p],v=S.ops.p[k]&&S.ops.p[k][p];return v!==undefined&&(P.ok?P.ok(v):P.v.includes(v))?v:P.d;}
|
||||
// Every value a setting can take, in the order its list shows them: providers that sell where you have POPs, and router
|
||||
// models you can buy, smallest first. The current value is always on the list, so the list can show it.
|
||||
function opsOpts(k,p){const cur=opsP(k,p),L=p==='prov'?['cheap','have',...NETS.filter(n=>n.price&&Object.keys(S.pops).some(c=>sellsAt(n,c))).map(n=>n.id)]
|
||||
:p==='model'?['next',...RG.map((r,i)=>i).filter(i=>rgOpen(i)).sort((a,b)=>RG[a].cls-RG[b].cls||RG[a].cap-RG[b].cap||a-b)]:OPSK[k].p[p].v.slice();
|
||||
if(!L.includes(cur))L.push(cur);return L;}
|
||||
const opsCaps=k=>OPSK[k].mo?OPS_CAPS_MO:OPS_CAPS;
|
||||
function opsCap(k){const c=S.ops.cap[k];return opsCaps(k).includes(c)?c:OPSK[k].cap||0;}
|
||||
const opsHere=(k,c)=>!(S.ops.skip[c]||[]).includes(k);
|
||||
|
|
@ -127,12 +134,20 @@ const opsProv=c=>{const pv=opsP('transit','prov'),n=isNet(pv)?NET[pv]:null;retur
|
|||
// The orders. Each takes the shift and does its jobs through the player's own actions.
|
||||
const OPS_RUN={
|
||||
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');
|
||||
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)));
|
||||
// A chosen model: swap every POP still on a smaller one to it, the busiest first, while the budget lasts. Never a
|
||||
// step down, never a model that is not unlocked or does not fit, and only with a second router or no traffic there.
|
||||
if(fix&&rgOpen(m))for(const c of opsPops('routers').sort((a,b)=>load(b)-load(a))){const p=S.pops[c],g=p.rgen||0;
|
||||
if(p.rupDay===S.day||g===m||RG[m].cap<=RG[g].cap||modelFits(c,m)||!((p.routers||1)>1||popIdle(c)))continue;
|
||||
const cost=swapCost(c,m);if(!X.can('routers',cost))continue;
|
||||
if(X.pay('routers',()=>ACT.upRouter({city:c,g:m})))X.did('routers',c+' ⇧'+RG[m].pn);}
|
||||
for(const c of opsPops('routers')){const p=S.pops[c];if(p.rupDay===S.day)continue;
|
||||
const ld=Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));if(ld<at)continue;
|
||||
const ld=load(c);if(ld<at)continue;
|
||||
const rt=p.routers||1,g=p.rgen||0,nx=mainRG(RG[g].cls+1);
|
||||
// A swap with one router is a maintenance window: the intern only swaps where a second router carries the traffic.
|
||||
const swap=nx>=0&&rgOpen(nx)&&!modelFits(c,nx)&&(rt>1||popIdle(c)),add=rt<RMAX;
|
||||
// With a chosen model the swaps are the ones above; a busy POP only gets more routers.
|
||||
const swap=!fix&&nx>=0&&rgOpen(nx)&&!modelFits(c,nx)&&(rt>1||popIdle(c)),add=rt<RMAX;
|
||||
const doSwap=how==='swap'?swap:how==='add'?false:swap&&(rt>=4||!add);if(!doSwap&&(how==='swap'||!add))continue;
|
||||
const cost=doSwap?swapCost(c,nx):routerCost(g,rt);if(!X.can('routers',cost))continue;
|
||||
if(X.pay('routers',()=>doSwap?ACT.upRouter({city:c,g:nx}):ACT.addRouter({city:c})))X.did('routers',c+(doSwap?' ⇧'+RG[nx].pn:' +1'));}},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
// Standing orders: hiring the intern, the switches and dials, and a new POP from the template.
|
||||
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;}};
|
||||
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;
|
||||
|
|
@ -9,11 +13,10 @@ Object.assign(ACT,{
|
|||
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();},
|
||||
opsParam:({k,p})=>{if(!opsHired()||!own(OPSK,k)||!own(OPSK[k].p,p))return;const P=OPSK[k].p[p];let v;
|
||||
if(p==='prov'){const ids=['cheap','have',...NETS.filter(n=>n.price&&Object.keys(S.pops).some(c=>sellsAt(n,c))).map(n=>n.id)];v=opsCycle(ids,opsP(k,p));}else v=opsCycle(P.v,opsP(k,p));
|
||||
(S.ops.p[k]||(S.ops.p[k]={}))[p]=v;sfx('click');after();opsModal();},
|
||||
opsCap:({k})=>{if(!opsHired()||!own(OPSK,k)||!OPSK[k].cap)return;S.ops.cap[k]=opsCycle(opsCaps(k),opsCap(k));sfx('click');after();opsModal();},
|
||||
opsFloor:()=>{if(!opsHired())return;S.ops.floor=opsCycle(OPS_FLOORS,S.ops.floor);sfx('click');after();opsModal();},
|
||||
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});},
|
||||
opsFloor:({v})=>{if(!opsHired())return;const x=opsPick(OPS_FLOORS,S.ops.floor,v);if(x===undefined)return;S.ops.floor=x;sfx('click');after();opsRedraw('opsFloor',{});},
|
||||
opsCity:({v})=>{if(!S||!S.pops[v])return;UI.opsCity=v;opsModal();},
|
||||
opsPop:({k,city})=>{if(!opsHired()||!OPS_POP.includes(k)||!S.pops[city])return;const sk=S.ops.skip,a=sk[city]||[];sk[city]=a.includes(k)?a.filter(x=>x!==k):[...a,k];if(!sk[city].length)delete sk[city];
|
||||
UI.opsCity=city;sfx('click');after();opsModal();},
|
||||
|
|
|
|||
|
|
@ -5,12 +5,15 @@ function opsCard(){if(!S)return '';const last=opsHired()&&S.ops.log[0];
|
|||
<div class="meta">${opsHired()?esc(last?opsEntry(last):tr('ops.l_quiet',{name:opsName()})):opsCanHire()?tr('ops.hire_pitch_short'):tr('ops.locked',{lv:2})}</div>
|
||||
<div class="btns">${btn(opsHired()?tr('ops.standing_orders'):tr('ops.hire_an_intern'),'opsOpen',{},opsHired()?'sm':'pink sm',!opsHired()&&!opsCanHire())}</div></div>`;}
|
||||
const opsEntry=e=>(e.f!==undefined?opsFFLine(e)+' ':'')+(e.r.length||e.f===undefined?opsLine(e):'');
|
||||
function opsVal(k,p){const P=OPSK[k].p[p],v=opsP(k,p);return p==='prov'?(v==='cheap'?tr('ops.cheapest'):v==='have'?tr('ops.already_connected'):NET[v].name):P.f(v);}
|
||||
function opsVal(k,p,v=opsP(k,p)){const P=OPSK[k].p[p];return p==='prov'?(v==='cheap'?tr('ops.cheapest'):v==='have'?tr('ops.already_connected'):NET[v].name):P.f(v);}
|
||||
// A setting as a list to pick from: the option values are positions in the list the action reads again.
|
||||
const opsSel=(lab,act,args,vals,cur,name)=>`<label class="ops-sel"><span>${lab}</span><select data-chg="${act}" data-args="${esc(JSON.stringify(args))}">${vals.map((v,i)=>`<option value="${i}"${v===cur?' selected':''}>${esc(name(v))}</option>`).join('')}</select></label>`;
|
||||
const opsCapName=(k,v)=>v?tr('common.price_mo',{price:(OPSK[k].mo?'+':'')+fmt$(v)}):tr('ops.no_cap');
|
||||
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>
|
||||
${on?`<div class="ops-p">${Object.keys(d.p).map(p=>btn(`${tr(d.p[p].l)}: <b>${esc(opsVal(k,p))}</b>`,'opsParam',{k,p},'ghost sm')).join('')}
|
||||
${d.cap?btn(`${d.mo?tr('ops.budget_running'):tr('ops.budget')}: <b>${cap?tr('common.price_mo',{price:(d.mo?'+':'')+fmt$(cap)}):tr('ops.no_cap')}</b>`,'opsCap',{k},'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>`:''}
|
||||
${k==='ix'&&ppol()!=='open'?`<p class="why">${tr('link_panels.off_while_your_peering_policy_is',{pol:tr(PPOL_N[ppol()])})}</p>`:''}`:''}</div>`;}
|
||||
function opsModal(){if(!S)return;const hired=opsHired();let h=`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('ops.ops')}</div><h2 style="font-size:26px">${tr('ops.standing_orders')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>`;
|
||||
|
|
@ -24,7 +27,7 @@ function opsModal(){if(!S)return;const hired=opsHired();let h=`<div style="displ
|
|||
${btn(UI.confirm==='opsFire'?tr('ops.really_fire'):tr('ops.fire'),'opsFire',{},'ghost sm')}</div>
|
||||
<p class="ops-mood">${esc(opsMood())}</p>${opsReportHtml()}
|
||||
${O.log.length?`<pre class="term ops-log">${O.log.slice(0,6).map(e=>esc(tr('ops.day_d',{d:e.d})+': '+opsEntry(e))).join('\n')}</pre>`:''}
|
||||
<div class="ops-p">${btn(`${tr('ops.floor')}: <b>${O.floor?fmt$(O.floor):tr('ops.no_cap')}</b>`,'opsFloor',{},'ghost sm')}</div></div>`;
|
||||
<div class="ops-p">${opsSel(tr('ops.floor'),'opsFloor',{},OPS_FLOORS,O.floor,v=>v?fmt$(v):tr('ops.no_cap'))}</div></div>`;
|
||||
h+=`<p class="note">${tr('ops.how_it_works',{name:opsName()})}</p>`+OPS.map(opsOrderHtml).join('');
|
||||
// Per POP: switch single orders off where the player wants to decide by hand.
|
||||
const cities=Object.keys(S.pops).sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name)),c=S.pops[UI.opsCity]?UI.opsCity:cities[0];
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ let pressing=false;
|
|||
document.addEventListener('pointerdown',e=>{if(e.target.closest('#panel,#left,#dash,#bankBox,#modal,#tabbar,#toasts,#pzBox'))pressing=true;});
|
||||
addEventListener('pointerup',()=>setTimeout(()=>pressing=false,0));
|
||||
addEventListener('pointercancel',()=>{pressing=false;});addEventListener('blur',()=>{pressing=false;});
|
||||
document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||(!S&&!['langSet','pickHome'].includes(el.dataset.chg)))return;const fn=ACT[el.dataset.chg];if(fn)fn({v:el.value});});
|
||||
document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||(!S&&!['langSet','pickHome'].includes(el.dataset.chg)))return;const fn=ACT[el.dataset.chg];if(!fn)return;let a={};try{a=el.dataset.args?JSON.parse(el.dataset.args):{};}catch(err){}fn({...(a&&typeof a==='object'?a:{}),v:el.value});});
|
||||
/* Taps that land on the wrong thing (#44): a real tap only fires the button it went down on, never something that
|
||||
appeared or moved under the finger, nothing behind a menu that opened or closed mid-tap, and no toast button in
|
||||
the first half second after the toast popped up. Synthetic clicks (keyboard, tests) are not affected. */
|
||||
|
|
|
|||
|
|
@ -3236,6 +3236,7 @@
|
|||
"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_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",
|
||||
"ops.mood_annie":"Annie answered three questions before you asked them, from whichever desk was closest.",
|
||||
"ops.mood_broke":"{name} has a shopping list ready for when next month's budget comes in.",
|
||||
"ops.mood_busy":"{name} has had a busy week and is on their third energy drink.",
|
||||
|
|
@ -3263,7 +3264,7 @@
|
|||
"ops.o_repair":"Rush repairs",
|
||||
"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_d":"Add a router, or swap to the next generation where a second router carries the traffic, when load or ports pass a level.",
|
||||
"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_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",
|
||||
|
|
@ -3272,6 +3273,7 @@
|
|||
"ops.p_g":"From",
|
||||
"ops.p_how":"How",
|
||||
"ops.p_keep":"Keep one spare",
|
||||
"ops.p_model":"Model",
|
||||
"ops.p_paid":"Paid peering",
|
||||
"ops.p_pick":"Optics",
|
||||
"ops.p_prov":"Provider",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
.ops-i{font-size:22px;line-height:1;flex:none}
|
||||
.ops-p{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
|
||||
.ops-p .b{white-space:normal;text-align:left;min-height:36px}
|
||||
/* A setting is a list to pick from: two to a row on a phone, the list as wide as its column. */
|
||||
.ops-sel{display:flex;flex-direction:column;gap:2px;flex:1 1 140px;min-width:0;font:800 12px Nunito,sans-serif;color:var(--ink2)}
|
||||
.ops-sel select{width:100%;min-height:36px;font:700 14px Nunito,sans-serif;color:var(--ink);background:var(--paper);padding:4px 6px;border:2px solid var(--ink);border-radius:8px}
|
||||
.ops-log{white-space:pre-wrap;font-size:11.5px;max-height:160px;overflow:auto}
|
||||
.ops-mood{margin:6px 0 0;font-style:italic;font-size:13px;color:var(--ink2)}
|
||||
.ops-rep{border-left:3px solid #8E5CF7;background:#F7F2FF;border-radius:0 8px 8px 0;padding:6px 8px;margin:6px 0;font-size:13px;line-height:1.35;overflow-wrap:anywhere}
|
||||
|
|
|
|||
|
|
@ -51,10 +51,12 @@ test('#262 the setting is saved, an unknown value falls back, and it shows on th
|
|||
dom.window.innerWidth = 360;
|
||||
ev("ACT.phoneTab({t:'noc'})");
|
||||
dom.window.document.querySelector('#leftBody [data-act="opsOpen"]').click();
|
||||
const btn = [...dom.window.document.querySelectorAll('#modalCard [data-act="opsParam"]')].find((b) => b.dataset.args.includes('pick'));
|
||||
assert.ok(btn, 'the Optics button is in the sheet');
|
||||
assert.match(btn.textContent, /Optics: biggest on new fiber/);
|
||||
btn.click();
|
||||
const sel = [...dom.window.document.querySelectorAll('#modalCard select[data-chg="opsParam"]')].find((s) => s.dataset.args.includes('pick'));
|
||||
assert.ok(sel, 'the Optics list is in the sheet');
|
||||
assert.match(sel.closest('label').textContent, /Optics/);
|
||||
assert.equal(sel.options[sel.selectedIndex].textContent, 'biggest on new fiber');
|
||||
sel.value = [...sel.options].find((o) => o.textContent !== 'biggest on new fiber').value;
|
||||
sel.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
|
||||
assert.equal(ev("opsP('optics','pick')"), 'cheap');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
112
tests/intern-router-model.test.js
Normal file
112
tests/intern-router-model.test.js
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
// The intern standardizes routers on a chosen model within the budget, and every setting in the Ops sheet is a list.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
// Frankfurt (one router, broadband), Amsterdam (two routers, broadband) and Paris (one router, nothing on it yet),
|
||||
// all on the Edge Lord 400. Change Freeze: no fat fingers.
|
||||
const BASE = "ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=3;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');" +
|
||||
"ACT.launchBB({city:'fra'});S.pops.fra.rgen=1;ACT.buyTransit({city:'fra',net:'cog',tier:1});" +
|
||||
"for(const c of ['ams','par'])ACT.buildPop({city:c});ACT.launchBB({city:'ams'});S.pops.ams.rgen=1;S.pops.ams.routers=2;S.pops.par.rgen=1;compute();" +
|
||||
"ACT.opsHire({id:'kevin'});S.ops.floor=0;closeModal()";
|
||||
const MODEL = "RG.findIndex(r=>r.n==='Arrrhipster 7800R')";
|
||||
function game(t) {
|
||||
const h = load();
|
||||
t.after(() => h.dom.window.close());
|
||||
h.ev(BASE);
|
||||
return h;
|
||||
}
|
||||
const gens = ev => JSON.parse(ev("JSON.stringify(['fra','ams','par'].map(c=>S.pops[c].rgen))"));
|
||||
|
||||
test('a chosen model: every POP on a smaller one is swapped to it, at the price of the swap, never as an outage', t => {
|
||||
const { ev, errors } = game(t);
|
||||
const m = ev(MODEL);
|
||||
assert.ok(m > 0 && ev(`rgOpen(${m})`), 'the model is unlocked at level 3');
|
||||
ev(`S.ops.on.routers=true;S.ops.p.routers={at:90,how:'auto',model:${m}};S.ops.cap.routers=0;compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0`);
|
||||
const want = ev(`swapCost('ams',${m})+swapCost('par',${m})`), c0 = ev('S.cash');
|
||||
ev('opsDay(S.day)');
|
||||
assert.deepEqual(gens(ev), [1, m, m], 'Amsterdam (a second router) and Paris (no traffic yet) are swapped; Frankfurt has one busy router, so no');
|
||||
assert.equal(c0 - ev('S.cash'), want, 'the shift paid exactly what the two swaps cost');
|
||||
assert.equal(ev("S.inc.some(i=>i.type==='maint')"), false, 'no outage');
|
||||
assert.match(ev('opsLine(S.ops.log[0])'), /Amsterdam ⇧800G/);
|
||||
// Frankfurt gets its turn once it has a second router.
|
||||
ev('S.pops.fra.routers=2;S.day++;compute();opsDay(S.day)');
|
||||
assert.deepEqual(gens(ev), [m, m, m]);
|
||||
// Busy POPs on the chosen model get more routers, never a swap to another one.
|
||||
ev("S.ops.p.routers.how='swap';S.day++;compute();R.nodeLoad.ams=R.nodeCap.ams*0.95;opsDay(S.day)");
|
||||
assert.equal(ev('S.pops.ams.rgen'), m, 'no swap away from the chosen model');
|
||||
ev("S.ops.p.routers.how='add';S.day++;compute();R.nodeLoad.ams=R.nodeCap.ams*0.95;opsDay(S.day)");
|
||||
assert.equal(ev('S.pops.ams.routers'), 3, 'a busy POP gets a third router');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the budget decides how far it gets, the busiest POP first; a smaller model is never a downgrade', t => {
|
||||
const { ev, errors } = game(t);
|
||||
const m = ev(MODEL);
|
||||
ev(`S.ops.on.routers=true;S.ops.p.routers={at:90,how:'auto',model:${m}};compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0;R.nodeLoad.par=R.nodeCap.par*0.5`);
|
||||
// A budget for one swap: Paris is the busier, so it goes first and Amsterdam waits for next month.
|
||||
const one = ev(`swapCost('par',${m})`);
|
||||
ev(`S.ops.cap.routers=OPS_CAPS.filter(c=>c>=${one}).sort((a,b)=>a-b)[0]`);
|
||||
assert.ok(ev('S.ops.cap.routers') < one + ev(`swapCost('ams',${m})`), 'the budget is too small for both');
|
||||
ev('opsDay(S.day)');
|
||||
assert.deepEqual(gens(ev), [1, 1, m], 'Paris first');
|
||||
assert.ok(ev("S.ops.log[0].r.some(x=>x[0]==='broke')"), 'the log says the budget ran out');
|
||||
// Next month, a new budget: Amsterdam.
|
||||
ev('{const m0=monthIdx(S.day);while(monthIdx(S.day)===m0)S.day++;}compute();for(const c in R.nodeLoad)R.nodeLoad[c]=0;opsDay(S.day)');
|
||||
assert.deepEqual(gens(ev), [1, m, m]);
|
||||
// Choosing a smaller model swaps nothing back.
|
||||
ev("S.ops.cap.routers=0;S.ops.p.routers.model=RG.findIndex(r=>r.n==='Edge Lord 400');S.day++;compute();opsDay(S.day)");
|
||||
assert.deepEqual(gens(ev), [1, m, m]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the setting is saved; an unknown model falls back to the next generation', t => {
|
||||
const { ev, errors } = game(t);
|
||||
const back = v => ev(`(()=>{const s=JSON.parse(JSON.stringify(S));s.ops.p.routers=${v};sanitize(s);return JSON.stringify(s.ops.p.routers);})()`);
|
||||
assert.deepEqual(JSON.parse(back(`{model:${ev(MODEL)}}`)), { model: ev(MODEL) });
|
||||
assert.deepEqual(JSON.parse(back('{model:999}')), {});
|
||||
assert.deepEqual(JSON.parse(back("{model:'7'}")), {});
|
||||
assert.deepEqual(JSON.parse(back('undefined')), {}, 'an old save without it');
|
||||
assert.equal(ev("opsP('routers','model')"), 'next');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('every setting in the Ops sheet is a list to pick from, on a phone too', t => {
|
||||
const { ev, dom, errors } = game(t);
|
||||
dom.window.innerWidth = 360;
|
||||
const doc = dom.window.document;
|
||||
ev("for(const k in S.ops.on)S.ops.on[k]=true;ACT.phoneTab({t:'noc'})");
|
||||
doc.querySelector('#leftBody [data-act="opsOpen"]').click();
|
||||
assert.equal(doc.querySelectorAll('#modalCard [data-act="opsParam"],#modalCard [data-act="opsCap"],#modalCard [data-act="opsFloor"]').length, 0, 'no buttons that step through values');
|
||||
const sel = (act, args) => [...doc.querySelectorAll(`#modalCard select[data-chg="${act}"]`)].find(s => s.dataset.args === JSON.stringify(args));
|
||||
const pick = (s, text) => {
|
||||
const o = [...s.options].find(o => o.textContent === text);
|
||||
assert.ok(o, `${text} is on the list`);
|
||||
s.value = o.value;
|
||||
s.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
|
||||
};
|
||||
// Every setting of every order, every budget and the floor.
|
||||
const n = ev('OPS.reduce((a,d)=>a+Object.keys(d.p).length+(d.cap?1:0),0)+1');
|
||||
assert.equal(doc.querySelectorAll('#modalCard .ops-p select').length, n);
|
||||
// The model list: the next generation, then the models you can buy, smallest first.
|
||||
const model = sel('opsParam', { k: 'routers', p: 'model' });
|
||||
assert.ok(model, 'the routers order has a model list');
|
||||
assert.equal(model.options[0].textContent, 'Next generation, when busy');
|
||||
assert.ok([...model.options].some(o => o.textContent === 'Arrrhipster 7800R'));
|
||||
assert.ok(![...model.options].some(o => o.textContent === 'Absolute Unit 3.2T'), 'only models unlocked at your level');
|
||||
pick(model, 'Arrrhipster 7800R');
|
||||
assert.equal(ev("opsP('routers','model')"), ev(MODEL));
|
||||
assert.equal(doc.activeElement && doc.activeElement.dataset.args, JSON.stringify({ k: 'routers', p: 'model' }), 'the keyboard stays on the list');
|
||||
pick(sel('opsParam', { k: 'transit', p: 'prov' }), 'Already connected');
|
||||
assert.equal(ev("opsP('transit','prov')"), 'have');
|
||||
pick(sel('opsCap', { k: 'routers' }), 'no limit');
|
||||
assert.equal(ev("opsCap('routers')"), 0);
|
||||
pick(sel('opsFloor', {}), ev('fmt$(1e6)'));
|
||||
assert.equal(ev('S.ops.floor'), 1e6);
|
||||
// A value from nowhere changes nothing; the MCP tools still step without a value.
|
||||
ev("ACT.opsParam({k:'routers',p:'model',v:'99'});ACT.opsCap({k:'routers',v:'-1'});ACT.opsFloor({v:'x'})");
|
||||
assert.deepEqual([ev("opsP('routers','model')"), ev("opsCap('routers')"), ev('S.ops.floor')], [ev(MODEL), 0, 1e6]);
|
||||
ev("ACT.opsParam({k:'routers',p:'how'})");
|
||||
assert.equal(ev("opsP('routers','how')"), 'add');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
@ -356,7 +356,9 @@ test('the Ops sheet works at 360 px in every language, from the NOC tab and the
|
|||
assert.ok(ev('opsHired()'), lang);
|
||||
doc.querySelector('#modalCard [data-act="opsToggle"]').click();
|
||||
assert.equal(doc.querySelector('#modalCard [data-act="opsToggle"]').getAttribute('aria-pressed'), 'true', lang);
|
||||
doc.querySelector('#modalCard [data-act="opsParam"]').click();
|
||||
const sel = doc.querySelector('#modalCard select[data-chg="opsParam"]');
|
||||
sel.value = String((sel.selectedIndex + 1) % sel.options.length);
|
||||
sel.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
|
||||
const txt = doc.getElementById('modalCard').textContent;
|
||||
assert.doesNotMatch(txt, /\bops\.[a-z_]+/, lang);
|
||||
assert.ok(doc.querySelector('#modalCard select[data-chg="opsCity"]'), lang);
|
||||
|
|
@ -495,7 +497,7 @@ test('the fat-fingered LAG member respects a paused transit order and per-POP ex
|
|||
});
|
||||
|
||||
test('caches: the cash floor and a running-cost budget hold; the panel and the log show what a month costs', t => {
|
||||
const { ev, errors } = game(t);
|
||||
const { ev, dom, errors } = game(t);
|
||||
hire(ev); on(ev, 'caches', { g: 1 });
|
||||
ev('S.pops.fra.rgen=0;compute()'); // 100G ports: 100G boxes at $400/mo
|
||||
const add = () => ev("utilityCaches('fra').add.filter(x=>(R.cityDem.fra||0)*NSH[x.net]>=1).length");
|
||||
|
|
@ -515,7 +517,8 @@ test('caches: the cash floor and a running-cost budget hold; the panel and the l
|
|||
ev('opsModal()');
|
||||
const txt = ev("document.getElementById('modalCard').textContent");
|
||||
assert.match(txt, /each box costs \$400\/mo/);
|
||||
assert.match(txt, /Adds at most: \+\$1\.0k\/mo/);
|
||||
const capSel = [...dom.window.document.querySelectorAll('#modalCard select[data-chg="opsCap"]')].find(x => x.dataset.args === '{"k":"caches"}');
|
||||
assert.equal(capSel.closest('label').firstChild.textContent + ': ' + capSel.options[capSel.selectedIndex].textContent, 'Adds at most: +$1.0k/mo');
|
||||
assert.match(txt, /This month: \$0 up front, \+\$800\/mo on the bill/);
|
||||
ev('S.day+=monLen(S.day);S.ops.cap.caches=0'); shift(ev);
|
||||
assert.equal(ev('S.ops.addMo.caches'), (ev('S.caches.length') - 2) * 400, 'a new month counts from zero');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue