Split the game page into partials under src/, assembled into one index.html at build
site/index.html (900 KB of HTML, CSS and JS in one file) becomes src/: a shell (src/index.html), styles/ and game/, concatenated in path order by scripts/lib/page.js. The assembled page is byte-identical to the old file, so load time and in-game performance are unchanged. - scripts/build.js replaces build.sh (same env vars, same output) - npm run dev: a zero-dependency dev server that assembles on every request - tests assemble the page in memory; npm test runs every tests/*.test.js - perf-bench takes --base-ref to build a git ref's page - scripts/legacy/split-index-html.js is the splitter, kept for older branches
This commit is contained in:
parent
295e68cc46
commit
67a40942b4
113 changed files with 5584 additions and 5195 deletions
24
src/game/70-rules/10-helpers.js
Normal file
24
src/game/70-rules/10-helpers.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* ================= HELPERS ================= */
|
||||
const fmt$=v=>{const a=Math.abs(v),s=v<0?'-':'';if(a>=1e6)return s+'$'+(a/1e6).toFixed(a>=1e7?1:2)+'M';if(a>=1e3)return s+'$'+(a/1e3).toFixed(a>=1e5?0:1)+'k';return s+'$'+Math.round(a);};
|
||||
const fmtG=g=>g>=1000?(g/1000).toFixed(g>=10000?1:2)+' Tbps':(g>=100?g.toFixed(0):g.toFixed(1))+' Gbps';
|
||||
const pct=x=>Math.round(x*100)+'%';
|
||||
// Reach never rounds up to 100%: Tier 1 needs more than 99.9%, and 99.6% must not look like a full house (#73).
|
||||
const reachPct=x=>x>0.999?'100%':x>=0.99?(Math.floor(x*1000)/10).toFixed(1)+'%':pct(x);
|
||||
const clamp=(v,a,b)=>Math.max(a,Math.min(b,v));
|
||||
const pick=a=>a[Math.floor(Math.random()*a.length)];
|
||||
const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||||
function dateStr(d){const y=1+Math.floor(d/360),m=Math.floor(d/30)%12,dd=d%30+1;return tr('Y{y} · {mon} {d}',{y,mon:MONTHS[m],d:dd});}
|
||||
function wrapDx(a,b){let dx=b-a;if(dx>W/2)dx-=W;if(dx<-W/2)dx+=W;return dx;}
|
||||
function kmBetween(a,b){const A=CITY[a],B=CITY[b];return Math.max(20,Math.round(hav(A.lon,A.lat,B.lon,B.lat)));}
|
||||
// Cities on a land bridge belong to two landmasses: Cairo reaches Asia overland across the Sinai, the way
|
||||
// Istanbul does across the Bosporus (#47). Overland between continents still costs the intercontinental price.
|
||||
const lands=C=>C.land2?[C.land,C.land2]:[C.land];
|
||||
const isSub=(a,b)=>{const A=lands(CITY[a]),B=lands(CITY[b]);return !A.some(x=>B.includes(x));};
|
||||
const popUp=c=>S.pops[c]&&!(S.pops[c].down>S.day);
|
||||
const regionsCount=()=>new Set(Object.keys(S.pops).map(c=>CITY[c].reg)).size;
|
||||
const ixCity=x=>String(x).split('~')[0];
|
||||
function ixIdsIn(c){const o=ixStatic(c);if(S&&S.myIx&&S.myIx[c]&&!o.includes(c))o.unshift(c);return o;}
|
||||
const hasIxAt=c=>ixIdsIn(c).some(x=>S.ixp[x]!==undefined);
|
||||
function ixName(c){if(XIXM[c])return XIXM[c].name;return S.myIx[c]?S.myIx[c].name:CITY[c].ix;}
|
||||
// IX.brrr Campinas already says where it is, so messages skip "in Campinas" (#134)
|
||||
const ixNamesCity=c=>String(ixName(c)||'').toLowerCase().includes(CITY[ixCity(c)].name.toLowerCase());
|
||||
30
src/game/70-rules/20-exchanges.js
Normal file
30
src/game/70-rules/20-exchanges.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* Australian exchanges follow PeeringDB (every Australian exchange's member list, Oct 2026): networks that sit on
|
||||
every IX elsewhere list the Australian cities they really peer in as auIx, and the big incumbents peer only privately. */
|
||||
/* Transit in Australia is sold only by carriers with an Australian site and at least ten Australian networks buying
|
||||
from them (RIPEstat, Oct 2026): Telstraya, Hocus Pocus, Speedyloop, SingTell, Drizzle Electric, Cogentle,
|
||||
Not That Telecom and Level Tree (whose real-world network lists no sites in PeeringDB at all, but sells in Sydney). Others can sit in
|
||||
an Australian city, like the Pacific carriers backhauling to Sydney, but reach Australian customers only from overseas. */
|
||||
const AU_SELLERS=['tsy','voc','spl','sgt','drz','cog','ntt','lvl'],sellsAt=(n,c)=>!!n.price&&n.pops.includes(c)&&(!CITY[c].au||AU_SELLERS.includes(n.id));
|
||||
const onIx=(n,c)=>CITY[c].au&&n.auIx?n.auIx.includes(c):n.ix==='ALL'||Array.isArray(n.ix)&&n.ix.includes(c);
|
||||
function ixMembers(c){if(XIXM[c])return XIXM[c].members.slice();if(S.myIx[c])return S.myIx[c].members.slice();if(!CITY[c].ix)return [];return NETS.filter(n=>onIx(n,c)).map(n=>n.id);}
|
||||
// LAG: several identical ports bundled into one logical link. Flow hashing is never perfectly even, so a bundle carries ~95% of the sum.
|
||||
const LAG_MAX=8;
|
||||
function lagCap(g,n){n=n||1;return g*n*(n>1?0.95:1);}
|
||||
function lagName(tier,n){return (n||1)>1?`${n}×${PORT[tier].n} LAG`:tr('{port} port',{port:PORT[tier].n});}
|
||||
function ixCap(c){return ixLagF(c)*(S.myIx[c]?myFab(c).g*(myIxLive(c)?1:0):liveCap(PORT[S.ixp[c]].g,ixCity(c),(S.ixSite||{})[c],(S.ixn||{})[c])*(isRemote(c)?REMOTE_CAP:1));}
|
||||
function ixSessions(c){
|
||||
const s=new Set(); if(S.ixp[c]===undefined)return s;
|
||||
for(const id of ixMembers(c)){const n=NET[id];
|
||||
if(S.peers[id+'@'+c]&&!snub(id,c)&&!(isRemote(c)&&noRemote(id))&&!mpDown(id,c))s.add(id);
|
||||
else if(S.rs[c]&&n.pol==='open')s.add(id);
|
||||
else if(S.myIx[c]&&(n.pol==='open'||n.pol==='selective'))s.add(id);}
|
||||
return s;
|
||||
}
|
||||
function t1Club(){
|
||||
const miss=[];const pops=Object.keys(S.pops).length;
|
||||
if(regionsCount()<3)miss.push(tr('POPs on 3+ continents'));
|
||||
if(pops<10)miss.push(tr('10+ POPs ({n})',{n:pops}));
|
||||
if(R.served<1500)miss.push(tr('serve 1.5 Tbps ({v})',{v:fmtG(R.served)}));
|
||||
if(R.sessions<20)miss.push(tr('20+ peering sessions ({n})',{n:R.sessions}));
|
||||
return {ok:!miss.length,missing:miss};
|
||||
}
|
||||
19
src/game/70-rules/30-pnis.js
Normal file
19
src/game/70-rules/30-pnis.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* ---------- PNIs with the big networks: slow orders and no small ports ----------
|
||||
Big content networks, Tier 1s and big eyeball networks usually deliver a PNI or an augment in about 30 days, but
|
||||
15% of orders get lost in provisioning for 6 to 12 months. The content networks and Tier 1s start at 100G. Doitsche Telekomm sells PNIs down to 1G, and takes its time too. */
|
||||
const pniBig=id=>{const n=NET[id];return n.type==='t1'||(n.type==='cdn'&&n.pol!=='open')||(n.type==='eye'&&n.share>=0.02);};
|
||||
const pniMin=id=>{const n=NET[id];return n.type==='t1'||(n.type==='cdn'&&n.pol!=='open')?1:0;};
|
||||
const pniG1=id=>id==='dtk';
|
||||
// A beer with their peering coordinator at a conference halves the wait. It is how it really works.
|
||||
const PNI_SLOW=0.15,pniLead=id=>{const n=pniBig(id)?(Math.random()<PNI_SLOW?180+Math.floor(Math.random()*186):30):14+Math.floor(Math.random()*29);return S.conf&&S.conf.until>S.day?Math.round(n/2):n;};
|
||||
const pniG=p=>p.g1?1:PORT[p.tier].g,pniPN=p=>p.g1?'1G':PORT[p.tier].n,pniOn=p=>!(p.ready>S.day);
|
||||
const pniEta=id=>pniBig(id)?tr('Delivery: about a month, sometimes 6 to 12 months'):tr('Delivery: 2 to 6 weeks');
|
||||
const PNI_G1_COST=1200,pniWhen=n=>n>=60?tr('Their team quotes {m} months',{m:Math.round(n/30)}):tr('Ready in about {n} days',{n});
|
||||
function pniWait(p,c){return `<div class="kv"><span>${(p.n||1)>1?p.n+'×':''}${pniPN(p)} PNI</span><b>${tr('on order')}</b></div><div class="meta">${tr('About {n} days to go. Nothing to do but wait, or chase it.',{n:Math.max(0,p.ready-S.day)})}</div><div class="btns">${btn(tr('Chase it'),'pniChase',{id:p.id},'ghost sm')}${btn(UI.confirm===p.id?tr('Really remove?'):tr('Cancel the order'),'cancelPni',{id:p.id},'ghost sm')}</div>`;}
|
||||
function pniDay(d){for(const p of S.pni){const nm=esc(NET[p.net].name),city=esc(CITY[p.city].name);
|
||||
if(p.ready===d)toast(tr('<b>PNI with {net} is up in {city}.</b><br>A cross-connect in {dc}. Private and fast.',{net:nm,city,dc:esc(siteName(p.city,'a'))}),'good');
|
||||
if(p.up&&p.up.ready<=d){p.tier=p.up.tier;p.n=p.up.n;if(p.up.g1)p.g1=true;else delete p.g1;delete p.up;toast(tr('<b>Augment with {net} delivered in {city}.</b><br>Now {port}.',{net:nm,city,port:((p.n||1)>1?p.n+'×':'')+pniPN(p)}),'good');}}}
|
||||
// Microsnoft has no capacity on the US east coast. Not for a PNI, not at an exchange, not for anyone.
|
||||
const US_EAST=['ash','nyc','bos','atn','mia'];
|
||||
const MSF_NOPE=[N_('No capacity in US East. You can join the waitlist; the waitlist is also out of capacity.'),N_('US East is sold out until further notice. Further notice is also sold out.'),N_('Their peering team says US East is “capacity constrained”, which is cloud for “no”.'),N_('A new region is coming online soon. It has been coming online soon since 2019.')];
|
||||
const msfNope=(id,city)=>id==='msf'&&!!city&&US_EAST.includes(ixCity(city));
|
||||
76
src/game/70-rules/40-peering-inbox.js
Normal file
76
src/game/70-rules/40-peering-inbox.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* ---------- The peering inbox ----------
|
||||
Every exchange port brings mail: peering requests from networks nobody has heard of, and sessions that drop
|
||||
because someone's PeeringDB says 50 prefixes and they now send 400 (or a full table). Answer it, or hire an AI. */
|
||||
const AI_MO=Math.round(20e6/12),INBOX_MAX=80,IBX_LEAKS=['nfx','ggl','fbk','amz','msf'];
|
||||
const TINY=['Basement Broadband','Uncle Dave’s WISP','Fibre Fiesta','Raspberry Pi Transit','Vanity ASN Ltd','Moonshot Crypto Hosting','Minecraft Collective','Bob’s Bits','Homelab Heroes','Hackerspace Uplink','Tiny Tower Networks','Pigeon Post IP','Retro BBS Revival','Overkill Home Network','Two Guys and a Rack','Big Dreams Small Prefix','Mesh-y Business','Garden Shed Datacenter','Carrier-Grade NAT Fan Club','LIR in a Box','Yet Another VPN','Grandma’s Fibre Co-op','Seedbox Society','The /24 That Could'];
|
||||
const REQ_SAY=[N_('Hi! We would like to peer with you at {ix}. Our PeeringDB record is up to date.'),N_('Dear Sir or Madam, please peer. We have three prefixes and very big plans.'),N_('We noticed you are at {ix}. So are we. Shall we?'),N_('Hello, please find attached our peering request as a Word document, scanned from a printout.'),N_('Peering request, fifth attempt. Is anyone there?'),N_('Hey, quick one: can you peer with us at {ix}? We have a very important Minecraft server.'),N_('Greetings. We are a fast-growing network. Last year we had one customer; this year we have two.'),N_('Please configure sessions with us at {ix}. We will do ours next week, or the week after.')];
|
||||
const IBX_AI=[N_('Replied to a peering request with a haiku about BGP. No answer yet.'),N_('Signed you up for a webinar on “Peering in the Age of AI”.'),N_('Opened a ticket with itself to review its own decisions. It approved them.'),N_('Wrote a thousand-word apology to a network you never peered with.'),N_('Updated your PeeringDB record. Your NOC phone number is now a pizza place.'),N_('Asked NetChill’s peering team to “please provide more Netchill”.')];
|
||||
function ibx(){if(!S.inbox||typeof S.inbox!=='object')S.inbox={items:[],down:{},tiny:{},rep:0,bot:false,log:[],seq:0};return S.inbox;}
|
||||
// Reputation nudges selective networks by up to 10% either way: worth caring about, never a wall.
|
||||
const repMul=()=>1-clamp((S.inbox&&S.inbox.rep)||0,-10,5)*0.01;
|
||||
const repName=r=>r>=1?tr('Responsive'):r>=-2?tr('Average'):r>=-6?tr('Mostly ignores email'):tr('Black hole');
|
||||
const ibxOpen=()=>S.inbox?S.inbox.items.length:0,ibxUrgent=()=>S.inbox?S.inbox.items.filter(x=>x.k==='mp').length:0;
|
||||
const mpDown=(id,c)=>{const t=S.inbox&&S.inbox.down[id+'@'+c];return !!t&&t>S.day;};
|
||||
const ibxWho=x=>x.net?NET[x.net].name:x.nm,ibxAsn=x=>x.net?NET[x.net].asn:x.asn;
|
||||
function ibxLog(m,a){const I=ibx();I.log.unshift({d:S.day,m,a:a||{}});I.log.length=Math.min(I.log.length,40);}
|
||||
function inboxDay(d){const I=ibx(),ixs=Object.keys(S.ixp);
|
||||
// new peering requests: more exchange ports, more mail
|
||||
if(ixs.length&&Math.random()<Math.min(0.9,0.15*ixs.length)){const c=pick(ixs),set=ixSessions(c);
|
||||
const real=ixMembers(c).filter(id=>{const n=NET[id];return !set.has(id)&&n.type!=='t1'&&n.type!=='cdn'&&n.pol!=='paid'&&n.share<=0.006&&!I.items.some(x=>x.net===id&&x.ix===c);});
|
||||
const it={id:++I.seq,k:'req',ix:c,day:d,stale:Math.random()<0.6,yrs:1+Math.floor(Math.random()*9),say:Math.floor(Math.random()*REQ_SAY.length)};
|
||||
if(real.length&&Math.random()<0.4)it.net=pick(real);else{it.nm=pick(TINY);it.asn=Math.random()<0.05?64512+Math.floor(Math.random()*1000):200000+Math.floor(Math.random()*200000);}
|
||||
I.items.push(it);}
|
||||
// max-prefix: someone grew past what their PeeringDB says, or leaked a full table
|
||||
const ses=Object.keys(S.peers).filter(k=>{const n=NET[k.split('@')[0]];return n&&n.type!=='cdn'&&n.type!=='t1'&&!mpDown(...k.split('@'));}).map(k=>({key:k,net:k.split('@')[0],ix:k.split('@')[1]}))
|
||||
.concat(Object.keys(I.tiny).map(a=>({key:'t'+a,nm:I.tiny[a].nm,asn:+a,ix:I.tiny[a].ix,stale:I.tiny[a].stale})));
|
||||
if(ses.length&&Math.random()<Math.min(0.15,0.004*ses.length)){const x=pick(ses);if(!I.items.some(y=>y.k==='mp'&&y.key===x.key)){
|
||||
const lim=pick([10,20,50,100,200,500,1000]),leak=Math.random()<0.3,yrs=1+Math.floor(Math.random()*9);
|
||||
I.items.push({id:++I.seq,k:'mp',key:x.key,net:x.net,nm:x.nm,asn:x.asn,ix:x.ix,day:d,lim,got:leak?940000+Math.floor(Math.random()*90000):Math.ceil(lim*(1.15+Math.random()*1.6)),leak,yrs});
|
||||
// A session that blows its limit is down for at most a few weeks: the other side eventually notices too.
|
||||
if(x.net){I.down[x.key]=d+20+Math.floor(Math.random()*20);toast(tr('<b>Max-prefix limit hit: {who} at {ix}.</b><br>The session is down until you look at it.',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))}),'bad',[{l:tr('Inbox'),act:'inbox',args:{}}]);}}}
|
||||
// unanswered mail: requests go stale and people start asking around about you
|
||||
for(const x of I.items){if(x.k==='mp')I.rep-=0.05;else if(d-x.day===14)x.bump=1;}
|
||||
// A max-prefix alert nobody answers resolves itself in the end: the other side raises it, or gives up.
|
||||
I.items=I.items.filter(x=>x.k!=='mp'||(x.net?(I.down[x.key]||0)>d:d-x.day<=30));
|
||||
const old=I.items.filter(x=>x.k==='req'&&d-x.day>30);if(old.length){I.rep-=0.25*old.length;I.items=I.items.filter(x=>!old.includes(x));
|
||||
if(old.some(x=>x.net))toast(tr('<b>{who} asked a mailing list whether anyone has a working contact at {me}.</b><br>Their peering request sat in your inbox for a month.',{who:esc(ibxWho(old.find(x=>x.net))),me:esc(S.name)}),'bad',[{l:tr('Inbox'),act:'inbox',args:{}}]);}
|
||||
while(I.items.length>INBOX_MAX){const i=I.items.findIndex(x=>x.k==='req');if(i<0)break;I.items.splice(i,1);I.rep-=0.5;}
|
||||
I.rep=clamp(I.rep,-10,5);
|
||||
if(I.bot)inboxBot();}
|
||||
// Answer one item. a: accept | decline | raise | keep. Returns false when the item is gone.
|
||||
function ibxAnswer(id,a,bot){const I=ibx(),i=I.items.findIndex(x=>x.id===id);if(i<0)return false;const x=I.items[i];I.items.splice(i,1);const who=ibxWho(x),ix=ixName(x.ix);
|
||||
if(x.k==='req'){if(a==='accept'){if(x.net){if(S.ixp[x.ix]!==undefined)S.peers[x.net+'@'+x.ix]=true;}else if(Object.keys(I.tiny).length<200)I.tiny[x.asn]={nm:x.nm,ix:x.ix,stale:!!x.stale};I.rep+=0.3;}else I.rep+=0.2;}
|
||||
else if(a==='raise'){delete I.down[x.key];if(x.leak){const n=pick(IBX_LEAKS);S.ev.leak={net:n,until:S.day+4};
|
||||
addInc({type:'leak',ref:n,until:S.day+4,msg:tr('{who} at {ix} was sending a full table, and the max-prefix limit was the only thing stopping it. With the limit raised, {net}’s prefixes point at their basement. Traffic to {net} over transit is black-holed for a few days.',{who,ix,net:NET[n].name}),cost:0});
|
||||
if(!bot)toast(tr('<b>That was a route leak.</b><br>{who} was announcing {n} prefixes: a full table. Next time, keep it down.',{who:esc(who),n:x.got.toLocaleString()}),'bad');I.rep-=1;}
|
||||
else{I.rep+=0.3;if(!bot)toast(tr('<b>Session with {who} is back up.</b><br>New limit: {n} prefixes. They promise to update PeeringDB.',{who:esc(who),n:Math.ceil(x.got*1.5).toLocaleString()}),'good');}}
|
||||
else{const back=S.day+(x.leak?3:10)+Math.floor(Math.random()*(x.leak?8:21));if(x.net)I.down[x.key]=back;I.rep+=x.leak?0.3:0.1;
|
||||
if(!bot)toast(x.leak?tr('<b>Good call: it was a route leak.</b><br>{who} found a fat-fingered route map. The session comes back on its own in a few days.',{who:esc(who)}):tr('<b>The session stays down.</b><br>{who} will update PeeringDB and ask again. Eventually.',{who:esc(who)}),x.leak?'good':'');}
|
||||
I.rep=clamp(I.rep,-10,5);return true;}
|
||||
// The AI agent clears the inbox every day. It is fast, polite and wrong about a third of the time.
|
||||
function inboxBot(){const I=ibx();let acc=0,dec=0;
|
||||
for(const x of I.items.slice()){const oops=Math.random()<0.3;
|
||||
if(x.k==='req'){const want=!x.stale||!!x.net;const a=(want!==oops)?'accept':'decline';ibxAnswer(x.id,a,true);a==='accept'?acc++:dec++;if(oops&&a==='decline'&&x.net)ibxLog(N_('Declined {who} at {ix}: “not a strategic fit”. They were.'),{who:ibxWho(x),ix:ixName(x.ix)});}
|
||||
else{const a=(x.leak!==oops)?'keep':'raise';ibxAnswer(x.id,a,true);
|
||||
if(a==='raise'&&x.leak)ibxLog(N_('Raised the max-prefix limit for {who} at {ix} to {n}. They seemed nice.'),{who:ibxWho(x),ix:ixName(x.ix),n:Math.ceil(x.got*1.5).toLocaleString()});
|
||||
else if(a==='keep'&&!x.leak)ibxLog(N_('Kept {who} down at {ix} for “suspicious growth”. They had grown by one customer.'),{who:ibxWho(x),ix:ixName(x.ix)});
|
||||
else ibxLog(a==='raise'?N_('Raised the max-prefix limit for {who} at {ix}. Correctly, this time.'):N_('Kept {who} down at {ix}: it was a route leak. Nailed it.'),{who:ibxWho(x),ix:ixName(x.ix)});}}
|
||||
if(acc||dec)ibxLog(N_('Answered your mail: {a} accepted, {d} declined.'),{a:acc,d:dec});
|
||||
if(Math.random()<0.01){const ks=Object.keys(S.peers);if(ks.length){const k=pick(ks),[id,c]=k.split('@');delete S.peers[k];ibxLog(N_('Tidied up a session it decided was unused: de-peered {who} at {ix}.'),{who:NET[id].name,ix:ixName(c)});}}
|
||||
if(Math.random()<0.08)ibxLog(pick(IBX_AI),{});}
|
||||
function inboxModal(){const I=ibx(),items=I.items.slice().sort((a,b)=>(b.k==='mp')-(a.k==='mp')||b.day-a.day),reqs=items.filter(x=>x.k==='req').length;
|
||||
const age=x=>{const n=S.day-x.day;return n?trn('{n} day ago','{n} days ago',n):tr('today');};
|
||||
const pdb=x=>x.stale?trn('PeeringDB last updated {n} year ago','PeeringDB last updated {n} years ago',x.yrs):tr('PeeringDB updated last month');
|
||||
const card=x=>x.k==='mp'?`<div class="ibx mp"><div class="nm">⚠️ ${tr('Max-prefix limit hit: {who} at {ix}',{who:esc(ibxWho(x)),ix:esc(ixName(x.ix))})}</div>
|
||||
<div class="meta">AS${ibxAsn(x)} · ${age(x)}</div><p class="note">${tr('Configured: {lim} prefixes. Received: {got}.',{lim:x.lim.toLocaleString(),got:x.got.toLocaleString()})} ${trn('Their PeeringDB says {lim}, last updated {n} year ago.','Their PeeringDB says {lim}, last updated {n} years ago.',x.yrs,{lim:x.lim.toLocaleString()})}</p>
|
||||
<div class="btns">${btn(tr('Raise the limit'),'inboxAct',{id:x.id,a:'raise'},'sm')}${btn(tr('Keep it down'),'inboxAct',{id:x.id,a:'keep'},'ghost sm')}</div></div>`
|
||||
:`<div class="ibx"><div class="nm">${esc(ibxWho(x))} <span class="meta">AS${ibxAsn(x)}</span>${x.bump?` <span class="tag">${tr('bumped')}</span>`:''}</div><div class="meta">${esc(ixName(x.ix))} · ${age(x)} · ${pdb(x)}</div>
|
||||
<p class="note">“${esc(tr(REQ_SAY[x.say]||REQ_SAY[0],{ix:ixName(x.ix)}))}”</p><div class="btns">${btn(tr('Accept'),'inboxAct',{id:x.id,a:'accept'},'sm')}${btn(tr('Decline'),'inboxAct',{id:x.id,a:'decline'},'ghost sm')}</div></div>`;
|
||||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('Peering inbox')}</div><h2 style="font-size:26px">📬 ${trn('{n} unanswered','{n} unanswered',items.length)}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div>
|
||||
<p class="tagline">${tr('Every exchange port brings mail. Answer peering requests, and look at sessions that hit their max-prefix limit: is it growth, or a route leak? Unanswered mail gets you a reputation, and selective networks hear about it.')}</p>
|
||||
<div class="kv"><span>${tr('Your reputation')}</span><b>${repName(I.rep)}</b></div>
|
||||
<div class="ibx ai">${I.bot?`<div class="nm">🤖 ${tr('Large Peering Model is answering your mail')}</div><div class="meta">${tr('{price}/year. It never sleeps, never complains and is often wrong.',{price:fmt$(20e6)})}</div>
|
||||
${I.log.length?`<pre class="term">${I.log.slice(0,8).map(e=>esc(tr('Day {d}',{d:e.d})+': '+tr(e.m,e.a))).join('\n')}</pre>`:''}<div class="btns">${btn(tr('Fire the AI'),'inboxBot',{on:0},'ghost sm')}</div>`
|
||||
:`<div class="nm">🤖 ${tr('Large Peering Model')}</div><div class="meta">${tr('An AI agent that answers every peering request and max-prefix alert for you, every day. {price}/year. Trained on twenty years of peering mailing lists.',{price:fmt$(20e6)})}</div><div class="btns">${btn(tr('Hire it <small>{mo}/mo</small>',{mo:fmt$(AI_MO)}),'inboxBot',{on:1},'aibtn sm',S.cash<AI_MO)}</div>`}</div>
|
||||
${reqs>1?`<div class="btns">${btn(tr('Accept all requests'),'inboxAll',{a:'accept'},'sm')}${btn(tr('Decline all requests'),'inboxAll',{a:'decline'},'ghost sm')}</div>`:''}
|
||||
${items.length?items.slice(0,40).map(card).join(''):`<p class="empty">${Object.keys(S.ixp).length?tr('Inbox zero. Enjoy it while it lasts.'):tr('No mail yet. Buy an IX port and it will come.')}</p>`}`);}
|
||||
32
src/game/70-rules/50-peering-policy.js
Normal file
32
src/game/70-rules/50-peering-policy.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* Big networks sometimes refuse to peer in a particular city, for a while. Each (network, city)
|
||||
pair gets a stable verdict per window, derived from a hash, so asking again does not reroll it. */
|
||||
const SNUB_WIN=150,SNUB_P=0.22;
|
||||
const SNUB_IX=[tr('Only peers over PNIs in this metro. Order a cross-connect instead.'),tr('Their IX port here is full until the next upgrade. They promise it is soon.'),tr('Moved everything in this city to PNIs. Please read their PearingDB page, all 40 pages of it.'),tr('The peering coordinator for this city is on a six-month sabbatical.'),tr('Their policy here says "IX peering by invitation only". You were not invited.')];
|
||||
const SNUB_ALL=[tr('Not accepting new peers in this region right now.'),tr('Region frozen while they renegotiate with the local incumbent.'),tr('Their routers in this city are "at capacity". They are not.'),tr('Already reach you through your transit provider here and think that is fine.'),tr('Their lawyers are reviewing every peering agreement in this country. Again.'),tr('A new VP wants to "monetise interconnection" in this market.')];
|
||||
function hstr(t){let h=2166136261;for(let i=0;i<t.length;i++){h^=t.charCodeAt(i);h=Math.imul(h,16777619);}return h>>>0;}
|
||||
function bigPeer(n){return !!n&&n.pol==='selective'&&n.share>=0.03;}
|
||||
function snub(id,c){
|
||||
const n=NET[id];if(!c||!bigPeer(n)||!S||S.myIx[c])return null;
|
||||
const off=hstr(id+c)%SNUB_WIN,ep=Math.floor((S.day+off)/SNUB_WIN),h=hstr(S.asn+'|'+id+'|'+c+'|'+ep);
|
||||
if(h%1000>=SNUB_P*1000)return null;
|
||||
const all=(h>>>10)%5<2,list=all?SNUB_ALL:SNUB_IX;
|
||||
return {all,why:list[(h>>>13)%list.length],until:(ep+1)*SNUB_WIN-off};
|
||||
}
|
||||
/* Remote peering: offered, but discouraged. A reseller marks up the port, oversubscribes it,
|
||||
and many selective networks refuse members who are not physically in the building. */
|
||||
const REMOTE_FEE=1.5,REMOTE_CAP=0.8;
|
||||
const REMOTE_WARN=`<p class="note" style="color:var(--bad)">${tr('<b>Remote peering is a last resort.</b> Ports come through a reseller at 1.5× the price, only 80% of the port is really yours, latency rides the fabric, one fabric outage drops every session, and many selective networks refuse remote members. A POP here is better.')}</p>`;
|
||||
const REMOTE_WHY=[tr('Policy: no remote peers. Be in the building or be in the transit bill.'),tr('Saw your session come in over a fabric and said "we can smell the VXC from here".'),tr('Only peers with members they can reach without a 1,500 km hairpin.'),tr('Their PearingDB entry says "Remote peering: No (we mean it)".'),tr('Tried a remote peer once. It flapped during a product launch. Never again.')];
|
||||
function isRemote(c){return S.ixp[c]!==undefined&&!S.pops[ixCity(c)]&&!S.myIx[c];}
|
||||
function noRemote(id){const n=NET[id];if(!n||n.pol!=='selective')return false;return hstr(id+'|remote')%100<(n.share>=0.03?60:30);}
|
||||
/* Europe's peering market is crowded and competitive: ports are cheaper, and incumbents cut prices
|
||||
when a challenger in the same metro gets too popular. DE-KICKS harmonises instead. */
|
||||
const IX_REG={EU:0.8};
|
||||
function ixMul(x){const X=XIXM[x],c=ixCity(x);return (X?X.cheap:(CITY[c].ixCheap||1))*(IX_REG[CITY[c].reg]||1)*(CITY[c].au?AU_IX:1)*((S&&S.ixCut&&S.ixCut[x])||1);}
|
||||
function ixPortMo(c,tier){const X=XIXM[c];if(X&&tier<=(X.freeTo??-1))return 0;return Math.round(PORT[tier].ix*(S.pops[ixCity(c)]?1:REMOTE_FEE)*dkMult(c)*ixMul(c));}
|
||||
function ixPriceWar(d){if(!S.ixp||Math.random()>=1/120)return;
|
||||
const mine=Object.keys(S.ixp).filter(x=>{const c=ixCity(x);return CITY[c].reg==='EU'&&ixStatic(c).length>1;});if(!mine.length)return;
|
||||
const x=pick(mine),c=ixCity(x),rival=pick(ixStatic(c).filter(y=>y!==x));
|
||||
if(isDk(x)){toast(tr('<b>{rival} is poaching DE-KICKS members in {city}.</b><br>DE-KICKS responded with a webinar about "the value of premium interconnection". Prices unchanged.',{rival:esc(ixName(rival)),city:esc(CITY[c].name)}),'bad');return;}
|
||||
S.ixCut=S.ixCut||{};const cur=S.ixCut[x]||1;if(cur<=0.62)return;S.ixCut[x]=+Math.max(0.6,cur*0.9).toFixed(3);
|
||||
toast(tr('<b>Price war in {city}!</b><br>{ix} cut its port prices 10% to stop members drifting to {rival}. Your invoice just got smaller.',{city:esc(CITY[c].name),ix:esc(ixName(x)),rival:esc(ixName(rival))}),'good');}
|
||||
30
src/game/70-rules/60-de-kicks.js
Normal file
30
src/game/70-rules/60-de-kicks.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* DE-KICKS Group: runs several big exchanges and really, really hates open pricing.
|
||||
No price list, personalised quotes, haggling, yearly "harmonisation", auto-enrolled add-ons
|
||||
you have to opt out of, and a retention offer when you try to leave. */
|
||||
const DK_CITIES=['fra','mad','mrs','dxb','bom','nyc'];
|
||||
const isDk=c=>(DK_CITIES.includes(c)||scnRule('dkAll'))&&!!CITY[c]&&!!CITY[c].ix&&!S.myIx[c];
|
||||
const DK_ADDONS=[['Blackholing Plus™',tr('Like blackholing, but with a Plus.')],['Route Server Gold',tr('The same route server, in a gold-coloured portal.')],['Premium Port LEDs',tr('Your port light now blinks in brand colours.')],['Strategic Peering Insights',tr('A monthly PDF of your own traffic graphs.')],['GlobePeer Ready™',tr('Makes your port "ready" for a product you did not buy.')],['Cloud Exchange Readiness Fee',tr('A fee for being ready for the cloud.')],['Account Manager Lunch Fund',tr('Your account manager is hungry.')]];
|
||||
const DK_STALL=[tr('Your account manager would love to "align on value" first. Strategic call booked for next week.'),tr('Pricing is reviewed by the Global Commercial Council, who meet on the next full moon.'),tr('They sent a 14-page NDA before they can even repeat the price. Lawyers estimate a week.'),tr('Your account manager is at a conference in Dubai. And then one in Madrid.')];
|
||||
function dkMult(c){if(!S||!isDk(c)||!S.dk||!S.dk.m[c])return 1;const ret=S.dk.ret[c];return S.dk.m[c]*(ret&&ret>S.day?0.6:1);}
|
||||
function dkAddonMo(c){return S.dk&&S.dk.add[c]?S.dk.add[c].reduce((a,x)=>a+x.mo,0):0;}
|
||||
function dkState(){S.dk=S.dk||{m:{},add:{},ret:{},retUsed:{},stall:0,q:null};return S.dk;}
|
||||
function dkQuoteMult(){const pops=Object.keys(S.pops).length,big=Math.min(1.2,pops*0.04+(R.served||0)/20000);return +(0.95+Math.random()*0.45+big).toFixed(2);}
|
||||
function dkQuoteModal(){const q=S.dk.q,c=q.city,mo=Math.round(PORT[q.tier].ix*(S.pops[c]?1:REMOTE_FEE)*q.m*ixMul(c));
|
||||
openModal(`<div class="eyebrow">${tr('DE-KICKS Group · Sales')}</div><h2 style="font-size:26px">${tr('Your personalised {port} quote for {ix}',{port:PORT[q.tier].n,ix:esc(ixName(c))})}</h2>
|
||||
<p class="tagline">${tr("“Thanks for your interest! We don't publish prices, because every customer is unique.”")}</p>
|
||||
<div class="kv"><span>${tr('Monthly price, just for you')}</span><b>${tr('{price}/mo',{price:fmt$(mo)})}</b></div>
|
||||
<div class="kv"><span>${tr('List price')}</span><b>${tr('Confidential')}</b></div>
|
||||
<div class="kv"><span>${tr('What others pay')}</span><b>${tr('Covered by NDA')}</b></div>
|
||||
<p class="note">${tr('Quotes go up with how big you look.')} ${q.h>=3?tr('Your account manager has stopped replying to haggling.'):tr('Haggles left: {n}.',{n:3-q.h})}</p>
|
||||
<div class="btns">${btn(tr('Sign <small>{price}/mo</small>',{price:fmt$(mo)}),'dkAccept',{},'pink',S.cash<mo)}${btn(tr('Haggle'),'dkHaggle',{},'',q.h>=3)}${btn(tr('Walk away'),'dkWalk',{},'ghost')}</div>`);}
|
||||
function dkTick(d){if(!S.dk)return;const dk=S.dk;
|
||||
for(const c in S.ixp){if(!isDk(c))continue;
|
||||
if(dk.ret[c]&&dk.ret[c]===d){dk.m[c]=+(dk.m[c]*1.1).toFixed(3);toast(tr('<b>Your {ix} promo ended.</b><br>Price is back, plus 10% for "loyalty programme administration".',{ix:esc(ixName(c))}),'bad');}
|
||||
if(dk.m[c]&&(d+hstr(c)%90)%365===0){const f=1.08+Math.random()*0.07;dk.m[c]=+(dk.m[c]*f).toFixed(3);toast(tr('<b>DE-KICKS has harmonised its prices.</b><br>Harmonised means up: {ix} now costs {p}% more. Thank you for your continued partnership.',{ix:esc(ixName(c)),p:Math.round((f-1)*100)}),'bad');}
|
||||
const add=dk.add[c]=dk.add[c]||[];
|
||||
if(add.length<3&&Math.random()<1/150){const a=DK_ADDONS.filter(x=>!add.some(y=>y.n===x[0]));if(a.length){const [n,blurb]=pick(a),mo=Math.round((300+Math.random()*1200)/50)*50;add.push({n,blurb,mo,day:d});
|
||||
toast(tr("<b>Good news! You've been enrolled in {addon}.</b><br>{blurb} {price}/mo, added to your {ix} invoice. Opt out any time in the IX panel.",{addon:esc(n),blurb:esc(blurb),price:fmt$(mo),ix:esc(ixName(c))}),'bad');}}}
|
||||
}
|
||||
|
||||
function elephant(){S.phpDone=true;S.ev.php=S.day+4;
|
||||
toast(tr(`<b>🐘 BREAKING: CVE-2026-31337 just took down half the internet.</b><br>A bug in PHP turned every WordPress-ish site on Earth into a crypto miner. Eyeball traffic is down 30% for a few days while the world patches. Your hosting customers are doing it at 3 a.m.`),'bad');sfx('alert');renderMega();}
|
||||
23
src/game/70-rules/70-sold-out.js
Normal file
23
src/game/70-rules/70-sold-out.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* Sold out: now and then a carrier has no spare capacity of a size on a route. Each route, size and 90-day window
|
||||
gets a stable verdict from a hash, so asking again does not reroll it, and bigger waves sell out more often. */
|
||||
const SOLD_WIN=90,SOLD_WHY=[N_('A hyperscaler bought every wave of that size on this route last week.'),N_('The carrier is out of spectrum here until its next line-system upgrade.'),N_('The transponders for this route are on a container ship. The ship is somewhere near Singapore.'),N_('The capacity is “available in the system”. Nobody can find it in the system.'),N_('Their capacity planner is on holiday, and he took the spreadsheet with him.'),N_('The upgrade is planned for Q3. Which year, the email does not say.')];
|
||||
const soldP=tier=>Math.min(0.1,0.02+0.012*tier);
|
||||
// Never in the first 90 days: a new network has enough on its plate. Never in the tutorial or a scenario's first quarter either.
|
||||
function soldOut(a,b,tier,via){if(!S||S.day<SOLD_WIN||S.tut)return null;const k=(a<b?a+b:b+a)+'|'+(via||'')+'|'+tier,off=hstr(k)%SOLD_WIN,ep=Math.floor((S.day+off)/SOLD_WIN),h=hstr(S.asn+'|'+k+'|'+ep);
|
||||
if(h%1000>=soldP(tier)*1000)return null;return {why:SOLD_WHY[(h>>>10)%SOLD_WHY.length],until:(ep+1)*SOLD_WIN-off};}
|
||||
function snubWhy(sn){const d=Math.max(1,sn.until-S.day);return sn.why+' '+trn('They will reconsider in {n} day.','They will reconsider in {n} days.',d);}
|
||||
// Paid-peering giants drop the fee for networks too big to ignore (freeLv: the customer level that does it).
|
||||
const paidFree=n=>!!(n&&n.freeLv&&lvl()>=n.freeLv);
|
||||
function peerOk(id,via,city){
|
||||
const n=NET[id],dem=R.demTo[id]||0;
|
||||
const sn=snub(id,city);if(sn&&(via==='ix'||sn.all))return {ok:false,snub:true,why:snubWhy(sn)};
|
||||
if(msfNope(id,city))return {ok:false,why:tr(MSF_NOPE[hstr(ixCity(city)+S.day)%MSF_NOPE.length])};
|
||||
if(via==='ix'&&city&&isRemote(city)&&noRemote(id))return {ok:false,remote:true,why:REMOTE_WHY[hstr(id)%REMOTE_WHY.length]};
|
||||
if(n.pol==='open')return {ok:true};
|
||||
if(n.pol==='selective'){const need=Math.round((via==='pni'?n.minPni:n.minIx)*confBoost(id)*repMul());return dem>=need?{ok:true}:{ok:false,why:tr('Wants ≥ {need} Gbps of traffic from you (you send {dem})',{need,dem:dem.toFixed(1)})};}
|
||||
if(n.pol==='paid'&&paidFree(n))return via==='pni'?{ok:true,free:true}:{ok:false,why:tr('Peers with you for free now, but only over a PNI')};
|
||||
if(n.pol==='paid')return via==='pni'?{ok:true,fee:n.paidFee}:{ok:false,why:n.perG?tr('Sender pays: a paid PNI only, {fee}/mo plus {g} per Gbps you send',{fee:fmt$(n.paidFee),g:fmt$(n.perG)}):tr('Paid peering only, over a PNI')};
|
||||
if(n.type!=='t1'){if(via!=='pni')return {ok:false,why:tr('Only peers over PNIs, and only with networks it considers important')};const need=Math.round(60*confBoost(id));return dem>=need||isTier2()?{ok:true}:{ok:false,why:tr('Wants you to be a Tier 2, or send ≥ {need} Gbps to it (you send {dem})',{need,dem:dem.toFixed(1)})};}
|
||||
if(via!=='pni')return {ok:false,why:tr('Tier 1s never peer at IXs')};
|
||||
const c=t1Club();return c.ok?{ok:true}:{ok:false,why:tr('Not big enough yet: {list}',{list:c.missing.join(', ')})};
|
||||
}
|
||||
19
src/game/70-rules/80-hot-ports-and-rank.js
Normal file
19
src/game/70-rules/80-hot-ports-and-rank.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Everything that can fill up at a POP: transit ports, IX ports, PNIs, caches and the routers themselves.
|
||||
const HOT=0.9,HOTL={t:'T',ix:'IX',p:'P',c:'C',r:'R'},HOTC={t:'#7B61FF',ix:'#FFD23F',p:'#2C7A7B',c:'#C8102E',r:'#FF4F9A'};
|
||||
function hotPorts(){const out=[];if(!R||!S)return out;
|
||||
for(const t of S.transit){if(t.down>S.day)continue;const cap=lagCap(PORT[t.tier].g,t.n),u=(R.useT[t.id]||0)/cap;if(u>=HOT)out.push({k:'t',city:t.city,lab:tr('{net} transit · {lag}',{net:NET[t.net].name,lag:lagName(t.tier,t.n)}),u,tip:tr('Add a LAG member, upgrade the port or buy a second upstream.')});}
|
||||
for(const c in S.ixp){const cap=ixCap(c);if(!cap)continue;const u=(R.useIx[c]||0)/cap;if(u>=HOT)out.push({k:'ix',city:ixCity(c),lab:tr('{port} port',{port:ixName(c)}),u,tip:tr('Upgrade the IX port or add a LAG member.')});}
|
||||
for(const p of S.pni){if(!pniOn(p))continue;const cap=lagCap(pniG(p),p.n),u=(R.usePni[p.id]||0)/cap;if(u>=HOT)out.push({k:'p',city:p.city,lab:tr('PNI with {net}',{net:NET[p.net].name}),u,tip:tr('Add a LAG member or upgrade the PNI.')});}
|
||||
const cc={};for(const x of S.caches){const k=x.city+'|'+x.net;(cc[k]=cc[k]||{city:x.city,net:x.net,used:0,cap:0});cc[k].used+=R.useCache[x.id]||0;cc[k].cap+=CACHE_CAP;}
|
||||
for(const k in cc){const x=cc[k],u=x.used/x.cap;if(u>=HOT)out.push({k:'c',city:x.city,lab:x.cap>CACHE_CAP?tr('{name} caches',{name:NET[x.net].cache.name}):tr('{name} cache',{name:NET[x.net].cache.name}),u,tip:tr('Ask for another box. The overflow goes out over peering or transit.')});}
|
||||
for(const c in S.pops){const cap=R.nodeCap[c];if(!cap)continue;const u=(R.nodeLoad[c]||0)/cap;if(u>=HOT)out.push({k:'r',city:c,lab:tr('Routers'),u,tip:tr('Upgrade the router or add a second one in the Infra tab.')});}
|
||||
return out.sort((a,b)=>b.u-a.u);}
|
||||
function hotByCity(){const m={};for(const h of hotPorts())(m[h.city]=m[h.city]||{})[h.k]=Math.max((m[h.city]||{})[h.k]||0,h.u);return m;}
|
||||
function isTier2(){return Object.keys(S.pops).length>=5&&Object.keys(S.ixp).length>=3&&R.sessions>=15;}
|
||||
// Sparkly Seabone joined the Tier 1s in 1.12. Older saves keep the five they were playing for.
|
||||
const t1Need=()=>NETS.filter(n=>n.type==='t1'&&(n.id!=='skl'||(S&&S.t1v>=2)));
|
||||
function isTier1(){return t1Need().every(n=>S.pni.some(p=>p.net===n.id&&pniOn(p)))&&S.transit.length===0&&R.reach>0.999;}
|
||||
// What you are now, not what you once were (#46): buying transit again or losing reach drops the label.
|
||||
function tierLabel(){return S.won&&isTier1()?'Tier 1':isTier2()?'Tier 2':'Tier 3';}
|
||||
function t1Why(){if(S.transit.length)return tr('you buy transit again');const miss=t1Need().filter(n=>!S.pni.some(p=>p.net===n.id&&pniOn(p)));if(miss.length)return tr('no PNI with {list}',{list:miss.map(n=>n.name).join(', ')});{const lost=NETS.filter(n=>!R.reachable[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id]);if(lost.length)return tr('you cannot reach {list}',{list:lost.slice(0,3).map(n=>n.name).join(', ')+(lost.length>3?' '+tr('and {n} more',{n:lost.length-3}):'')});}return tr('your reach is {p}, not 100%',{p:reachPct(R.reach)});}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue