diff --git a/scripts/lib/mcp-commands.js b/scripts/lib/mcp-commands.js index 6a5d8e1..00efa5f 100644 --- a/scripts/lib/mcp-commands.js +++ b/scripts/lib/mcp-commands.js @@ -547,6 +547,9 @@ const API_VIEW={ findOpen:{args:[],doc:'Open the city finder (the 🔍 in the top bar).'}, findGo:{args:[['city','cityId']],doc:'Close the finder and jump to a city.'}, routingOpen:{args:[],doc:'Open the Routing & DDoS window: backbone, Auto-TE and DDoS settings (the button at the top of the NOC tab).'}, + popStep:{args:[['d','step']],doc:'Select and centre the previous (-1) or next (1) of your POPs, in name order, wrapping around (the [ and ] keys).'}, + zoomStep:{args:[['d','step']],doc:'Zoom the map out (-1) or in (1) around its middle (the - and = keys).'}, + keys:{args:[],doc:'Open the list of keyboard shortcuts (the ? key).'}, opsOpen:{args:[],doc:'Open the Ops sheet: the NOC intern\'s mood, weekly shift report and standing orders.'}, opsCity:{args:[['v','cityId',false]],doc:'Show one POP\'s standing-order exceptions in the Ops sheet.'}, utilities:{args:[['city','cityId',false]],doc:'Open the utilities sheet: route servers, the redundancy kit, caches and bulk peering, for one city or the whole network.'}, diff --git a/src/game/93-ui/82-keys.js b/src/game/93-ui/82-keys.js index 334a05c..d2a7087 100644 --- a/src/game/93-ui/82-keys.js +++ b/src/game/93-ui/82-keys.js @@ -17,6 +17,6 @@ document.addEventListener('keydown',e=>{ const lead=Date.now()-keyLead{PD={t:performance.now(),b:e.target.closest('[data-act]')};},true); function tapOk(e,b){if(!e.isTrusted||!PD.t||e.detail===0)return true;const now=performance.now();if(now-PD.t>4000)return true; if(PD.b!==b)return false;if((UI.layerAt||0)>PD.t)return false;const ts=b.closest('.toast');if(ts&&PD.t-(+ts.dataset.born||0)<500)return false;return true;} -document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;if(!$('modal').hidden&&!b.closest('#modal'))return;if(!tapOk(e,b))return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','randomName','pickStart','cont','help','helpClose','newgame','mute','animSet','soundSet','langSet','closeModal','speed','bankClose','whatsNewShow','updateNow','updateLater','importPick','importGo','modeSet','presetSet','chaosSet','puzzleDoor','puzzleMenu','pzStart','pzArStart','pzWeekly','scenarios','startScn','startWeekly','settings','settingsClose','prefSet','vpSet','install','pitchSkip','slotMenu','slotExport','slotDel','slotDelGo','slotBack','slotSwitch','slotTake','slotSpace','toTitle'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);}); +document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;if(!$('modal').hidden&&!b.closest('#modal'))return;if(!tapOk(e,b))return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','keys','randomName','pickStart','cont','help','helpClose','newgame','mute','animSet','soundSet','langSet','closeModal','speed','bankClose','whatsNewShow','updateNow','updateLater','importPick','importGo','modeSet','presetSet','chaosSet','puzzleDoor','puzzleMenu','pzStart','pzArStart','pzWeekly','scenarios','startScn','startWeekly','settings','settingsClose','prefSet','vpSet','install','pitchSkip','slotMenu','slotExport','slotDel','slotDelGo','slotBack','slotSwitch','slotTake','slotSpace','toTitle'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);}); diff --git a/tests/keyboard-shortcuts.test.js b/tests/keyboard-shortcuts.test.js index 0590076..960ab35 100644 --- a/tests/keyboard-shortcuts.test.js +++ b/tests/keyboard-shortcuts.test.js @@ -106,3 +106,16 @@ test('the shortcut list in German', () => { assert.match(txt, /Leertaste/); assert.deepEqual(errors, []); }); + +test('on the title screen, Help opens the shortcut list and both ways out lead back to the title', () => { + const { ev, dom, errors } = load(); + const doc = dom.window.document, key = keyer(dom), title = () => !ev("$('modal').hidden") && ev("$('modal').className") !== 'keys'; + assert.ok(ev('!S'), 'no game yet'); + ev('ACT.help()'); + doc.querySelector('#modalCard [data-act="keys"]').click(); + assert.equal(ev("$('modal').className"), 'keys', 'the button works before a game starts'); + key('?'); assert.ok(title(), '? goes back to the title, not to an empty map'); + ev('ACT.help()'); doc.querySelector('#modalCard [data-act="keys"]').click(); + doc.querySelector('#modalCard .btns [data-act="helpClose"]').click(); assert.ok(title(), 'and so does its button'); + assert.deepEqual(errors, []); +});