Standing orders: caches get a running-cost budget and respect the cash floor; budgets and the shift log show monthly costs

This commit is contained in:
Frederic Jung 2026-10-28 20:28:50 +01:00
parent ef700a3480
commit e56659f949
No known key found for this signature in database
10 changed files with 107 additions and 29 deletions

View file

@ -2533,8 +2533,10 @@
"ops.anycast_annie":"Anycast-Annie", "ops.anycast_annie":"Anycast-Annie",
"ops.at_least_port":"mindestens {port}", "ops.at_least_port":"mindestens {port}",
"ops.budget":"Budget", "ops.budget":"Budget",
"ops.budget_running":"Höchstens dazu",
"ops.by_hand":"Einmal alles", "ops.by_hand":"Einmal alles",
"ops.by_hand_note":"Für den Moment, in dem alles sofort erledigt sein soll: jeder Peer an jedem Exchange, ein Redundanz-Kit, PNIs mit allen.", "ops.by_hand_note":"Für den Moment, in dem alles sofort erledigt sein soll: jeder Peer an jedem Exchange, ein Redundanz-Kit, PNIs mit allen.",
"ops.caches_rent":"Kostenlos ins Rack, aber jede Box kostet {price}/Monat für Platz und Strom.",
"ops.cheapest":"Günstigster", "ops.cheapest":"Günstigster",
"ops.ff_desc":"hat einen Port in {city} „TODO: später fixen (nicht fixen)“ beschriftet", "ops.ff_desc":"hat einen Port in {city} „TODO: später fixen (nicht fixen)“ beschriftet",
"ops.ff_hostname":"hat den Router in {city} in router-final-FINAL-v2 umbenannt", "ops.ff_hostname":"hat den Router in {city} in router-final-FINAL-v2 umbenannt",
@ -2563,6 +2565,7 @@
"ops.l_decom":{"one":"hat eine kleine Wave auf {where} zurückgegeben","other":"hat {n} kleine Waves zurückgegeben ({where})"}, "ops.l_decom":{"one":"hat eine kleine Wave auf {where} zurückgegeben","other":"hat {n} kleine Waves zurückgegeben ({where})"},
"ops.l_line":"{name} {list}.", "ops.l_line":"{name} {list}.",
"ops.l_optics":{"one":"hat einen Kanal auf {where} aufgeschaltet","other":"hat {n} Kanäle aufgeschaltet ({where})"}, "ops.l_optics":{"one":"hat einen Kanal auf {where} aufgeschaltet","other":"hat {n} Kanäle aufgeschaltet ({where})"},
"ops.l_paid":"Kosten: {cost} einmalig, {mo}/Monat.",
"ops.l_peer":{"one":"hat mit einem Netz an {where} gepeert","other":"hat mit {n} Netzen an {where} gepeert"}, "ops.l_peer":{"one":"hat mit einem Netz an {where} gepeert","other":"hat mit {n} Netzen an {where} gepeert"},
"ops.l_pni":{"one":"hat einen PNI in {where} bestellt","other":"hat {n} PNIs bestellt ({where})"}, "ops.l_pni":{"one":"hat einen PNI in {where} bestellt","other":"hat {n} PNIs bestellt ({where})"},
"ops.l_quiet":"{name} hat auf die Graphen geschaut. Nichts zu tun.", "ops.l_quiet":"{name} hat auf die Graphen geschaut. Nichts zu tun.",
@ -2614,7 +2617,7 @@
"ops.really_fire":"Wirklich entlassen?", "ops.really_fire":"Wirklich entlassen?",
"ops.salary":"Gehalt {price}/Monat · seit {d}", "ops.salary":"Gehalt {price}/Monat · seit {d}",
"ops.shift":"Schicht von {name}", "ops.shift":"Schicht von {name}",
"ops.spent_this_month":"Diesen Monat ausgegeben: {price}", "ops.spent_and_mo":"Diesen Monat: {price} einmalig, {mo}/Monat auf der Rechnung",
"ops.standing_orders":"Daueraufträge", "ops.standing_orders":"Daueraufträge",
"ops.template":"Neuer POP aus der Vorlage", "ops.template":"Neuer POP aus der Vorlage",
"ops.template_note":"Wähle, was {name} einrichtet, wenn du eine Stadt aus der Vorlage eröffnest. Den Rest übernehmen die Daueraufträge.", "ops.template_note":"Wähle, was {name} einrichtet, wenn du eine Stadt aus der Vorlage eröffnest. Den Rest übernehmen die Daueraufträge.",

View file

@ -2531,8 +2531,10 @@
"ops.anycast_annie":"Annie Anycast", "ops.anycast_annie":"Annie Anycast",
"ops.at_least_port":"al menos {port}", "ops.at_least_port":"al menos {port}",
"ops.budget":"Presupuesto", "ops.budget":"Presupuesto",
"ops.budget_running":"Añade como máximo",
"ops.by_hand":"Lotes puntuales", "ops.by_hand":"Lotes puntuales",
"ops.by_hand_note":"Para cuando lo quieres todo hecho ya: cada peer en cada exchange, un kit de redundancia, PNIs con todos.", "ops.by_hand_note":"Para cuando lo quieres todo hecho ya: cada peer en cada exchange, un kit de redundancia, PNIs con todos.",
"ops.caches_rent":"Instalarla es gratis, pero cada caja cuesta {price}/mes en espacio y energía.",
"ops.cheapest":"El más barato", "ops.cheapest":"El más barato",
"ops.ff_desc":"etiquetó un puerto en {city} como «TODO: arreglar luego (no arreglar)»", "ops.ff_desc":"etiquetó un puerto en {city} como «TODO: arreglar luego (no arreglar)»",
"ops.ff_hostname":"renombró el router de {city} a router-final-FINAL-v2", "ops.ff_hostname":"renombró el router de {city} a router-final-FINAL-v2",
@ -2561,6 +2563,7 @@
"ops.l_decom":{"one":"devolvió una wave pequeña en {where}","other":"devolvió {n} waves pequeñas ({where})"}, "ops.l_decom":{"one":"devolvió una wave pequeña en {where}","other":"devolvió {n} waves pequeñas ({where})"},
"ops.l_line":"{name} {list}.", "ops.l_line":"{name} {list}.",
"ops.l_optics":{"one":"encendió un canal en {where}","other":"encendió {n} canales ({where})"}, "ops.l_optics":{"one":"encendió un canal en {where}","other":"encendió {n} canales ({where})"},
"ops.l_paid":"Coste: {cost} de entrada, {mo}/mes.",
"ops.l_peer":{"one":"hizo peering con una red en {where}","other":"hizo peering con {n} redes en {where}"}, "ops.l_peer":{"one":"hizo peering con una red en {where}","other":"hizo peering con {n} redes en {where}"},
"ops.l_pni":{"one":"pidió un PNI en {where}","other":"pidió {n} PNIs ({where})"}, "ops.l_pni":{"one":"pidió un PNI en {where}","other":"pidió {n} PNIs ({where})"},
"ops.l_quiet":"{name} miró las gráficas. No había nada que hacer.", "ops.l_quiet":"{name} miró las gráficas. No había nada que hacer.",
@ -2612,7 +2615,7 @@
"ops.really_fire":"¿Despedir de verdad?", "ops.really_fire":"¿Despedir de verdad?",
"ops.salary":"Sueldo {price}/mes · desde {d}", "ops.salary":"Sueldo {price}/mes · desde {d}",
"ops.shift":"Turno de {name}", "ops.shift":"Turno de {name}",
"ops.spent_this_month":"Gastado este mes: {price}", "ops.spent_and_mo":"Este mes: {price} de entrada, {mo}/mes en la factura",
"ops.standing_orders":"Órdenes permanentes", "ops.standing_orders":"Órdenes permanentes",
"ops.template":"POP nuevo desde plantilla", "ops.template":"POP nuevo desde plantilla",
"ops.template_note":"Elige lo que monta {name} cuando abres una ciudad desde la plantilla. Las órdenes permanentes se encargan del resto.", "ops.template_note":"Elige lo que monta {name} cuando abres una ciudad desde la plantilla. Las órdenes permanentes se encargan del resto.",

View file

@ -2531,8 +2531,10 @@
"ops.anycast_annie":"Annie Anycast", "ops.anycast_annie":"Annie Anycast",
"ops.at_least_port":"au moins {port}", "ops.at_least_port":"au moins {port}",
"ops.budget":"Budget", "ops.budget":"Budget",
"ops.budget_running":"Ajoute au plus",
"ops.by_hand":"Lots ponctuels", "ops.by_hand":"Lots ponctuels",
"ops.by_hand_note":"Pour quand tu veux tout, tout de suite : chaque peer sur chaque exchange, un kit de redondance, des PNI avec tout le monde.", "ops.by_hand_note":"Pour quand tu veux tout, tout de suite : chaque peer sur chaque exchange, un kit de redondance, des PNI avec tout le monde.",
"ops.caches_rent":"Gratuit à installer, mais chaque boîtier coûte {price}/mois en espace et en électricité.",
"ops.cheapest":"Le moins cher", "ops.cheapest":"Le moins cher",
"ops.ff_desc":"a étiqueté un port à {city} « TODO : corriger plus tard (ne pas corriger) »", "ops.ff_desc":"a étiqueté un port à {city} « TODO : corriger plus tard (ne pas corriger) »",
"ops.ff_hostname":"a renommé le routeur de {city} en router-final-FINAL-v2", "ops.ff_hostname":"a renommé le routeur de {city} en router-final-FINAL-v2",
@ -2561,6 +2563,7 @@
"ops.l_decom":{"one":"a rendu une petite wave sur {where}","other":"a rendu {n} petites waves ({where})"}, "ops.l_decom":{"one":"a rendu une petite wave sur {where}","other":"a rendu {n} petites waves ({where})"},
"ops.l_line":"{name} {list}.", "ops.l_line":"{name} {list}.",
"ops.l_optics":{"one":"a allumé un canal sur {where}","other":"a allumé {n} canaux ({where})"}, "ops.l_optics":{"one":"a allumé un canal sur {where}","other":"a allumé {n} canaux ({where})"},
"ops.l_paid":"Coût : {cost} d'entrée, {mo}/mois.",
"ops.l_peer":{"one":"a peeré avec un réseau à {where}","other":"a peeré avec {n} réseaux à {where}"}, "ops.l_peer":{"one":"a peeré avec un réseau à {where}","other":"a peeré avec {n} réseaux à {where}"},
"ops.l_pni":{"one":"a commandé un PNI à {where}","other":"a commandé {n} PNI ({where})"}, "ops.l_pni":{"one":"a commandé un PNI à {where}","other":"a commandé {n} PNI ({where})"},
"ops.l_quiet":"{name} a surveillé les graphes. Rien à faire.", "ops.l_quiet":"{name} a surveillé les graphes. Rien à faire.",
@ -2612,7 +2615,7 @@
"ops.really_fire":"Vraiment remercier ?", "ops.really_fire":"Vraiment remercier ?",
"ops.salary":"Salaire {price}/mois · depuis {d}", "ops.salary":"Salaire {price}/mois · depuis {d}",
"ops.shift":"Le service de {name}", "ops.shift":"Le service de {name}",
"ops.spent_this_month":"Dépensé ce mois-ci : {price}", "ops.spent_and_mo":"Ce mois-ci : {price} d'entrée, {mo}/mois sur la facture",
"ops.standing_orders":"Ordres permanents", "ops.standing_orders":"Ordres permanents",
"ops.template":"Nouveau POP depuis le modèle", "ops.template":"Nouveau POP depuis le modèle",
"ops.template_note":"Choisis ce que {name} installe quand tu ouvres une ville depuis le modèle. Les ordres permanents s'occupent du reste.", "ops.template_note":"Choisis ce que {name} installe quand tu ouvres une ville depuis le modèle. Les ordres permanents s'occupent du reste.",

View file

@ -2531,8 +2531,10 @@
"ops.anycast_annie":"Annie Anycast", "ops.anycast_annie":"Annie Anycast",
"ops.at_least_port":"almeno {port}", "ops.at_least_port":"almeno {port}",
"ops.budget":"Budget", "ops.budget":"Budget",
"ops.budget_running":"Aggiunge al massimo",
"ops.by_hand":"Lotti una tantum", "ops.by_hand":"Lotti una tantum",
"ops.by_hand_note":"Per quando vuoi tutto fatto subito: ogni peer su ogni exchange, un kit di ridondanza, PNI con tutti.", "ops.by_hand_note":"Per quando vuoi tutto fatto subito: ogni peer su ogni exchange, un kit di ridondanza, PNI con tutti.",
"ops.caches_rent":"Gratis da montare, ma ogni box costa {price}/mese di spazio e corrente.",
"ops.cheapest":"Il più economico", "ops.cheapest":"Il più economico",
"ops.ff_desc":"ha etichettato una porta a {city} «TODO: sistemare dopo (non sistemare)»", "ops.ff_desc":"ha etichettato una porta a {city} «TODO: sistemare dopo (non sistemare)»",
"ops.ff_hostname":"ha rinominato il router di {city} in router-final-FINAL-v2", "ops.ff_hostname":"ha rinominato il router di {city} in router-final-FINAL-v2",
@ -2561,6 +2563,7 @@
"ops.l_decom":{"one":"ha restituito una wave piccola su {where}","other":"ha restituito {n} wave piccole ({where})"}, "ops.l_decom":{"one":"ha restituito una wave piccola su {where}","other":"ha restituito {n} wave piccole ({where})"},
"ops.l_line":"{name} {list}.", "ops.l_line":"{name} {list}.",
"ops.l_optics":{"one":"ha acceso un canale su {where}","other":"ha acceso {n} canali ({where})"}, "ops.l_optics":{"one":"ha acceso un canale su {where}","other":"ha acceso {n} canali ({where})"},
"ops.l_paid":"Costo: {cost} subito, {mo}/mese.",
"ops.l_peer":{"one":"ha fatto peering con una rete a {where}","other":"ha fatto peering con {n} reti a {where}"}, "ops.l_peer":{"one":"ha fatto peering con una rete a {where}","other":"ha fatto peering con {n} reti a {where}"},
"ops.l_pni":{"one":"ha ordinato un PNI a {where}","other":"ha ordinato {n} PNI ({where})"}, "ops.l_pni":{"one":"ha ordinato un PNI a {where}","other":"ha ordinato {n} PNI ({where})"},
"ops.l_quiet":"{name} ha guardato i grafici. Niente da fare.", "ops.l_quiet":"{name} ha guardato i grafici. Niente da fare.",
@ -2612,7 +2615,7 @@
"ops.really_fire":"Licenziare davvero?", "ops.really_fire":"Licenziare davvero?",
"ops.salary":"Stipendio {price}/mese · dal {d}", "ops.salary":"Stipendio {price}/mese · dal {d}",
"ops.shift":"Il turno di {name}", "ops.shift":"Il turno di {name}",
"ops.spent_this_month":"Speso questo mese: {price}", "ops.spent_and_mo":"Questo mese: {price} subito, {mo}/mese in bolletta",
"ops.standing_orders":"Ordini permanenti", "ops.standing_orders":"Ordini permanenti",
"ops.template":"Nuovo POP da modello", "ops.template":"Nuovo POP da modello",
"ops.template_note":"Scegli cosa monta {name} quando apri una città dal modello. Al resto pensano gli ordini permanenti.", "ops.template_note":"Scegli cosa monta {name} quando apri una città dal modello. Al resto pensano gli ordini permanenti.",

View file

@ -2531,8 +2531,10 @@
"ops.anycast_annie":"Annie Anycast", "ops.anycast_annie":"Annie Anycast",
"ops.at_least_port":"pelo menos {port}", "ops.at_least_port":"pelo menos {port}",
"ops.budget":"Orçamento", "ops.budget":"Orçamento",
"ops.budget_running":"Adiciona no máximo",
"ops.by_hand":"Lotes avulsos", "ops.by_hand":"Lotes avulsos",
"ops.by_hand_note":"Para quando você quer tudo feito agora: cada peer em cada exchange, um kit de redundância, PNIs com todo mundo.", "ops.by_hand_note":"Para quando você quer tudo feito agora: cada peer em cada exchange, um kit de redundância, PNIs com todo mundo.",
"ops.caches_rent":"Instalar é grátis, mas cada caixa custa {price}/mês em espaço e energia.",
"ops.cheapest":"O mais barato", "ops.cheapest":"O mais barato",
"ops.ff_desc":"etiquetou uma porta em {city} como “TODO: corrigir depois (não corrigir)”", "ops.ff_desc":"etiquetou uma porta em {city} como “TODO: corrigir depois (não corrigir)”",
"ops.ff_hostname":"renomeou o roteador de {city} para router-final-FINAL-v2", "ops.ff_hostname":"renomeou o roteador de {city} para router-final-FINAL-v2",
@ -2561,6 +2563,7 @@
"ops.l_decom":{"one":"devolveu uma wave pequena em {where}","other":"devolveu {n} waves pequenas ({where})"}, "ops.l_decom":{"one":"devolveu uma wave pequena em {where}","other":"devolveu {n} waves pequenas ({where})"},
"ops.l_line":"{name} {list}.", "ops.l_line":"{name} {list}.",
"ops.l_optics":{"one":"acendeu um canal em {where}","other":"acendeu {n} canais ({where})"}, "ops.l_optics":{"one":"acendeu um canal em {where}","other":"acendeu {n} canais ({where})"},
"ops.l_paid":"Custo: {cost} de entrada, {mo}/mês.",
"ops.l_peer":{"one":"fez peering com uma rede em {where}","other":"fez peering com {n} redes em {where}"}, "ops.l_peer":{"one":"fez peering com uma rede em {where}","other":"fez peering com {n} redes em {where}"},
"ops.l_pni":{"one":"pediu um PNI em {where}","other":"pediu {n} PNIs ({where})"}, "ops.l_pni":{"one":"pediu um PNI em {where}","other":"pediu {n} PNIs ({where})"},
"ops.l_quiet":"{name} ficou olhando os gráficos. Nada a fazer.", "ops.l_quiet":"{name} ficou olhando os gráficos. Nada a fazer.",
@ -2612,7 +2615,7 @@
"ops.really_fire":"Dispensar mesmo?", "ops.really_fire":"Dispensar mesmo?",
"ops.salary":"Salário {price}/mês · desde {d}", "ops.salary":"Salário {price}/mês · desde {d}",
"ops.shift":"Turno de {name}", "ops.shift":"Turno de {name}",
"ops.spent_this_month":"Gasto este mês: {price}", "ops.spent_and_mo":"Este mês: {price} de entrada, {mo}/mês na fatura",
"ops.standing_orders":"Ordens permanentes", "ops.standing_orders":"Ordens permanentes",
"ops.template":"Novo POP por modelo", "ops.template":"Novo POP por modelo",
"ops.template_note":"Escolha o que {name} monta quando você abre uma cidade pelo modelo. As ordens permanentes cuidam do resto.", "ops.template_note":"Escolha o que {name} monta quando você abre uma cidade pelo modelo. As ordens permanentes cuidam do resto.",

View file

@ -2,17 +2,18 @@
A NOC intern runs the player's standing orders once per game day. Every job goes through the same action a click A NOC intern runs the player's standing orders once per game day. Every job goes through the same action a click
would (ACT.*, pniPlace, the #185/#192 planners), so it costs exactly what the click costs, with toasts and redraws would (ACT.*, pniPlace, the #185/#192 planners), so it costs exactly what the click costs, with toasts and redraws
muted and one recompute at the end. Without an intern nothing here runs and no random numbers are drawn. */ muted and one recompute at the end. Without an intern nothing here runs and no random numbers are drawn. */
const INTERN_MO=6000,OPS_LOG=12,OPS_CAPS=[10000,50000,250000,1e6,5e6,0],OPS_FLOORS=[0,50000,250000,1e6,5e6]; const INTERN_MO=6000,OPS_LOG=12,OPS_CAPS=[10000,50000,250000,1e6,5e6,0],OPS_CAPS_MO=[1000,2500,5000,10000,25000,0],OPS_FLOORS=[0,50000,250000,1e6,5e6];
const INTERNS={ const INTERNS={
annie:{i:'📡',n:N_('ops.anycast_annie'),s:N_('ops.annie'),d:N_('ops.annie_d')}, annie:{i:'📡',n:N_('ops.anycast_annie'),s:N_('ops.annie'),d:N_('ops.annie_d')},
kevin:{i:'🌙',n:N_('ops.kevin_from_the_night_shift'),s:N_('ops.kevin'),d:N_('ops.kevin_d')}, kevin:{i:'🌙',n:N_('ops.kevin_from_the_night_shift'),s:N_('ops.kevin'),d:N_('ops.kevin_d')},
tracy:{i:'🧭',n:N_('ops.tracy_route'),s:N_('ops.tracy'),d:N_('ops.tracy_d')}, tracy:{i:'🧭',n:N_('ops.tracy_route'),s:N_('ops.tracy'),d:N_('ops.tracy_d')},
}; };
// The orders, in the order the panel shows them. pop: can be switched off per POP. cap: default monthly budget. // The orders, in the order the panel shows them. pop: can be switched off per POP. cap: default monthly budget, of setup
// fees, or (mo) of the running costs the order adds, for caches, which are free to rack but cost rent every month.
const OPS=[ 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'||(isNet(v)&&!!NET[v].price),l:N_('ops.p_prov')}}}, {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'||(isNet(v)&&!!NET[v].price),l:N_('ops.p_prov')}}},
{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_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:'caches',i:'📦',pop: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:'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:'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=>tr(v?'common.on':'common.off')}}}, {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=>tr(v?'common.on':'common.off')}}},
{k:'sales',i:'💼',t:N_('ops.o_sales'),d:N_('ops.o_sales_d'),p:{acc:{d:true,v:[true,false],l:N_('ops.p_acc'),f:v=>tr(v?'common.on':'common.off')},min:{d:0,v:[0,2000,5000,10000,25000,50000],l:N_('ops.p_min'),f:v=>v?tr('common.price_mo',{price:fmt$(v)}):tr('ops.never')}}}, {k:'sales',i:'💼',t:N_('ops.o_sales'),d:N_('ops.o_sales_d'),p:{acc:{d:true,v:[true,false],l:N_('ops.p_acc'),f:v=>tr(v?'common.on':'common.off')},min:{d:0,v:[0,2000,5000,10000,25000,50000],l:N_('ops.p_min'),f:v=>v?tr('common.price_mo',{price:fmt$(v)}):tr('ops.never')}}},
@ -27,13 +28,14 @@ const OPS_SAY={transit:N_('ops.l_transit'),routers:N_('ops.l_routers'),caches:N_
// Fat fingers: rare, visible, harmless. Only the LAG one costs anything, and only a little. // 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=[N_('ops.ff_desc'),N_('ops.ff_hostname'),N_('ops.ff_typo'),N_('ops.ff_lag'),N_('ops.ff_ping')];
const OPS_TRIALS=1,OPS_FF_RATE={oncall:1/150,bgp:1/60}; const OPS_TRIALS=1,OPS_FF_RATE={oncall:1/150,bgp:1/60};
function opsNew(){return {intern:null,hired:0,on:Object.fromEntries(OPS.map(o=>[o.k,false])),p:{},cap:{},spent:Object.fromEntries(OPS.filter(o=>o.cap).map(o=>[o.k,0])),mon:0,skip:{},log:[],floor:50000,tpl:{bb:true,transit:true,ix:true,kit:true}};} function opsNew(){return {intern:null,hired:0,on:Object.fromEntries(OPS.map(o=>[o.k,false])),p:{},cap:{},spent:Object.fromEntries(OPS.filter(o=>o.cap).map(o=>[o.k,0])),addMo:{},mon:0,skip:{},log:[],floor:50000,tpl:{bb:true,transit:true,ix:true,kit:true}};}
const opsO=()=>S.ops||(S.ops=opsNew()); const opsO=()=>S.ops||(S.ops=opsNew());
const opsHired=()=>!!(S&&S.ops&&S.ops.intern&&own(INTERNS,S.ops.intern)); const opsHired=()=>!!(S&&S.ops&&S.ops.intern&&own(INTERNS,S.ops.intern));
const opsCanHire=()=>lvl()>=2; const opsCanHire=()=>lvl()>=2;
const opsName=(long)=>{const I=INTERNS[S.ops.intern];return I?tr(long?I.n:I.s):'';}; 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;} 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;}
function opsCap(k){const c=S.ops.cap[k];return OPS_CAPS.includes(c)?c:OPSK[k].cap||0;} 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); const opsHere=(k,c)=>!(S.ops.skip[c]||[]).includes(k);
const opsPops=k=>Object.keys(S.pops).filter(c=>opsHere(k,c)); const opsPops=k=>Object.keys(S.pops).filter(c=>opsHere(k,c));
// Saves are untrusted: rebuild ops from known orders, params, cities and log shapes. Runs after the POPs are repaired, // Saves are untrusted: rebuild ops from known orders, params, cities and log shapes. Runs after the POPs are repaired,
@ -45,31 +47,47 @@ function opsSanitize(s){const o=s.ops&&typeof s.ops==='object'&&!Array.isArray(s
const on=ob(o.on),p=ob(o.p),cap=ob(o.cap),sp=ob(o.spent); const on=ob(o.on),p=ob(o.p),cap=ob(o.cap),sp=ob(o.spent);
for(const d of OPS){const k=d.k;n.on[k]=on[k]===true;const q=ob(p[k]),r={}; for(const d of OPS){const k=d.k;n.on[k]=on[k]===true;const q=ob(p[k]),r={};
for(const pk of Object.keys(d.p)){const P=d.p[pk];if(own(q,pk)&&(P.ok?P.ok(q[pk]):P.v.includes(q[pk])))r[pk]=q[pk];}n.p[k]=r; for(const pk of Object.keys(d.p)){const P=d.p[pk];if(own(q,pk)&&(P.ok?P.ok(q[pk]):P.v.includes(q[pk])))r[pk]=q[pk];}n.p[k]=r;
if(d.cap&&OPS_CAPS.includes(cap[k]))n.cap[k]=cap[k];if(d.cap)n.spent[k]=Math.max(0,num(sp[k],0));} if(d.cap&&opsCaps(k).includes(cap[k]))n.cap[k]=cap[k];if(d.cap)n.spent[k]=Math.max(0,num(sp[k],0));
{const v=num(ob(o.addMo)[k],0);if(v)n.addMo[k]=Math.max(-1e9,Math.min(1e9,v));}}
{const t=ob(o.tpl);for(const k of OPS_TPL)if(typeof t[k]==='boolean')n.tpl[k]=t[k];} {const t=ob(o.tpl);for(const k of OPS_TPL)if(typeof t[k]==='boolean')n.tpl[k]=t[k];}
{const sk=ob(o.skip);for(const c of Object.keys(sk))if(isCity(c)&&own(s.pops,c)&&Array.isArray(sk[c])){const ks=[...new Set(sk[c].filter(k=>OPS_POP.includes(k)))];if(ks.length)n.skip[c]=ks;}} {const sk=ob(o.skip);for(const c of Object.keys(sk))if(isCity(c)&&own(s.pops,c)&&Array.isArray(sk[c])){const ks=[...new Set(sk[c].filter(k=>OPS_POP.includes(k)))];if(ks.length)n.skip[c]=ks;}}
if(Array.isArray(o.log))n.log=o.log.map(opsLogOk).filter(Boolean).slice(0,OPS_LOG); if(Array.isArray(o.log))n.log=o.log.map(opsLogOk).filter(Boolean).slice(0,OPS_LOG);
if(s.autoSales===true)n.on.sales=true;if(s.autoRepair===true)n.on.repair=true;delete s.autoSales;delete s.autoRepair; if(s.autoSales===true)n.on.sales=true;if(s.autoRepair===true)n.on.repair=true;delete s.autoSales;delete s.autoRepair;
s.ops=n;} s.ops=n;}
// A log entry: {d, i: intern, r: [[kind, n, [where…]]], f: fat-finger index, c: its city}. // A log entry: {d, i: intern, r: [[kind, n, [where…]]], f: fat-finger index, c: its city, up: paid up front, mo: running costs added}.
const opsWhereOk=w=>typeof w==='string'&&w.length<=48&&/^[a-z0-9~|]+( [+\w.×→⇧]+)?$/i.test(w)&&w.split(' ')[0].split('|').every(x=>isIx(x)||own(OPSK,x)||isNet(x)); const opsWhereOk=w=>typeof w==='string'&&w.length<=48&&/^[a-z0-9~|]+( [+\w.×→⇧]+)?$/i.test(w)&&w.split(' ')[0].split('|').every(x=>isIx(x)||own(OPSK,x)||isNet(x));
function opsLogOk(e){if(!e||typeof e!=='object'||!own(INTERNS,e.i))return null;const r=Array.isArray(e.r)?e.r.filter(x=>Array.isArray(x)&&own(OPS_SAY,x[0])&&Array.isArray(x[2])).map(x=>[x[0],int(x[1],1,1e6,1),x[2].filter(opsWhereOk).slice(0,3)]).slice(0,16):[]; function opsLogOk(e){if(!e||typeof e!=='object'||!own(INTERNS,e.i))return null;const r=Array.isArray(e.r)?e.r.filter(x=>Array.isArray(x)&&own(OPS_SAY,x[0])&&Array.isArray(x[2])).map(x=>[x[0],int(x[1],1,1e6,1),x[2].filter(opsWhereOk).slice(0,3)]).slice(0,16):[];
const f=Number.isInteger(e.f)&&OPS_FF[e.f]?e.f:undefined;return {d:int(e.d,0,1e7,0),i:e.i,r,...(f!==undefined&&isCity(e.c)?{f,c:e.c}:{})};} const f=Number.isInteger(e.f)&&OPS_FF[e.f]?e.f:undefined,up=int(e.up,0,1e12,0),mo=int(e.mo,-1e9,1e9,0);
return {d:int(e.d,0,1e7,0),i:e.i,r,...(f!==undefined&&isCity(e.c)?{f,c:e.c}:{}),...(up?{up}:{}),...(mo?{mo}:{})};}
// "fra +1×100G", "fra|ams", "ams~3", "transit" (an order, for the budget line) or "ggl" (a network). // "fra +1×100G", "fra|ams", "ams~3", "transit" (an order, for the budget line) or "ggl" (a network).
function opsWhere(w){const [a,x]=w.split(' '),nm=a.split('|').map(p=>own(OPSK,p)?tr(OPSK[p].t):isCity(p)?CITY[p].name:isNet(p)?NET[p].name:ixName(p)).join('–');return x?nm+' '+(isNet(x)?NET[x].name:x):nm;} function opsWhere(w){const [a,x]=w.split(' '),nm=a.split('|').map(p=>own(OPSK,p)?tr(OPSK[p].t):isCity(p)?CITY[p].name:isNet(p)?NET[p].name:ixName(p)).join('–');return x?nm+' '+(isNet(x)?NET[x].name:x):nm;}
function opsLine(e){const I=INTERNS[e.i],name=I?tr(I.s):'',parts=e.r.map(([k,n,w])=>trn(OPS_SAY[k],n,{where:w.map(opsWhere).join(', ')})); function opsLine(e){const I=INTERNS[e.i],name=I?tr(I.s):'',parts=e.r.map(([k,n,w])=>trn(OPS_SAY[k],n,{where:w.map(opsWhere).join(', ')}));
return parts.length?tr('ops.l_line',{name,list:parts.join(', ')}):tr('ops.l_quiet',{name});} return (parts.length?tr('ops.l_line',{name,list:parts.join(', ')}):tr('ops.l_quiet',{name}))+opsPaid(e);}
const opsMo$=v=>(v>0?'+':'')+fmt$(v);
const opsPaid=e=>e.up||e.mo?' '+tr('ops.l_paid',{cost:fmt$(e.up||0),mo:opsMo$(e.mo||0)}):'';
// 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=S.caches.length*CACHE_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;}
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);}
return m;}
const opsFFLine=e=>tr('ops.ff_line',{name:tr(INTERNS[e.i].s),what:tr(OPS_FF[e.f],{city:CITY[e.c].name})}); const opsFFLine=e=>tr('ops.ff_line',{name:tr(INTERNS[e.i].s),what:tr(OPS_FF[e.f],{city:CITY[e.c].name})});
// Mute what a click would show (toasts, sounds, floaters, the full redraw) and keep the player's selection. // Mute what a click would show (toasts, sounds, floaters, the full redraw) and keep the player's selection.
function opsQuiet(fn){const a=after,t=toast,s=sfx,f=floater,sel=UI.sel,cf=UI.confirm,tab=UI.tab;after=()=>{};toast=()=>{};sfx=()=>{};floater=()=>{}; function opsQuiet(fn){const a=after,t=toast,s=sfx,f=floater,sel=UI.sel,cf=UI.confirm,tab=UI.tab;after=()=>{};toast=()=>{};sfx=()=>{};floater=()=>{};
try{return fn();}finally{after=a;toast=t;sfx=s;floater=f;UI.confirm=cf;UI.tab=tab;UI.sel=sel&&(sel.type!=='link'||S.links.some(l=>l.id===sel.id))&&(sel.type!=='city'||isCity(sel.id))?sel:null;}} try{return fn();}finally{after=a;toast=t;sfx=s;floater=f;UI.confirm=cf;UI.tab=tab;UI.sel=sel&&(sel.type!=='link'||S.links.some(l=>l.id===sel.id))&&(sel.type!=='city'||isCity(sel.id))?sel:null;}}
// One shift's bookkeeping: what got done, and whether a job had to wait for next month's budget. // One shift's bookkeeping: what got done, and whether a job had to wait for next month's budget.
// dirty: a job changed the network, so R (loads, routing) is out of date until the next compute(). // dirty: a job changed the network, so R (loads, routing) is out of date until the next compute().
// up/mo/rev: what this shift paid up front, added to the monthly bill, and signed in monthly revenue.
function opsShift(){const r=new Map(),broke=new Set(); function opsShift(){const r=new Map(),broke=new Set();
return {r,broke,dirty:false,did(k,w){if(k!=='decline')this.dirty=true;const x=r.get(k)||{n:0,w:[]};x.n++;if(w&&x.w.length<3&&!x.w.includes(w))x.w.push(w);r.set(k,x);}, return {r,broke,dirty:false,up:0,mo:0,rev:0,did(k,w){if(k!=='decline')this.dirty=true;const x=r.get(k)||{n:0,w:[]};x.n++;if(w&&x.w.length<3&&!x.w.includes(w))x.w.push(w);r.set(k,x);},
can(k,cost){const O=S.ops,cap=opsCap(k);if(cost<=0)return true;if(S.cash-cost<O.floor||(cap&&(O.spent[k]||0)+cost>cap)){broke.add(k);return false;}return true;}, // A job that costs nothing up front still has to pass the cash floor if it adds to the monthly bill.
can(k,cost,mo=0){const O=S.ops,cap=opsCap(k);if(cost<=0&&!(mo>0))return true;
if(S.cash-Math.max(0,cost)<O.floor||(cap&&(OPSK[k].mo?(O.addMo[k]||0)+mo:(O.spent[k]||0)+cost)>cap)){broke.add(k);return false;}return true;},
book(k,d,dm){const O=S.ops;if(d>0){this.up+=d;if(OPSK[k].cap)O.spent[k]=(O.spent[k]||0)+d;}if(dm){this.mo+=dm;O.addMo[k]=(O.addMo[k]||0)+dm;}},
// Run a click and book what it really cost; false when the action refused (no ports, no cash, a quote changed). // Run a click and book what it really cost; false when the action refused (no ports, no cash, a quote changed).
pay(k,fn){const c0=S.cash,x=fn();const d=c0-S.cash;if(d>0&&OPSK[k].cap)S.ops.spent[k]=(S.ops.spent[k]||0)+d;return x===undefined?d>0:x;}};} pay(k,fn){const c0=S.cash,m0=opsMoNow(),x=fn();this.book(k,c0-S.cash,opsMoNow()-m0);return x===undefined?c0-S.cash>0:x;}};}
// Never buy from a provider that breaks a promise: a customer's "no Cogentle" or "two upstreams", a bank's covenant, // Never buy from a provider that breaks a promise: a customer's "no Cogentle" or "two upstreams", a bank's covenant,
// or Cogentle while it is not speaking to Goggle (the Spat scenario, a de-peering). Only met → failed counts. // or Cogentle while it is not speaking to Goggle (the Spat scenario, a de-peering). Only met → failed counts.
const OPS_TREQ=['nocog','twoup']; const OPS_TREQ=['nocog','twoup'];
@ -87,7 +105,7 @@ const OPS_RUN={
if(min&&v<min){S.offers=S.offers.filter(x=>x!==o);X.did('decline');continue;} if(min&&v<min){S.offers=S.offers.filter(x=>x!==o);X.did('decline');continue;}
// Each trial is a full routing pass: at most one a shift, and an offer that did not fit waits a week. // Each trial is a full routing pass: at most one a shift, and an offer that did not fit waits a week.
if(acc&&o.exp>S.day&&bCities(o).every(popUp)&&reqOk(o)&&tries<OPS_TRIALS&&!(UI.opsTried&&UI.opsTried.s===S&&UI.opsTried.m.get(o.id)>S.day-7)){tries++;ACT.accept({id:o.id,auto:true}); if(acc&&o.exp>S.day&&bCities(o).every(popUp)&&reqOk(o)&&tries<OPS_TRIALS&&!(UI.opsTried&&UI.opsTried.s===S&&UI.opsTried.m.get(o.id)>S.day-7)){tries++;ACT.accept({id:o.id,auto:true});
if(!S.offers.includes(o))X.did('sales');else{if(!UI.opsTried||UI.opsTried.s!==S)UI.opsTried={s:S,m:new Map()};UI.opsTried.m.set(o.id,S.day);}}}}, if(!S.offers.includes(o)){X.did('sales');X.rev+=bizMo(o);}else{if(!UI.opsTried||UI.opsTried.s!==S)UI.opsTried={s:S,m:new Map()};UI.opsTried.m.set(o.id,S.day);}}}},
routers(X){const at=opsP('routers','at')/100,how=opsP('routers','how'); routers(X){const at=opsP('routers','at')/100,how=opsP('routers','how');
for(const c of opsPops('routers')){const p=S.pops[c];if(p.rupDay===S.day)continue; 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=Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));if(ld<at)continue;
@ -126,7 +144,7 @@ const OPS_RUN={
caches(X){const g=opsP('caches','g'); caches(X){const g=opsP('caches','g');
for(const c of opsPops('caches')){const q=utilityCaches(c);if(!q||!q.add.length)continue; for(const c of opsPops('caches')){const q=utilityCaches(c);if(!q||!q.add.length)continue;
const want=q.add.filter(x=>(R.cityDem[c]||0)*(NSH[x.net]||0)>=g),free=Math.floor(portsMax(c)-portsUsed(c)+1e-9); const want=q.add.filter(x=>(R.cityDem[c]||0)*(NSH[x.net]||0)>=g),free=Math.floor(portsMax(c)-portsUsed(c)+1e-9);
for(const x of want.slice(0,Math.max(0,free))){S.caches.push({id:uid(),city:c,net:x.net,site:x.site});X.did('caches',c);}}}, for(const x of want.slice(0,Math.max(0,free))){if(!X.can('caches',0,CACHE_MO))return;S.caches.push({id:uid(),city:c,net:x.net,site:x.site});X.book('caches',0,CACHE_MO);X.did('caches',c);}}},
// Weekly, like a person going through PeeringDB on a Monday: route servers, then every willing member (#192). // Weekly, like a person going through PeeringDB on a Monday: route servers, then every willing member (#192).
ix(X){if(S.day%7)return;for(const ix of utilityRouteServers()){S.rs[ix]=true;X.did('rs');} ix(X){if(S.day%7)return;for(const ix of utilityRouteServers()){S.rs[ix]=true;X.did('rs');}
for(const row of utilityPeers())for(const id of row.requests){S.peers[id+'@'+row.ix]=true;X.did('peer',row.ix);}}, for(const row of utilityPeers())for(const id of row.requests){S.peers[id+'@'+row.ix]=true;X.did('peer',row.ix);}},
@ -144,7 +162,7 @@ const OPS_RUN={
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)); 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. // 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);} 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;ACT.rmLink({id:l.id});if(!S.links.includes(l))X.did('decom',l.a+'|'+l.b);}}}, 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);}}},
}; };
// A wave can carry a promise: diverse paths, no subsea, a latency budget. Try the network without it first. // 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; 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;
@ -152,7 +170,7 @@ function opsDecomSafe(l){const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>k==='dive
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 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','sales','routers','transit','optics','caches','ix','pni','decom']; const OPS_ORDER=['repair','sales','routers','transit','optics','caches','ix','pni','decom'];
// The shift: once per game day from dayTick, after outages and events have had their turn. // 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=Math.floor(d/30);if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;} function opsDay(d){if(!opsHired())return;const O=S.ops,m=Math.floor(d/30);if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;O.addMo={};}
const X=opsShift(),cash=S.cash; const X=opsShift(),cash=S.cash;
// One order that trips over something (an odd save, a bug) is paused and noted; payday, goals and the save still happen. // One order that trips over something (an odd save, a bug) is paused and noted; payday, goals and the save still happen.
opsQuiet(()=>{for(const k of OPS_ORDER)if(O.on[k])try{OPS_RUN[k](X);}catch(err){O.on[k]=false;X.dirty=true;X.did('snag',k);console.error('[tubes] standing order failed',k,err);}}); opsQuiet(()=>{for(const k of OPS_ORDER)if(O.on[k])try{OPS_RUN[k](X);}catch(err){O.on[k]=false;X.dirty=true;X.did('snag',k);console.error('[tubes] standing order failed',k,err);}});
@ -161,10 +179,11 @@ function opsDay(d){if(!opsHired())return;const O=S.ops,m=Math.floor(d/30);if(m!=
const ff=OPS_FF_RATE[rulePreset()];if(ff&&Object.keys(S.pops).length&&Math.random()<ff){const c=pick(Object.keys(S.pops));let f=Math.floor(Math.random()*OPS_FF.length); const ff=OPS_FF_RATE[rulePreset()];if(ff&&Object.keys(S.pops).length&&Math.random()<ff){const c=pick(Object.keys(S.pops));let f=Math.floor(Math.random()*OPS_FF.length);
if(f===3){const t=O.on.transit&&opsHere('transit',c)&&!scnRule('noTransit')&&S.transit.find(t=>t.city===c&&(t.n||1)<LAG_MAX&&portOk(c,t.tier)&&PORT[t.tier].setup<=Math.min(20000,S.cash*0.05));if(!t||!opsQuiet(()=>X.pay('transit',()=>ACT.lagT({id:t.id,d:1}))))f=0;else X.dirty=true;} if(f===3){const t=O.on.transit&&opsHere('transit',c)&&!scnRule('noTransit')&&S.transit.find(t=>t.city===c&&(t.n||1)<LAG_MAX&&portOk(c,t.tier)&&PORT[t.tier].setup<=Math.min(20000,S.cash*0.05));if(!t||!opsQuiet(()=>X.pay('transit',()=>ACT.lagT({id:t.id,d:1}))))f=0;else X.dirty=true;}
e.f=f;e.c=c;toast(esc(opsFFLine(e)),'',[{l:tr('ops.ops'),act:'opsOpen',args:{}}]);} e.f=f;e.c=c;toast(esc(opsFFLine(e)),'',[{l:tr('ops.ops'),act:'opsOpen',args:{}}]);}
if(X.up)e.up=Math.round(X.up);if(Math.round(X.mo))e.mo=Math.round(X.mo);
// Declining an offer or stopping at a budget changes nothing a route depends on: no recompute for those. // Declining an offer or stopping at a budget changes nothing a route depends on: no recompute for those.
if(X.dirty)compute(); if(X.dirty)compute();
if(e.r.length||e.f!==undefined){O.log.unshift(e);O.log.length=Math.min(O.log.length,OPS_LOG);} if(e.r.length||e.f!==undefined){O.log.unshift(e);O.log.length=Math.min(O.log.length,OPS_LOG);}
if(e.r.length)logNote(`<b>${esc(tr('ops.shift',{name:opsName()}))}</b> ${esc(opsLine(e))}`,cash>S.cash?'':'good',[],{a:'tab',v:'noc'});} if(e.r.length||e.up||e.mo)logNote(`<b>${esc(tr('ops.shift',{name:opsName()}))}</b> ${esc(opsLine(e))}`,cash>S.cash?'':'good',[],{a:'tab',v:'noc'});}
// New POP from the template: price the whole bundle first, then click through it in one go. // New POP from the template: price the whole bundle first, then click through it in one go.
function opsTplQuote(c){if(!S||S.pops[c]||!cityOn(c)||(cnCity(c)&&!cnOk()))return null;const T=S.ops.tpl,parts=[];let cost=popCost(c),net=null,ix=null,kit=null; function opsTplQuote(c){if(!S||S.pops[c]||!cityOn(c)||(cnCity(c)&&!cnOk()))return null;const T=S.ops.tpl,parts=[];let cost=popCost(c),net=null,ix=null,kit=null;
if(T.bb){cost+=bbCost(c);parts.push(tr('ops.tpl_bb'));} if(T.bb){cost+=bbCost(c);parts.push(tr('ops.tpl_bb'));}

View file

@ -4,7 +4,7 @@ Object.assign(ACT,{
opsOpen:()=>{if(S)opsModal();}, 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=Math.floor(S.day/30);O.intern=id;O.hired=S.day; opsHire:({id})=>{if(!S||opsHired()||!own(INTERNS,id)||!opsCanHire()||!rule('clock'))return;if(!spend(INTERN_MO))return;const O=opsO(),m=Math.floor(S.day/30);O.intern=id;O.hired=S.day;
// A new hire starts on a fresh month's budget, whatever the last one spent. // A new hire starts on a fresh month's budget, whatever the last one spent.
if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;} if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;O.addMo={};}
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();}, 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; 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();}, toast(esc(tr('ops.fired',{name:nm})),'');after();opsModal();},
@ -12,7 +12,7 @@ Object.assign(ACT,{
opsParam:({k,p})=>{if(!opsHired()||!own(OPSK,k)||!own(OPSK[k].p,p))return;const P=OPSK[k].p[p];let v; 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',...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)); if(p==='prov'){const ids=['cheap',...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();}, (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(OPS_CAPS,opsCap(k));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();}, opsFloor:()=>{if(!opsHired())return;S.ops.floor=opsCycle(OPS_FLOORS,S.ops.floor);sfx('click');after();opsModal();},
opsCity:({v})=>{if(!S||!S.pops[v])return;UI.opsCity=v;opsModal();}, 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]; 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];

View file

@ -6,12 +6,12 @@ function opsCard(){if(!S)return '';const last=opsHired()&&S.ops.log[0];
<div class="btns">${btn(opsHired()?tr('ops.standing_orders'):tr('ops.hire_an_intern'),'opsOpen',{},opsHired()?'sm':'pink sm',!opsHired()&&!opsCanHire())}</div></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):''); 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'):NET[v].name):P.f(v);} function opsVal(k,p){const P=OPSK[k].p[p],v=opsP(k,p);return p==='prov'?(v==='cheap'?tr('ops.cheapest'):NET[v].name):P.f(v);}
function opsOrderHtml(d){const k=d.k,on=S.ops.on[k],cap=d.cap?opsCap(k):0; 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)}</div></div> 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)}):''}</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> <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('')} ${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(`${tr('ops.budget')}: <b>${cap?tr('common.price_mo',{price:fmt$(cap)}):tr('ops.no_cap')}</b>`,'opsCap',{k},'ghost sm'):''}</div> ${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>
${d.cap&&S.ops.spent[k]?`<div class="meta">${tr('ops.spent_this_month',{price:fmt$(S.ops.spent[k])})}</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>`;} ${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>`; 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>`;
if(!hired){h+=`<p class="tagline">${tr('ops.hire_pitch')}</p>`; if(!hired){h+=`<p class="tagline">${tr('ops.hire_pitch')}</p>`;

View file

@ -2532,8 +2532,10 @@
"ops.anycast_annie":"Anycast Annie", "ops.anycast_annie":"Anycast Annie",
"ops.at_least_port":"at least {port}", "ops.at_least_port":"at least {port}",
"ops.budget":"Budget", "ops.budget":"Budget",
"ops.budget_running":"Adds at most",
"ops.by_hand":"One-off batches", "ops.by_hand":"One-off batches",
"ops.by_hand_note":"For when you want it all done right now: every peer at every exchange, a redundancy kit, PNIs with everyone.", "ops.by_hand_note":"For when you want it all done right now: every peer at every exchange, a redundancy kit, PNIs with everyone.",
"ops.caches_rent":"Free to rack, but each box costs {price}/mo in space and power.",
"ops.cheapest":"Cheapest", "ops.cheapest":"Cheapest",
"ops.ff_desc":"labelled a port in {city} “TODO: fix later (do not fix)”", "ops.ff_desc":"labelled a port in {city} “TODO: fix later (do not fix)”",
"ops.ff_hostname":"renamed the router in {city} to router-final-FINAL-v2", "ops.ff_hostname":"renamed the router in {city} to router-final-FINAL-v2",
@ -2562,6 +2564,7 @@
"ops.l_decom":{"one":"handed back a small wave on {where}","other":"handed back {n} small waves ({where})"}, "ops.l_decom":{"one":"handed back a small wave on {where}","other":"handed back {n} small waves ({where})"},
"ops.l_line":"{name} {list}.", "ops.l_line":"{name} {list}.",
"ops.l_optics":{"one":"lit a channel on {where}","other":"lit {n} channels ({where})"}, "ops.l_optics":{"one":"lit a channel on {where}","other":"lit {n} channels ({where})"},
"ops.l_paid":"Cost: {cost} up front, {mo}/mo.",
"ops.l_peer":{"one":"peered with a network at {where}","other":"peered with {n} networks at {where}"}, "ops.l_peer":{"one":"peered with a network at {where}","other":"peered with {n} networks at {where}"},
"ops.l_pni":{"one":"ordered a PNI in {where}","other":"ordered {n} PNIs ({where})"}, "ops.l_pni":{"one":"ordered a PNI in {where}","other":"ordered {n} PNIs ({where})"},
"ops.l_quiet":"{name} watched the graphs. Nothing needed doing.", "ops.l_quiet":"{name} watched the graphs. Nothing needed doing.",
@ -2613,7 +2616,7 @@
"ops.really_fire":"Really let go?", "ops.really_fire":"Really let go?",
"ops.salary":"Salary {price}/mo · since {d}", "ops.salary":"Salary {price}/mo · since {d}",
"ops.shift":"{name}'s shift", "ops.shift":"{name}'s shift",
"ops.spent_this_month":"Spent this month: {price}", "ops.spent_and_mo":"This month: {price} up front, {mo}/mo on the bill",
"ops.standing_orders":"Standing orders", "ops.standing_orders":"Standing orders",
"ops.template":"New POP from template", "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.template_note":"Pick what {name} sets up when you open a city from the template. The standing orders take it from there.",

View file

@ -465,3 +465,44 @@ test('the fat-fingered LAG member respects a paused transit order and per-POP ex
ev('Math.random=__r'); ev('Math.random=__r');
assert.deepEqual(errors, []); assert.deepEqual(errors, []);
}); });
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);
hire(ev); on(ev, 'caches', { g: 1 });
const add = () => ev("utilityCaches('fra').add.filter(x=>(R.cityDem.fra||0)*NSH[x.net]>=1).length");
assert.ok(add() >= 2, 'several boxes on offer');
ev('S.ops.floor=50000;S.cash=1000');
shift(ev);
assert.equal(ev('S.caches.length'), 0, 'below the floor: no new rent either');
assert.match(ev('opsEntry(S.ops.log[0])'), /stopped at the budget for Accept free caches/);
ev('S.cash=1e8;S.ops.cap.caches=1000');
const m0 = ev('opsMoNow()');
shift(ev);
assert.equal(ev('S.caches.length'), 2, 'a $1k/mo budget fits two $400/mo boxes');
assert.equal(ev('S.ops.addMo.caches'), 800);
assert.equal(ev('opsMoNow()') - m0, 800);
assert.equal(ev('S.ops.log[0].mo'), 800);
assert.match(ev('opsEntry(S.ops.log[0])'), /racked 2 free caches \(Frankfurt\).*Cost: \$0 up front, \+\$800\/mo\./);
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/);
assert.match(txt, /This month: \$0 up front, \+\$800\/mo on the bill/);
ev('S.day+=30;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');
assert.deepEqual(errors, []);
});
test('transit: the log line and budget line show the monthly cost a top-up adds', t => {
const { ev, errors } = game(t, "S.transit[0].hist=[60,80,70]");
hire(ev); on(ev, 'transit', { x: 1.5 });
const m0 = ev('opsMoNow()'), c0 = cash(ev);
shift(ev);
const mo = ev('opsMoNow()') - m0;
assert.ok(mo > 0);
assert.equal(ev('S.ops.log[0].up'), c0 - cash(ev));
assert.equal(ev('S.ops.log[0].mo'), Math.round(mo));
assert.equal(ev('Math.round(S.ops.addMo.transit)'), Math.round(mo));
assert.match(ev('S.log[0].t'), /Cost: \$[\d.]+k up front, \+\$[\d.]+k?\/mo\./);
assert.deepEqual(errors, []);
});