Co-op robustness, audio/a11y, new towers and enemies, Uplink rebalance
Co-op (QA'd with two to three real browsers, TCP-proxy chaos scenarios): - partner's tower changes are never dropped after a render stall or snapshot burst - half-open connections show "reconnecting" in ~6 s instead of 45-65 s - upgrade and next-wave are idempotent (stale commands refused), restart message, promoted host gets Play again, failed joins never kill a live game, listener leaks Audio / keyboard / a11y: - one Audio element per track, fade/stinger supersede tokens, play() retry on the next gesture, 5 s fallback to the synth, mute works everywhere, dialogs with role/aria-modal/focus handling, accessible names for sound/speed/pause New content: - enemies: Daemon (healer), Proxy (regenerating shield), Botnet (flyer swarm); waves weave them in from wave 9 (waves 1-8 unchanged) - towers: Sandbox (stun pulse), Load Balancer (fire-rate aura); hotkeys 1-9 - glyphs/shapes, stun/heal effects, gallery e2e that pixel-checks every kind Orbital Uplink rebalanced after playtesting (was affordable by wave ~6 and buyable in bulk from boss rewards): 1500 credits, upgrades 1200/2000/3200, and every Uplink already owned makes the next one 25% dearer to buy AND to upgrade (each tower remembers its multiplier, carried in the tower list as a 9th field). Shared TD.priceFor/upgradePrice so the UI shows exactly what the sim charges. Also: tablet/foldable viewports in the layout matrix (tolerant colour check), docs (README tower/enemy tables, PROTOCOL shield/stun/pm encodings, NEXT roadmap). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
parent
962189419a
commit
28502984ec
29 changed files with 3370 additions and 230 deletions
|
|
@ -16,11 +16,38 @@ module.exports = async function ({ browser, url: URL, out: OUT }) {
|
|||
// lose
|
||||
await page.evaluate(() => { NW.app.ctrl.sim.lives = 1; });
|
||||
await page.click('#btnSpeed'); await page.click('#btnSpeed');
|
||||
await page.evaluate(() => { const e = document.getElementById('end'); new MutationObserver(() => { if (!e.hidden) window.__endAt = performance.now(); }).observe(e, { attributes: true, attributeFilter: ['hidden'] }); });
|
||||
await page.click('#btnWave');
|
||||
await until(() => page.evaluate(() => !document.getElementById('end').hidden), 60000, 'end overlay after losing');
|
||||
// a key-style click (detail 0: what Enter or Space on the focused button produces) inside the first 0.6 s must not press Play again: a player
|
||||
// who was tapping Enter for waves would skip the result. Measured in the page, so a slow machine cannot make this flaky.
|
||||
const early = await page.evaluate(() => { const age = performance.now() - window.__endAt; document.getElementById('btnAgain').click(); return { age, state: NW.app.ctrl.view.state, hidden: document.getElementById('end').hidden }; });
|
||||
assert(early.age >= 600 || (early.state === 'lost' && !early.hidden), 'Enter / Space on Play again ' + Math.round(early.age) + ' ms after the dialog opened does not press it');
|
||||
assert((await page.evaluate(() => document.getElementById('endTitle').textContent)) === 'Breach!', 'lose title');
|
||||
await page.screenshot({ path: OUT + 'end-lose.png' });
|
||||
await page.click('#btnAgain'); await sleep(300);
|
||||
|
||||
// the end screen is a real dialog (code-8, code-9, code-13): labelled, modal, focus inside on the primary button, the page behind it inert
|
||||
const dlg = await page.evaluate(() => {
|
||||
const e = document.getElementById('end'), lab = document.getElementById(e.getAttribute('aria-labelledby'));
|
||||
return { role: e.getAttribute('role'), modal: e.getAttribute('aria-modal'), label: lab && lab.textContent, active: document.activeElement.id, inert: ['topbar', 'stage', 'side'].map((id) => document.getElementById(id).hasAttribute('inert')) };
|
||||
});
|
||||
assert(dlg.role === 'dialog' && dlg.modal === 'true' && dlg.label === 'Breach!', 'the end overlay is role=dialog, aria-modal, named by its title: ' + JSON.stringify(dlg));
|
||||
assert(dlg.active === 'btnAgain', 'focus moved onto Play again: ' + dlg.active);
|
||||
assert(dlg.inert.every(Boolean), 'the top bar, board and side panel are inert behind it');
|
||||
const outside = [];
|
||||
for (let i = 0; i < 8; i++) { await page.keyboard.press('Tab'); outside.push(await page.evaluate(() => (document.activeElement.closest('#end') ? '' : document.activeElement.id || document.activeElement.tagName))); }
|
||||
assert(outside.every((x) => x === ''), 'Tab and Shift+Tab stay inside the dialog (8 Tabs): ' + JSON.stringify(outside));
|
||||
await page.keyboard.press('Shift+Tab');
|
||||
assert(await page.evaluate(() => !!document.activeElement.closest('#end')), 'Shift+Tab too');
|
||||
await page.keyboard.press('m'); // (before Escape: the old code let Escape dismiss the dialog, after which M worked again)
|
||||
assert(await page.evaluate(() => NW.Audio.muted), 'M mutes on the end screen');
|
||||
await until(() => page.evaluate(() => document.getElementById('btnEndSound').textContent === 'Sound: off'), 1500, 'the end dialog sound button shows it');
|
||||
await page.keyboard.press('m');
|
||||
assert(!(await page.evaluate(() => NW.Audio.muted)), 'and unmutes');
|
||||
await page.keyboard.press('Escape'); await sleep(250);
|
||||
assert(await page.evaluate(() => !document.getElementById('end').hidden && NW.app.ctrl.view.state === 'lost'), 'Escape does not dismiss the game-over dialog (it used to leave a dead board with no buttons)');
|
||||
await page.focus('#btnAgain'); await sleep(700);
|
||||
await page.keyboard.press('Enter'); await sleep(300); // the keyboard path: Enter on the focused button
|
||||
let st = await page.evaluate(() => ({ s: NW.app.ctrl.view.state, hidden: document.getElementById('end').hidden, lives: NW.app.ctrl.view.lives, towers: NW.app.ctrl.view.towers.length, map: NW.app.ctrl.board.mapId }));
|
||||
assert(st.s === 'playing' && st.hidden && st.lives === 20 && st.towers === 0 && st.map === 'hub', 'play again resets the same map: ' + JSON.stringify(st));
|
||||
|
||||
|
|
@ -43,11 +70,19 @@ module.exports = async function ({ browser, url: URL, out: OUT }) {
|
|||
assert((await page.evaluate(() => NW.app.selType)) === null, 'escape clears');
|
||||
await page.keyboard.press('p'); assert((await page.evaluate(() => NW.app.ctrl.view.paused)) === true, 'p pauses');
|
||||
await page.keyboard.press('p');
|
||||
// menu while playing
|
||||
await page.click('#btnMenu'); await sleep(200);
|
||||
// menu while playing, by keyboard: Enter on the focused Menu button opens it (it used to start a wave), focus goes into the dialog and back
|
||||
const wave0 = await page.evaluate(() => NW.app.ctrl.view.wave);
|
||||
await page.focus('#btnMenu'); await page.keyboard.press('Enter'); await sleep(250);
|
||||
assert(!(await page.locator('#btnCloseMenu').isHidden()), 'menu has back-to-game while playing');
|
||||
assert((await page.evaluate(() => NW.app.ctrl.view.wave)) === wave0, 'Enter on the focused Menu button did not start a wave');
|
||||
assert((await page.evaluate(() => document.activeElement.id)) === 'btnSolo', 'focus moved into the menu dialog, onto its primary button');
|
||||
const lost = [];
|
||||
for (let i = 0; i < 16; i++) { await page.keyboard.press('Tab'); lost.push(await page.evaluate(() => (document.activeElement.closest('#menu') ? '' : document.activeElement.id || document.activeElement.tagName))); }
|
||||
assert(lost.every((x) => x === ''), 'Tab never reaches the HUD behind the menu (16 Tabs): ' + JSON.stringify(lost.filter(Boolean)));
|
||||
await page.keyboard.press('Escape'); await sleep(200);
|
||||
assert(await page.locator('#menu').isHidden(), 'escape closes the menu');
|
||||
assert((await page.evaluate(() => document.activeElement.id)) === 'btnMenu', 'and focus returns to the Menu button');
|
||||
assert(await page.evaluate(() => ['topbar', 'stage', 'side'].every((id) => !document.getElementById(id).hasAttribute('inert'))), 'the page is live again');
|
||||
if (errors.length) throw new Error('console errors:\n' + errors.join('\n'));
|
||||
console.log('no console errors');
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue