From dc89369c2a8742685156c2c3f255a4e3dab85a43 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sat, 31 Oct 2026 07:31:22 +0100 Subject: [PATCH] NOC notices that would open the NOC get no Open button (#226) The notice list is the NOC tab, so a target of tab:noc did nothing. #232 gave the shift report a real target; the chaos monkey's arrival still pointed at the NOC, where its own card already is. logSection() now leaves the button off for that target, whatever posts it. --- CHANGELOG.md | 1 + src/game/95-modals/20-notifications.js | 3 ++- tests/chaos-monkey.test.js | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02b2278..3cae84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- The chaos monkey's notice in the NOC no longer has an Open button that did nothing; the monkey's own card is right above it (#226). - Big networks freeze for less on every game day and every click: working out where traffic goes skips exits whose route is already full, so a game day takes about 40% less time (#210). Traffic goes exactly where it went before. - Premium submarine terminals and Optical engineering can no longer be bought on a cable where they would change nothing (#198). The button now says so, and an upgrade that only helps together with the other one stays available. - A wave size that is sold out on a route can no longer be reached by upgrading a smaller wave on it (#201). The upgrade button says how long it is sold out, just like when buying. diff --git a/src/game/95-modals/20-notifications.js b/src/game/95-modals/20-notifications.js index 64b56f1..84447c6 100644 --- a/src/game/95-modals/20-notifications.js +++ b/src/game/95-modals/20-notifications.js @@ -19,11 +19,12 @@ function logNote(html,kind,actions,open){S.log=S.log||[];const tmp=document.crea const logRecent=()=>{const now=Date.now();return (S.log||[]).filter(e=>e.at&&now-e.atlogRecent().filter(e=>e.at>(UI.logSeen||0)).length; const agoStr=at=>{const m=Math.floor((Date.now()-at)/60000);return m<1?tr('common.just_now'):trn('notifications.n_min_ago',m);}; +// The list is the NOC tab: a notice that would open the NOC gets no Open button, since it would do nothing (#226). function logSection(){const L=logRecent(),MAX=5,all=UI.logAll,sh=all?L:L.slice(0,MAX); let h=`

${tr('common.notifications')} ${tr('notifications.last_10_minutes')}

`; if(!L.length)return h+`

${tr('notifications.nothing_in_the_last_10_minutes')}

`; h+=sh.map(e=>{const body=e.h&&e.t.startsWith(e.h)?e.t.slice(e.h.length).trim():e.t; - return `
${e.h?`
${esc(e.h)}${e.n>1?` ×${e.n}`:''}
`:''}${body?`
${esc(body)}${!e.h&&e.n>1?` ×${e.n}`:''}
`:''}
${agoStr(e.at)} · ${dateStr(e.d)}
${e.o?btn(tr('common.open'),'logOpen',{id:e.id},'ghost sm'):''}
`;}).join(''); + return `
${e.h?`
${esc(e.h)}${e.n>1?` ×${e.n}`:''}
`:''}${body?`
${esc(body)}${!e.h&&e.n>1?` ×${e.n}`:''}
`:''}
${agoStr(e.at)} · ${dateStr(e.d)}
${e.o&&!(e.o.a==='tab'&&e.o.v==='noc')?btn(tr('common.open'),'logOpen',{id:e.id},'ghost sm'):''}
`;}).join(''); if(L.length>MAX)h+=`
${btn(all?tr('common.show_fewer'):tr('notifications.show_all_n',{n:L.length}),'logAll',{},'ghost sm')}
`; return h;} const markLayer=()=>{UI.layerAt=performance.now();}; diff --git a/tests/chaos-monkey.test.js b/tests/chaos-monkey.test.js index 4e75a9e..fedcfdd 100644 --- a/tests/chaos-monkey.test.js +++ b/tests/chaos-monkey.test.js @@ -107,3 +107,14 @@ test('"Met the Chaos Monkey" comes from a visit, not from an ordinary fiber cut' assert.equal(ev("BADGES.find(b=>b.id==='backhoe').t"), 'Met the Chaos Monkey'); assert.deepEqual(errors, []); }); + +test('#226 the monkey\'s notice in the NOC has no Open button that would open the NOC again', () => { + const { ev, errors } = net('oncall'); + ev('mkArrive(S.day);ACT.leftTab({t:"noc"})'); + const row = ev(`(()=>{const e=S.log.find(x=>x.o&&x.o.a==='tab'&&x.o.v==='noc');if(!e)return 'none';const r=[...document.querySelectorAll('#left .row.note')].find(n=>n.textContent.includes(e.t.slice(0,20)));return r?(r.querySelector('[data-act=logOpen]')?'button':'no button'):'not shown'})()`); + assert.equal(row, 'no button'); + // a notice that opens something else keeps its button + ev("toast('A test notice','',[],{a:'bank'});ACT.leftTab({t:'noc'})"); + assert.equal(ev(`!![...document.querySelectorAll('#left .row.note')].find(n=>n.textContent.includes('A test notice')).querySelector('[data-act=logOpen]')`), true); + assert.deepEqual(errors, []); +});