diff --git a/CHANGELOG.md b/CHANGELOG.md index 148958c..5655e1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- The intern's transit order has a new provider choice, Already connected: it only grows the transit you already buy at each POP, the smallest port first, and never signs a new provider, so several upstreams grow together and no customer's "no Cogentle" gets a surprise (#227). - The intern's PNI order now counts the traffic the PNI list shows at each POP, so it no longer orders a PNI where a network's own cache boxes already serve most of its traffic (#244). - Find any city with the new 🔍 button in the top bar, or press / on a keyboard (#218). Type a city, a country (in your language or in English) or an exchange, and the map jumps there. - Cities on the map now show how big they are: zoomed out, bigger cities are bigger dots and megacities glow; zoomed in, a city's skyline grows from a hut to a megacity's towers. When cities crowd together, the smaller ones step back to a dot until you zoom in, so the map stays readable, and exchanges you haven't joined are quieter tags. diff --git a/site/i18n/de.js b/site/i18n/de.js index 259c2d3..1bf175c 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -2796,6 +2796,7 @@ "notifications.n_min_ago":{"one":"vor {n} Min.","other":"vor {n} Min."}, "notifications.nothing_in_the_last_10_minutes":"Nichts in den letzten 10 Minuten.", "notifications.show_all_n":"Alle {n} anzeigen", +"ops.already_connected":"Nur bestehende", "ops.annie":"Annie", "ops.annie_d":"Antwortet vom nächstgelegenen Schreibtisch. Liebt billige Ports und volle IXe.", "ops.anycast_annie":"Anycast-Annie", diff --git a/site/i18n/es.js b/site/i18n/es.js index a93046b..b1605b1 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -2794,6 +2794,7 @@ "notifications.n_min_ago":{"one":"hace {n} min","other":"hace {n} min"}, "notifications.nothing_in_the_last_10_minutes":"Nada en los últimos 10 minutos.", "notifications.show_all_n":"Mostrar las {n}", +"ops.already_connected":"Solo los que ya tengo", "ops.annie":"Annie", "ops.annie_d":"Responde desde el escritorio más cercano. Le encantan los puertos baratos y los IX llenos.", "ops.anycast_annie":"Annie Anycast", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index 714e6c6..8129919 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -2794,6 +2794,7 @@ "notifications.n_min_ago":{"one":"il y a {n} min","other":"il y a {n} min"}, "notifications.nothing_in_the_last_10_minutes":"Rien ces 10 dernières minutes.", "notifications.show_all_n":"Tout afficher ({n})", +"ops.already_connected":"Déjà branchés", "ops.annie":"Annie", "ops.annie_d":"Répond depuis le bureau le plus proche. Adore les ports pas chers et les IX bien remplis.", "ops.anycast_annie":"Annie Anycast", diff --git a/site/i18n/it.js b/site/i18n/it.js index 43ec801..5569001 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2794,6 +2794,7 @@ "notifications.n_min_ago":{"one":"{n} min fa","other":"{n} min fa"}, "notifications.nothing_in_the_last_10_minutes":"Niente negli ultimi 10 minuti.", "notifications.show_all_n":"Mostra tutte e {n}", +"ops.already_connected":"Solo quelli già collegati", "ops.annie":"Annie", "ops.annie_d":"Risponde dalla scrivania più vicina. Adora le porte economiche e gli IX pieni.", "ops.anycast_annie":"Annie Anycast", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 05e0c28..343db3e 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2794,6 +2794,7 @@ "notifications.n_min_ago":{"one":"há {n} min","other":"há {n} min"}, "notifications.nothing_in_the_last_10_minutes":"Nada nos últimos 10 minutos.", "notifications.show_all_n":"Mostrar todas as {n}", +"ops.already_connected":"Só os já conectados", "ops.annie":"Annie", "ops.annie_d":"Responde da mesa mais próxima. Adora uma porta barata e um IX cheio.", "ops.anycast_annie":"Annie Anycast", diff --git a/src/game/60-features/95-standing-orders.js b/src/game/60-features/95-standing-orders.js index 919f08c..eabd0b1 100644 --- a/src/game/60-features/95-standing-orders.js +++ b/src/game/60-features/95-standing-orders.js @@ -11,7 +11,7 @@ const INTERNS={ // 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=[ - {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'||v==='have'||(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:'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:{}}, @@ -137,15 +137,19 @@ const OPS_RUN={ for(const c of opsPops('transit')){let ts=S.transit.filter(t=>t.city===c);if(!ts.length)continue; // Thirty days of 95th-percentile-ish history per port; their peaks summed is a safe (high) estimate of the POP's peak. const peak=ts.reduce((a,t)=>a+(t.hist||[]).reduce((m,v)=>Math.max(m,v),0),0);if(!(peak>0))continue; - const n=opsProv(c);if(!n)continue; + // "Already connected" (#227): only the providers you buy from here, the smallest first, never a new contract. + const have=opsP('transit','prov')==='have',n=have?null:opsProv(c);if(!have&&!n)continue; + const grow=t=>{const k=t.n||1,up=t.tier+1; + if(k<4&&portOk(c,t.tier))return {cost:PORT[t.tier].setup,go:()=>ACT.lagT({id:t.id,d:1}),w:'+1×'+PORT[t.tier].n}; + if(PORT[up]&&portShown(up)&&portOk(c,up))return {cost:PORT[up].setup*k,go:()=>ACT.buyTransit({city:c,net:t.net,tier:up}),w:PORT[t.tier].n+'→'+PORT[up].n}; + if(kACT.lagT({id:t.id,d:1}),w:'+1×'+PORT[t.tier].n};return null;}; for(let step=0;step<4;step++){const cap=ts.reduce((a,t)=>a+lagCap(PORT[t.tier].g,t.n),0);if(cap>=N*peak)break; - const t=ts.find(x=>x.net===n.id);let job=null; - if(t){const k=t.n||1,up=t.tier+1; - if(k<4&&portOk(c,t.tier))job={cost:PORT[t.tier].setup,go:()=>ACT.lagT({id:t.id,d:1}),w:'+1×'+PORT[t.tier].n}; - else if(PORT[up]&&portShown(up)&&portOk(c,up))job={cost:PORT[up].setup*k,go:()=>ACT.buyTransit({city:c,net:n.id,tier:up}),w:PORT[t.tier].n+'→'+PORT[up].n}; - else if(kACT.lagT({id:t.id,d:1}),w:'+1×'+PORT[t.tier].n};} - else{const need=N*peak-cap,ok=PORT.map((P,i)=>i).filter(i=>portShown(i)&&portOk(c,i)),i=ok.find(i=>PORT[i].g>=need)??ok.at(-1); - if(i!==undefined)job={cost:PORT[i].setup,go:()=>ACT.buyTransit({city:c,net:n.id,tier:i}),w:'+'+PORT[i].n};} + let job=null; + if(have){for(const t of ts.slice().sort((a,b)=>lagCap(PORT[a.tier].g,a.n)-lagCap(PORT[b.tier].g,b.n)||transitPerG(NET[a.net],c,!!a.premium)-transitPerG(NET[b.net],c,!!b.premium))){job=grow(t);if(job)break;}} + else{const t=ts.find(x=>x.net===n.id); + if(t)job=grow(t); + else{const need=N*peak-cap,ok=PORT.map((P,i)=>i).filter(i=>portShown(i)&&portOk(c,i)),i=ok.find(i=>PORT[i].g>=need)??ok.at(-1); + if(i!==undefined)job={cost:PORT[i].setup,go:()=>ACT.buyTransit({city:c,net:n.id,tier:i}),w:'+'+PORT[i].n};}} if(!job||!X.can('transit',job.cost)||!X.pay('transit',job.go))break; X.did('transit',c+' '+job.w);ts=S.transit.filter(t=>t.city===c);}}}, optics(X){const at=opsP('optics','at')/100; diff --git a/src/game/90-actions/88-ops.js b/src/game/90-actions/88-ops.js index 3d8115a..11f1a49 100644 --- a/src/game/90-actions/88-ops.js +++ b/src/game/90-actions/88-ops.js @@ -10,7 +10,7 @@ Object.assign(ACT,{ toast(esc(tr('ops.fired',{name:nm})),'');after();opsModal();}, opsToggle:({k})=>{if(!opsHired()||!own(OPSK,k))return;S.ops.on[k]=!S.ops.on[k];sfx('click');after();opsModal();}, opsParam:({k,p})=>{if(!opsHired()||!own(OPSK,k)||!own(OPSK[k].p,p))return;const P=OPSK[k].p[p];let v; - if(p==='prov'){const ids=['cheap',...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','have',...NETS.filter(n=>n.price&&Object.keys(S.pops).some(c=>sellsAt(n,c))).map(n=>n.id)];v=opsCycle(ids,opsP(k,p));}else v=opsCycle(P.v,opsP(k,p)); (S.ops.p[k]||(S.ops.p[k]={}))[p]=v;sfx('click');after();opsModal();}, opsCap:({k})=>{if(!opsHired()||!own(OPSK,k)||!OPSK[k].cap)return;S.ops.cap[k]=opsCycle(opsCaps(k),opsCap(k));sfx('click');after();opsModal();}, opsFloor:()=>{if(!opsHired())return;S.ops.floor=opsCycle(OPS_FLOORS,S.ops.floor);sfx('click');after();opsModal();}, diff --git a/src/game/93-ui/57-ops-panel.js b/src/game/93-ui/57-ops-panel.js index e63fd93..cb1a28d 100644 --- a/src/game/93-ui/57-ops-panel.js +++ b/src/game/93-ui/57-ops-panel.js @@ -5,7 +5,7 @@ function opsCard(){if(!S)return '';const last=opsHired()&&S.ops.log[0];
${opsHired()?esc(last?opsEntry(last):tr('ops.l_quiet',{name:opsName()})):opsCanHire()?tr('ops.hire_pitch_short'):tr('ops.locked',{lv:2})}
${btn(opsHired()?tr('ops.standing_orders'):tr('ops.hire_an_intern'),'opsOpen',{},opsHired()?'sm':'pink sm',!opsHired()&&!opsCanHire())}
`;} 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'):v==='have'?tr('ops.already_connected'):NET[v].name):P.f(v);} function opsOrderHtml(d){const k=d.k,on=S.ops.on[k],cap=d.cap?opsCap(k):0,sp=S.ops.spent[k]||0,am=Math.round(S.ops.addMo[k]||0); return `
${tr(d.t)}
${tr(d.d)}${k==='caches'?' '+tr('ops.caches_rent',{price:fmt$(CACHE_MO)}):''}
diff --git a/src/i18n/en.js b/src/i18n/en.js index abec28b..0cf7629 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -2795,6 +2795,7 @@ "notifications.n_min_ago":{"one":"{n} min ago","other":"{n} min ago"}, "notifications.nothing_in_the_last_10_minutes":"Nothing in the last 10 minutes.", "notifications.show_all_n":"Show all {n}", +"ops.already_connected":"Already connected", "ops.annie":"Annie", "ops.annie_d":"Answers from whichever desk is closest. Loves a cheap port and a full IX.", "ops.anycast_annie":"Anycast Annie", diff --git a/tests/standing-orders.test.js b/tests/standing-orders.test.js index 231f9d6..e2c5bbf 100644 --- a/tests/standing-orders.test.js +++ b/tests/standing-orders.test.js @@ -596,6 +596,30 @@ test('#228 the intern names the exchanges it peered at, even one that shares its assert.deepEqual(errors, []); }); +test('#227 transit "Already connected" grows the providers you have, the smallest first, and never signs a new one', t => { + const { ev, errors } = game(t, "ACT.buyTransit({city:'fra',net:'ntt',tier:1});compute()"); + hire(ev); on(ev, 'transit', { x: 1.5, prov: 'have' }); + const capOf = net => ev(`(()=>{const t=S.transit.find(x=>x.city==='fra'&&x.net==='${net}');return lagCap(PORT[t.tier].g,t.n)})()`); + const c0 = capOf('cog'), n0 = capOf('ntt'); + assert.equal(c0, n0, 'two equal ports to start'); + ev('for(const t of S.transit)t.hist=[100]'); shift(ev); + assert.equal(ev("JSON.stringify(S.transit.filter(t=>t.city==='fra').map(t=>t.net).sort())"), '["cog","ntt"]', 'no new provider'); + assert.ok(capOf('cog') > c0 && capOf('ntt') > n0, 'both grew, not just one'); + assert.equal(capOf('cog'), capOf('ntt'), 'evenly, smallest first'); + // a POP whose only upstream is not the cheapest never gets the cheapest added (Cheapest would buy Cogentle there) + ev("ACT.buildPop({city:'ams'});S.pops.ams.rgen=1;ACT.launchBB({city:'ams'});ACT.buyTransit({city:'ams',net:'ntt',tier:1});compute()"); + assert.equal(ev("cheapestTransit('ams').id"), 'cog'); + ev("for(const t of S.transit)t.hist=[400]"); ev('S.day++'); shift(ev); + assert.equal(ev("JSON.stringify(S.transit.filter(t=>t.city==='ams').map(t=>t.net))"), '["ntt"]'); + // the setting cycles through it, reads "Already connected" and survives a save + ev("S.ops.p.transit.prov='cheap';ACT.opsParam({k:'transit',p:'prov'})"); + assert.equal(ev("opsP('transit','prov')"), 'have'); + assert.equal(ev("opsVal('transit','prov')"), 'Already connected'); + ev('S=migrate(JSON.parse(JSON.stringify(S)))'); + assert.equal(ev("opsP('transit','prov')"), 'have'); + assert.deepEqual(errors, []); +}); + test('#244 the PNI order counts the traffic the PNI list shows at that POP, not what cache boxes there already serve', t => { const { ev, errors } = game(t, "ACT.buildPop({city:'ham'});for(const c of ['fra','ham']){S.pops[c].rgen=mainRG(4);S.pops[c].routers=6;if(!S.pops[c].bb)ACT.launchBB({city:c});S.pops[c].bb.d=CITY[c].P*0.9;}UI.pending={a:'fra',b:'ham'};ACT.buildLink({tier:3});closeModal();ACT.buyTransit({city:'fra',net:'cog',tier:3});ACT.buyTransit({city:'ham',net:'cog',tier:3});for(let i=0;i<6;i++)S.caches.push({id:'nfx'+i,city:'ham',net:'nfx'});compute()"); // Hamburg's users want a lot from NetChill, but its cache boxes there serve most of it: little is left for a PNI