diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fb4ce3..382ce54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Your intern can upgrade optical transport: a new standing order moves full, busy fiber to a bigger line system, or trades its smallest channels for bigger optics. Pick a line system, and every fiber on a smaller one is moved up to it. A line system swap takes the fiber down for a day, so the intern only does it where the traffic gets around it and no customer rides it, one a night. - 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 diff --git a/site/i18n/de.js b/site/i18n/de.js index 4374a2f..36c6582 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -3226,6 +3226,8 @@ "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_optics":{"one":"hat einen Kanal auf {where} aufgeschaltet","other":"hat {n} Kanäle aufgeschaltet ({where})"}, +"ops.l_optswap":{"one":"hat eine Optik auf {where} gegen eine größere getauscht","other":"hat {n} Optiken gegen größere getauscht ({where})"}, +"ops.l_optup":{"one":"hat das Line System auf {where} ausgebaut","other":"hat {n} Line Systems ausgebaut ({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_pni":{"one":"hat einen PNI in {where} bestellt","other":"hat {n} PNIs bestellt ({where})"}, @@ -3258,6 +3260,8 @@ "ops.o_ix_d":"Jede Woche: den Route Servern beitreten und jedes willige Mitglied an jedem deiner Exchange-Ports fragen.", "ops.o_optics":"Mehr Dark Fiber beleuchten", "ops.o_optics_d":"Optiken auf heiß laufende Dark Fiber stecken und neue Glasfaser am Tag der Übergabe beleuchten.", +"ops.o_optup":"Optischen Transport ausbauen", +"ops.o_optup_d":"Auf Glasfaser, die voll ist und heiß läuft, das Line System eine Größe hochziehen oder die kleinsten Kanäle gegen größere Optiken tauschen (die alten kommen ins Ersatzteillager). Wähl ein Line System, und jede Faser mit einem kleineren wird darauf hochgezogen. Ein Tausch des Line Systems legt die Faser für einen Tag lahm, also nur, wo der Traffic einen Weg drumherum hat und kein Kunde darauf fährt, einer pro Nacht.", "ops.o_pni":"PNI mit den Großen", "ops.o_pni_d":"Jede Woche: mit jedem willigen Netz, das an deinen POPs genug Traffic schickt, einen PNI bestellen, in der jeweils kleinsten Größe des Netzes.", "ops.o_ports":"Peering-Reserve halten", @@ -3278,6 +3282,8 @@ "ops.p_paid":"Paid Peering", "ops.p_pick":"Optiken", "ops.p_prov":"Anbieter", +"ops.p_swap":"Größere Optiken", +"ops.p_sys":"Line System", "ops.p_tier":"Größe", "ops.p_x":"Reserve", "ops.paused":"Pausiert", @@ -3292,6 +3298,7 @@ "ops.shift_report":"{name}s Woche", "ops.spent_and_mo":"Diesen Monat: {price} einmalig, {mo}/Monat auf der Rechnung", "ops.standing_orders":"Daueraufträge", +"ops.sys_next":"Das nächste, wenn voll", "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.tpl_bb":"Breitband", diff --git a/site/i18n/es.js b/site/i18n/es.js index 40ce8a0..d447ada 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -3224,6 +3224,8 @@ "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_optics":{"one":"encendió un canal en {where}","other":"encendió {n} canales ({where})"}, +"ops.l_optswap":{"one":"cambió una óptica por una más grande en {where}","other":"cambió {n} ópticas por otras más grandes ({where})"}, +"ops.l_optup":{"one":"mejoró el sistema de línea en {where}","other":"mejoró {n} sistemas de línea ({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_pni":{"one":"pidió un PNI en {where}","other":"pidió {n} PNIs ({where})"}, @@ -3256,6 +3258,8 @@ "ops.o_ix_d":"Cada semana: unirse a los route servers y pedir peering a cada miembro dispuesto en cada uno de tus puertos de exchange.", "ops.o_optics":"Encender más fibra", "ops.o_optics_d":"Añadir ópticas a la fibra oscura que va caliente y encender la fibra nueva el día que te la entregan.", +"ops.o_optup":"Mejorar el transporte óptico", +"ops.o_optup_d":"En la fibra que está llena y va caliente, sube el sistema de línea un tamaño o cambia los canales más pequeños por ópticas más grandes (las viejas van a la estantería). Elige un sistema de línea y cada fibra con uno más pequeño sube a ese. Cambiar el sistema de línea deja la fibra sin servicio un día, así que solo donde el tráfico puede rodearla y ningún cliente va por ella, uno por noche.", "ops.o_pni":"PNI con los grandes", "ops.o_pni_d":"Cada semana: pedir un PNI a cada red dispuesta que envíe suficiente tráfico en tus POPs, con el tamaño mínimo de cada red.", "ops.o_ports":"Margen en puertos de peering", @@ -3276,6 +3280,8 @@ "ops.p_paid":"Peering de pago", "ops.p_pick":"Ópticas", "ops.p_prov":"Proveedor", +"ops.p_swap":"Ópticas más grandes", +"ops.p_sys":"Sistema de línea", "ops.p_tier":"Tamaño", "ops.p_x":"Margen", "ops.paused":"En pausa", @@ -3290,6 +3296,7 @@ "ops.shift_report":"La semana de {name}", "ops.spent_and_mo":"Este mes: {price} de entrada, {mo}/mes en la factura", "ops.standing_orders":"Órdenes permanentes", +"ops.sys_next":"El siguiente, si está lleno", "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.tpl_bb":"Banda ancha", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index 07a75e6..908b461 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -3224,6 +3224,8 @@ "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_optics":{"one":"a allumé un canal sur {where}","other":"a allumé {n} canaux ({where})"}, +"ops.l_optswap":{"one":"a remplacé une optique par une plus grande sur {where}","other":"a remplacé {n} optiques par de plus grandes ({where})"}, +"ops.l_optup":{"one":"a amélioré le système de ligne sur {where}","other":"a amélioré {n} systèmes de ligne ({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_pni":{"one":"a commandé un PNI à {where}","other":"a commandé {n} PNI ({where})"}, @@ -3256,6 +3258,8 @@ "ops.o_ix_d":"Chaque semaine : rejoindre les route servers et solliciter chaque membre partant sur chacun de tes ports d'exchange.", "ops.o_optics":"Allumer plus de fibre", "ops.o_optics_d":"Ajouter des optiques sur la fibre noire qui chauffe, et allumer la nouvelle fibre le jour de sa livraison.", +"ops.o_optup":"Améliorer le transport optique", +"ops.o_optup_d":"Sur une fibre pleine qui chauffe, passer le système de ligne à la taille au-dessus, ou échanger les plus petits canaux contre des optiques plus grandes (les anciennes partent sur l’étagère). Choisissez un système de ligne, et chaque fibre équipée d’un plus petit y passe. Un changement de système de ligne coupe la fibre pour une journée : seulement là où le trafic peut la contourner et où aucun client ne passe, un par nuit.", "ops.o_pni":"PNI avec les gros", "ops.o_pni_d":"Chaque semaine : commander un PNI avec chaque réseau partant qui envoie assez de trafic sur tes POP, à la taille minimale de chaque réseau.", "ops.o_ports":"Garder de la marge sur les ports de peering", @@ -3276,6 +3280,8 @@ "ops.p_paid":"Peering payant", "ops.p_pick":"Optiques", "ops.p_prov":"Fournisseur", +"ops.p_swap":"Optiques plus grandes", +"ops.p_sys":"Système de ligne", "ops.p_tier":"Taille", "ops.p_x":"Marge", "ops.paused":"En pause", @@ -3290,6 +3296,7 @@ "ops.shift_report":"La semaine de {name}", "ops.spent_and_mo":"Ce mois-ci : {price} d'entrée, {mo}/mois sur la facture", "ops.standing_orders":"Ordres permanents", +"ops.sys_next":"Le suivant, quand c’est plein", "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.tpl_bb":"Haut débit", diff --git a/site/i18n/it.js b/site/i18n/it.js index af05b1c..e745eff 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -3224,6 +3224,8 @@ "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_optics":{"one":"ha acceso un canale su {where}","other":"ha acceso {n} canali ({where})"}, +"ops.l_optswap":{"one":"ha scambiato un’ottica con una più grande su {where}","other":"ha scambiato {n} ottiche con altre più grandi ({where})"}, +"ops.l_optup":{"one":"ha potenziato il line system su {where}","other":"ha potenziato {n} line system ({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_pni":{"one":"ha ordinato un PNI a {where}","other":"ha ordinato {n} PNI ({where})"}, @@ -3256,6 +3258,8 @@ "ops.o_ix_d":"Ogni settimana: entra nei route server e chiedi il peering a ogni membro disponibile su ciascuna delle tue porte di exchange.", "ops.o_optics":"Accendi più fibra", "ops.o_optics_d":"Aggiungi ottiche alla dark fiber che scotta e accendi la fibra nuova il giorno della consegna.", +"ops.o_optup":"Potenzia il trasporto ottico", +"ops.o_optup_d":"Sulla fibra piena che va calda, porta il line system alla taglia successiva, o scambia i canali più piccoli con ottiche più grandi (le vecchie finiscono a scaffale). Scegli un line system e ogni fibra con uno più piccolo passa a quello. Cambiare line system spegne la fibra per un giorno, quindi solo dove il traffico può girarle intorno e nessun cliente ci passa, uno per notte.", "ops.o_pni":"PNI con i grandi", "ops.o_pni_d":"Ogni settimana: ordina un PNI con ogni rete disponibile che manda abbastanza traffico nei tuoi POP, alla taglia minima di ciascuna rete.", "ops.o_ports":"Margine sulle porte di peering", @@ -3276,6 +3280,8 @@ "ops.p_paid":"Peering a pagamento", "ops.p_pick":"Ottiche", "ops.p_prov":"Fornitore", +"ops.p_swap":"Ottiche più grandi", +"ops.p_sys":"Line system", "ops.p_tier":"Taglia", "ops.p_x":"Margine", "ops.paused":"In pausa", @@ -3290,6 +3296,7 @@ "ops.shift_report":"La settimana di {name}", "ops.spent_and_mo":"Questo mese: {price} subito, {mo}/mese in bolletta", "ops.standing_orders":"Ordini permanenti", +"ops.sys_next":"Il successivo, quando è pieno", "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.tpl_bb":"Banda larga", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 084cdaf..2ff2e89 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -3224,6 +3224,8 @@ "ops.l_decom":{"one":"devolveu uma wave pequena em {where}","other":"devolveu {n} waves pequenas ({where})"}, "ops.l_line":"{name} {list}.", "ops.l_optics":{"one":"acendeu um canal em {where}","other":"acendeu {n} canais ({where})"}, +"ops.l_optswap":{"one":"trocou uma óptica por uma maior em {where}","other":"trocou {n} ópticas por maiores ({where})"}, +"ops.l_optup":{"one":"melhorou o sistema de linha em {where}","other":"melhorou {n} sistemas de linha ({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_pni":{"one":"pediu um PNI em {where}","other":"pediu {n} PNIs ({where})"}, @@ -3256,6 +3258,8 @@ "ops.o_ix_d":"Toda semana: entrar nos route servers e pedir peering a cada membro disposto em cada uma das suas portas de exchange.", "ops.o_optics":"Acender mais fibra", "ops.o_optics_d":"Adicionar ópticas à fibra escura que está esquentando e acender a fibra nova no dia da entrega.", +"ops.o_optup":"Melhorar o transporte óptico", +"ops.o_optup_d":"Na fibra que está cheia e esquentando, sobe o sistema de linha um tamanho ou troca os canais menores por ópticas maiores (as antigas vão para a prateleira). Escolha um sistema de linha e cada fibra com um menor sobe para ele. Trocar o sistema de linha derruba a fibra por um dia, então só onde o tráfego consegue contorná-la e nenhum cliente passa por ela, uma por noite.", "ops.o_pni":"PNI com os grandes", "ops.o_pni_d":"Toda semana: pedir um PNI com cada rede disposta que mande tráfego suficiente nos seus POPs, no tamanho mínimo de cada rede.", "ops.o_ports":"Folga nas portas de peering", @@ -3276,6 +3280,8 @@ "ops.p_paid":"Peering pago", "ops.p_pick":"Ópticas", "ops.p_prov":"Provedor", +"ops.p_swap":"Ópticas maiores", +"ops.p_sys":"Sistema de linha", "ops.p_tier":"Tamanho", "ops.p_x":"Folga", "ops.paused":"Em pausa", @@ -3290,6 +3296,7 @@ "ops.shift_report":"A semana de {name}", "ops.spent_and_mo":"Este mês: {price} de entrada, {mo}/mês na fatura", "ops.standing_orders":"Ordens permanentes", +"ops.sys_next":"O próximo, quando cheio", "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.tpl_bb":"Banda larga", diff --git a/src/game/60-features/95-standing-orders.js b/src/game/60-features/95-standing-orders.js index 8f9f78e..da183e6 100644 --- a/src/game/60-features/95-standing-orders.js +++ b/src/game/60-features/95-standing-orders.js @@ -22,12 +22,16 @@ const OPS=[ {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')}}}, {k:'repair',i:'🔧',cap:50000,t:N_('ops.o_repair'),d:N_('ops.o_repair_d'),p:{}}, {k:'optics',i:'🌈',cap:250000,t:N_('ops.o_optics'),d:N_('ops.o_optics_d'),p:{at:{d:70,v:[50,60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'},pick:{d:'cheap',v:['cheap','big'],l:N_('ops.p_pick'),f:v=>tr({cheap:N_('ops.pick_cheap'),big:N_('ops.pick_big')}[v])}}}, + // Line systems up to a bigger one, and optics swapped for bigger ones, on fiber that is full and runs hot, or every fiber up to + // a chosen line system. A line system swap is a day without that fiber: only where the traffic gets around it. + {k:'optup',i:'🔭',cap:250000,t:N_('ops.o_optup'),d:N_('ops.o_optup_d'),p:{at:{d:80,v:[60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'}, + sys:{d:'next',v:['next','roadm','cl'],l:N_('ops.p_sys'),f:v=>v==='next'?tr('ops.sys_next'):DF_SYS[v].n},swap:{d:true,v:[true,false],l:N_('ops.p_swap'),f:v=>v?tr('common.on'):tr('common.off')}}}, {k:'decom',i:'🧹',t:N_('ops.o_decom'),d:N_('ops.o_decom_d'),p:{keep:{d:true,v:[true,false],l:N_('ops.p_keep'),f:v=>v?tr('common.on'):tr('common.off')}}}, ]; const OPSK=Object.fromEntries(OPS.map(o=>[o.k,o])),OPS_POP=OPS.filter(o=>o.pop).map(o=>o.k); const OPS_TPL=['bb','transit','ix','kit']; // What the shift log can say. One line per day: "{name} did this, that and the other." -const OPS_SAY={transit:N_('ops.l_transit'),ports:N_('ops.l_ports'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')}; +const OPS_SAY={transit:N_('ops.l_transit'),ports:N_('ops.l_ports'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),optup:N_('ops.l_optup'),optswap:N_('ops.l_optswap'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')}; // Fat fingers: rare, visible, harmless. Only the LAG one costs anything, and only a little. const OPS_FF=[N_('ops.ff_desc'),N_('ops.ff_hostname'),N_('ops.ff_typo'),N_('ops.ff_lag'),N_('ops.ff_ping')]; const OPS_FF_RATE={oncall:1/150,bgp:1/60}; @@ -206,6 +210,33 @@ const OPS_RUN={ const n=(cnt[o]||0)+1,cost=opticCountCost(l,o,n),before=(l.ch||[]).length;if(!X.can('optics',cost))break; X.pay('optics',()=>{ACT.setChCount({id:l.id,o,n});return (l.ch||[]).length>before;});if((l.ch||[]).length<=before)break; cap+=optG(o,l);X.did('optics',l.a+'|'+l.b);}}}, + optup(X){const at=opsP('optup','at')/100,goal=opsP('optup','sys'),swap=opsP('optup','swap');let ups=0,tries=0; + const hot=l=>{const c=dfCap(l);return c>0&&((R.load&&R.load[l.id])||0)>=c*at;},full=l=>freeCh(l)<=0,u=l=>((R.load&&R.load[l.id])||0)/Math.max(1,dfCap(l)); + const ls=S.links.filter(l=>l.kind==='df'&&!l.seat&&l.ready<=S.day&&!(l.eqDown>S.day)&&!(l.cut>S.day)).sort((a,b)=>u(b)-u(a)); + for(const l of ls){ + // The line system: one step at a time up to the chosen one, or the next one where the fiber is full and hot. + const want=goal==='next'?(full(l)&&hot(l)?sysNext(l):null):SYS_RANK[l.sys]S.day)&&X.can('optup',cost)){tries++;const ok=opsDarkOk(l,X);if(!ok)OPTUP_NO.set(l.id,S.day+OPTUP_WAIT); + if(ok){const s0=l.sys,top=goal==='next'?to:goal; + for(let k=0;k<2&&sysNext(l)&&SYS_RANK[l.sys]{const s=l.sys;ACT.upSys({id:l.id});return l.sys!==s;}))break;} + // The fiber is dark until tomorrow: its optics wait. + if(l.sys!==s0){ups++;X.did('optup',l.a+'|'+l.b+' ⇧'+SYS_TAG[l.sys]);continue;}}}} + // Optics: a full, hot fiber trades its smallest channels for the biggest optic that fits, one at a time. Hitless, and + // the old optics go on the shelf as spares. + if(!swap)continue; + for(let step=0;step<8&&full(l)&&hot(l);step++){const cnt={};for(const k of l.ch||[])cnt[k]=(cnt[k]||0)+1; + const lit=Object.keys(cnt).sort((a,b)=>optG(a,l)-optG(b,l)),o1=lit[0];if(!o1)break; + const ports=(o,c)=>S.pops[c]?chPorts(o,c):0,room=(o2,c)=>!S.pops[c]||portsUsed(c)+ports(o2,c)-ports(o1,c)<=portsMax(c)+1e-9; + // Asked with one small channel already out: a full fiber refuses any optic. + const ch0=l.ch,i1=ch0.indexOf(o1);l.ch=ch0.filter((k,i)=>i!==i1);let o2; + try{o2=Object.keys(OPT).filter(o=>optG(o,l)>optG(o1,l)&&!chWhy(l,o)&&room(o,l.a)&&room(o,l.b)).sort((a,b)=>optG(b,l)-optG(a,l)||optCost(a)-optCost(b))[0];}finally{l.ch=ch0;}if(!o2)break; + const n2=(cnt[o2]||0)+1,cost=opticCountCost(l,o2,n2);if(!X.can('optup',cost))break; + const was=dfCap(l); + X.pay('optup',()=>{ACT.setChCount({id:l.id,o:o1,n:cnt[o1]-1});ACT.setChCount({id:l.id,o:o2,n:n2}); + if((l.ch||[]).filter(k=>k===o2).length===n2)return true;ACT.setChCount({id:l.id,o:o1,n:cnt[o1]});return false;}); + if(!(dfCap(l)>was))break;X.did('optswap',l.a+'|'+l.b+' '+fmtCap(optG(o1,l))+'→'+fmtCap(optG(o2,l)));}}}, caches(X){const g=opsP('caches','g'); for(const c of opsPops('caches')){const q=utilityCaches(c);if(!q||!q.add.length)continue; const want=q.add.filter(x=>cacheDem(c,x.net)>=g),free=()=>portsMax(c)-portsUsed(c)+1e-9; @@ -232,11 +263,24 @@ const OPS_RUN={ 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)ACT.rmLink({id:l.id}));if(!S.links.includes(l))X.did('decom',l.a+'|'+l.b);}}}, }; +// Line system swaps per shift, and how many fibers a shift may test for one: each test routes the whole network once, +// so a shift costs at most one routing more, and only on a night with a fiber to try. A fiber that failed the test is not tested again for a week +// (not saved: after a reload it is simply tested again). +const OPTUP_MAX=1,OPTUP_TRY=1,OPTUP_WAIT=7,OPTUP_NO=new Map(),SYS_RANK={lite:0,roadm:1,cl:2},SYS_TAG={roadm:'ROADM',cl:'C+L'}; +// Another live path between the fiber's two cities, without it: a plain walk, no routing. +function opsAround(l){const adj={};for(const x of S.links){if(x===l||linkDown(x))continue;(adj[x.a]=adj[x.a]||[]).push(x.b);(adj[x.b]=adj[x.b]||[]).push(x.a);} + const seen=new Set([l.a]),q=[l.a];while(q.length){const u=q.pop();if(u===l.b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;} +// A day without this fiber: does every gigabit still get where it went today, and every circuit stay whole? Today's routing +// is the yardstick (routed again first if this shift already changed the network); R is put back after. +function opsDarkOk(l,X){if(S.biz.some(b=>b.link===l.id)||!opsAround(l))return false;if(X.dirty){compute();X.dirty=false;} + const R0=R,e0=l.eqDown,s0=R0.served,L0=R0.l2||{}; + try{l.eqDown=S.day+1;compute();return R.served>=s0-1e-6*Math.max(1,s0)&&Object.keys(L0).every(id=>(R.l2[id]||0)>=L0[id]-1e-6);} + finally{if(e0===undefined)delete l.eqDown;else l.eqDown=e0;R=R0;}} // A wave can carry a promise: diverse paths, no subsea, a latency budget. Try the network without it first. function opsDecomSafe(l){const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>k==='diverse'||k==='sharks'||k==='lat')&&b.city2);if(!bz.length)return true; const chk=b=>(b.reqs||[]).every(k=>k==='diverse'?diversePaths(b.city,b.city2):k==='sharks'?terrestrialPath(b.city,b.city2):k==='lat'?bestLat(b.city,b.city2)<=b.latMax:true); const was=bz.filter(chk),all=S.links;S.links=all.filter(x=>x!==l);try{return was.every(chk);}finally{S.links=all;}} -const OPS_ORDER=['repair','routers','transit','ports','optics','caches','ix','pni','decom']; +const OPS_ORDER=['repair','routers','transit','ports','optup','optics','caches','ix','pni','decom']; // The shift: once per game day from dayTick, after outages and events have had their turn. function opsDay(d){if(!opsHired())return;const O=S.ops,m=monthIdx(d);if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;O.addMo={};} // A new week: last week's tally becomes the shift report, and the one NOC notice of the week. diff --git a/src/i18n/en.js b/src/i18n/en.js index 6f9778d..da93f15 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -3225,6 +3225,8 @@ "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_optics":{"one":"lit a channel on {where}","other":"lit {n} channels ({where})"}, +"ops.l_optswap":{"one":"swapped an optic for a bigger one on {where}","other":"swapped {n} optics for bigger ones ({where})"}, +"ops.l_optup":{"one":"upgraded the line system on {where}","other":"upgraded {n} line systems ({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_pni":{"one":"ordered a PNI in {where}","other":"ordered {n} PNIs ({where})"}, @@ -3257,6 +3259,8 @@ "ops.o_ix_d":"Every week: join the route servers and ask every willing member at each of your exchange ports.", "ops.o_optics":"Light more fiber", "ops.o_optics_d":"Add optics to dark fiber that runs hot, and light new fiber the day it is handed over.", +"ops.o_optup":"Upgrade optical transport", +"ops.o_optup_d":"On fiber that is full and runs hot, move the line system up a size, or trade the smallest channels for bigger optics (the old ones go on the shelf). Pick a line system, and every fiber on a smaller one is moved up to it. A line system swap takes the fiber down for a day, so only where the traffic gets around it and no customer rides it, one a night.", "ops.o_pni":"PNI with the big ones", "ops.o_pni_d":"Every week: order a PNI with every willing network sending enough traffic at your POPs, at each network's own minimum size.", "ops.o_ports":"Keep peering headroom", @@ -3277,6 +3281,8 @@ "ops.p_paid":"Paid peering", "ops.p_pick":"Optics", "ops.p_prov":"Provider", +"ops.p_swap":"Bigger optics", +"ops.p_sys":"Line system", "ops.p_tier":"Size", "ops.p_x":"Headroom", "ops.paused":"Paused", @@ -3291,6 +3297,7 @@ "ops.shift_report":"{name}'s week", "ops.spent_and_mo":"This month: {price} up front, {mo}/mo on the bill", "ops.standing_orders":"Standing orders", +"ops.sys_next":"Next one, when full", "ops.template":"New POP from template", "ops.template_note":"Pick what {name} sets up when you open a city from the template. The standing orders take it from there.", "ops.tpl_bb":"Broadband", diff --git a/tests/intern-optical-upgrade.test.js b/tests/intern-optical-upgrade.test.js new file mode 100644 index 0000000..a18ad12 --- /dev/null +++ b/tests/intern-optical-upgrade.test.js @@ -0,0 +1,121 @@ +// The intern upgrades optical transport: line systems up a size (only where the traffic gets around the day-long swap and +// no customer rides the fiber), optics traded for bigger ones on full, hot fiber, or every fiber up to a chosen line system. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +// Frankfurt (transit) and Amsterdam (broadband) joined by a full Rainbow-in-a-Box fiber of 16×400G, and the long way +// round through Paris on two waves. Level 6: every line system and optic unlocked. Change Freeze: no fat fingers. +const BASE = "ACT.start({});S.cash=1e9;for(const g of GOALS)S.done[g.id]=0;S.lvl=6;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');" + + "for(const c of ['ams','par'])ACT.buildPop({city:c});for(const c of ['fra','ams','par']){S.pops[c].rgen=mainRG(3);S.pops[c].routers=2;}ACT.launchBB({city:'ams'});" + + "S.transit=[];ACT.buyTransit({city:'fra',net:'cog',tier:2});" + + "S.links=[{id:'f',a:'fra',b:'ams',kind:'df',own:true,sys:'lite',ch:Array(16).fill('zr4'),km:450,trench:'t1',ready:0,cut:0,mo:1,pairs:1}," + + "{id:'w1',a:'fra',b:'par',kind:'wave',tier:4,km:480,cut:0,mo:1},{id:'w2',a:'par',b:'ams',kind:'wave',tier:4,km:430,cut:0,mo:1}];compute();" + + "ACT.opsHire({id:'kevin'});S.ops.floor=0;S.ops.cap.optup=0;closeModal()"; +function game(t, extra) { + const h = load(); + t.after(() => h.dom.window.close()); + h.ev(BASE); + if (extra) h.ev(extra); + return h; +} +const order = (ev, p) => ev(`S.ops.on.optup=true;S.ops.p.optup=${JSON.stringify(p)}`); +// The fiber runs at 90% of what it carries. +const heat = ev => ev("R.load.f=dfCap(S.links[0])*0.9"); +const fiber = ev => JSON.parse(ev("JSON.stringify({sys:S.links[0].sys,ch:S.links[0].ch.join(),down:S.links[0].eqDown>S.day})")); + +test('a full, hot fiber gets the next line system where the traffic gets around it, at the price of the click', t => { + const { ev, errors } = game(t); + order(ev, { at: 80 }); + const want = ev('sysUpCost(S.links[0])'), served = ev('R.served'), c0 = ev('S.cash'); + heat(ev); + ev('opsDay(S.day)'); + assert.equal(fiber(ev).sys, 'roadm', 'up to the ROADMaster'); + assert.equal(c0 - ev('S.cash'), want, 'the shift paid exactly what Upgrade costs'); + assert.equal(fiber(ev).down, true, 'the swap takes the fiber down for the day, as by hand'); + assert.ok(ev('R.served') >= served - 1e-6, 'and every gigabit still gets through, the long way round'); + assert.match(ev('opsLine(S.ops.log[0])'), /upgraded the line system on Frankfurt–Amsterdam ⇧ROADM/); + // Not hot enough, or not full: nothing. + const { ev: ev2 } = game(t); + order(ev2, { at: 80 }); + ev2('R.load.f=dfCap(S.links[0])*0.5;opsDay(S.day)'); + ev2('S.links[0].ch.pop();R.load.f=dfCap(S.links[0])*0.95;S.day++;opsDay(S.day)'); + assert.equal(fiber(ev2).sys, 'lite', 'a fiber with a free channel gets more optics from Light more fiber, not a new line system'); + assert.deepEqual(errors, []); +}); + +test('no way around, or a customer on the fiber: no swap; bigger optics instead, one channel at a time', t => { + // Without the waves through Paris, Amsterdam would be cut off for the day. + const { ev, errors } = game(t, "S.links=S.links.filter(l=>l.kind==='df');compute()"); + order(ev, { at: 80 }); + heat(ev); + const c0 = ev('dfCap(S.links[0])'), cash0 = ev('S.cash'); + ev('opsDay(S.day)'); + assert.equal(fiber(ev).sys, 'lite', 'no outage'); + assert.equal(fiber(ev).down, false); + assert.ok(ev('dfCap(S.links[0])') > c0, 'more capacity from bigger optics'); + assert.match(fiber(ev).ch, /zr8/, 'Sizzle 800ZR+ in place of some 400ZR+'); + assert.equal(ev("S.links[0].ch.length"), 16, 'still sixteen channels'); + assert.ok(ev("S.spares.zr4") > 0, 'the old optics went on the shelf'); + assert.ok(cash0 - ev('S.cash') > 0); + assert.match(ev('opsLine(S.ops.log[0])'), /swapped \d+ optics for bigger ones \(Frankfurt–Amsterdam 400G→800G\)/); + // A customer's wave on the fiber: the intern never swaps its line system, even with a way around. + const { ev: ev2 } = game(t, "S.links[0].ch.length=15;S.biz.push({id:'cw',name:'Wave',city:'fra',city2:'ams',type:'wwave',link:'f',slots:1,bw:400,rate:1})"); + order(ev2, { at: 80, swap: false }); + heat(ev2); + ev2('opsDay(S.day)'); + assert.equal(fiber(ev2).sys, 'lite'); + assert.deepEqual(errors, []); +}); + +test('a chosen line system: every fiber below it is moved up, two steps in one night if need be, one fiber a night', t => { + const { ev, errors } = game(t, "S.links[0].ch=['zr4'];" + + "for(const [i,a,b] of [[2,'fra','par'],[3,'par','ams']])S.links.push({id:'g'+i,a,b,kind:'df',own:true,sys:'lite',ch:['zr4'],km:450,trench:'t'+i,ready:0,cut:0,mo:1,pairs:1});compute()"); + order(ev, { sys: 'cl', at: 90 }); + const want = ev("sysCost('roadm')+sysCost('cl')"); + const sys = () => JSON.parse(ev("JSON.stringify(S.links.filter(l=>l.kind==='df').map(l=>l.sys))")); + const c0 = ev('S.cash'); + ev('opsDay(S.day)'); + assert.equal(sys().filter(s => s === 'cl').length, 1, 'one fiber a night, cold or not'); + assert.equal(c0 - ev('S.cash'), want, 'both steps in one night: one outage, not two'); + for (let n = 0; n < 6 && sys().some(s => s !== 'cl'); n++) ev('S.day+=2;compute();opsDay(S.day)'); + assert.deepEqual(sys(), ['cl', 'cl', 'cl', 'cl'].slice(0, sys().length), 'the rest on the nights after'); + // Nothing is ever moved down. + ev("S.ops.p.optup.sys='roadm';S.day+=2;compute();opsDay(S.day)"); + assert.ok(sys().every(s => s === 'cl')); + // A fiber with no way around is tested once, then left alone for a week: no routing every night for nothing. + ev("S.links=S.links.filter(l=>l.id==='f');S.links[0].sys='lite';S.ops.p.optup.sys='cl';S.day+=2;compute()"); + const runs = () => ev('window.__runs||0'); + ev("window.__runs=0;const c0=compute;compute=function(){window.__runs++;return c0.apply(this,arguments);};opsDay(S.day)"); + assert.equal(sys()[0], 'lite'); + assert.equal(runs(), 0, 'no other path at all: not even one routing to find out'); + ev("S.links.push({id:'w9',a:'fra',b:'ams',kind:'wave',tier:0,km:450,cut:0,mo:1});S.day+=OPTUP_WAIT;window.__runs=0;opsDay(S.day)"); + assert.equal(runs(), 1, 'a path, too thin: one routing to find out'); + assert.equal(sys()[0], 'lite'); + ev('S.day++;window.__runs=0;opsDay(S.day)'); + assert.equal(runs(), 0, 'and not again the next night'); + assert.deepEqual(errors, []); +}); + +test('the budget holds, the setting is saved, and the sheet shows it as lists', t => { + const { ev, dom, errors } = game(t); + order(ev, { at: 80 }); + ev('S.ops.cap.optup=10000'); + heat(ev); + ev('opsDay(S.day)'); + assert.equal(fiber(ev).sys, 'lite', 'a $10k budget does not buy a line system'); + assert.ok(ev("S.ops.log[0].r.some(x=>x[0]==='broke')")); + const back = v => ev(`(()=>{const s=JSON.parse(JSON.stringify(S));s.ops.p.optup=${v};sanitize(s);return JSON.stringify(s.ops.p.optup);})()`); + assert.deepEqual(JSON.parse(back("{sys:'cl',swap:false,at:70}")), { at: 70, sys: 'cl', swap: false }); + assert.deepEqual(JSON.parse(back("{sys:'lite',swap:'yes'}")), {}); + assert.deepEqual(JSON.parse(back('undefined')), {}, 'an old save without the order'); + ev("const s=JSON.parse(JSON.stringify(S));delete s.ops.on.optup;sanitize(s);window.__off=s.ops.on.optup"); + assert.equal(ev('__off'), false, 'off in an old save'); + dom.window.innerWidth = 360; + ev("ACT.phoneTab({t:'noc'})"); + dom.window.document.querySelector('#leftBody [data-act="opsOpen"]').click(); + const sel = [...dom.window.document.querySelectorAll('#modalCard select[data-chg="opsParam"]')].find(s => s.dataset.args === '{"k":"optup","p":"sys"}'); + assert.deepEqual([...sel.options].map(o => o.textContent), ['Next one, when full', 'ROADMaster 9000', 'ROADMaster 9000 C+L']); + assert.match(dom.window.document.getElementById('modalCard').textContent, /Upgrade optical transport/); + assert.deepEqual(errors, []); +});