From ef700a3480fd0996ef4168a75dfda9bbd48617f3 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Wed, 28 Oct 2026 20:22:09 +0100 Subject: [PATCH] Standing orders: one failing order is paused instead of breaking the day; the LAG slip follows the transit order's switches --- site/i18n/de.js | 1 + site/i18n/es.js | 1 + site/i18n/fr.js | 1 + site/i18n/it.js | 1 + site/i18n/pt.js | 1 + src/game/60-features/95-standing-orders.js | 7 +++-- src/i18n/en.js | 1 + tests/standing-orders.test.js | 34 ++++++++++++++++++++++ 8 files changed, 44 insertions(+), 3 deletions(-) diff --git a/site/i18n/de.js b/site/i18n/de.js index c6b6e91..8271f7b 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -2570,6 +2570,7 @@ "ops.l_routers":{"one":"hat Router in {where} aufgerüstet","other":"hat Router an {n} Orten aufgerüstet ({where})"}, "ops.l_rs":{"one":"hat sich einem Route Server angeschlossen","other":"hat sich {n} Route Servern angeschlossen"}, "ops.l_sales":{"one":"hat einen Kunden unterschrieben","other":"hat {n} Kunden unterschrieben"}, +"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.lpm_off":"Die Peering-Inbox bleibt deine Sache. Dafür gibt es das Large Peering Model; {name} macht keine E-Mails.", diff --git a/site/i18n/es.js b/site/i18n/es.js index 4ab93d8..ed4c0a0 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -2568,6 +2568,7 @@ "ops.l_routers":{"one":"mejoró los routers en {where}","other":"mejoró los routers en {n} sitios ({where})"}, "ops.l_rs":{"one":"se unió a un route server","other":"se unió a {n} route servers"}, "ops.l_sales":{"one":"firmó un cliente","other":"firmó {n} clientes"}, +"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.lpm_off":"La bandeja de peering sigue siendo cosa tuya. Para eso está el Large Peering Model; {name} no contesta correos.", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index 26a6ad8..0a23368 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -2568,6 +2568,7 @@ "ops.l_routers":{"one":"a mis à niveau les routeurs à {where}","other":"a mis à niveau les routeurs à {n} endroits ({where})"}, "ops.l_rs":{"one":"a rejoint un route server","other":"a rejoint {n} route servers"}, "ops.l_sales":{"one":"a signé un client","other":"a signé {n} clients"}, +"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.lpm_off":"La boîte de peering reste à toi. Pour ça, il y a le Large Peering Model ; {name} ne fait pas les mails.", diff --git a/site/i18n/it.js b/site/i18n/it.js index b2547d1..045e456 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2568,6 +2568,7 @@ "ops.l_routers":{"one":"ha potenziato i router a {where}","other":"ha potenziato i router in {n} posti ({where})"}, "ops.l_rs":{"one":"si è unito a un route server","other":"si è unito a {n} route server"}, "ops.l_sales":{"one":"ha firmato un cliente","other":"ha firmato {n} clienti"}, +"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.lpm_off":"La casella del peering resta tua. Per quella c'è il Large Peering Model; {name} non risponde alle email.", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index a05f651..7435693 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2568,6 +2568,7 @@ "ops.l_routers":{"one":"melhorou os roteadores em {where}","other":"melhorou os roteadores em {n} lugares ({where})"}, "ops.l_rs":{"one":"entrou em um route server","other":"entrou em {n} route servers"}, "ops.l_sales":{"one":"fechou com um cliente","other":"fechou com {n} clientes"}, +"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.lpm_off":"A caixa de peering continua com você. Para isso existe o Large Peering Model; {name} não responde e-mail.", diff --git a/src/game/60-features/95-standing-orders.js b/src/game/60-features/95-standing-orders.js index d5a87a1..10b4d89 100644 --- a/src/game/60-features/95-standing-orders.js +++ b/src/game/60-features/95-standing-orders.js @@ -23,7 +23,7 @@ const OPS=[ const OPSK=Object.fromEntries(OPS.map(o=>[o.k,o])),OPS_POP=OPS.filter(o=>o.pop).map(o=>o.k); const OPS_TPL=['bb','transit','ix','kit']; // What the shift log can say. One line per day: "{name} did this, that and the other." -const OPS_SAY={transit:N_('ops.l_transit'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),sales:N_('ops.l_sales'),decline:N_('ops.l_decline'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke')}; +const OPS_SAY={transit:N_('ops.l_transit'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),sales:N_('ops.l_sales'),decline:N_('ops.l_decline'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')}; // Fat fingers: rare, visible, harmless. Only the LAG one costs anything, and only a little. const OPS_FF=[N_('ops.ff_desc'),N_('ops.ff_hostname'),N_('ops.ff_typo'),N_('ops.ff_lag'),N_('ops.ff_ping')]; const OPS_TRIALS=1,OPS_FF_RATE={oncall:1/150,bgp:1/60}; @@ -154,11 +154,12 @@ const OPS_ORDER=['repair','sales','routers','transit','optics','caches','ix','pn // 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;} const X=opsShift(),cash=S.cash; - opsQuiet(()=>{for(const k of OPS_ORDER)if(O.on[k])OPS_RUN[k](X);}); + // 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);}}); const e={d,i:O.intern,r:[]};for(const [k,x] of X.r)e.r.push([k,x.n,x.w]);if(X.broke.size)e.r.push(['broke',X.broke.size,[...X.broke]]); // Very rarely, and never under Change Freeze, the intern fat-fingers something harmless. const ff=OPS_FF_RATE[rulePreset()];if(ff&&Object.keys(S.pops).length&&Math.random()t.city===c&&(t.n||1)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)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:{}}]);} // Declining an offer or stopping at a budget changes nothing a route depends on: no recompute for those. if(X.dirty)compute(); diff --git a/src/i18n/en.js b/src/i18n/en.js index 9e5308b..cce79e4 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -2569,6 +2569,7 @@ "ops.l_routers":{"one":"upgraded routers in {where}","other":"upgraded routers in {n} places ({where})"}, "ops.l_rs":{"one":"joined a route server","other":"joined {n} route servers"}, "ops.l_sales":{"one":"signed a customer","other":"signed {n} customers"}, +"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.lpm_off":"The peering inbox is still yours. Hire the Large Peering Model for that; {name} does not do email.", diff --git a/tests/standing-orders.test.js b/tests/standing-orders.test.js index 126d126..0ebad47 100644 --- a/tests/standing-orders.test.js +++ b/tests/standing-orders.test.js @@ -431,3 +431,37 @@ test('per-POP exceptions go with the POP: on decommission, and in a save that lo assert.equal(ev('JSON.stringify(S.ops.skip)'), '{"lon":["caches"]}', 'no POP in Paris: its exception is dropped on load'); assert.deepEqual(errors, []); }); + +test('one order that throws is paused and noted; the rest of the shift and the day still run', t => { + const { ev, errors } = game(t, "S.transit[0].hist=[60,80,70]"); + hire(ev); on(ev, 'repair'); on(ev, 'transit', { x: 1.5 }); + ev("window.__r=OPS_RUN.repair;OPS_RUN.repair=()=>{throw new Error('boom')};window.__e=console.error;console.error=()=>{}"); + const d = ev('S.day'), saves = ev("window.__s=0;window.__sv=save;save=()=>{__s++;return __sv()};S.day=29;dayTick();save=__sv;__s"); + ev("OPS_RUN.repair=__r;console.error=__e"); + assert.ok(d >= 0 && saves >= 1, 'dayTick reached the save on day 30'); + assert.equal(ev('S.ops.on.repair'), false, 'the broken order is paused'); + assert.ok(ev("(S.transit[0].n||1)") > 1, 'the next order still ran'); + assert.match(ev('opsEntry(S.ops.log[0])'), /got stuck on Rush repairs and paused it/); + assert.deepEqual(errors, []); +}); + +test('the fat-fingered LAG member respects a paused transit order and per-POP exceptions', t => { + const { ev, errors } = game(t); + hire(ev); + // Each shift rolls: fat finger yes, the only POP, the LAG slip (index 3). + ev("S.rules=makeRules('bgp');window.__r=Math.random;window.__k=0;Math.random=()=>[0,0,0.7][__k++%3]"); + const n0 = ev('S.transit[0].n||1'), c0 = cash(ev); + shift(ev); + assert.equal(ev('__k'), 3); + assert.equal(ev('S.ops.log[0].f'), 0, 'transit order paused: a harmless label instead'); + assert.equal(ev('S.transit[0].n||1'), n0); assert.equal(cash(ev), c0); + on(ev, 'transit', { x: 1 }); ev("ACT.opsPop({k:'transit',city:'fra'});closeModal();S.transit[0].hist=[0]"); + shift(ev); + assert.equal(ev('S.ops.log[0].f'), 0, 'Frankfurt excepted: the same'); + ev("ACT.opsPop({k:'transit',city:'fra'});closeModal()"); + shift(ev); + assert.equal(ev('S.ops.log[0].f'), 3, 'allowed: the extra member'); + assert.equal(ev('S.transit[0].n||1'), n0 + 1); + ev('Math.random=__r'); + assert.deepEqual(errors, []); +});