${btn(tr('hud_and_panels.open_noc_dashboard'),'dash',{},'pink')}${btn(tr('common.connections'),'connOpen',{},'')}${btn(tr('common.traceroute'),'trace',{},'')}
`;
h+=`${incTitle(i.type)}
${esc(i.msg)}
${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)})}`:''}
${i.cost?`
${btn(`${esc(i.fix||tr('common.rush_repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash`:''}
`;}
h+=logSection();UI.logSeen=Date.now();
diff --git a/src/game/96-map/60-draw.js b/src/game/96-map/60-draw.js
index f82dee0..a0d1f0c 100644
--- a/src/game/96-map/60-draw.js
+++ b/src/game/96-map/60-draw.js
@@ -86,6 +86,8 @@ function drawFrame(now){
CM.off=new Set();CM.big=new Set();for(const o of S.offers){const big=BIZ_T[o.type].lv>=3||BIZ_T[o.type].event;for(const c of bCities(o)){CM.off.add(c);if(big)CM.big.add(c);}}
CM.inc=new Set(S.inc.filter(i=>i.type!=='leak').map(i=>i.ref));CM.far=farL;
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);
+ // 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;}}
diff --git a/src/game/96-map/87-chaos-monkey.js b/src/game/96-map/87-chaos-monkey.js
new file mode 100644
index 0000000..7919764
--- /dev/null
+++ b/src/game/96-map/87-chaos-monkey.js
@@ -0,0 +1,73 @@
+/* ---------- 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).
+const mkMid=l=>[(CITY[l.a].x+CITY[l.a].x+wrapDx(CITY[l.a].x,CITY[l.b].x))/2,(CITY[l.a].y+CITY[l.b].y)/2];
+function mkStart(c){const C=CITY[c];UI.mk={x:C.x,y:C.y,fx:C.x,fy:C.y,tx:C.x,ty:C.y,t0:animT,dur:1,face:1,mood:'run',spray:[],sprayAt:null,bad:false};}
+// Off to the next cut: arrive, then spray.
+function mkRun(l,dur,bad){const m=UI.mk;if(!m)return;const [x,y]=mkMid(l);m.fx=m.x;m.fy=m.y;m.tx=x;m.ty=y;m.t0=animT;m.dur=Math.max(1,dur*MK_RUN);
+ 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});}}
+// 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;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;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;}
+ const sz=Math.round(36*Math.max(0.85,Math.min(1.4,Math.sqrt(cam.z))));
+ // Hops while running, bounces on the spot otherwise.
+ const hop=m.mood==='run'&&p<1?Math.abs(Math.sin((animT-m.t0)/70))*sz*0.45:m.mood==='dance'?Math.abs(Math.sin((animT-m.t0)/90))*sz*0.6:m.mood==='cheer'?Math.abs(Math.sin((animT-m.t0)/120))*sz*0.35:0;
+ ctx.save();ctx.textAlign='center';ctx.textBaseline='middle';
+ for(let i=m.spray.length-1;i>=0;i--){const q=m.spray[i],a=(animT-q.t)/900;if(a>1){m.spray.splice(i,1);continue;}
+ 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);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);
+ if(m.mood==='cheer'){ctx.scale(m.face,1);ctx.fillStyle='#000';ctx.fillText('🎉',sz*0.75,-sz*1.1);}ctx.restore();}
+ ctx.restore();}
+// Our own monkey, drawn in the map's outline style, facing right with its feet at (0,0); s is its height.
+// Shades on, spray can in hand: the arms and legs move with its mood.
+function mkSprite(s,t,mood){const u=s/40,O='#1E2640',B='#A0673A',T='#F4CFA0',lw=Math.max(1.4,2*u),k=Math.sin(t/70);
+ ctx.lineJoin=ctx.lineCap='round';ctx.strokeStyle=O;ctx.lineWidth=lw;
+ const dot=(x,y,r,c)=>{ctx.fillStyle=c;ctx.beginPath();ctx.arc(x*u,y*u,r*u,0,Math.PI*2);ctx.fill();ctx.stroke();};
+ const limb=(x1,y1,x2,y2,w)=>{ctx.beginPath();ctx.moveTo(x1*u,y1*u);ctx.lineTo(x2*u,y2*u);ctx.lineWidth=w*u+2*lw;ctx.strokeStyle=O;ctx.stroke();ctx.lineWidth=w*u;ctx.strokeStyle=B;ctx.stroke();ctx.lineWidth=lw;ctx.strokeStyle=O;};
+ const run=mood==='run',up=mood==='cheer',wave=mood==='snip'||mood==='dance';
+ // tail: a curl that sways
+ const sw=Math.sin(t/160)*3;ctx.beginPath();ctx.moveTo(-6*u,-9*u);ctx.bezierCurveTo(-19*u,-8*u,(-21+sw)*u,-26*u,(-13+sw)*u,-29*u);ctx.bezierCurveTo((-7+sw)*u,-31*u,(-6+sw)*u,-24*u,(-10+sw)*u,-24*u);
+ ctx.lineWidth=3*u+2*lw;ctx.stroke();ctx.lineWidth=3*u;ctx.strokeStyle=B;ctx.stroke();ctx.lineWidth=lw;ctx.strokeStyle=O;
+ // legs and feet
+ const g=run?5*k:mood==='dance'?3*k:0;limb(-3,-10,-4-g,-1.5,3.6);limb(4,-10,5+g,-1.5,3.6);
+ ctx.fillStyle=T;for(const x of [-4-g,5+g]){ctx.beginPath();ctx.ellipse((x+1)*u,-1*u,3*u,1.8*u,0,0,Math.PI*2);ctx.fill();ctx.stroke();}
+ // back arm, body, belly
+ const ba=up?[-10,-33]:wave?[-11,-25+2*k]:run?[-10,-14-3*k]:[-9,-13];limb(-4,-20,ba[0],ba[1],3.2);dot(ba[0],ba[1],2.2,T);
+ ctx.fillStyle=B;ctx.beginPath();ctx.ellipse(0,-15*u,9*u,10*u,0,0,Math.PI*2);ctx.fill();ctx.stroke();
+ ctx.fillStyle=T;ctx.beginPath();ctx.ellipse(1.5*u,-14*u,5.5*u,7*u,0,0,Math.PI*2);ctx.fill();
+ // head: ears, skull, face
+ dot(-6,-32,3.6,B);dot(10,-32,3.6,B);ctx.fillStyle=T;for(const x of [-6,10]){ctx.beginPath();ctx.arc(x*u,-32*u,1.9*u,0,Math.PI*2);ctx.fill();}
+ dot(2,-31,9,B);ctx.fillStyle=T;ctx.beginPath();ctx.arc(-1*u,-31.5*u,4*u,0,Math.PI*2);ctx.arc(5*u,-31.5*u,4*u,0,Math.PI*2);ctx.fill();
+ ctx.beginPath();ctx.ellipse(2*u,-27.5*u,6.5*u,4.6*u,0,0,Math.PI*2);ctx.fill();
+ // shades: two dark lenses on a bridge, with a glint
+ ctx.fillStyle=O;ctx.beginPath();ctx.ellipse(-1.2*u,-32.5*u,3.3*u,2.6*u,0,0,Math.PI*2);ctx.ellipse(5.4*u,-32.5*u,3.3*u,2.6*u,0,0,Math.PI*2);ctx.fill();
+ ctx.beginPath();ctx.moveTo(1.5*u,-33.5*u);ctx.lineTo(2.7*u,-33.5*u);ctx.moveTo(-4.4*u,-33*u);ctx.lineTo(-7*u,-33.5*u);ctx.stroke();
+ ctx.strokeStyle='#fff';ctx.lineWidth=Math.max(1,0.9*u);ctx.beginPath();ctx.moveTo(-2.6*u,-33.6*u);ctx.lineTo(-1.2*u,-34.3*u);ctx.moveTo(4*u,-33.6*u);ctx.lineTo(5.4*u,-34.3*u);ctx.stroke();ctx.strokeStyle=O;ctx.lineWidth=lw;
+ // mouth: a smirk, or a laugh when it breaks something
+ ctx.beginPath();if(mood==='dance'||up){ctx.fillStyle='#7A2633';ctx.ellipse(2.5*u,-26.5*u,2.6*u,2*u,0,0,Math.PI*2);ctx.fill();ctx.stroke();}
+ else{ctx.moveTo(-0.5*u,-27*u);ctx.quadraticCurveTo(3*u,-25*u,6*u,-28*u);ctx.stroke();}
+ // front arm with the spray can
+ const fa=up?[11,-34]:wave?[13,-27-2*k]:run?[11,-17+3*k]:[10,-14];limb(5,-20,fa[0],fa[1],3.2);
+ ctx.save();ctx.translate(fa[0]*u,fa[1]*u);ctx.rotate(wave?0.5:0);
+ ctx.fillStyle='#FF4F9A';ctx.beginPath();ctx.roundRect(-2.6*u,-8*u,5.2*u,9*u,1.2*u);ctx.fill();ctx.stroke();
+ 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)
🐒 A chaos monkey got into your network!
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":"🍌 Banana accepted.
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":"🐒 Snip!
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":"🐒 You outlasted the chaos monkey!
{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":"🐒 The chaos monkey went home.
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.",
diff --git a/tests/chaos-monkey.test.js b/tests/chaos-monkey.test.js
new file mode 100644
index 0000000..4089064
--- /dev/null
+++ b/tests/chaos-monkey.test.js
@@ -0,0 +1,99 @@
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const { load } = require('./harness');
+
+// A small network on a fixed seed: Frankfurt, Amsterdam, London and Paris in a ring, with a spur out to Zurich.
+function net(preset) {
+ const { ev, errors, dom } = load();
+ ev(`beginGame('Monkey Testers','fra',${JSON.stringify({ mode: 'normal', preset })});if(UI.pendGame)ACT.pitchSkip()`);
+ ev("S.cash=1e9;S.lvl=4;for(const c of ['ams','lon','par','zrh'])ACT.buildPop({city:c})");
+ ev("ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1})");
+ ev("for(const [a,b] of [['fra','ams'],['ams','lon'],['lon','par'],['par','fra'],['fra','zrh']]){UI.pending={a,b};ACT.buildLink({tier:1});}closeModal()");
+ ev('for(let i=0;i<60;i++)dayTick();S.inc=[];for(const l of S.links)l.cut=0;compute()');
+ return { ev, errors, dom };
+}
+const link = (ev, a, b) => `S.links.find(l=>(l.a==='${a}'&&l.b==='${b}')||(l.a==='${b}'&&l.b==='${a}'))`;
+
+test('the chaos monkey visits On-call and BGP at 3 a.m., never Change Freeze or Sandbox', () => {
+ for (const [preset, ok] of [['oncall', true], ['bgp', true], ['freeze', false]]) {
+ const { ev, errors } = net(preset);
+ assert.equal(ev('mkElig()'), ok, preset);
+ ev('S.monkey.next=S.day;dayTick()');
+ assert.equal(ev('!!S.monkey.on'), ok, preset);
+ assert.deepEqual(errors, []);
+ }
+ const { ev } = net('oncall');
+ ev("S.mode='sandbox'");
+ assert.equal(ev('mkElig()'), false);
+ ev("S.mode='normal';S.monkey.next=S.day;dayTick();S.scn={rules:{}}");
+ assert.equal(ev('mkOn()'), false, 'never in a scenario');
+});
+
+test('a visit lasts 120 to 240 days, snips every couple of weeks and pauses the usual failures', () => {
+ const { ev, errors } = net('oncall');
+ ev('S.monkey.next=S.day;dayTick()');
+ const len = ev('S.monkey.until-S.monkey.start');
+ assert.ok(len >= 120 && len <= 240, `visit of ${len} days`);
+ ev('S.nextFail=S.day');
+ const nf = ev('S.nextFail');
+ ev('for(let i=0;i<60;i++)dayTick()');
+ assert.ok(ev('S.monkey.n') >= 2, 'it snipped');
+ assert.equal(ev('S.nextFail'), nf, 'no ordinary failure fired while it was here');
+ assert.ok(ev("S.inc.some(i=>i.type==='cut')||S.stats.survived>0"));
+ // It leaves on time, and the ordinary failures wait a little before they start again.
+ ev('for(let i=0;i<200&&S.monkey.on;i++)dayTick()');
+ assert.equal(ev('S.monkey.on'), 0);
+ assert.ok(ev('S.monkey.next>S.day+200'));
+ assert.ok(ev('S.nextFail>=S.day'));
+ assert.deepEqual(errors, []);
+});
+
+test('weak spots are tubes with no other way round', () => {
+ const { ev } = net('oncall');
+ assert.equal(ev(`mkWeak(${link(ev, 'fra', 'zrh')})`), true);
+ assert.equal(ev(`mkWeak(${link(ev, 'fra', 'ams')})`), false);
+});
+
+test('outlasting it unnoticed pays a bonus and earns the badge; going home hurt pays nothing', () => {
+ const { ev, errors } = net('oncall');
+ ev('S.monkey.next=S.day;dayTick();S.monkey.n=4;S.monkey.hurt=0;S.monkey.until=S.day+1');
+ const cash = ev('S.cash'), bonus = ev('mkBonus()');
+ ev('dayTick();checkBadges()');
+ assert.equal(ev('S.monkey.on'), 0);
+ assert.equal(ev('S.stats.mkSurv'), 1);
+ assert.ok(ev('S.cash') >= cash + bonus - 1e6, 'bonus paid');
+ assert.ok(ev("S.ach.monkey!==undefined"));
+ ev('S.monkey.next=S.day;dayTick();S.monkey.n=4;S.monkey.hurt=2;S.monkey.until=S.day+1;dayTick()');
+ assert.equal(ev('S.stats.mkSurv'), 1, 'no bonus when customers felt it');
+ assert.deepEqual(errors, []);
+});
+
+test('a banana sends it home early, for a price', () => {
+ const { ev, errors, dom } = net('bgp');
+ ev("S.monkey.next=S.day;dayTick();UI.left='noc';renderLeft()");
+ assert.ok(dom.window.document.querySelector('[data-act=mkBanana]'), 'the NOC card offers a banana');
+ const cash = ev('S.cash'), cost = ev('mkBananaCost()');
+ ev('ACT.mkBanana({})');
+ assert.equal(ev('S.monkey.on'), 0);
+ assert.equal(ev('S.cash'), cash - cost);
+ assert.equal(ev('S.stats.mkSurv||0'), 0);
+ ev('S.cash=0;S.monkey.next=S.day;dayTick();ACT.mkBanana({})');
+ assert.equal(ev('S.monkey.on'), 1, 'no banana without the cash');
+ assert.deepEqual(errors, []);
+});
+
+test('saves keep the monkey; old and broken saves are repaired', () => {
+ const { ev, errors } = net('oncall');
+ ev('S.monkey.next=S.day;dayTick();const t=JSON.stringify(packSave(S));S=migrate(JSON.parse(t))');
+ assert.equal(ev('S.monkey.on'), 1);
+ assert.ok(ev('S.monkey.until>S.day'));
+ ev("const o=JSON.parse(JSON.stringify(packSave(S)));delete o.monkey;S=migrate(o)");
+ assert.deepEqual(JSON.parse(ev('JSON.stringify(S.monkey)')), { next: null, on: 0 });
+ ev("const o=JSON.parse(JSON.stringify(packSave(S)));o.monkey={on:1,until:'soon',n:-3,hurt:99,c:''};S=migrate(o)");
+ assert.equal(ev('S.monkey.n'), 0);
+ assert.equal(ev('S.monkey.hurt'), 0);
+ assert.equal(ev('S.monkey.c'), ev('S.home'));
+ assert.ok(ev('S.monkey.until>=S.monkey.start'));
+ ev('for(let i=0;i<5;i++)dayTick()');
+ assert.deepEqual(errors, []);
+});
diff --git a/tests/gameplay-rules.test.js b/tests/gameplay-rules.test.js
index 76cf1ba..fb1603c 100644
--- a/tests/gameplay-rules.test.js
+++ b/tests/gameplay-rules.test.js
@@ -361,6 +361,27 @@ test('F3: a specialist path only brings customers you can already serve', () =>
assert.deepEqual(g.errors, []);
});
+test('F4: the chaos monkey only visits On-call and BGP at 3 a.m., late, for 120 to 240 days, instead of the ordinary failures', () => {
+ for (const preset of ['freeze', 'oncall', 'bgp']) {
+ const g = load();
+ g.ev(`beginGame('Monkey','fra',{mode:'normal',preset:'${preset}'});if(UI.pendGame)ACT.pitchSkip()`);
+ g.ev("S.cash=1e9;S.lvl=4;for(const c of ['ams','lon','par'])ACT.buildPop({city:c});for(const [a,b] of [['fra','ams'],['ams','lon'],['lon','par'],['par','fra']]){UI.pending={a,b};ACT.buildLink({tier:1});}closeModal()");
+ g.ev('for(let i=0;i<2;i++)dayTick()');
+ if (preset === 'freeze') { assert.equal(g.ev('mkElig()'), false, 'F4: never in Change Freeze'); continue; }
+ assert.ok(g.ev('S.monkey.next') >= 180, 'F4: not before day 180');
+ g.ev('S.monkey.next=S.day;dayTick();S.nextFail=S.day');
+ const len = g.ev('S.monkey.until-S.monkey.start');
+ assert.ok(len >= 120 && len <= 240, `F4: a visit of ${len} days`);
+ g.ev('for(let i=0;i<40;i++)dayTick()');
+ assert.ok(g.ev('S.nextFail') <= g.ev('S.day'), 'F4: no ordinary failure fired during the visit');
+ assert.ok(g.ev("S.inc.filter(i=>i.type==='cut').every(i=>i.until-i.start<=(rule('chaos')==='spicy'?11:7))"), 'F4: snips heal within a week (spicy stretches by half)');
+ assert.deepEqual(g.errors, []);
+ }
+ const g = load();
+ g.ev("beginGame('Monkey','fra',{mode:'normal',preset:'oncall'});if(UI.pendGame)ACT.pitchSkip();S.mode='sandbox'");
+ assert.equal(g.ev('mkElig()'), false, 'F4: never in Sandbox');
+});
+
test('no page errors while checking the rules', () => {
assert.deepEqual(errors, []);
});