Merge v2 into architect: the chaos monkey in every puzzle, and in normal games
Starting a run or a puzzle now sends a monkey left over from an Architect review away.
This commit is contained in:
commit
dc4c0f07d5
28 changed files with 446 additions and 68 deletions
|
|
@ -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:3,auV:1,ops:opsNew(),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:[],ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',capDeal: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};
|
||||
done:{},inc:[],ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',capDeal: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}};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ const pzSig=()=>JSON.stringify([S.pops,S.links,S.pairMet||null,S.biz.map(b=>b.ro
|
|||
/* ⭐ every flow delivered in full (circuits within their latency cap), and the twists; ⭐⭐ the year's spend within
|
||||
budget; ⭐⭐⭐ N-1 under load: whichever single trench or cable is cut, every priority flow still gets all of its traffic
|
||||
(best-effort flows may drop). The cut is routed by compute() like the real thing. */
|
||||
function pzEval(){const sig=pzSig(),c0=UI.pzEv;if(c0&&c0.sig===sig)return c0.e;
|
||||
function pzEval(){const sig=pzSig(),c0=UI.pzEv;if(c0&&(c0.sig===sig||UI.pzMk))return c0.e;// mid-scene the monkey's cuts are not the build
|
||||
const P=S.pz,hot=UI.hotMap;compute();const R0=R,got=pzGot(),spend=pzSpend(),peak={},pk=()=>{for(const c in R.nodeLoad)peak[c]=Math.max(peak[c]||0,R.nodeLoad[c]);};pk();
|
||||
const flows=P.dem.map((f,i)=>({f,i,g:got[i].g,ms:got[i].ms,full:pzFull(f,got[i]),fast:pzFast(f,got[i])}));
|
||||
const tw=[];if(P.noSub)tw.push({k:'sub',ok:!S.links.some(l=>l.sub)});
|
||||
|
|
@ -118,7 +118,7 @@ const pzToastsClear=()=>{$('toasts').textContent='';};
|
|||
// The running game gets its usual save first and is kept in memory, set aside: save() keeps writing it to its slot
|
||||
// (leaving the page mid-puzzle), and leaving the puzzle picks it up again.
|
||||
function pzFlush(){save(true);UI.pzKeep=S;}
|
||||
function pzBegin(def){if(!def)return;
|
||||
function pzBegin(def){if(!def)return;pzMkStop();mkStop();
|
||||
const go=()=>{const cs=pzCities(def);newGame(pzName(def),cs[0]);S.pops={};S.mode='puzzle';S.rules=makeRules('puzzle');S.nextFail=S.nextEvent=1e9;S.tut=null;
|
||||
S.pz={id:def.id,key:def.key||null,cities:cs,src:(def.src||[]).slice(),dem:def.dem.map(f=>({t:f.t,a:f.a,b:f.t==='l2'?f.b:null,g:f.g,ms:f.ms||0,be:!!f.be})),
|
||||
via:(def.via||[]).slice(),avoid:(def.avoid||[]).slice(),budget:def.budget||0,noSub:!!def.noSub,ring:!!def.ring,wn:def.wn||null,wj:def.wj||null,theme:def.theme||null,rev:def.rev||1};
|
||||
|
|
@ -130,7 +130,7 @@ function pzBegin(def){if(!def)return;
|
|||
if(pzOn()){go();return;}
|
||||
const live=!!(S&&UI.started&&!S.lost);UI.pzFrom=live?'game':'title';
|
||||
if(live)pzFlush();go();}
|
||||
function pzLeave(){if(S&&S.ar)arStop(true);const from=UI.pzFrom;pzToastsClear();document.body.classList.remove('pz');UI.sel=null;UI.pzHist=null;UI.pzFrom=null;UI.pzEv=null;closeModal();$('panel').hidden=true;$('pzBox').hidden=true;S=null;R=emptyR();UI.started=false;
|
||||
function pzLeave(){pzMkStop();if(S&&S.ar)arStop(true);mkStop();const from=UI.pzFrom;pzToastsClear();document.body.classList.remove('pz');UI.sel=null;UI.pzHist=null;UI.pzFrom=null;UI.pzEv=null;closeModal();$('panel').hidden=true;$('pzBox').hidden=true;S=null;R=emptyR();UI.started=false;
|
||||
if(from==='game'){const sv=UI.pzKeep||loadSave();UI.pzKeep=null;
|
||||
if(sv){try{S=migrate(sv);compute();UI.started=true;UI.speed=[0,0.5,1,2,4,8].includes(S.uiSpeed)?S.uiSpeed:1;if(S.cam&&isFinite(S.cam.x))Object.assign(cam,S.cam);renderAll();return;}catch(e){console.error('[tubes] loading the network failed',e);S=null;UI.started=false;}}
|
||||
// It cannot be loaded back: marked damaged (kept, so it can be exported), and the player is told.
|
||||
|
|
@ -142,14 +142,14 @@ function pzCam(){const cs=[...S.pz.cities,...S.pz.via].map(c=>CITY[c]),x0=cs[0].
|
|||
const ph=isPhone(),side=ph&&CW>CH,pl=side?-Math.min(360,CW*0.52):ph?0:S.ar&&CW>760&&CH>500?410:330,pb=ph&&!side?Math.min(230,CH*0.4):0,aw=Math.max(120,CW-Math.abs(pl)-90),ah=Math.max(120,CH-pb-150);
|
||||
cam.z=clamp(Math.min(aw/Math.max(40,b-a),ah/Math.max(40,d-c)),0.5,4);cam.x=(a+b)/2-pl/2/cam.z;cam.y=(c+d)/2+(pb/2-30)/cam.z;wrapCam();}
|
||||
// ---------- building ----------
|
||||
function pzSnap(){if(S.ar)arStop();const h=UI.pzHist||(UI.pzHist=[]);h.push(JSON.stringify({p:S.pops,l:S.links,m:S.pairMet||{},r:S.biz.map(b=>b.route),k:S.ar?S.ar.sunk:0}));if(h.length>60)h.shift();}
|
||||
function pzSnap(){pzMkStop();if(S.ar)arStop();const h=UI.pzHist||(UI.pzHist=[]);h.push(JSON.stringify({p:S.pops,l:S.links,m:S.pairMet||{},r:S.biz.map(b=>b.route),k:S.ar?S.ar.sunk:0}));if(h.length>60)h.shift();}
|
||||
function pzAfter(){if(UI.sel&&((UI.sel.type==='link'&&!S.links.some(l=>l.id===UI.sel.id))||(UI.sel.type==='city'&&!pzKind(UI.sel.id))))UI.sel=null;
|
||||
if(S.ar)arRouters();compute();renderAll();pzCheck();}
|
||||
// Stars count the moment they are earned.
|
||||
// Every solved state is recorded, so a cheaper build at the same stars counts too.
|
||||
// A new star below three is a cheer and a nudge, and play goes on; the results card opens at three stars, or when the
|
||||
// player says they are done (the card's Finish button).
|
||||
function pzCheck(){if(arOn())return null;const e=pzEval();if(e.stars)pzRecord(e);if(e.stars<=(UI.pzTop||0))return e;const prev=UI.pzTop||0;UI.pzTop=e.stars;if(e.stars>=3)pzResults(e,prev);else{pzCheer(e,prev);renderAll();}return e;}
|
||||
function pzCheck(){if(arOn())return null;const e=pzEval();if(e.stars)pzRecord(e);if(e.stars<=(UI.pzTop||0))return e;const prev=UI.pzTop||0;UI.pzTop=e.stars;const show=()=>{if(e.stars>=3)pzResults(e,prev);else{pzCheer(e,prev);renderAll();}};if(pzMkCan())pzMonkey(show);else show();return e;}
|
||||
// The best spend belongs to the best star count: more stars start it again, the same stars keep the lower spend.
|
||||
function pzRecord(e){const p=pzLoad(),P=S.pz,bag=P.id==='weekly'?p.wk:p.s,k=P.id==='weekly'?P.key:P.id,r=(P.id==='weekly'?pzWkRec(p,P):bag[k])||{st:0,sp:null};
|
||||
if(e.stars<r.st||(e.stars===r.st&&r.sp!=null&&r.sp<=e.spend))return;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ function arRouters(){for(const c in S.pops){const p=S.pops[c];p.routers=1;p.rgen
|
|||
// The yearly router cost a tube of this size would add at a city (0 when its router already takes it).
|
||||
function arRouterDelta(c,tier){const p=S.pops[c],cur=p?pzRtCost(p.rgen||0,1):0,need=Math.max(tier,...S.links.filter(l=>l.a===c||l.b===c).map(l=>l.tier)),g=AR_RG().find(i=>RG[i].maxLT>=need);return g==null?0:Math.max(0,pzRtCost(g,1)-cur);}
|
||||
const arSnapStr=()=>JSON.stringify({p:S.pops,l:S.links,m:S.pairMet||{},k:S.ar.sunk});
|
||||
function arBegin(run){if(!run)return;const b0=run.briefs[0];
|
||||
function arBegin(run){if(!run)return;mkStop();const b0=run.briefs[0];
|
||||
pzBegin({id:'ar_'+run.id,n:run.n,src:[run.hq],dem:b0.add.map(c=>({t:'eye',a:c,g:1})),via:run.via,budget:0});
|
||||
pzToastsClear();S.pz.n=run.n;S.te={on:true,day:0};S.ar={id:run.id,hq:run.hq,bi:-1,sunk:0,over:0,dem:{},rings:[],gold:[],lat:null,passed:null,start:null};UI.arAll=false;arStop(true);
|
||||
S.pops[run.hq]=pzNewPop(run.hq);arApply(0);}
|
||||
|
|
|
|||
23
src/game/60-features/97-puzzle-monkey.js
Normal file
23
src/game/60-features/97-puzzle-monkey.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ---------- the chaos monkey in puzzles: the N-1 star, acted out ----------
|
||||
The third star already asks whether the build survives any single cut (pzEval tries every trench and cable). When a
|
||||
new star lands, and on request, the monkey plays that check on the map: it runs to each trench or cable, snips it,
|
||||
and the cities that lose traffic say so. Only while the map is really being drawn: the stars never wait on it. */
|
||||
const PZ_RUN=450,PZ_HOLD=550; // ms: the run to a tube, then how long its cut shows
|
||||
const pzMkCan=()=>animOn()&&!UI.mapHid&&performance.now()-(UI.drawnAt||-1e9)<2000;
|
||||
function pzMonkey(then){pzMkStop();const units=[...new Set(S.links.map(pzUnit))];if(!units.length){if(then)then();return;}
|
||||
const c=S.pz.src[0]||S.pz.cities[0];UI.pzMk={units,i:-1,t:0,then,bad:0};if(CITY[c])mkStart(c);sfx('alert');pzMkStep();}
|
||||
// Off to the next one: the tube it last snipped is whole again, the next one stays whole until it gets there.
|
||||
function pzMkStep(){const m=UI.pzMk;if(!m||!pzOn())return;for(const l of S.links)l.cut=0;m.i++;if(m.i>=m.units.length){pzMkDone();return;}
|
||||
const u=m.units[m.i];compute();renderAll();mkRun(S.links.find(l=>pzUnit(l)===u),PZ_RUN/MK_RUN);m.t=setTimeout(pzMkHit,PZ_RUN);}
|
||||
function pzMkHit(){const m=UI.pzMk;if(!m||!pzOn())return;const ls=S.links.filter(l=>pzUnit(l)===m.units[m.i]),l0=ls[0];for(const l of ls)l.cut=1;compute();
|
||||
const g=pzGot(),lost=[];S.pz.dem.forEach((f,i)=>{if(!f.be&&!pzFull(f,g[i]))lost.push({c:f.t==='l2'?f.b:f.a,g:Math.max(0,f.g-g[i].g)});});
|
||||
floater((CITY[l0.a].x+CITY[l0.a].x+wrapDx(CITY[l0.a].x,CITY[l0.b].x))/2,(CITY[l0.a].y+CITY[l0.b].y)/2-26,tr('puzzles.monkey_snip'),'#FF8A3D');
|
||||
for(const x of lost)floater(CITY[x.c].x,CITY[x.c].y-34,tr('puzzles.city_loses_g',{city:CITY[x.c].name,g:fmtG(x.g)}),'#FF4D5E');
|
||||
if(UI.mk)UI.mk.bad=lost.length>0;if(lost.length)m.bad++;sfx(lost.length?'err':'click');renderAll();m.t=setTimeout(pzMkStep,lost.length?PZ_HOLD*2:PZ_HOLD);}
|
||||
// The end: a cheer if nothing broke, a tantrum if something did, then whatever was waiting (the stars).
|
||||
function pzMkDone(bad){const m=UI.pzMk;if(!m)return;clearTimeout(m.t);UI.pzMk=null;for(const l of S.links)l.cut=0;compute();
|
||||
mkEnd(!(bad!=null?bad:m.bad),true);renderAll();if(m.then)m.then();}
|
||||
// Skip: straight to the end; the verdict is already known.
|
||||
function pzMkSkip(){if(UI.pzMk)pzMkDone(pzEval().n1?0:1);}
|
||||
// Gone without a word: the build changed under it, or the puzzle closed.
|
||||
function pzMkStop(){const m=UI.pzMk;if(!m)return;clearTimeout(m.t);UI.pzMk=null;for(const l of S.links)l.cut=0;mkStop();}
|
||||
|
|
@ -13,6 +13,10 @@ function sanitize(s){
|
|||
s.priceMul=num(s.priceMul,1);s.nextFail=num(s.nextFail,s.day+45);s.nextEvent=num(s.nextEvent,s.day+40);s.lvl=int(s.lvl,1,LEVELS.length,1);s.neg=int(s.neg,0,1e7,0);s.loanStrikes=int(s.loanStrikes,0,1e3,0);
|
||||
for(const k of Object.keys(s.stats)){const v=s.stats[k];if(k==='by'||k==='f'){if(!v||typeof v!=='object')s.stats[k]={};else for(const j of Object.keys(v))v[j]=num(v[j],0);}else if(typeof v!=='boolean')s.stats[k]=num(v,0);}
|
||||
for(const k of ['survived','incidents','peak'])s.stats[k]=num(s.stats[k],0);
|
||||
// The chaos monkey (2.0): saves without one get their first visit scheduled on the next day tick.
|
||||
{const m=s.monkey&&typeof s.monkey==='object'&&!Array.isArray(s.monkey)?s.monkey:{},on=m.on?1:0,o={next:m.next==null?null:int(m.next,0,1e7,s.day+90),on};
|
||||
if(on){o.start=int(m.start,0,s.day,s.day);o.until=int(m.until,o.start,o.start+400,s.day+30);o.snip=int(m.snip,0,1e7,s.day+3);o.n=int(m.n,0,1e4,0);o.hurt=int(m.hurt,0,o.n,0);o.c=isCity(m.c)?m.c:isCity(s.home)?s.home:null;}
|
||||
s.monkey=o;}
|
||||
for(const c of Object.keys(s.pops)){const p=s.pops[c];if(!isCity(c)||!p||typeof p!=='object'){delete s.pops[c];continue;}p.routers=int(p.routers,1,RMAX,1);if(p.rupDay!==undefined)p.rupDay=num(p.rupDay,-1);if(p.rgen!==undefined)p.rgen=int(p.rgen,0,RG.length-1,0);p.down=num(p.down,0);if(p.bb&&typeof p.bb==='object')p.bb.d=num(p.bb.d,0);else p.bb=null;}
|
||||
if(!isCity(s.home))s.home=Object.keys(s.pops)[0]||'fra';
|
||||
opsSanitize(s);
|
||||
|
|
|
|||
53
src/game/85-incidents/40-chaos-monkey.js
Normal file
53
src/game/85-incidents/40-chaos-monkey.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* ---------- the chaos monkey: a visitor that breaks things on purpose ----------
|
||||
Like the real one (Netflix, 2011): something switches off random bits of production so you find out whether the
|
||||
rest copes. Now and then, in On-call and BGP at 3 a.m. only, a monkey moves in for 120 to 240 days and snips a tube
|
||||
every couple of weeks, preferring tubes with no other path round them. Its snips stand in for the usual random
|
||||
failures while it is here, so the visit is a test, not a pile-on. Get through it without a customer noticing and
|
||||
there is a bonus; a banana sends it home early. S.monkey: next (day of the next visit, null until the first tick),
|
||||
on, start, until, snip (day of the next snip), n (snips), hurt (snips customers felt), c (city it last snipped by). */
|
||||
const MK_SNIPS=[N_('chaos_monkey.snip_unplugged'),N_('chaos_monkey.snip_sprayed'),N_('chaos_monkey.snip_to_see')];
|
||||
const mkSpicy=()=>rule('chaos')==='spicy';
|
||||
// Only the real game with real chaos: not Change Freeze (calm), Sandbox, puzzles or scenarios.
|
||||
function mkElig(){return !!S&&S.mode!=='sandbox'&&S.mode!=='puzzle'&&!S.scn&&!S.lost&&['normal','spicy'].includes(rule('chaos'));}
|
||||
const mkOn=()=>!!(S&&S.monkey&&S.monkey.on&&mkElig());
|
||||
const rint=(a,n)=>a+Math.floor(Math.random()*n);
|
||||
// A quarter of a month's revenue to send it home; half a month's as the bonus for outlasting it.
|
||||
const mkBananaCost=()=>Math.round(Math.min(1e6,Math.max(10000,(R.revMo||0)*0.25))/1000)*1000;
|
||||
const mkBonus=()=>Math.round(Math.min(2e6,Math.max(20000,(R.revMo||0)*0.5))/1000)*1000;
|
||||
// Is there another way between this tube's ends once its whole trench is gone? If not, it is a weak spot.
|
||||
function mkWeak(l){const trc=l.trench||l.id,adj={};
|
||||
for(const x of S.links){if(x===l||(x.trench||x.id)===trc||linkDown(x))continue;(adj[x.a]||(adj[x.a]=[])).push(x.b);(adj[x.b]||(adj[x.b]=[])).push(x.a);}
|
||||
const seen=new Set([l.a]),q=[l.a];while(q.length){const c=q.pop();if(c===l.b)return false;for(const n of adj[c]||[])if(!seen.has(n)){seen.add(n);q.push(n);}}return true;}
|
||||
function mkTick(d){const M=S.monkey;if(!M)return;
|
||||
if(!mkElig()){if(M.on)mkLeave('quiet');return;}
|
||||
// The first visit is spread by the ASN, not the dice, so a game's other luck stays exactly as it was.
|
||||
if(M.next==null)M.next=d+(mkSpicy()?180:270)+(S.asn||0)%120;
|
||||
if(!M.on){if(d<M.next)return;if(S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l)).length<3){M.next=d+30;return;}mkArrive(d);return;}
|
||||
if(d>=M.until){mkLeave();return;}
|
||||
if(d>=M.snip){mkSnip();M.snip=d+(mkSpicy()?rint(9,7):rint(14,11));}}
|
||||
function mkArrive(d){const M=S.monkey,cs=Object.keys(S.pops),len=mkSpicy()?rint(180,61):rint(120,121);
|
||||
S.stats.mkMet=(S.stats.mkMet||0)+1;
|
||||
Object.assign(M,{on:1,start:d,until:d+len,snip:d+3,n:0,hurt:0,c:cs.length?pick(cs):S.home});
|
||||
toast(tr('chaos_monkey.arrived',{n:len}),'bad',[{l:tr('chaos_monkey.banana',{cost:fmt$(mkBananaCost())}),act:'mkBanana',args:{}}],{a:'tab',v:'noc'});sfx('alert');track('monkey_arrive');
|
||||
if(typeof mkStart==='function'&&CITY[M.c])mkStart(M.c);}
|
||||
function mkSnip(){const M=S.monkey,live=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l));if(!live.length)return;
|
||||
// Weak spots first: a sample keeps this cheap on big networks.
|
||||
const smp=live.length>40?Array.from({length:40},()=>pick(live)):live,l=pick(smp.flatMap(x=>mkWeak(x)?[x,x,x,x,x]:[x]));
|
||||
const dur=rint(3,4),trc=l.trench||l.id,hit=S.links.filter(x=>(x.trench||x.id)===trc),A=CITY[l.a].name,B=CITY[l.b].name,before=R.served;
|
||||
hit.forEach(x=>x.cut=Math.max(x.cut||0,S.day+dur));M.n++;M.c=l.a;
|
||||
addInc({type:'cut',ref:trc,until:S.day+dur,msg:tr(pick(MK_SNIPS),{a:A,b:B}),cost:Math.max(4000,Math.round(hit.reduce((a,x)=>a+x.mo,0)*0.5))},'');
|
||||
compute();const i=S.inc[S.inc.length-1],imp=Math.max(0,before-R.served);if(i)i.impact=imp;
|
||||
const felt=before>1&&imp>=before*0.03;if(felt)M.hurt++;else S.stats.survived++;
|
||||
toast(felt?`<b>🐒 ${incTitle('cut')}</b><br>${esc(i?i.msg:'')}`:tr('chaos_monkey.rerouted',{a:A,b:B}),felt?'bad':'good',[],i?incOpen(i):null);sfx(felt?'err':'alert');
|
||||
if(typeof mkRun==='function'){if(!UI.mk&&CITY[M.c])mkStart(M.c);mkRun(l,1400,felt);}}
|
||||
// why: 'banana' (bribed), 'quiet' (the rules or the game changed under it), or nothing (its time was up).
|
||||
function mkLeave(why){const M=S.monkey,d=S.day,ok=!why&&M.n>0&&M.hurt===0;M.on=0;M.next=d+(mkSpicy()?rint(220,181):rint(360,361));
|
||||
// The usual failures were paused for the visit; give the NOC a breather before they start again.
|
||||
S.nextFail=Math.max(S.nextFail,d+15);
|
||||
if(why==='banana')toast(tr('chaos_monkey.bribed'),'good');
|
||||
else if(ok){const b=mkBonus();S.cash+=b;S.stats.mkSurv=(S.stats.mkSurv||0)+1;toast(tr('chaos_monkey.survived',{n:M.n,cash:fmt$(b)}),'goal');sfx('coin');track('monkey_survived');}
|
||||
else if(!why)toast(tr('chaos_monkey.went_home',{n:M.n,hurt:M.hurt}),'');
|
||||
if(typeof mkEnd==='function')mkEnd(ok,true);}
|
||||
// The NOC tab's card while it is here.
|
||||
function mkCard(){if(!mkOn())return '';const M=S.monkey,c=mkBananaCost();
|
||||
return `<div class="inc" style="background:#FFF1D6;border:1px solid #FFC56B"><div class="nm">🐒 ${tr('chaos_monkey.loose')}</div><div class="meta">${tr('chaos_monkey.card',{n:Math.max(1,M.until-S.day),s:M.n,hurt:M.hurt})}</div><div class="btns">${btn(tr('chaos_monkey.banana',{cost:fmt$(c)}),'mkBanana',{},'sm',S.cash<c)}</div></div>`;}
|
||||
|
|
@ -63,7 +63,9 @@ function dayTick(){
|
|||
// failures & events
|
||||
// Chaos (the rules) scales how often: calm waits about three times as long, spicy comes almost twice as often, none never.
|
||||
let dirty=false;const cm=chaosMul();
|
||||
if(cm&&d>=S.nextFail){dirty=true;fireFailure();const size=S.links.length+Object.keys(S.pops).length;S.nextFail=d+Math.round((Math.max(22,50-size*1.5)+Math.floor(Math.random()*25))*(scnRule('chaos')?0.5:1)/cm);}
|
||||
// A visiting chaos monkey does the breaking instead (its snips replace these while it is here).
|
||||
mkTick(d);
|
||||
if(cm&&d>=S.nextFail&&!mkOn()){dirty=true;fireFailure();const size=S.links.length+Object.keys(S.pops).length;S.nextFail=d+Math.round((Math.max(22,50-size*1.5)+Math.floor(Math.random()*25))*(scnRule('chaos')?0.5:1)/cm);}
|
||||
// Anchors Away: on top of the usual failures, ships drag anchors over each Baltic seabed link (about three cuts a link-year).
|
||||
if(cm&&d>45&&scnRule('anchors')){const n=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l)&&anchorProne(l)).length;if(n&&Math.random()<Math.min(5,+S.scn.rules.anchors||1)*n/365){dirty=true;fireFailure('cut');}}
|
||||
if(cm&&d>=S.nextEvent){dirty=true;fireEvent();S.nextEvent=d+Math.round((45+Math.floor(Math.random()*45))/cm);}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ const RARITY={c:{n:tr('common.common'),col:'#16A866'},r:{n:tr('common.rare'),col
|
|||
const st=()=>S.stats||{};
|
||||
const BADGES=[
|
||||
{id:'hello',i:'👋',t:tr('common.hello_neighbour'),d:tr('badges.bring_up_your_first_peering_session'),r:'c',ok:()=>R.sessions>=1},
|
||||
{id:'backhoe',i:'🚜',t:tr('badges.met_the_backhoe'),d:tr('badges.have_a_fiber_cut'),r:'c',ok:()=>(st().by||{}).cut>=1},
|
||||
// Keeps its old id so badges already earned (in saves and the hall of fame) carry over.
|
||||
{id:'backhoe',i:'🐒',t:tr('badges.met_the_chaos_monkey'),d:tr('badges.get_a_visit_from_the_chaos_monkey'),r:'c',ok:()=>(st().mkMet||0)>=1},
|
||||
{id:'debt',i:'🏦',t:tr('badges.in_debt_we_trust'),d:tr('badges.take_out_a_loan'),r:'c',ok:()=>(st().loans||0)>=1||(S.loans||[]).length>0},
|
||||
{id:'twins',i:'👯',t:tr('common.twins'),d:tr('badges.run_two_routers_in_one_pop'),r:'c',ok:()=>Object.values(S.pops).some(p=>(p.routers||1)>=2)},
|
||||
{id:'shark',i:'🦈',t:tr('common.shark_week'),d:tr('badges.get_a_subsea_cable_bitten_by'),r:'r',ok:()=>(st().sharks||0)>=1},
|
||||
|
|
@ -68,6 +69,7 @@ const BADGES=[
|
|||
{id:'toaster',i:'🍞',t:tr('common.toaster_wrangler'),d:tr('badges.weather_a_ddos_with_your_defences'),r:'c',ok:()=>(st().ddosHeld||0)>=1},
|
||||
{id:'cleanpipe',i:'🚿',t:tr('common.clean_pipes'),d:tr('badges.turn_on_a_transit_clean_pipe'),r:'r',ok:()=>S.transit.some(t=>t.clean)},
|
||||
{id:'lamb',i:'🐐',t:tr('common.sacrificial_lamb'),d:tr('badges.run_a_sacrificial_pni_choke_point'),r:'r',ok:()=>S.pni.some(p=>p.sacrif)},
|
||||
{id:'monkey',i:'🛡️',t:tr('badges.monkey_proof'),d:tr('badges.outlast_a_chaos_monkey_visit'),r:'e',ok:()=>(st().mkSurv||0)>=1},
|
||||
{id:'flood',i:'🌊',t:tr('badges.held_the_flood'),d:tr('badges.weather_a_multi_terabit_ddos'),r:'e',ok:()=>(st().ddosMonster||0)>=1},
|
||||
{id:'skynot',i:'🤖',t:tr('common.skynot_smiles'),d:tr('badges.land_a_hackback_3000tm_that_actually'),r:'e',secret:true,ok:()=>(st().hackWin||0)>=1},
|
||||
{id:'zero',i:'🕳️',t:tr('badges.zero_peers_given'),d:tr('badges.reach_tier_2_with_every_single'),r:'l',secret:true,ok:()=>isTier2()&&!Object.keys(S.peers).length&&!S.pni.length},
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ Object.assign(ACT,{
|
|||
decomToggle:({city})=>{if(!S.pops[city])return;UI.decom=UI.decom||new Set();if(UI.decom.has(city))UI.decom.delete(city);else UI.decom.add(city);decomModal();},
|
||||
decomGo:()=>{const sel=[...(UI.decom||[])].filter(c=>S.pops[c]);if(!sel.length||sel.length>=Object.keys(S.pops).length)return;closeModal();UI.decom=null;UI.sel=null;decommission(sel);sfx('alert');after();},
|
||||
rmLink:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}{const l=S.links.find(x=>x.id===id),back=cabBack(l);if(back>0){S.cash+=back;toast(tr('links.name_is_called_off_the_cable',{name:esc(l.cname||tr('common.your_cable')),price:fmt$(back)}),'good');}}S.links=S.links.filter(l=>l.id!==id);prunePairMet();UI.sel=null;UI.confirm=null;after();},
|
||||
// The chaos monkey takes a banana and goes home early (no bonus).
|
||||
mkBanana:()=>{if(!mkOn())return;if(!spend(mkBananaCost()))return;S.stats.bananas=(S.stats.bananas||0)+1;mkLeave('banana');track('monkey_banana');after();},
|
||||
fixInc:({id})=>{const i=S.inc.find(x=>x.id===id);if(!i||!(i.cost>0))return;if(i.slow&&i.rushed)return;if(!spend(i.cost))return;
|
||||
if(i.slow&&i.until>S.day+1){i.rushed=true;i.cost=0;i.until=S.day+1;const p=S.pops[i.ref];if(p)p.down=Math.min(p.down,S.day+1);toast(tr('links.power_cycled_the_router_in_city',{city:esc(CITY[i.ref].name),chip:esc(RG[(p&&p.rgen)||0].chip)}),'good');after();return;}clearInc(i);toast(tr('links.fixed_what_resolved_early',{what:incTitle(i.type)}),'good');after();},
|
||||
myIxUp:({city})=>{const m=S.myIx[city];if(!m)return;const f=(m.fab|0)+1,N=MYIX_FAB[f];if(!N)return;if(N.lvl>lvl()){toast(tr('links.a_fab_fabric_unlocks_at_customer',{fab:N.n,lv:N.lvl}),'bad');sfx('err');return;}if(!spend(N.cost))return;m.fab=f;toast(tr('links.ix_now_runs_a_fab_fabric',{ix:esc(m.name),fab:N.n,max:N.max}),'good');m.next=Math.min(m.next,S.day+3);after();},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
function pzWaveWhy(a,b,tier,r){if(r&&subWaveWhy(tier,r.km,r.sub))return tr('common.too_far_for_this_cable');if(!S.ar&&!waveOk(a,b,tier))return tr('puzzles.needs_what',{what:waveNeed(tier)});return '';}
|
||||
const pzPortsFree=c=>!S.pops[c]||portsUsed(c)+1<=portsMax(c)+1e-9;
|
||||
Object.assign(ACT,{
|
||||
// The chaos monkey acts out the N-1 check, or is told to get on with it.
|
||||
pzMonkey:()=>{if(pzOn()&&pzEval().goal)pzMonkey();},
|
||||
pzMkSkip:()=>{if(pzOn())pzMkSkip();},
|
||||
// The puzzle list. The ruleset's title-screen door calls this.
|
||||
puzzleMenu:()=>{if(S&&UI.started&&!pzOn())UI.nm=S.name;pzMenu();},
|
||||
pzStart:({id})=>{const d=pzDef(id);if(!d||!pzPackOpen(d.pack))return;pzBegin(d);},
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ function renderLeft(){checkLayer();
|
|||
}else if(UI.left==='noc'){
|
||||
h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('hud_and_panels.open_noc_dashboard'),'dash',{},'pink')}${btn(tr('common.connections'),'connOpen',{},'')}${btn(tr('common.traceroute'),'trace',{},'')}</div>`;
|
||||
h+=`<p class="lead">${tr('hud_and_panels.your_network_operations_center_every')}</p>`;
|
||||
h+=opsCard();
|
||||
h+=opsCard()+mkCard();
|
||||
// Incidents come first, the ones you can fix with one click at the top (#63): no scrolling past hot ports to replace an optic.
|
||||
for(const i of S.inc.filter(i=>i.type!=='ddos').sort((a,b)=>(b.cost?1:0)-(a.cost?1:0)||(b.impact||0)-(a.impact||0))){h+=`<div class="inc"><div class="nm">${incTitle(i.type)}</div><div class="meta">${esc(i.msg)}</div><div class="meta">${trn('hud_and_panels.auto_fix_in_n_day',i.until-S.day)}${i.impact?` · ${tr('hud_and_panels.g_lost',{g:fmtG(i.impact)})}`:''}</div>${i.cost?`<div class="btns">${btn(`${esc(i.fix||tr('common.rush_repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash<i.cost)}</div>`:''}</div>`;}
|
||||
h+=logSection();UI.logSeen=Date.now();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ function pzRender(){const el=$('pzBox');if(!pzOn()){el.hidden=true;return;}el.hi
|
|||
const w=e.worst;
|
||||
h+=!e.goal?`<div class="pzn1">🛡 ${tr('puzzles.n_1_deliver_everything_first')}</div>`:e.n1?`<div class="pzn1 on">🛡 ${tr('puzzles.survives_any_single_cut_under_load')}</div>`
|
||||
:`<div class="pzn1 bad">⚠️ ${tr('puzzles.a_cut_on_where_drops_g',{where:pzUnitName(w.u),g:fmtG(w.g)})}<br><small>${w.lost.map(x=>esc(pzFlowName(P.dem[x.i]))).join(', ')}</small></div>`;
|
||||
if(UI.pzMk)h+=`<div class="btns">${btn('⏩ '+tr('puzzles.skip_the_monkey'),'pzMkSkip',{},'big')}</div>`;else if(e.goal)h+=`<div class="btns">${btn(tr('puzzles.let_the_chaos_monkey_loose'),'pzMonkey',{},'sm')}</div>`;
|
||||
h+=`<div class="btns">${btn('↶ '+tr('puzzles.undo'),'pzUndo',{},'ghost sm',!(UI.pzHist&&UI.pzHist.length))}${btn(tr('puzzles.reset'),'pzReset',{},'ghost sm',!S.links.length&&!Object.keys(S.pops).length)}${(UI.pzTop||0)>0&&(UI.pzTop||0)<3?btn(tr('puzzles.finish_here'),'pzFinish',{},'sm'):''}${btn(UI.pzFrom==='game'?tr('puzzles.back_to_my_network'):tr('puzzles.back_to_the_title'),'pzLeave',{},'ghost sm')}</div>`;
|
||||
if(h!==UI._pzh){UI._pzh=h;morph(el,h);}}
|
||||
// Trenches on a pair get numbers, cables their names, so parallel links say where they run.
|
||||
|
|
@ -91,13 +92,13 @@ function pzLinkModal(a,b,keep){if(S.ar)return arLinkModal(a,b,keep);const kb=pzK
|
|||
h+=`<h4 class="sub4">${tr('common.route')}</h4><div class="seg">${rs.map(x=>btn(`${x.cab?esc(CAB[x.cab].name):tr('common.overland')} <small>${x.ms.toFixed(1)} ms${pl.some(l=>(l.cable||'land')===x.via)?' · ✓':''}</small>`,'pzVia',{v:x.via},x.via===r.via?'pink':'ghost',P.noSub&&x.sub)).join('')}</div>`;
|
||||
if(P.noSub&&r.sub)h+=`<p class="why">${tr('puzzles.the_sharks_say_no')}</p>`;
|
||||
if(r.cab)h+=`<p class="note">${esc(CAB[r.cab].blurb)}${pl.some(l=>l.cable===r.cab)?' '+tr('puzzles.same_cable_same_anchor'):''}</p>`;
|
||||
if(land)h+=`<div class="seg" style="margin-top:8px">${btn(tr('puzzles.diverse_route_40_survives_a_backhoe'),'pzDiv',{v:1},div?'pink':'ghost')}${btn(tr('puzzles.same_trench_cheaper_one_backhoe_cuts'),'pzDiv',{v:0},div?'ghost':'pink')}</div>`;
|
||||
if(land)h+=`<div class="seg" style="margin-top:8px">${btn(tr('puzzles.diverse_route_40_survives_the_monkey'),'pzDiv',{v:1},div?'pink':'ghost')}${btn(tr('puzzles.same_trench_cheaper_one_snip_cuts'),'pzDiv',{v:0},div?'ghost':'pink')}</div>`;
|
||||
if(pop)h+=`<p class="lead" style="margin-top:8px">${tr('puzzles.includes_a_new_pop_in_city',{city:esc(CITY[b].name),price:fmt$(pop)})}</p>`;
|
||||
const full=[a,b].filter(c=>!pzPortsFree(c));if(full.length)h+=`<p class="why">${tr('puzzles.no_free_ports_in_list',{list:full.map(c=>esc(CITY[c].name)).join(', ')})}</p>`;
|
||||
h+=`<div class="tiers">${PZ_TIERS.map(i=>{const why=pzWaveWhy(a,b,i,r),c=pzLinkCost(r,i,div)+pop;return `<button class="tierbtn" data-act="pzLink" data-args='{"tier":${i}}'${why||full.length||(P.noSub&&r.sub)?' disabled':''}><span class="sz">${LT[i].n}</span><span class="grow meta">${why?esc(why):pop?tr('puzzles.with_the_pop_price',{price:fmt$(c)}):''}</span><span class="pr num">${tr('puzzles.price_per_year',{price:fmt$(pzLinkCost(r,i,div))})}</span></button>`;}).join('')}</div>`;
|
||||
openModal(h);}
|
||||
// ---------- results ----------
|
||||
function pzLine(e){return e.stars>=3?tr('puzzles.a_backhoe_walks_into_your_network'):!e.n1&&!e.cheap?tr('puzzles.it_works_finance_and_the_backhoe'):!e.n1?tr('puzzles.one_backhoe_away_from_a_very'):tr('puzzles.rock_solid_and_gold_plated_the');}
|
||||
function pzLine(e){return e.stars>=3?tr('puzzles.a_chaos_monkey_walks_into_your_network'):!e.n1&&!e.cheap?tr('puzzles.it_works_finance_and_the_monkey'):!e.n1?tr('puzzles.one_monkey_away_from_a_very'):tr('puzzles.rock_solid_and_gold_plated_the');}
|
||||
// Stars still to win in this puzzle's pack, from the progress just saved.
|
||||
function pzPackLeft(P){const d=pzDef(P.id);if(!d)return null;const p=pzLoad(),xs=PZ.filter(x=>x.pack===d.pack);return xs.length*3-xs.reduce((a,x)=>a+((p.s[x.id]||{}).st|0),0);}
|
||||
function pzConfetti(){if(!animOn())return '';const cols=['#FF4F9A','#FFD23F','#22C47A','#2F8CFF','#FF8A3D','#7B61FF'];let h='';
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ function drawFrame(now){
|
|||
if(pzOn()){for(const v of vis.slice().reverse())pzDrawCity(v,sc,now);}else for(const v of vis.slice().reverse())drawCity(v.C,v.sx,v.sy,sc,now,v.ly);
|
||||
// Architect runs: what the tubes between two cities are (one trench, or separate paths), above the cities.
|
||||
for(const [x,y,t,one] of AR_PILLS){ctx.font='800 11px "Baloo 2", sans-serif';const tw=ctx.measureText(t).width+12;ctx.fillStyle=one?'#FFE3C2':'#DDF7E7';ctx.strokeStyle=one?'#FF8A3D':'#16A866';ctx.lineWidth=2;rr(x-tw/2,y-9,tw,17,8);ctx.fill();ctx.stroke();ctx.fillStyle='#1E2640';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(t,x,y+1);}
|
||||
if(UI.mk)mkDraw(ks);
|
||||
// the chaos monkey (woken here after a reload, wherever it last snipped)
|
||||
if(UI.mk)mkDraw(ks);else if(mkOn()&&!pzOn()&&CITY[S.monkey.c])mkStart(S.monkey.c);
|
||||
// floaters
|
||||
for(let i=FLOATS.length-1;i>=0;i--){const f=FLOATS[i],a=(now-f.t)/1600;if(a>1){FLOATS.splice(i,1);continue;}
|
||||
for(const k of ks){const [sx,sy]=toS(f.x,f.y,k);ctx.globalAlpha=1-a*a;ctx.font='800 17px "Baloo 2", sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.lineWidth=4;ctx.strokeStyle='#fff';ctx.strokeText(f.text,sx,sy-a*40);ctx.fillStyle=f.col;ctx.fillText(f.text,sx,sy-a*40);ctx.globalAlpha=1;}}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* ---------- the chaos monkey: Architect's review, as a monkey running round the map ----------
|
||||
It hops from cut to cut, sprays chaos where it snips, and dances on the spot that breaks a mission-critical site.
|
||||
Pure decoration on the animation clock: the review's result never depends on it, and with animations off the monkey
|
||||
just sits at the cut. */
|
||||
/* ---------- the chaos monkey, on the map ----------
|
||||
It hops from cut to cut, sprays chaos where it snips, and dances where a snip really hurt. It visits normal games
|
||||
(85-incidents/40-chaos-monkey.js) and reviews Architect runs. Pure decoration on the animation clock: nothing
|
||||
depends on it, and with animations off the monkey just sits at the cut. */
|
||||
const MK_RUN=0.62; // share of a review step the monkey spends running to the next cut
|
||||
const MK_COLS=['#FF4F9A','#FFD23F','#22C47A','#2F8CFF','#FF8A3D','#7B61FF'];
|
||||
// Where a link's middle is, in world coordinates (the shorter way round the date line).
|
||||
|
|
@ -12,11 +12,12 @@ function mkRun(l,dur,bad){const m=UI.mk;if(!m)return;const [x,y]=mkMid(l);m.fx=m
|
|||
m.face=wrapDx(m.fx,x)<0?-1:1;m.mood='run';m.sprayAt=animT+m.dur;m.bad=!!bad;if(!animOn()){m.x=x;m.y=y;}}
|
||||
function mkSpray(m){for(let i=0;i<(m.bad?26:16);i++){const a=Math.PI*2*i/(m.bad?26:16)+((i*37)%10)/10,v=0.05+((i*53)%10)/180;
|
||||
m.spray.push({x:m.tx,y:m.ty,vx:Math.cos(a)*v,vy:Math.sin(a)*v-0.06,c:m.bad?(i%3?'#FF4D5E':'#FFD23F'):MK_COLS[i%MK_COLS.length],t:animT,s:i%4===0?(m.bad?'💥':'✂️'):null});}}
|
||||
// The review is over: a cheer when everything held, a tantrum where it broke.
|
||||
function mkEnd(ok){const m=UI.mk;if(!m)return;// a pending spray (the review was skipped mid-run) would override the cheer
|
||||
m.sprayAt=null;m.mood=ok?'cheer':'dance';m.t0=animT;}
|
||||
// It is over: a cheer when everything held, a tantrum where it broke; with bye it then leaves the map.
|
||||
function mkEnd(ok,bye){const m=UI.mk;if(!m)return;// a pending spray (the review was skipped mid-run) would override the cheer
|
||||
m.sprayAt=null;m.mood=ok?'cheer':'dance';m.t0=animT;m.bye=bye?animT:0;}
|
||||
function mkStop(){UI.mk=null;}
|
||||
function mkDraw(ks){const m=UI.mk;if(!m)return;
|
||||
function mkDraw(ks){const m=UI.mk;if(!m)return;if(m.bye&&animT-m.bye>2600){mkStop();return;}
|
||||
if(m.mood==='snip'&&animT-m.t0>1500){m.mood='stand';m.t0=animT;}
|
||||
const p=Math.min(1,(animT-m.t0)/m.dur),e=p<0.5?2*p*p:1-Math.pow(-2*p+2,2)/2;
|
||||
if(m.mood==='run'){m.x=m.fx+wrapDx(m.fx,m.tx)*e;m.y=m.fy+(m.ty-m.fy)*e;}
|
||||
if(m.sprayAt!=null&&animT>=m.sprayAt){m.sprayAt=null;if(animOn())mkSpray(m);m.mood=m.bad?'dance':'snip';m.t0=animT;}
|
||||
|
|
@ -28,7 +29,7 @@ function mkDraw(ks){const m=UI.mk;if(!m)return;
|
|||
const dt=animT-q.t,wx=q.x+q.vx*dt/cam.z,wy=q.y+(q.vy*dt+0.00012*dt*dt)/cam.z;
|
||||
for(const k of ks){const [sx,sy]=toS(wx,wy,k);ctx.globalAlpha=1-a;if(q.s){ctx.font=`${Math.round(sz*0.7)}px sans-serif`;ctx.fillText(q.s,sx,sy);}else{ctx.fillStyle=q.c;ctx.beginPath();ctx.arc(sx,sy,Math.max(2,sz*0.13*(1-a*0.5)),0,Math.PI*2);ctx.fill();}}}
|
||||
ctx.globalAlpha=1;ctx.font=`${sz}px sans-serif`;
|
||||
for(const k of ks){const [sx,sy]=toS(m.x,m.y,k);ctx.save();ctx.translate(sx,sy+sz*0.15);
|
||||
for(const k of ks){const [sx,sy]=toS(m.x,m.y,k);m.sx=sx;m.sy=sy-sz*0.6;m.r=sz*0.8;ctx.save();ctx.translate(sx,sy+sz*0.15);
|
||||
ctx.fillStyle='rgba(30,38,64,.18)';ctx.beginPath();ctx.ellipse(0,0,sz*0.38,sz*0.12,0,0,Math.PI*2);ctx.fill();
|
||||
ctx.translate(0,-hop);const tilt=m.mood==='snip'?Math.sin((animT-m.t0)/60)*0.25:m.mood==='dance'?Math.sin((animT-m.t0)/80)*0.35:0;ctx.rotate(tilt);ctx.scale(m.face,1);
|
||||
mkSprite(sz*1.25,animT-m.t0,m.mood==='run'&&p>=1?'stand':m.mood);
|
||||
|
|
@ -69,3 +70,5 @@ function mkSprite(s,t,mood){const u=s/40,O='#1E2640',B='#A0673A',T='#F4CFA0',lw=
|
|||
ctx.fillStyle='#FFD23F';ctx.fillRect(-2.6*u,-5*u,5.2*u,2*u);ctx.fillStyle='#C9D1E6';ctx.beginPath();ctx.roundRect(-1.6*u,-10.5*u,3.2*u,2.6*u,0.8*u);ctx.fill();ctx.stroke();
|
||||
if(wave){ctx.fillStyle='rgba(255,79,154,.45)';for(let i=0;i<4;i++){ctx.beginPath();ctx.arc((4+i*2.2)*u,(-11-i*1.4+Math.sin(t/40+i))*u,(0.9+i*0.4)*u,0,Math.PI*2);ctx.fill();}}
|
||||
ctx.restore();dot(fa[0],fa[1],2.2,T);}
|
||||
// Did a tap land on the monkey? (Where it was last drawn.)
|
||||
const mkHit=(x,y)=>!!(UI.mk&&UI.mk.sx!=null&&Math.hypot(x-UI.mk.sx,y-UI.mk.sy)<UI.mk.r);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ function endPtr(e){
|
|||
ptrs.delete(e.pointerId);const d=UI.drag;if(!d)return;
|
||||
if(d.mode==='pinch'){if(ptrs.size===0){UI.drag=null;UI.snap=null;cv.classList.remove('linking');}return;}
|
||||
if(d.mode==='link'){if(UI.snap&&UI.snap.id!==d.from){if(pzOn())pzLinkModal(d.from,UI.snap.id);else openLinkModal(d.from,UI.snap.id);sfx('click');}}
|
||||
else if(!d.moved&&S&&mkOn()&&mkHit(e.clientX,e.clientY)){sfx('click');toast(tr('chaos_monkey.tap'),'',[{l:tr('chaos_monkey.banana',{cost:fmt$(mkBananaCost())}),act:'mkBanana',args:{}}]);}
|
||||
else if(!d.moved&&S){const h=pickCity(e.clientX,e.clientY);
|
||||
if(h){selectCity(h.id);renderLeft();sfx('click');}
|
||||
else{const l=hitLink(e.clientX,e.clientY);if(l){selectLink(l);sfx('click');}else{UI.sel=null;renderPanel();renderLeft();}}}
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@
|
|||
"badges.fire_the_hackback_3000tm_and_flatten":"Fire the HackBack 3000™ and flatten an innocent.",
|
||||
"badges.friend_of_giants":"Friend of Giants",
|
||||
"badges.get_a_subsea_cable_bitten_by":"Get a subsea cable bitten by a shark.",
|
||||
"badges.get_a_visit_from_the_chaos_monkey":"Get a visit from the chaos monkey.",
|
||||
"badges.get_bitten_by_sharks_3_times":"Get bitten by sharks 3 times in one game.",
|
||||
"badges.get_de_peered_by_a_big":"Get de-peered by a big network.",
|
||||
"badges.go_transit_free":"Go transit-free.",
|
||||
|
|
@ -152,7 +153,6 @@
|
|||
"badges.got_total_this_game_ever_ever":"{got}/{total} this game · {ever} ever",
|
||||
"badges.haggle_a_de_kicks_quote_down":"Haggle a DE-KICKS quote down.",
|
||||
"badges.have_a_cable_cut_by_a":"Have a cable cut by a dragged anchor.",
|
||||
"badges.have_a_fiber_cut":"Have a fiber cut.",
|
||||
"badges.have_a_second_site_in_3":"Have a second site in 3 metros.",
|
||||
"badges.have_auto_te_move_100_gbps":"Have Auto-TE move 100 Gbps onto alternate paths at once.",
|
||||
"badges.have_pops_in_50_cities":"Have POPs in 50 cities.",
|
||||
|
|
@ -175,9 +175,11 @@
|
|||
"badges.live_through_the_day_half_the":"Live through the day half the internet went down.",
|
||||
"badges.lose_a_metro_ring_to_one":"Lose a metro ring to one backhoe.",
|
||||
"badges.lose_fiber_to_a_llama_herd":"Lose fiber to a llama herd.",
|
||||
"badges.met_the_backhoe":"Met the Backhoe",
|
||||
"badges.met_the_chaos_monkey":"Met the Chaos Monkey",
|
||||
"badges.monkey_proof":"Monkey-proof",
|
||||
"badges.never_paid_list_price":"Never Paid List Price",
|
||||
"badges.opt_out_of_3_auto_enrolled":"Opt out of 3 auto-enrolled add-ons.",
|
||||
"badges.outlast_a_chaos_monkey_visit":"Outlast a chaos monkey visit without a customer noticing",
|
||||
"badges.over_the_mountains":"Over the Mountains",
|
||||
"badges.paid_pnis_with_all_three_korean":"Paid PNIs with all three Korean incumbents.",
|
||||
"badges.peer_at_an_ix_remotely":"Peer at an IX remotely.",
|
||||
|
|
@ -561,6 +563,18 @@
|
|||
"capacity_deals.what_price_mo_deliver_within_n":"{what} · {price}/mo · deliver within {n} days of signing",
|
||||
"capacity_deals.what_price_mo_due_date":"{what} · {price}/mo once delivered · due {date}",
|
||||
"capacity_deals.wholesale_waves":"Wholesale waves",
|
||||
"chaos_monkey.arrived":"<b>🐒 A chaos monkey got into your network!</b><br>For about {n} days it snips tubes on purpose, the ones without a backup path first. Ride it out with no customer noticing for a bonus.",
|
||||
"chaos_monkey.banana":"🍌 Throw a banana {cost}",
|
||||
"chaos_monkey.bribed":"<b>🍌 Banana accepted.</b><br>The chaos monkey wandered off with its snack. Your pager can rest.",
|
||||
"chaos_monkey.card":"Snipping tubes for {n} more days. Snips so far: {s}, felt by customers: {hurt}.",
|
||||
"chaos_monkey.loose":"Chaos monkey on the loose",
|
||||
"chaos_monkey.rerouted":"<b>🐒 Snip!</b><br>The chaos monkey cut {a} ⇄ {b}, and traffic simply went round. It looks disappointed.",
|
||||
"chaos_monkey.snip_sprayed":"The chaos monkey sprayed {a} ⇄ {b} with something sticky. It is down.",
|
||||
"chaos_monkey.snip_to_see":"The chaos monkey cut {a} ⇄ {b}, just to see what would happen.",
|
||||
"chaos_monkey.snip_unplugged":"The chaos monkey unplugged {a} ⇄ {b} and is grinning at you.",
|
||||
"chaos_monkey.survived":"<b>🐒 You outlasted the chaos monkey!</b><br>{n} snips and no customer noticed. Resilience bonus: {cash}.",
|
||||
"chaos_monkey.tap":"🐒 It snips your tubes on purpose, to prove you can survive it. A banana would send it home.",
|
||||
"chaos_monkey.went_home":"<b>🐒 The chaos monkey went home.</b><br>Snips: {n}. Felt by customers: {hurt}. Where it hurt, a second path would have saved you.",
|
||||
"cities.270_million_people_on_17_000":"270 million people on 17,000 islands. Mobile first, and very hungry for bandwidth.",
|
||||
"cities.a_capital_high_in_the_andes":"A capital high in the Andes, just south of the equator, that pays in US dollars. Volcanoes on every horizon.",
|
||||
"cities.a_capital_in_a_valley_under":"A capital in a valley under a green mountain. The national grid has had some famous bad days, so bring a generator.",
|
||||
|
|
@ -2978,8 +2992,8 @@
|
|||
"progress.under_attack_now":"Under attack now",
|
||||
"progress.your_score_peak_traffic":"Your score: peak traffic",
|
||||
"progress.your_traffic_to_and_from_asia":"Your traffic to and from Asia",
|
||||
"puzzles.a_backhoe_walks_into_your_network":"A backhoe walks into your network. Nothing happens.",
|
||||
"puzzles.a_bigger_boat":"A Bigger Boat",
|
||||
"puzzles.a_chaos_monkey_walks_into_your_network":"A chaos monkey walks into your network. Nothing happens.",
|
||||
"puzzles.a_cut_on_where_drops_g":"A cut on {where} drops {g}",
|
||||
"puzzles.a_different_route":"A different route",
|
||||
"puzzles.a_diverse_route":"A diverse route (+40%)",
|
||||
|
|
@ -3003,11 +3017,12 @@
|
|||
"puzzles.carry_list":"Carry: {list}.",
|
||||
"puzzles.carrying":"Carrying",
|
||||
"puzzles.carrying_on_this_pair":"Carrying (all {n} links on this pair)",
|
||||
"puzzles.city_loses_g":"{city} −{g}",
|
||||
"puzzles.content_lives_in_list":"Content lives in {list}: eyeballs pull from the nearest.",
|
||||
"puzzles.copied_paste_it_anywhere":"Copied! Paste it anywhere:<br>{t}",
|
||||
"puzzles.de_kicks_sales_has_your_number":"DE-KICKS sales has your number. Connect Germany without Frankfurt.",
|
||||
"puzzles.delivered":"Delivered",
|
||||
"puzzles.diverse_route_40_survives_a_backhoe":"Diverse route (+40%, survives a backhoe)",
|
||||
"puzzles.diverse_route_40_survives_the_monkey":"Diverse route (+40%, survives the chaos monkey)",
|
||||
"puzzles.down_under_up_and_running":"Down Under, Up and Running",
|
||||
"puzzles.drag_from_a_pink_pop_to":"Drag from a pink POP to another city to lease a wave",
|
||||
"puzzles.drag_from_this_pop_onto_another":"Drag from this POP onto another puzzle city, or pick one here.",
|
||||
|
|
@ -3034,15 +3049,17 @@
|
|||
"puzzles.hub_cap":"Hub Cap",
|
||||
"puzzles.includes_a_new_pop_in_city":"Includes a new POP in {city} ({price} for a year).",
|
||||
"puzzles.installed":"installed",
|
||||
"puzzles.it_works_finance_and_the_backhoe":"It works! Finance and the backhoe would like a word.",
|
||||
"puzzles.it_works_finance_and_the_monkey":"It works! Finance and the chaos monkey would like a word.",
|
||||
"puzzles.keep_building":"Keep building",
|
||||
"puzzles.kiwi_fruit_salad":"Kiwi Fruit Salad",
|
||||
"puzzles.latency":"Latency",
|
||||
"puzzles.latency_caps":"latency caps",
|
||||
"puzzles.lease_a_wave_to":"Lease a wave to",
|
||||
"puzzles.let_the_chaos_monkey_loose":"🐒 Let the chaos monkey loose",
|
||||
"puzzles.loading_this_week_s_puzzle":"Loading this week's puzzle…",
|
||||
"puzzles.london_wants_half_a_terabit_your":"London wants half a terabit, and your routers came off eBuy.",
|
||||
"puzzles.model_facts":"{cap} · {ports} ports · waves up to {wave}",
|
||||
"puzzles.monkey_snip":"🐒 Snip!",
|
||||
"puzzles.more_puzzles":"More puzzles",
|
||||
"puzzles.n_1_club":"N-1 Club",
|
||||
"puzzles.n_1_deliver_everything_first":"N-1: deliver everything first",
|
||||
|
|
@ -3072,7 +3089,7 @@
|
|||
"puzzles.not_through_frankfurt":"Not Through Frankfurt",
|
||||
"puzzles.off_limits":"Off limits",
|
||||
"puzzles.on_the_house":"On the house",
|
||||
"puzzles.one_backhoe_away_from_a_very":"One backhoe away from a very long night. Add a second path for ⭐⭐⭐.",
|
||||
"puzzles.one_monkey_away_from_a_very":"One chaos monkey away from a very long night. Add a second path for ⭐⭐⭐.",
|
||||
"puzzles.one_ring_through_every_pop":"One ring through every POP",
|
||||
"puzzles.one_very_big_island_and_a":"One very big island, and a lot of very empty fiber.",
|
||||
"puzzles.open_a_pop_cost":"Open a POP · {cost}",
|
||||
|
|
@ -3102,12 +3119,13 @@
|
|||
"puzzles.same_cable_same_anchor":"Same cable as a link you have: one anchor takes both.",
|
||||
"puzzles.same_puzzle_for_everyone_this_week":"Same puzzle for everyone this week",
|
||||
"puzzles.same_trench_cheaper":"Same trench (cheaper)",
|
||||
"puzzles.same_trench_cheaper_one_backhoe_cuts":"Same trench (cheaper, one backhoe cuts both)",
|
||||
"puzzles.same_trench_cheaper_one_snip_cuts":"Same trench (cheaper, one snip cuts both)",
|
||||
"puzzles.sao_paulo_to_miami_before_the":"São Paulo to Miami before the caipirinha gets warm.",
|
||||
"puzzles.sea_to_shining_sea":"Sea to Shining Sea",
|
||||
"puzzles.share_line":"Series of Tubes puzzle {what} {stars} {spend} · seriesoftub.es",
|
||||
"puzzles.six_cities_a_few_gigs_each":"Six cities, a few gigs each, and a router with eight ports. Count before you dig.",
|
||||
"puzzles.size":"Size",
|
||||
"puzzles.skip_the_monkey":"Skip",
|
||||
"puzzles.small_networks_real_traffic":"Small networks, real traffic",
|
||||
"puzzles.spent_x":"Spent {x}",
|
||||
"puzzles.spent_x_of_y":"Spent {x} / {y}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue