Lambda Bazaar: a capacity market for your dark fiber

A new NOC tab sells spectrum, managed 100G, 400G, 800G and 1.6T waves, and dark pair IRUs on every route you hold
fiber on. Demand per route moves every day (its own cycle, noise, and news: fiber cuts, hyperscalers, AI clusters,
rivals lighting glass, mergers) and grows about 15% a year, with buyers moving to bigger waves over the years and
carriers on your glass asking to move up a size. You choose what to keep back for your own traffic, from what demand
the broker lists, and the price it never sells below. Managed waves come out of capacity you lit; prices follow the
fiber's cost, how hot and how full the route is, and its latency (400G at 2.7x 100G on land, 3.8x subsea). A Cable
broker pays 3% instead of 10% and sees each route's forecast and routes worth building.

Rule F5 now bounds sales by the moving market; new rule F8 covers managed waves. The route fuzz skips dashboard tabs
main does not have yet.
This commit is contained in:
Frederic Jung 2026-11-07 13:15:56 +01:00
parent e6b5464352
commit 2f738dceda
No known key found for this signature in database
34 changed files with 891 additions and 56 deletions

View file

@ -68,7 +68,10 @@ const regenNeed=(o,l)=>Math.max(0,Math.ceil(l.km/reachOn(OPT[o].reach,l.sub))-1)
// all its channels. Nothing changes while a frame is drawn, so draw() keeps the answers in DFC for that frame.
let DFC=null;
const dfCap=l=>{if(!DFC)return dfCap0(l);let g=DFC.get(l);if(g===undefined)DFC.set(l,g=dfCap0(l));return g;};
const dfCap0=l=>{if(l.ready>S.day||l.eqDown>S.day)return 0;const ch=l.ch||[];let g=0;for(const c of ch)g+=optG(c,l);const f=l.chFail&&l.chFail.until>S.day?l.chFail:null;if(f){const fo=f.o&&ch.includes(f.o)?f.o:ch.slice().sort((a,b)=>optG(a,l)-optG(b,l))[0];if(fo)g-=optG(fo,l);}return Math.max(0,g);};
// dfLit: everything the optics carry; dfCap0: what is left for your own traffic once managed waves sold on it (mwG(),
// the capacity market) are carved out.
const dfLit=l=>{if(l.ready>S.day||l.eqDown>S.day)return 0;const ch=l.ch||[];let g=0;for(const c of ch)g+=optG(c,l);const f=l.chFail&&l.chFail.until>S.day?l.chFail:null;if(f){const fo=f.o&&ch.includes(f.o)?f.o:ch.slice().sort((a,b)=>optG(a,l)-optG(b,l))[0];if(fo)g-=optG(fo,l);}return Math.max(0,g);};
const dfCap0=l=>Math.max(0,dfLit(l)-mwG(l));
const capOf=l=>(l.kind==='vxc'?VXC[l.vt].g:l.kind==='df'?dfCap(l):LT[l.tier].g)*(l.deg>S.day?0.5:1)*(l.loss&&l.loss.until>S.day?l.loss.f:1);
// A sick LAG (LACP trouble) keeps only part of its capacity until the incident clears.
const lagF=o=>o&&o.lacp&&o.lacp.until>S.day?o.lacp.f:1,ixLagF=x=>lagF(S.ev&&S.ev.ixlacp&&{lacp:S.ev.ixlacp[x]});

View file

@ -18,6 +18,8 @@ const BIZ_T={
event:{l:tr('common.event_network'),opts:[100,200,400,800,1600,3200],rate:0,event:true,lv:2,names:['Carnaval Parade','Diwali Streaming Night','The Big Football Final','NANOG 99','APRICOT 2027','DENOG 18','UKNOF 56','RIPE 94','DKNOG 16','Burning Router Festival','Euro-Pop Song Contest','Formula Ping Grand Prix','The Big Game','Olympic Pings','A Pop Megastar Stadium Tour','LAN Party of the Century','The Keynote (One More Thing)','Gamer-Con Expo','Oktoberfest Livestream']},
sdwan:{l:tr('businesses.sd_wan_for_a_chain'),opts:[1,2,5,10],rate:0,l2:true,sdwan:true,km:0,lv:2,names:['Kebab Kingdom','Pretzel Palace','Burger Router Inc.','Café Latte-ncy','Hardware Hut Stores','Pharma-See Pharmacies','Bank of Tiny Branches','Supermarket Superhighway','Fitness Pings Gyms','Hotel Hops Group','Doughnut Data Diners']},
wwave:{l:tr('common.wholesale_wave'),opts:[1],rate:0,fiber:true,lv:2,names:['Zay-No Fiber','Loomin’ Technologies','Clown Castle Fiber','G&T (Gin and Transit)','A Hyperscaler Who Shall Not Be Named','Megapork','youNetworks']},
// A managed wave (the capacity market): carved out of capacity you lit; b.g is its size (100 or 400G), b.slots how many.
mwave:{l:tr('market.managed_wave'),opts:[1],rate:0,fiber:true,lv:2,names:['Lambda Lambda Lambda','Coherent Thoughts Inc.','Photon Express','Transponder Tribe','Sea Change Networks','Spectrum Spectacle','Wavelength Wanderers','Muxed Signals Ltd.']},
dfpair:{l:tr('businesses.dark_fiber_pair_lease'),opts:[1],rate:0,fiber:true,lv:3,names:['A Hyperscaler Who Shall Not Be Named','Goggle Fiber Division','Faceplant Infra','Amazin’ Backbone Team','A Very Secretive Trading Firm']},
scrub:{l:tr('businesses.ddos_protection_dia'),opts:[1,5,10,20],rate:900},
aiwan:{l:tr('businesses.ai_wan_between_two_ai_factories'),opts:[3200,6400,12800],rate:0,l2:true,div:true,mega:true,km:0.45,lv:4,names:['Fairweather AI WAN','Planet-Scale Superfactory Link','Two Brains One Model Inc.','Distributed Godlike Compute','The Gigawatt Handshake']},

View file

@ -24,7 +24,7 @@ const GOALS=[
// (37-cable-broker.js). Ids of their own, so a save keeps the ladder it ran. Rewards are larger: glass costs more.
const BROKER_GOALS=[
{id:'bk_df',t:tr('goals.light_your_own_dark_fiber'),d:tr('broker.goal_df_d'),r:25000,ok:()=>S.links.some(l=>l.kind==='df'&&dfCap(l)>0)},
{id:'bk_wave',t:tr('broker.goal_wave'),d:tr('broker.goal_wave_d'),r:40000,ok:()=>S.biz.some(b=>b.type==='wwave'||b.type==='capw'&&!capPend(b))},
{id:'bk_wave',t:tr('broker.goal_wave'),d:tr('broker.goal_wave_d'),r:40000,ok:()=>S.biz.some(b=>b.type==='wwave'||b.type==='mwave'||b.type==='capw'&&!capPend(b))},
{id:'bk_pair',t:tr('broker.goal_pair'),d:tr('broker.goal_pair_d'),r:50000,ok:()=>S.biz.some(b=>(b.type==='dfpair'||b.type==='pairs'||b.type==='capfib')&&!capPend(b))},
{id:'bk_sea',t:tr('broker.goal_sea'),d:tr('broker.goal_sea_d'),r:150000,ok:()=>S.links.some(l=>ownGlassL(l)&&l.sub)},
{id:'bk_deal',t:tr('broker.goal_deal'),d:tr('broker.goal_deal_d'),r:100000,ok:()=>(S.stats.capDone||0)>0},

View file

@ -10,11 +10,11 @@ const glassKm=()=>S.links.reduce((a,l)=>a+(ownGlassL(l)?l.km:0),0);
// The continents your own subsea cables land on.
function cableConts(){const r=new Set();for(const l of S.links)if(ownGlassL(l)&&l.sub)for(const c of [l.a,l.b])r.add(CITY[c].reg);return r.size;}
// Capacity other carriers buy from you: alien waves, fiber pairs and capacity deals (once delivered).
const CAP_TYPES=['wwave','dfpair','pairs','capw','capsub','capfib'];
const CAP_TYPES=['wwave','mwave','dfpair','pairs','capw','capsub','capfib'];
const capSold=b=>CAP_TYPES.includes(b.type)&&!capPend(b);
const capSalesMo=()=>S.biz.reduce((a,b)=>a+(capSold(b)?bizMo(b):0),0);
// Lit capacity sold, in Gbps: waves (400G each) and subsea capacity. A dark pair is the buyer's to light.
const capSoldG=()=>S.biz.reduce((a,b)=>a+(!capSold(b)?0:b.type==='wwave'?(b.slots||1)*400:b.type==='capw'||b.type==='capsub'?b.bw:0),0);
const capSoldG=()=>S.biz.reduce((a,b)=>a+(!capSold(b)?0:b.type==='wwave'?(b.slots||1)*400:b.type==='mwave'?(b.slots||1)*(b.g||100):b.type==='capw'||b.type==='capsub'?b.bw:0),0);
// Two hops of your own glass through one city, each lit to at least g.
function glassChain(g){const by={};for(const l of S.links)if(ownGlassL(l)&&dfCap(l)>=g)for(const [c,o] of [[l.a,l.b],[l.b,l.a]])(by[c]=by[c]||new Set()).add(o);
return Object.values(by).some(s=>s.size>=2);}

View file

@ -21,16 +21,5 @@ const brFree=l=>Math.max(0,brMarket(l.a,l.b)-brSold(l.a,l.b));
const WW_SHARE=0.3,WW_FALL=0.6;
function wwRate(l,n,cut=1){const F=dfLeaseMo(l.km)+ampCount(l.km)*AMP_MO,M=brMarket(l.a,l.b),s=brSold(l.a,l.b);let r=0;
for(let i=0;i<n;i++)r+=F*WW_SHARE*(1-WW_FALL*Math.min(1,(s+i)/M));return Math.round(r*cut);}
// Once a day, each listing may find a buyer: the more room the route has left, the sooner.
function brTick(){for(const l of S.links){const L=l.list;if(!L||l.kind!=='df'||!fiberOk({link:l.id,type:'wwave'}))continue;
const free=brFree(l);if(!free)continue;
if(L.w>0&&freeCh(l)>=1&&Math.random()<Math.min(0.3,free/45)){const n=Math.max(1,Math.min(L.w,freeCh(l),free,1+Math.floor(Math.random()*4)));brSell(l,'wwave',n);L.w-=n;}
else if(L.p>0&&pairFree(l)&&free>=BR_PAIR&&Math.random()<1/90){brSell(l,'dfpair',1);L.p--;}
if(!(L.w>0)&&!(L.p>0))delete l.list;}}
// A sale: a new carrier on this fiber, or more waves for one that already rents here.
function brSell(l,t,n){const T=BIZ_T[t],nm=()=>{const list=T.names.filter(x=>!S.usedNames.includes(x)),x=list.length?pick(list):pick(T.names);useName(x);return x;};
const o=fiberOffer(t,l,nm,0.9);if(t==='wwave'){o.slots=n;o.rate=wwRate(l,n,0.9);o.what=wwWhat(l,n);}
const more=t==='wwave'&&S.biz.find(b=>b.type==='wwave'&&b.link===l.id&&b.name===o.name);
if(more){more.slots=(more.slots||0)+n;more.rate+=o.rate;more.what=wwWhat(l,more.slots);}else S.biz.push(clSign(offerCustomer(o)));
toast(tr('broker.sold',{name:esc(o.name),what:esc(t==='wwave'?wwWhat(l,n):o.what),price:fmt$(o.rate)}),'good');
floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,tr('common.signed'),'#16A866');}
// The listings sell in the capacity market now (cmDay(), 37-fiber-market.js), with prices and demand that move.
const brTick=()=>cmDay(S.day);

View file

@ -0,0 +1,182 @@
/* ---------- the capacity market: what carriers want on each route, today and tomorrow ----------
Every route you hold dark fiber on has buyers for spectrum (an alien wave, the buyer brings the optics), managed
100G, 400G, 800G and 1.6T waves (carved out of capacity you lit yourself), and dark pairs on fiber you dug (an IRU: a
big sum up front, then a little upkeep a month). How much each route wants moves all the time, as it does in real
life: a slow cycle of its own, weeks of noise, and news (a cable cut next door, a hyperscaler breaking ground, a rival
lighting new glass). Underneath, it grows: carriers want more every year, and bigger waves as the years go by (100G
gives way to 400G, then 800G and 1.6T), and carriers already on your glass ask to move up a size. Hot routes pay more
and fill faster; a short, straight route sells waves at a premium, and a long one costs more because its fiber does. The broker keeps 10% (3% for a Cable broker, who also sees where
each route is heading). S.cm: hold (share kept for your own traffic), p (per product: auto on, min demand, price
floor), off (routes left alone), sh (shocks), news, seen (incidents already turned into news). */
const CM_P=['spec','w100','w400','w800','w1600','iru'],CM_W=['w100','w400','w800','w1600'];
const CM_L={spec:'w',w100:'m1',w400:'m4',w800:'m8',w1600:'m16',iru:'p'},CM_G={w100:100,w400:400,w800:800,w1600:1600};
const CM_HOLD=[0,10,25,50],CM_FLOOR=[60,80,100,120],CM_MIN={spec:[1,2,4,8],w100:[1,4,8,16],w400:[1,2,4,8],w800:[1,2,4,8],w1600:[1,2,4],iru:[1,2]};
const CM_DEF={spec:{on:false,min:2,floor:80},w100:{on:false,min:4,floor:80},w400:{on:false,min:2,floor:80},w800:{on:false,min:1,floor:80},w1600:{on:false,min:1,floor:80},iru:{on:false,min:1,floor:100}};
// A wave's price against a 100G one, on land and on subsea: 2.7x and 3.8x for 400G (real markets in 2025), and the
// price of a bit keeps falling as waves grow.
const CM_X={w100:[1,1],w400:[2.7,3.8],w800:[4.6,6.6],w1600:[7.8,11]};
// Cities where trading firms sit: a short route between two of them pays the most for a fast wave.
const CM_FIN=['nyc','chi','lon','fra','tok','sin','hkg','ams','ash'];
const CM_HMAX=2.5;
const cmNew=()=>({hold:25,p:JSON.parse(JSON.stringify(CM_DEF)),off:{},sh:[],news:[],seen:[]});
const cmCut=()=>broker()?0.97:0.9;
/* A fiber's listing, l.list: {w: spectrum slots, p: pairs} as it always was, plus m1/m4/m8/m16 (managed 100G to 1.6T
waves) when any are listed. cmClean() checks one (a save, or after a day of sales) and returns null when nothing is left. */
const cmLs=l=>l.list||(l.list={w:0,p:0});
function cmClean(L){if(!L||typeof L!=='object'||Array.isArray(L))return null;const x={w:int(L.w,0,256,0),p:int(L.p,0,2,0)};let any=x.w||x.p;
for(const p of CM_W){const v=int(L[CM_L[p]],0,256,0);if(v){x[CM_L[p]]=v;any=1;}}return any?x:null;}
// A stable number in [0,1) for a route and a question, different in every game.
const cmU=(k,q)=>hstr(k+'|'+q+'|'+((S&&S.asn)||0))%100000/100000;
/* How hot a route is (1 = its usual self). Its own slow cycle (two waves of 4 to 10 and 1.5 to 3 months) is what a
forecast can see; the weeks of noise on top and news nobody has heard yet are not. */
function cmCycle(k,d){const p1=120+180*cmU(k,'p1'),p2=40+50*cmU(k,'p2');return 1+0.25*Math.sin(2*Math.PI*(d/p1+cmU(k,'f1')))+0.15*Math.sin(2*Math.PI*(d/p2+cmU(k,'f2')));}
function cmNoise(k,d){const i=Math.floor(d/15),t=(d-i*15)/15,u=t*t*(3-2*t),v=j=>0.85+0.3*cmU(k,'n'+j);return v(i)*(1-u)+v(i+1)*u;}
// News: a shock ramps up over a week, holds, and fades over the last 40% of its time.
const cmShockF=(x,d)=>d<x.from||d>=x.until?0:Math.max(0,Math.min(1,(d-x.from+1)/7,(x.until-d)/Math.max(1,(x.until-x.from)*0.4)));
const cmHits=(x,r)=>x.k?x.k===r.k:x.c?x.c===r.a||x.c===r.b:!!x.sub&&r.sub;
function cmShock(r,p,d){let m=1;for(const x of S.cm.sh)if(cmHits(x,r)&&(!x.p||x.p.includes(p))){const f=cmShockF(x,d);if(f)m*=1+(x.m-1)*f;}return m;}
function cmHeat(r,p,d,fc){return clamp(cmCycle(r.k,d)*(fc?1:cmNoise(r.k,d))*cmShock(r,p,d),0.3,CM_HMAX);}
// What a route is: its cities, its fiber (yours, if any), how far and how fast. Without fiber, as you could dig it
// (straight, at your own fiber's 1.1 path factor).
function cmRoute(a,b,ls=[]){const k=a<b?a+'|'+b:b+'|'+a,km=ls.length?Math.min(...ls.map(l=>l.km)):kmBetween(a,b),sub=ls.length?ls.some(l=>l.sub):isSub(a,b);
const lat=ls.length?Math.min(...ls.map(linkLat)):kmBetween(a,b)*1.1/200,gc=kmBetween(a,b)/200,st=gc>0?lat/gc:2,fin=CM_FIN.includes(a)&&CM_FIN.includes(b);
// Latency is dominated by the length of the route: a short, straight one sells fast waves at a premium (up to +50%,
// +80% between two trading cities).
const lp=1+0.5*clamp((1.5-st)/0.4,0,1)*(fin?1.6:1);
return {k,a,b,ls,km,sub,lat,st,lp,fin,dc:MEGA.some(m=>m.c===a||m.c===b)};}
// The routes you hold ready dark fiber on.
function cmRoutes(){const by=new Map();for(const l of S.links)if(l.kind==='df'&&l.ready<=S.day){const k=edgeKey(l);(by.get(k)||by.set(k,[]).get(k)).push(l);}
const rs=new Map();for(const [k,ls] of by){const [a,b]=k.split('|');rs.set(k,cmRoute(a,b,ls));}return rs;}
/* Growth: carriers want about 15% more every year (non-AI traffic grows about that fast, AI traffic faster), up to 8
times what they wanted at the start. */
const cmGrowth=d=>Math.min(8,Math.pow(1.15,Math.max(0,d)/365));
/* Which wave sizes buyers want: each size catches on along an S-curve over game years plus the network era, and takes
over from the one before (100G, then 400G, 800G from about year 5, 1.6T from about year 9; a later network era
brings each a little sooner). */
const CM_ADOPT={w400:1.5,w800:5,w1600:9};
const cmA=(p,d)=>1/(1+Math.exp(-(Math.max(0,d)/365+0.15*lvl()-CM_ADOPT[p])/1.3));
function cmShare(p,d){const a4=cmA('w400',d),a8=cmA('w800',d),a16=cmA('w1600',d);return p==='w100'?1-a4:p==='w400'?a4-a8:p==='w800'?a8-a16:a16;}
/* What a route wants of a product, in units: spectrum slots, waves of that size, dark pairs. The size comes from the
eyeballs at both ends (brMarket(), as before) and growth; managed waves split by the sizes buyers want now, fast
waves from latency, the big ones and dark pairs from data centers at either end; dark pairs are mostly bought for
shorter hauls. */
function cmDem(r,p,d,fc){const M=brMarket(r.a,r.b),H=cmHeat(r,p,d,fc),g=cmGrowth(d);
if(p==='spec')return M*0.5*Math.pow(g,0.7)*H;
if(p==='iru')return Math.min(2,M/12*(r.dc?2:1)*clamp(900/r.km,0.35,1.5))*Math.sqrt(g)*H;
const dc=r.dc&&p!=='w100'?(p==='w400'?1.3:1.6):1;return M*160*Math.sqrt(r.lp)*g*cmShare(p,d)*dc*H/CM_G[p];}
// What carriers already rent on a route, by product, in the same units.
const cmWP=g=>CM_W.find(p=>CM_G[p]===g)||'w100';
function cmSold(rs){const m=new Map(),ids=new Map();for(const r of rs.values()){m.set(r.k,Object.fromEntries(CM_P.map(p=>[p,0])));for(const l of r.ls)ids.set(l.id,r.k);}
for(const b of S.biz){const k=b.link&&ids.get(b.link);if(!k)continue;const s=m.get(k);
if(b.type==='wwave')s.spec+=b.slots||0;else if(b.type==='mwave')s[cmWP(b.g)]+=b.slots||0;else if(b.type==='dfpair')s.iru++;}
return m;}
/* List prices, before the market index (mkt()) and the broker's cut: spectrum is 30% of what the fiber costs a month
(as before, #203); a managed 100G wave 30% of that times the latency premium, bigger ones by CM_X; a dark pair two
years of its lease up front, then 15% of it a month. */
const cmF=r=>dfLeaseMo(r.km)+ampCount(r.km)*AMP_MO;
function cmList(r,p){return p==='spec'?cmF(r)*WW_SHARE:p==='iru'?dfLeaseMo(r.km)*0.15:cmF(r)*WW_SHARE*0.3*r.lp*CM_X[p][r.sub?1:0];}
const cmUpList=r=>dfLeaseMo(r.km)*0.9*24;
/* The price of the i-th unit from now, as a share of list: heat pushes it up or down (hot routes pay off), and each
unit sold on the route makes the next one cheaper, down to 40% once its market is full. */
function cmIdx(r,p,s,i,d,fc){const D=cmDem(r,p,d,fc),H=cmHeat(r,p,d,fc);return clamp(Math.pow(H,0.6),0.7,1.35)*(1-WW_FALL*Math.min(1,D>0?(s+i)/D:1));}
// Managed waves sold on a fiber, in Gbps: they come off what your own traffic gets (dfCap0()).
let CM_MW=null,CM_V=0;
function mwG(l){if(!S||!S.biz)return 0;if(!CM_MW||CM_MW.b!==S.biz||CM_MW.n!==S.biz.length||CM_MW.v!==CM_V){const m=new Map();
for(const b of S.biz)if(b.type==='mwave'&&b.link)m.set(b.link,(m.get(b.link)||0)+(b.slots||0)*(b.g||100));CM_MW={b:S.biz,n:S.biz.length,v:CM_V,m};}
return CM_MW.m.get(l.id)||0;}
// How much of a product a fiber has spare, after the share kept back for your own traffic (spectrum slots, or lit
// capacity your traffic is not using). A wave rides one channel, so an 800G or 1.6T one needs an optic that big. A pair
// is never kept back: it is glass you are not lighting.
const cmFreeG=(l,hold=S.cm.hold)=>dfCap0(l)-(R.load[l.id]||0)*1.05-hold/100*dfLit(l);
const cmOptG=l=>Math.max(0,...(l.ch||[]).map(c=>optG(c,l)));
function cmSpare(l,p,hold=S.cm.hold){
if(p==='spec')return Math.max(0,freeCh(l)-Math.ceil(hold/100*chMax(l)));
if(p==='iru')return l.own&&pairFree(l)&&!(l.cut>S.day)?1:0;
return cmOptG(l)<CM_G[p]?0:Math.max(0,Math.floor(cmFreeG(l,hold)/CM_G[p]));}
const cmWhat=(l,p,n)=>p==='spec'?wwWhat(l,n):p==='iru'?tr('requirements.a_spare_fiber_pair_in_your',{a:CITY[l.a].name,b:CITY[l.b].name}):trn('market.n_g_wave_on',n,{g:fmtCap(CM_G[p]),a:CITY[l.a].name,b:CITY[l.b].name});
// A sale: a new carrier on this fiber, or more of the same product for one that already rents here.
function cmSell(l,p,n,rate,up){const t=p==='spec'?'wwave':p==='iru'?'dfpair':'mwave',T=BIZ_T[t],nm=()=>{const list=T.names.filter(x=>!S.usedNames.includes(x)),x=list.length?pick(list):pick(T.names);useName(x);return x;};
const g=CM_G[p],name=nm(),more=t!=='dfpair'&&S.biz.find(b=>b.type===t&&b.link===l.id&&b.name===name&&(t!=='mwave'||b.g===g));
if(more){more.slots=(more.slots||0)+n;more.rate+=rate;more.what=cmWhat(l,p,more.slots);}
else{const o={id:uid(),city:l.a,city2:l.b,link:l.id,slots:t==='dfpair'?0:n,what:cmWhat(l,p,n),name,type:t,bw:1,rate,reqs:[],exp:S.day+30};const b=clSign(offerCustomer(o));if(g)b.g=g;S.biz.push(b);}
CM_V++;if(up)S.cash+=up;S.stats.cmSold=(S.stats.cmSold||0)+1;
toast(up?tr('market.sold_pair',{name:esc(name),what:esc(cmWhat(l,p,n)),up:fmt$(up),price:fmt$(rate)}):tr('broker.sold',{name:esc(name),what:esc(cmWhat(l,p,n)),price:fmt$(rate)}),'good');
floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,tr('common.signed'),'#16A866');}
// What one fiber can still sell of a product right now, whatever is listed: free spectrum, lit capacity your traffic
// is not using, a free pair.
function cmCan(l,p){if(!fiberOk({link:l.id,type:p==='iru'?'dfpair':'wwave'}))return 0;return p==='spec'?Math.max(0,freeCh(l)):p==='iru'?cmSpare(l,'iru'):cmSpare(l,p,0);}
/* News: incidents that cut glass become news the next morning, and every so often something happens on its own.
Each one is a shock on a route, around a city, or on every subsea route, for some products, for a while. */
const CM_NEWS={
cut:{m:1.6,days:45,p:null,t:N_('market.news_cut')},redsea:{m:1.8,days:90,p:null,t:N_('market.news_redsea')},
dc:{m:2,days:150,p:['w400','w800','w1600','iru'],t:N_('market.news_dc_big')},ai:{m:2.5,days:70,p:['w400','w800','w1600'],t:N_('market.news_ai_big')},
glut:{m:0.6,days:120,p:null,t:N_('market.news_glut')},exch:{m:1.7,days:60,p:CM_W,t:N_('market.news_exch')},
merge:{m:0.75,days:90,p:null,t:N_('market.news_merge')},boom:{m:1.4,days:60,p:['spec','w100'],t:N_('market.news_boom')}};
function cmNews(why,x,d){const N=CM_NEWS[why],s={why,from:d,until:d+N.days,m:N.m,...x};if(N.p)s.p=N.p.slice();S.cm.sh.push(s);
S.cm.news.unshift({d,why,a:x.a||x.c||null,b:x.b||null});S.cm.news.length=Math.min(S.cm.news.length,8);
const rs=cmRoutes();if([...rs.values()].some(r=>cmHits(s,r)))toast(cmNewsText(S.cm.news[0]),N.m>1?'info':'warn',[{l:tr('market.open'),act:'marketOpen',args:{}}]);}
const cmNewsText=n=>tr(CM_NEWS[n.why].t,{a:n.a?CITY[n.a].name:'',b:n.b?CITY[n.b].name:''});
function cmShocks(d){const C=S.cm;C.sh=C.sh.filter(x=>x.until>d);
for(const i of S.inc)if(LINKCUT_TR.includes(i.type)&&!C.seen.includes(i.id)){C.seen.push(i.id);if(C.seen.length>40)C.seen.shift();
if(i.type==='redsea'){cmNews('redsea',{sub:1},d);continue;}
const l=S.links.find(x=>x.id===i.ref||x.trench===i.ref);if(l)cmNews('cut',{c:hstr(String(i.id))%2?l.a:l.b,a:l.a,b:l.b},d);}
// Without dark fiber there is no market to move, and no random number is drawn (the rest of the day stays as it was).
const rs=[...cmRoutes().values()],cs=[...new Set(rs.flatMap(r=>[r.a,r.b]))];if(!rs.length||Math.random()>=1/10)return;
const why=pick(['dc','ai','glut','exch','merge','boom','boom','dc']),r=pick(rs),c=pick(cs);
if(why==='dc'||why==='boom')cmNews(why,{c},d);
else if(why==='exch'){const f=cs.filter(x=>CM_FIN.includes(x));if(f.length){const x=pick(f);cmNews(why,{c:x},d);}}
else cmNews(why,{k:r.k,a:r.a,b:r.b},d);}
/* Once a day: news, then on every route the broker lists what your thresholds allow (spare after the share kept back,
while demand is at least your minimum and the price at least your floor) or takes it off, then each listing may
find a buyer: the more room the route has left and the hotter it is, the sooner; the fastest fiber sells first. */
function cmList1(r,p,s,d){const c=S.cm.p[p],lk=CM_L[p];if(!c.on||S.cm.off[r.k])return;const ok=cmDem(r,p,d)>=c.min&&cmIdx(r,p,s,0,d)*100>=c.floor;
for(const l of r.ls){const n=ok?cmSpare(l,p):0;if(n>0)cmLs(l)[lk]=n;else if(l.list)l.list[lk]=0;}}
// The listings as the thresholds want them right now (after you change a setting), without selling anything.
function cmRelist(){const rs=cmRoutes(),sold=cmSold(rs);for(const r of rs.values())for(const p of CM_P)cmList1(r,p,sold.get(r.k)[p],S.day);cmTidy();}
const cmTidy=()=>{for(const l of S.links)if(l.list){const L=cmClean(l.list);if(L)l.list=L;else delete l.list;}};
function cmDay(d=S.day){const C=S.cm;cmShocks(d);const rs=cmRoutes(),sold=cmSold(rs);
for(const r of rs.values()){const s=sold.get(r.k);
for(const p of CM_P){const lk=CM_L[p];cmList1(r,p,s[p],d);
// Room rounds to the nearest unit: a road to nowhere that wants about one wave sells one.
const D=cmDem(r,p,d),room=Math.round(D-s[p]);if(room<1)continue;
const ls=r.ls.filter(l=>l.list&&l.list[lk]>0&&cmCan(l,p)>0).sort((x,y)=>linkLat(x)-linkLat(y));if(!ls.length)continue;
if(Math.random()>=Math.min(0.35,0.06+0.25*room/Math.max(1,D))*(p==='iru'?0.08:1)*(p==='spec'?1:Math.sqrt(r.lp)))continue;
const l=ls[0];let n=p==='iru'?1:Math.max(1,Math.min(l.list[lk],cmCan(l,p),room,1+Math.floor(Math.random()*(p==='spec'||p==='w100'?4:2))));
// Never below your floor: fewer units, or none.
while(n>0&&cmIdx(r,p,s[p],n-1,d)*100<C.p[p].floor)n--;if(!n)continue;
const cut=cmCut()*mkt(),L=cmList(r,p);let rate=0;for(let i=0;i<n;i++)rate+=L*cmIdx(r,p,s[p],i,d);
const up=p==='iru'?Math.round(cmUpList(r)*cmIdx(r,p,s[p],0,d)*cut):0;
cmSell(l,p,n,Math.round(rate*cut),up);s[p]+=n;l.list[lk]-=n;}}
cmGrow(d);cmTidy();}
/* What the next 30 and 90 days look like on a route, for a Cable broker: the route's own cycle and the news already
out, but not the noise or news still to come. */
const cmFc=(r,p,t)=>cmDem(r,p,S.day+t,true);
/* Growth inside contracts: once the next size is common (15% of what buyers want), a carrier on a managed wave asks
now and then to move all its waves up one size. With room on the fiber (after what you keep back) it moves at once
and pays more (a bigger wave, at a lower price per bit); without, it tells you, at most twice a year. */
function cmGrow(d){for(const b of S.biz){if(b.type!=='mwave')continue;const i=CM_W.indexOf(cmWP(b.g)),q=CM_W[i+1];if(!q||cmShare(q,d)<0.15||Math.random()>=1/300)continue;
const l=S.links.find(x=>x.id===b.link);if(!l||!fiberOk(b))continue;const g1=CM_G[q],extra=(g1-b.g)*(b.slots||1),sub=l.sub?1:0,arg={name:esc(b.name),n:b.slots||1,g0:fmtCap(b.g),g1:fmtCap(g1),a:CITY[l.a].name,b:CITY[l.b].name};
if(cmOptG(l)>=g1&&cmFreeG(l)>=extra){const p0=cmWP(b.g);b.rate=Math.round(b.rate*CM_X[q][sub]/CM_X[p0][sub]*0.85);b.g=g1;b.what=cmWhat(l,q,b.slots||1);CM_V++;
toast(tr('market.upgraded',{...arg,price:fmt$(b.rate)}),'good');}
else if(!(b.gw>d-180)){b.gw=d;toast(tr('market.wants_more',arg),'warn',[{l:tr('lease_swaps.open_your_fiber'),act:'dashLink',args:{id:l.id}}]);}}}
// How many more spectrum slots a fiber's route wants today (the fiber panel's market line).
function cmRoomSpec(l){const rs=cmRoutes(),r=rs.get(edgeKey(l));if(!r)return 0;return Math.max(0,Math.round(cmDem(r,'spec',S.day)-cmSold(rs).get(r.k).spec));}
// Routes a Cable broker could build between two of its POPs, the most wanted first.
function cmScout(n=6){const ps=Object.keys(S.pops),have=new Set(S.links.filter(l=>l.kind==='df').map(edgeKey)),out=[];
for(let i=0;i<ps.length;i++)for(let j=i+1;j<ps.length;j++){const a=ps[i],b=ps[j],k=a<b?a+'|'+b:b+'|'+a;if(have.has(k))continue;
const sub=isSub(a,b);if(sub?!seaCab(a,b):kmBetween(a,b)>1500||!dfAllowed(a,b))continue;const r=cmRoute(a,b);
out.push({r,v:CM_P.reduce((s,p)=>s+cmDem(r,p,S.day)*cmList(r,p),0)});}
return out.sort((x,y)=>y.v-x.v).slice(0,n).map(x=>x.r);}
// Saves: everything checked, old saves get the defaults.
function cmFix(s){const c=s.cm&&typeof s.cm==='object'&&!Array.isArray(s.cm)?s.cm:{},n=cmNew();
n.hold=CM_HOLD.includes(+c.hold)?+c.hold:25;
for(const p of CM_P){const x=c.p&&c.p[p]||{};n.p[p]={on:!!x.on,min:CM_MIN[p].includes(+x.min)?+x.min:CM_DEF[p].min,floor:CM_FLOOR.includes(+x.floor)?+x.floor:CM_DEF[p].floor};}
if(c.off&&typeof c.off==='object')for(const k in c.off){const [a,b]=k.split('|');if(c.off[k]&&isCity(a)&&isCity(b)&&a<b)n.off[k]=1;}
if(Array.isArray(c.sh))n.sh=c.sh.filter(x=>x&&own(CM_NEWS,x.why)&&(x.k?typeof x.k==='string'&&x.k.split('|').every(isCity):x.c?isCity(x.c):!!x.sub)).slice(-24).map(x=>{
const y={why:x.why,from:int(x.from,-1e6,1e7,0),until:int(x.until,-1e6,1e7,0),m:clamp(num(x.m,1),0.3,3)};if(x.k)y.k=x.k;else if(x.c)y.c=x.c;else y.sub=1;
if(isCity(x.a))y.a=x.a;if(isCity(x.b))y.b=x.b;if(Array.isArray(x.p)){const p=x.p.filter(q=>CM_P.includes(q));if(p.length)y.p=p;}return y;});
if(Array.isArray(c.news))n.news=c.news.filter(x=>x&&own(CM_NEWS,x.why)).slice(0,8).map(x=>({d:int(x.d,-1e6,1e7,0),why:x.why,a:isCity(x.a)?x.a:null,b:isCity(x.b)?x.b:null}));
if(Array.isArray(c.seen))n.seen=c.seen.filter(x=>typeof x==='string').slice(-40);
s.cm=n;
for(const l of s.links){if(l.kind!=='df'||!l.list)continue;const L=cmClean(l.list);if(L)l.list=L;else delete l.list;}
for(const b of s.biz)if(b.type==='mwave'){b.g=CM_W.some(p=>CM_G[p]===b.g)?b.g:100;b.slots=Math.max(1,Math.round(b.slots||1));if(b.gw!==undefined)b.gw=int(b.gw,-1e6,1e7,0);}}

View file

@ -19,7 +19,7 @@ const SALES={
const SALES_LV=2,SALES_VP=50000,SALES_VP_DAYS=30;
// The ones the engineer never lands, and the nerds the shark never calls back.
const salesBig=t=>{const T=BIZ_T[t];return !!T&&(!!T.mega||(T.lv||1)>=4);};
const SALES_NERDS=['hft','edu','isp','l2vpn','bulk','provedor','fabl2','wwave','dfpair'];
const SALES_NERDS=['hft','edu','isp','l2vpn','bulk','provedor','fabl2','wwave','mwave','dfpair'];
const SALES_SAY=[N_('sales.ceo_say_synergy'),N_('sales.ceo_say_golf'),N_('sales.ceo_say_blockchain'),N_('sales.ceo_say_napkin'),N_('sales.ceo_say_mbps'),N_('sales.ceo_say_airport')];
const slP=()=>S&&S.sales&&own(SALES,S.sales.p)?S.sales.p:null;
const slName=(long)=>{const p=slP();return p?tr(long?SALES[p].n:SALES[p].s):'';};

View file

@ -1,6 +1,6 @@
function newGame(name,home){
S={v:1,name,asn:200000+Math.floor(_rand()*15000),home,day:0,cash:START_CASH,
ltv:2,t1v:4,auV:1,calV:1,pieV:1,pie:null,ops:opsNew(),slAuto:slAutoNew(),achP:{},seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{},pairMet:{},
done:{},inc:[],fleet:{},ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},vol:0,cnLic:{state:'none'},scrubs:[],scrubMode:'always',ddosAuto:{rtbh:false,scrub:true},capDeal:null,core:{lv:0,run:0},popStd:null,won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,ppol:'open',pdesk:null,pdeskRep:null,hw:{},rules:makeRules('oncall'),charter:'global',chartSet:false,demo:{},seatOff:null,solWon:0,monkey:{next:null,on:0}};
done:{},inc:[],fleet:{},ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},vol:0,cnLic:{state:'none'},scrubs:[],scrubMode:'always',ddosAuto:{rtbh:false,scrub:true},capDeal:null,core:{lv:0,run:0},popStd:null,won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,ppol:'open',pdesk:null,pdeskRep:null,hw:{},rules:makeRules('oncall'),charter:'global',cm:cmNew(),chartSet:false,demo:{},seatOff:null,solWon:0,monkey:{next:null,on:0}};
}

View file

@ -21,7 +21,7 @@ function sanitize(s){
if(!isCity(s.home))s.home=Object.keys(s.pops)[0]||'fra';
opsSanitize(s);
const tier=v=>int(v,0,PORT.length-1,0),lag=v=>int(v,1,LAG_MAX,1),sid=v=>String(v==null?uid():v).slice(0,40);
s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);if(l.list!==undefined){const L=l.list;if(l.kind==='df'&&L&&typeof L==='object'&&!Array.isArray(L)){const w=int(L.w,0,256,0),p=int(L.p,0,2,0);if(w||p)l.list={w,p};else delete l.list;}else delete l.list;}l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.cname!=null)l.cname=String(l.cname).slice(0,60);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&(!own(CAB,l.cable)||!cablePair(l.cable,l.a,l.b)))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);if(l.day!==undefined)l.day=Math.min(s.day,Math.max(0,num(l.day,s.day)));for(const k of Object.keys(SUB_UPGRADES)){const f='sub'+k;if(l[f]!==undefined){if(l.own&&l.sub&&Number.isFinite(l[f])&&l[f]>=0)l[f]=Math.round(l[f]);else delete l[f];}}if(l.seaPath!==undefined){if(l.own&&l.sub&&Array.isArray(l.seaPath)&&l.seaPath.length>=2&&l.seaPath.length<=2048&&l.seaPath.every(p=>Array.isArray(p)&&p.length===2&&p.every(Number.isFinite)&&Math.abs(p[0])<=180&&Math.abs(p[1])<=90))l.seaPath=l.seaPath.map(p=>p.slice());else delete l.seaPath;}if(l.paid!==undefined){if(l.own&&l.sub&&Number.isFinite(l.paid)&&l.paid>=0)l.paid=Math.round(l.paid);else delete l.paid;}if(l.own&&l.sub&&!own(SEA_DESIGNS,l.seaDesign))l.seaDesign='standard';l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);return l;});
s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);if(l.list!==undefined){const L=l.kind==='df'?cmClean(l.list):null;if(L)l.list=L;else delete l.list;}l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.cname!=null)l.cname=String(l.cname).slice(0,60);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&(!own(CAB,l.cable)||!cablePair(l.cable,l.a,l.b)))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);if(l.day!==undefined)l.day=Math.min(s.day,Math.max(0,num(l.day,s.day)));for(const k of Object.keys(SUB_UPGRADES)){const f='sub'+k;if(l[f]!==undefined){if(l.own&&l.sub&&Number.isFinite(l[f])&&l[f]>=0)l[f]=Math.round(l[f]);else delete l[f];}}if(l.seaPath!==undefined){if(l.own&&l.sub&&Array.isArray(l.seaPath)&&l.seaPath.length>=2&&l.seaPath.length<=2048&&l.seaPath.every(p=>Array.isArray(p)&&p.length===2&&p.every(Number.isFinite)&&Math.abs(p[0])<=180&&Math.abs(p[1])<=90))l.seaPath=l.seaPath.map(p=>p.slice());else delete l.seaPath;}if(l.paid!==undefined){if(l.own&&l.sub&&Number.isFinite(l.paid)&&l.paid>=0)l.paid=Math.round(l.paid);else delete l.paid;}if(l.own&&l.sub&&!own(SEA_DESIGNS,l.seaDesign))l.seaDesign='standard';l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);return l;});
for(const l of s.links)repairSubUpgradeDates(l,s.day);
/* Metrics moved from each link to its city pair (#122). Older saves routed a pair at the lowest metric of its
links, with all of them carrying traffic, so the pair keeps that metric and nothing goes on standby. */
@ -111,6 +111,7 @@ function sanitize(s){
{const r=s.rules&&typeof s.rules==='object'&&!Array.isArray(s.rules)?s.rules:{};
const m={mods:r.mods};s.rules=s.scn&&typeof s.scn==='object'?makeRules('oncall',m):s.mode==='sandbox'?makeRules('sandbox',{...m,chaos:r.chaos}):makeRules(NORMAL_PRESETS.includes(r.preset)?r.preset:'oncall',m);}
specSanitize(s);
cmFix(s);
pieSanitize(s);pieIncFix(s);volFix(s);
if(s.te){if(typeof s.te!=='object')s.te=null;else{s.te.on=!!s.te.on;s.te.script=typeof s.te.script==='string'?s.te.script.slice(0,4000):'';}}
return s;}

View file

@ -80,7 +80,7 @@ const linkIds=()=>{const m=new Map();for(const l of S.links)if(!m.has(l.id))m.se
function fiberUse(){const sold=new Map(),dfp=new Map(),pairs=new Set();
for(const b of S.biz){if(b.type==='wwave')sold.set(b.link,(sold.get(b.link)||0)+(b.slots||0));else if(b.type==='dfpair')dfp.set(b.link,(dfp.get(b.link)||0)+1);else if(b.type==='pairs'||b.type==='capfib')pairs.add(b.link);}
return {sold,dfp,pairs};}
function fiberOk(b,ids){const l=ids?ids.get(b.link):S.links.find(x=>x.id===b.link);if(!l)return false;if(b.type==='dfpair'||b.type==='pairs'||b.type==='capfib')return l.ready<=S.day&&!(l.cut>S.day);return l.ready<=S.day&&!(l.cut>S.day)&&!(l.eqDown>S.day);}
function fiberOk(b,ids){const l=ids?ids.get(b.link):S.links.find(x=>x.id===b.link);if(!l)return false;if(b.type==='dfpair'||b.type==='pairs'||b.type==='capfib')return l.ready<=S.day&&!(l.cut>S.day);return l.ready<=S.day&&!(l.cut>S.day)&&!(l.eqDown>S.day)&&(b.type!=='mwave'||dfLit(l)>=mwG(l));}
function soldSlots(l,u){return u?u.sold.get(l.id)||0:S.biz.filter(b=>b.type==='wwave'&&b.link===l.id).reduce((a,b)=>a+(b.slots||0),0);}
// Spare capacity other carriers can rent on a dark fiber (#51): free channels for alien waves, and on your own build
// a spare pair in the trench. Random offers and broker listings follow the same rules and the same prices.

View file

@ -95,7 +95,7 @@ function* dayPost(d){
if(rule('money')==='infinite'&&S.cash<1e8)S.cash=1e9;
// offers
S.offers=S.offers.filter(o=>o.exp>d);
brTick();
cmDay(d);
if(S.offers.length<5&&Math.random()<(0.05+0.01*(S.lvl||1))*(ppol()==='closed'?0.6:1)*(confSpOn()?SP_OFFERS:1)*salesSpawn()){const n0=S.offers.length;spawnOffer();mktPrice(n0);salesShape(n0);}
yield DAY_REST;
// failures & events

View file

@ -0,0 +1,14 @@
// The capacity market (37-fiber-market.js): its tab, and the settings the broker sells by.
Object.assign(ACT,{
marketOpen:()=>{if(!S||pzOn())return;UI.dtab='market';$('dash').hidden=false;renderDash();},
mktHold:({v})=>{if(!CM_HOLD.includes(v))return;S.cm.hold=v;cmRelist();sfx('click');after();},
// Switching a product off takes what the broker listed of it off the market; what it already sold stays sold.
mktCfg:({p,k,v})=>{const c=CM_P.includes(p)&&S.cm.p[p];if(!c)return;
if(k==='on'){c.on=!!v;if(!c.on)for(const l of S.links)if(l.list&&l.list[CM_L[p]])l.list[CM_L[p]]=0;}
else if(k==='min'&&CM_MIN[p].includes(v))c.min=v;else if(k==='floor'&&CM_FLOOR.includes(v))c.floor=v;else return;
cmRelist();sfx('click');after();},
// A route the broker leaves alone keeps nothing listed by the thresholds.
mktRoute:({k})=>{const r=typeof k==='string'&&cmRoutes().get(k);if(!r)return;if(S.cm.off[k]){delete S.cm.off[k];}else{S.cm.off[k]=1;
for(const l of r.ls)if(l.list)for(const p of CM_P)if(S.cm.p[p].on)l.list[CM_L[p]]=0;}
cmRelist();sfx('click');after();},
});

View file

@ -117,10 +117,10 @@ function dfPanel(l){
if(bld){const tot=Math.max(1,l.ready-l.day),done=clamp((S.day-l.day)/tot,0,1);
h+=`<section><h3>${l.own?tr('common.under_construction'):tr('common.being_spliced')}</h3><div class="kv"><span>${l.own?tr('link_panels.permits_trenching_splicing'):tr('common.iru_handover')}</span><b>${tr('common.n_days_left',{n:l.ready-S.day})}</b></div><div class="bar me"><i style="width:${done*100}%"></i></div>${l.own&&l.sub?layPanel(l):l.own?`<div class="btns">${btn(tr('link_panels.hire_extra_crews_price_30_days',{price:fmt$(crewCost(l))}),'crews',{id:l.id},'sm',!crewSteps(l)||S.cash<crewCost(l))}${btn(trn('link_panels.all_crews_done_in_n_days_price',Math.max(1,crewFloor(l)-S.day),{price:fmt$(crewSteps(l)*crewCost(l))}),'crews',{id:l.id,all:1},'sm',!crewSteps(l)||S.cash<crewSteps(l)*crewCost(l))}</div>${!crewSteps(l)&&l.ready>S.day+1?`<p class="note">${tr('link_panels.crews_can_halve_a_build_at_most')}</p>`:''}`:''}<p class="note">${tr('link_panels.you_can_pre_install_optics_now')}</p></section>`;}
else if(inc&&linkDown(l))h+=`<section><h3 style="color:var(--bad)">${tr('common.dark_6bf5')}</h3><p class="lead">${esc(inc.msg)}</p>${shipNote(inc)}${inc.cost?btn(`${esc(inc.fix||tr('common.rush_repair'))} ${fmt$(inc.cost)}`,'fixInc',{id:inc.id},'red',S.cash<inc.cost):''}</section>`;
h+=`<section><h3>${tr('common.capacity')}</h3><div class="kv"><span>${tr('link_panels.n_of_max_channels_lit',{n:(l.ch||[]).length,max:chMax(l)})}${soldSlots(l)?` · ${tr('link_panels.n_sold_as_alien_waves',{n:soldSlots(l)})}`:''}</span><b>${fmtG(load)} / ${fmtG(cap)}</b></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div>
h+=`<section><h3>${tr('common.capacity')}</h3><div class="kv"><span>${tr('link_panels.n_of_max_channels_lit',{n:(l.ch||[]).length,max:chMax(l)})}${soldSlots(l)?` · ${tr('link_panels.n_sold_as_alien_waves',{n:soldSlots(l)})}`:''}${mwG(l)?` · ${tr('market.g_sold_as_managed',{g:fmtCap(mwG(l))})}`:''}</span><b>${fmtG(load)} / ${fmtG(cap)}</b></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div>
${seatPanel(l)}${l.own&&l.sub?`<div class="kv"><span>${tr('common.cable_design')}</span><b>${tr((SEA_DESIGNS[l.seaDesign]||SEA_DESIGNS.standard).n)}</b></div>`:''}
<div class="kv"><span>${tr('common.latency')}</span><b>${tr('common.ms_ms_one_way',{ms:linkLat(l).toFixed(1)})}</b></div><div class="kv"><span>${l.own?tr('link_panels.right_of_way_upkeep'):tr('common.iru_lease')}</span><b>${tr('common.price_mo',{price:fmt$(l.mo)})}</b></div><div class="kv"><span>${tr('link_panels.n_amp_huts',{n:amps})}</span><b>${tr('common.price_mo',{price:fmt$(amps*AMP_MO)})}</b></div>${!bld&&!(l.ch||[]).length?`<p class="why">${tr('link_panels.this_fiber_is_dark_add_optics')}</p>`:''}</section>`;
if(!bld){const sold=S.biz.filter(b=>b.link===l.id&&(b.type==='wwave'||b.type==='dfpair'||b.type==='pairs')),off=S.offers.find(o=>o.link===l.id),fc=freeCh(l);
if(!bld){const sold=S.biz.filter(b=>b.link===l.id&&(b.type==='wwave'||b.type==='mwave'||b.type==='dfpair'||b.type==='pairs')),off=S.offers.find(o=>o.link===l.id),fc=freeCh(l);
h+=`<section><h3>${tr('link_panels.selling_spare_capacity')}</h3><p class="lead">${tr('link_panels.other_carriers_rent_what_you_do')}</p>
<div class="kv"><span>${tr('common.free_channels')}</span><b>${fc} / ${chMax(l)}</b></div>${sold.map(b=>`<div class="row"><div class="grow"><div class="nm">${esc(b.name)}</div><div class="meta">${esc(b.what||BIZ_T[b.type].l)} · ${tr('common.price_mo',{price:fmt$(b.rate)})}</div></div></div>`).join('')}
${off?`<div class="row"><div class="grow"><div class="nm">${esc(off.name)}</div><div class="meta">${esc(off.what)} · ${tr('common.price_mo',{price:fmt$(off.rate)})} · ${tr('ui.n_d_left',{n:off.exp-S.day})}${off.broker?' · '+tr('link_panels.via_a_capacity_broker'):''}</div></div>${btn(tr('common.accept'),'accept',{id:off.id},'pink sm')}</div>`:brListHtml(l,fc)}</section>`;}
@ -188,10 +188,10 @@ function offTransitHint(id,city){const n=NET[id];if(n.type==='t1'&&n.pol==='rest
if(pniC.length)return tr('link_panels.pni_in_city_why',{city:CITY[pniC[0]].name,why:pOk.why});{const x=nearestSpot(id);return x?tr('link_panels.not_in_your_cities_yet_nearest',{city:CITY[x.c].name}):tr('link_panels.not_present_in_any_of_your');}}
function transitTop(ids,k=5){const m={};for(const id of ids)for(const [n,v] of Object.entries(R.tNet[id]||{}))m[n]=(m[n]||0)+v;return Object.entries(m).filter(([,v])=>v>0.01).sort((a,b)=>b[1]-a[1]).slice(0,k);}
// The broker: what is listed and how the route's market looks, or the buttons to list some (#203).
function brListHtml(l,fc){const L=l.list,free=brFree(l),pf=l.own&&pairFree(l)&&!(L&&L.p);
function brListHtml(l,fc){const L=l.list,free=cmRoomSpec(l),pf=l.own&&pairFree(l)&&!(L&&L.p),cut=Math.round((1-cmCut())*100),go=`<div class="btns">${btn(tr('market.open'),'marketOpen',{},'ghost sm')}</div>`;
const mk=`<div class="kv"><span>${tr('broker.market',{a:CITY[l.a].name,b:CITY[l.b].name})}</span><b>${trn('broker.n_waves',free)}</b></div>`;
if(L)return mk+`<div class="row"><div class="grow"><div class="nm">${tr('broker.listed_title')}</div><div class="meta">${[L.w?trn('broker.n_waves_left',L.w):'',L.p?trn('broker.n_pairs_left',L.p):''].filter(Boolean).join(' · ')} · ${tr('broker.how')}</div></div>${btn(tr('broker.unlist'),'unlistFiber',{id:l.id},'ghost sm')}</div>`+
(fc-L.w>=1?`<div class="btns">${btn(tr('broker.list_more',{n:Math.min(4,fc-L.w)}),'listFiber',{id:l.id,w:Math.min(4,fc-L.w)},'ghost sm')}</div>`:'');
if(fc<1&&!pf)return mk+`<p class="note">${tr('link_panels.nothing_spare_to_sell_on_this')}</p>`;
if(L)return mk+`<div class="row"><div class="grow"><div class="nm">${tr('broker.listed_title')}</div><div class="meta">${[L.w?trn('broker.n_waves_left',L.w):'',...CM_W.map(p=>L[CM_L[p]]?trn('market.n_g_left',L[CM_L[p]],{g:fmtCap(CM_G[p])}):''),L.p?trn('broker.n_pairs_left',L.p):''].filter(Boolean).join(' · ')} · ${tr('market.how',{n:cut})}</div></div>${btn(tr('broker.unlist'),'unlistFiber',{id:l.id},'ghost sm')}</div>`+
(fc-L.w>=1?`<div class="btns">${btn(tr('broker.list_more',{n:Math.min(4,fc-L.w)}),'listFiber',{id:l.id,w:Math.min(4,fc-L.w)},'ghost sm')}${btn(tr('market.open'),'marketOpen',{},'ghost sm')}</div>`:go);
if(fc<1&&!pf)return mk+`<p class="note">${tr('link_panels.nothing_spare_to_sell_on_this')}</p>`+go;
const ns=[...new Set([1,4,Math.min(16,fc),fc])].filter(n=>n>=1&&n<=fc);
return mk+`<p class="meta">${tr('broker.lead')}</p><div class="btns">${ns.map(n=>btn(n===fc&&n>1?tr('broker.list_all',{n}):trn('broker.list_n',n),'listFiber',{id:l.id,w:n},'sm')).join('')}${pf?btn(tr('broker.list_pair'),'listFiber',{id:l.id,p:1},'sm'):''}</div>`+(free<1?`<p class="why">${tr('broker.no_market')}</p>`:'');}
return mk+`<p class="meta">${tr('market.lead_fiber',{n:cut})}</p><div class="btns">${ns.map(n=>btn(n===fc&&n>1?tr('broker.list_all',{n}):trn('broker.list_n',n),'listFiber',{id:l.id,w:n},'sm')).join('')}${pf?btn(tr('broker.list_pair'),'listFiber',{id:l.id,p:1},'sm'):''}</div>`+(free<1?`<p class="why">${tr('broker.no_market')}</p>`:'')+go;}

View file

@ -6,7 +6,7 @@ const popOrder=()=>S&&S.pops?Object.keys(S.pops).filter(isCity).sort((a,b)=>CITY
const offerOrder=()=>S&&S.offers?S.offers.filter(o=>isCity(o.city)).sort((a,b)=>a.exp-b.exp):[];
// n opens the NOC dashboard, and a letter within KEY_LEAD ms of it picks a tab (n c: Connections). n never closes the
// dashboard, so n c switches tabs without it flashing shut; Escape closes it.
const DASH_KEYS={o:'overview',u:'cust',c:'conn',t:'traffic',r:'infra',l:'lease'},KEY_LEAD=1000;let keyLead=0;
const DASH_KEYS={o:'overview',u:'cust',c:'conn',t:'traffic',r:'infra',l:'lease',m:'market'},KEY_LEAD=1000;let keyLead=0;
// Arrow keys and WASD move the map while held, at a steady speed on screen. Their own frame loop runs only while one is
// down, so the game loop does no extra work; letting go, a window opening or leaving the browser window stops it.
const PAN_KEYS={ArrowUp:[0,-1],w:[0,-1],ArrowDown:[0,1],s:[0,1],ArrowLeft:[-1,0],a:[-1,0],ArrowRight:[1,0],d:[1,0]},PAN_SPEED=700;
@ -15,7 +15,7 @@ function panFrame(t){if(!panHeld.size||!$('modal').hidden||!$('dash').hidden){pa
// A slow frame (a busy day, a background tab) moves at most 50 ms worth, not a jump across the map.
const dt=panAt==null?0:Math.min(0.05,(t-panAt)/1000);panAt=t;let dx=0,dy=0;for(const k of panHeld){dx+=PAN_KEYS[k][0];dy+=PAN_KEYS[k][1];}
cam.x+=dx*PAN_SPEED*dt/cam.z;cam.y+=dy*PAN_SPEED*dt/cam.z;wrapCam();requestAnimationFrame(panFrame);}
function showKeys(){const k=s=>`<span class="kbd">${s}</span>`,TN={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),lease:tr('common.leased_lines')};
function showKeys(){const k=s=>`<span class="kbd">${s}</span>`,TN={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),lease:tr('common.leased_lines'),market:tr('market.tab')};
const tabs=Object.entries(DASH_KEYS).map(([l,t])=>`<span class="keytab">${k(l)} ${TN[t]}</span>`).join(' ');
const rows=[[[...'←↑↓→'].map(k).join(' ')+'<br>'+[...'wasd'].map(k).join(' '),tr('keys.move_around_the_map')],[k(tr('keys.space')),tr('keys.pause_or_play')],[k('0')+' – '+k('4'),tr('keys.game_speed')],[k('/'),tr('find.find_a_city')],[k('[')+' '+k(']'),tr('keys.previous_or_next_of_your')],[k('$'),tr('keys.next_open_offer_soonest_to')],[k('-')+' '+k('='),tr('keys.zoom_the_map_out_or')],[k('n'),`${tr('keys.noc_dashboard_a_letter_right')}<br>${tabs}`],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]];
openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:28px">⌨️ ${tr('keys.keyboard_shortcuts')}</h2><button class="x" data-act="helpClose" aria-label="${tr('common.close')}">×</button></div>

View file

@ -66,4 +66,4 @@ function netWhereIdx(){const B={t:{},p:{},ix:{},c:{}},add=(k,id,x)=>(B[k][id]||(
function netWhere(n,where){const ch=(where||netWhereIdx())(n.id);
if(!ch.length)return '';const MAX=6;
return `<div class="btns">${ch.slice(0,MAX).map(([l,c,k])=>btn(`${esc(l)} <small>${esc(CITY[c].name)}</small>`,'goConn',{city:c,k},'ghost sm')).join('')}${ch.length>MAX?btn(tr('dashboard.n_more',{n:ch.length-MAX}),'connFor',{net:n.id},'ghost sm'):''}</div>`;}
const DTABS=['overview','cust','conn','traffic','infra','pops','lease'];
const DTABS=['overview','cust','conn','traffic','infra','pops','lease','market'];

View file

@ -0,0 +1,38 @@
/* ---------- the capacity market tab (37-fiber-market.js) ----------
Your settings (what the broker may sell, from what demand and price, and how much it keeps back), the news, and
every route you hold dark fiber on: per product what is wanted, sold and listed, as a bar with your threshold on
it, and today's price against your floor. A Cable broker also sees where each route is heading, and routes it could
build. Markup is deterministic (the NOC window copies it). */
const CM_NAME={spec:N_('market.p_spec'),w100:N_('market.p_w100'),w400:N_('market.p_w400'),w800:N_('market.p_w800'),w1600:N_('market.p_w1600'),iru:N_('market.p_iru')};
const CM_DESC={spec:N_('market.p_spec_d'),w100:N_('market.p_w100_d'),w400:N_('market.p_w400_d'),w800:N_('market.p_w800_d'),w1600:N_('market.p_w1600_d'),iru:N_('market.p_iru_d')};
const cmN=v=>v>=10?String(Math.round(v)):v.toFixed(1).replace(/\.0$/,'');
// Why nothing is listed although the route wants it and the price is right: no optic that big, or no room left on
// the fiber after what you keep back. Growing means lighting more.
// A bar: sold (green) of what the route wants (the dark line), and your minimum (the pink tick) when the broker lists.
function cmBar(D,sold,min){const top=Math.max(D,sold,min||0,1)*1.15,w=v=>(100*Math.min(1,v/top)).toFixed(1)+'%';
return `<div class="cmbar"><i style="width:${w(sold)}"></i><b style="left:${w(D)}"></b>${min?`<u style="left:${w(min)}"></u>`:''}</div>`;}
const cmSeg=(vals,cur,act,args,f)=>`<div class="seg">${vals.map(v=>btn(f(v),act,{...args,v},v===cur?'pink sm':'ghost sm')).join('')}</div>`;
function cmHeatTag(r){const H=cmHeat(r,'spec',S.day);return H>=1.15?`<span class="tag cmhot">${tr('market.hot',{x:H.toFixed(1)})}</span>`:H<=0.85?`<span class="tag cmcool">${tr('market.cool',{x:H.toFixed(1)})}</span>`:`<span class="tag st">${tr('market.steady')}</span>`;}
function cmProdLine(r,p,s,L,fc){const C=S.cm.p[p],D=cmDem(r,p,S.day),i=cmIdx(r,p,s,0,S.day),pc=Math.round(i*100),m=mkt()*cmCut();
const price=p==='iru'?tr('market.price_pair',{up:fmt$(Math.round(cmUpList(r)*i*m)),price:fmt$(Math.round(cmList(r,p)*m)),pct:pc}):tr('market.price',{price:fmt$(Math.round(cmList(r,p)*i*m)),pct:pc});
return `<div class="cmp"><div class="meta"><b>${tr(CM_NAME[p])}</b> · ${tr('market.row',{want:cmN(D),sold:s,listed:L})} · ${price}${C.on&&pc<C.floor?` <b style="color:var(--bad)">${tr('market.below_floor')}</b>`:C.on&&!L&&D>=C.min&&p!=='iru'&&!S.cm.off[r.k]?` <b style="color:var(--warn)">${CM_G[p]&&!r.ls.some(l=>cmOptG(l)>=CM_G[p])?tr('market.needs_optic',{g:fmtCap(CM_G[p])}):tr('market.no_room')}</b>`:''}</div>
${cmBar(D,s,C.on?C.min:0)}${fc?`<div class="meta">${tr('market.forecast',{a:cmN(cmFc(r,p,30)),b:cmN(cmFc(r,p,90))})}</div>`:''}</div>`;}
function marketTab(){const C=S.cm,rs=[...cmRoutes().values()].sort((x,y)=>brMarket(y.a,y.b)-brMarket(x.a,x.b)),sold=cmSold(new Map(rs.map(r=>[r.k,r]))),bk=broker();
const mo=S.biz.reduce((a,b)=>a+(['wwave','mwave','dfpair'].includes(b.type)?bizMo(b):0),0),ago=n=>S.day-n.d<1?tr('market.today'):trn('market.days_ago',S.day-n.d);
let h=`<div class="panel2" style="margin-top:12px"><h3>${tr('market.title')}</h3><p class="note" style="margin-top:0">${tr('market.lead')}</p>
<div class="kv"><span>${tr('market.sales')}</span><b>${tr('common.price_mo',{price:fmt$(mo)})}</b></div>
<div class="kv"><span>${tr('market.fee')}</span><b>${Math.round((1-cmCut())*100)}%${bk?` · ${tr('market.fee_broker')}`:''}</b></div>
<div class="cmset"><div class="nm">${tr('market.hold')}</div><div class="meta">${tr('market.hold_d')}</div>${cmSeg(CM_HOLD,C.hold,'mktHold',{},v=>v+'%')}</div>
${CM_P.map(p=>{const c=C.p[p];return `<div class="cmset"><div class="nm">${tr(CM_NAME[p])} ${btn(c.on?tr('market.selling'):tr('market.not_selling'),'mktCfg',{p,k:'on',v:c.on?0:1},c.on?'pink sm':'ghost sm')}</div><div class="meta">${tr(CM_DESC[p])}</div>
${c.on?`<div class="meta">${tr('market.min')}</div>${cmSeg(CM_MIN[p],c.min,'mktCfg',{p,k:'min'},v=>'≥ '+v)}<div class="meta">${tr('market.floor')}</div>${cmSeg(CM_FLOOR,c.floor,'mktCfg',{p,k:'floor'},v=>v+'%')}`:''}</div>`;}).join('')}
<h3 style="margin-top:10px">${tr('market.news')}</h3>${C.news.length?C.news.slice(0,5).map(n=>`<div class="meta">${ago(n)} · ${cmNewsText(n)}</div>`).join(''):`<p class="empty">${tr('market.no_news')}</p>`}</div>`;
h+=`<div class="panel2" style="margin-top:12px"><h3>${tr('market.routes')}</h3>${rs.length?`<p class="meta" style="margin-top:0">${tr('market.legend')}${bk?'':' '+tr('market.forecast_lock')}</p>`+rs.map(r=>{const s=sold.get(r.k),off=!!C.off[r.k],L=p=>r.ls.reduce((a,l)=>a+((l.list&&l.list[CM_L[p]])||0),0);
return `<div class="row cmroute"><div class="grow"><div class="nm">${CITY[r.a].name} ⇄ ${CITY[r.b].name} <span class="tag st">${r.sub?tr('common.subsea'):tr('common.land')}</span> ${cmHeatTag(r)}</div>
<div class="meta">${tr('market.route_meta',{km:Math.round(r.km).toLocaleString(),ms:r.lat.toFixed(1),n:Math.round((r.lp-1)*100)})}</div>
${(()=>{const shown=CM_P.filter(p=>s[p]>0||L(p)>0||cmDem(r,p,S.day)>=0.3||bk&&cmFc(r,p,90)>=0.3),rest=CM_P.filter(p=>!shown.includes(p));
return shown.map(p=>cmProdLine(r,p,s[p],L(p),bk)).join('')+(rest.length?`<div class="meta">${tr('market.not_yet',{list:rest.map(p=>tr(CM_NAME[p])).join(', ')})}</div>`:'');})()}
<div class="btns">${btn(off?tr('market.route_off'):tr('market.route_on'),'mktRoute',{k:r.k},off?'ghost sm':'pink sm')}${btn(tr('lease_swaps.open_your_fiber'),'dashLink',{id:r.ls[0].id},'ghost sm')}</div></div></div>`;}).join(''):`<p class="empty">${tr('market.no_routes')}</p>`}</div>`;
if(bk){const sc=cmScout();h+=`<div class="panel2" style="margin-top:12px"><h3>${tr('market.scout')}</h3><p class="meta" style="margin-top:0">${tr('market.scout_d')}</p>${sc.length?sc.map(r=>{const v=CM_P.reduce((a,p)=>a+cmDem(r,p,S.day)*cmList(r,p),0)*mkt()*cmCut();
return `<div class="row"><div class="grow"><div class="nm">${CITY[r.a].name} ⇄ ${CITY[r.b].name} <span class="tag st">${r.sub?tr('common.subsea'):tr('common.land')}</span> ${cmHeatTag(r)}</div>
<div class="meta">${tr('market.scout_spend',{km:Math.round(r.km).toLocaleString(),v:fmt$(Math.round(v))})}</div>${CM_P.filter(p=>cmDem(r,p,S.day)>=0.3||cmFc(r,p,90)>=0.3).map(p=>`<div class="meta"><b>${tr(CM_NAME[p])}</b> · ${tr('market.forecast_now',{n:cmN(cmDem(r,p,S.day)),a:cmN(cmFc(r,p,30)),b:cmN(cmFc(r,p,90))})}</div>`).join('')}</div></div>`;}).join(''):`<p class="empty">${tr('market.scout_none')}</p>`}</div>`;}
return h;}

View file

@ -1,4 +1,4 @@
function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),pops:tr('unbuilt_pops.no_pop_yet'),lease:tr('common.leased_lines')};
function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),pops:tr('unbuilt_pops.no_pop_yet'),lease:tr('common.leased_lines'),market:tr('market.tab')};
return `<nav class="dtabs">${DTABS.map(k=>`<button class="${cur===k?'on':''}" data-act="dashTab" data-args='{"k":"${k}"}'>${L[k]}${k==='cust'&&u?`<span class="cnt red">${u}</span>`:''}</button>`).join('')}</nav>`;}
function renderDash(){checkLayer();
const H=S.hist||[],rows=H.slice(-90),last30=H.slice(-30);
@ -31,5 +31,6 @@ function renderDash(){checkLayer();
<h3 style="margin-top:10px">${tr('common.your_as')}</h3><div class="kv"><span>${tr('common.as_number')}</span><b>AS${S.asn}</b></div><div class="kv"><span>${tr('common.prefixes')}</span><b>${Math.max(1,Math.ceil(Object.keys(S.pops).length/3))} × /22 IPv4, 1 × /32 IPv6</b></div><div class="kv"><span>${tr('common.bgp_sessions')}</span><b>${R.sessions}</b></div><div class="kv"><span>${tr('common.upstreams')}</span><b>${new Set(S.transit.map(t=>t.net)).size}</b></div><div class="kv"><span>${tr('common.reach')}</span><b>${pct(R.reach)}</b></div><div class="kv"><span>${tr('common.customers')}</span><b>${tr('dashboard.n_businesses',{n:S.biz.length})}</b></div></div></div>`;
if(DT==='pops')h+=popsSection();
if(DT==='lease')h+=leaseTab();
if(DT==='market')h+=marketTab();
if(h!==UI._dh){UI._dh=h;morph($('dashCard'),h);}
}

View file

@ -6,7 +6,7 @@
const NOC_HB=3000,NOC_LOST=10000,NOC_GAP=1000;
// What a click in the window does: changes only its own view, or runs in the game. Every button the dashboard draws is in one list.
const NOC_LOCAL=['chartToggle','connCity','connF','connNet','connSort','custCity','custF','custSort','dashClose','dashSort','dashTab','listMore','popsReg','popsSort'];
const NOC_GO=['buyIx','buyNni','buyTransit','cache','connCancel','custGo','dashLink','goConn','lagIx','lagNni','lagP','lagT','leaseSwap','netFocus','opsOpen','pni','pniAllOpen','popGo'];
const NOC_GO=['buyIx','buyNni','buyTransit','cache','connCancel','custGo','dashLink','goConn','lagIx','lagNni','lagP','lagT','leaseSwap','mktCfg','mktHold','mktRoute','netFocus','opsOpen','pni','pniAllOpen','popGo'];
const NOC={win:false,id:null,ctl:null,st:null,stId:null,peer:false,until:0,dirty:false,sent:0,speed:1,hid:false,yoAt:0,gone:false};
{const id=RW_IN?null:new URLSearchParams(location.search).get('noc');if(slotOkId(id)){NOC.win=true;NOC.id=id;}}
if(!RW_IN)try{if(typeof BroadcastChannel==='function'){NOC.ctl=new BroadcastChannel('sot-noc');NOC.ctl.onmessage=e=>{const m=e.data;if(!m||typeof m!=='object'||!slotOkId(m.id))return;if(NOC.win)nocWinMsg(m);else nocGameMsg(m);};}}catch(e){}