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
62 lines
4.5 KiB
JavaScript
62 lines
4.5 KiB
JavaScript
// The Orbital Uplink is an endgame weapon: very expensive, and each one owned makes the next dearer. The UI must show the price
|
|
// the server will charge (palette tile, armed-tower panel, aria label) and keep it current as towers are built and sold.
|
|
module.exports = async function ({ browser, url: URL }) {
|
|
const assert = (c, m) => { if (!c) throw new Error('ASSERT: ' + m); console.log('ok -', m); };
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
const errors = [];
|
|
const ctx = await browser.newContext({ viewport: { width: 1280, height: 800 } });
|
|
await ctx.addInitScript(() => { try { localStorage.setItem('nw.helped', 'true'); } catch (e) { /* ignore */ } });
|
|
const page = await ctx.newPage();
|
|
page.on('pageerror', (e) => errors.push('pageerror: ' + e.message));
|
|
page.on('console', (m) => { if (m.type() === 'error') errors.push('console.error: ' + m.text()); });
|
|
await page.goto(URL); await sleep(300);
|
|
await page.click('#btnSolo'); await sleep(300);
|
|
if (await page.locator('#btnHelpClose').isVisible()) await page.click('#btnHelpClose');
|
|
const tile = () => page.evaluate(() => { const b = document.querySelector('.tbtn[data-type="uplink"]'); return { cost: b.querySelector('.cost').textContent, label: b.getAttribute('aria-label'), poor: b.classList.contains('poor') }; });
|
|
const base = await page.evaluate(() => TD.TOWERS.uplink.levels[0].cost);
|
|
|
|
let t = await tile();
|
|
assert(t.cost === String(base) && base >= 1000, `palette shows the first Uplink at ${base} credits`);
|
|
assert(t.poor, 'it is unaffordable with the opening credits');
|
|
assert(/not enough credits/.test(t.label), 'and the aria label says so');
|
|
|
|
// a rich player builds one through the real UI, then the tile shows the dearer second one
|
|
await page.evaluate(() => { NW.app.ctrl.sim.gold = 20000; });
|
|
await sleep(200);
|
|
const box = await page.locator('#board').boundingBox();
|
|
const pt = async (cx, cy) => { const r = await page.evaluate(([a, b]) => NW.app.renderer.cellToScreen(a, b), [cx, cy]); return { x: box.x + r.x, y: box.y + r.y }; };
|
|
await page.keyboard.press('9'); await sleep(150);
|
|
assert((await page.locator('#info').innerText()).includes(String(base) + ' credits'), 'the armed-tower panel shows the same price');
|
|
let p = await pt(6, 5); await page.mouse.click(p.x, p.y); await sleep(250);
|
|
const g1 = await page.evaluate(() => NW.app.ctrl.view.gold);
|
|
assert(g1 === 20000 - base, `the first Uplink was charged ${base}`);
|
|
t = await tile();
|
|
const second = await page.evaluate(() => TD.priceFor('uplink', NW.app.ctrl.view.towers));
|
|
assert(second > base * 1.2 && second < base * 1.3 && t.cost === String(second), `the tile now shows the second one at ${second} (about 25% dearer)`);
|
|
assert((await page.locator('#info').innerText()).includes(String(second) + ' credits'), 'and so does the armed panel');
|
|
p = await pt(9, 5); await page.mouse.click(p.x, p.y); await sleep(250);
|
|
assert((await page.evaluate(() => NW.app.ctrl.view.gold)) === g1 - second, `the second one was charged ${second}`);
|
|
|
|
// upgrades scale by the same factor: the first Uplink upgrades at the base price, the second at the same multiple it was bought at
|
|
await page.keyboard.press('Escape');
|
|
const upBtn = () => page.locator('#info [data-act="up"] .cost').innerText();
|
|
p = await pt(6, 5); await page.mouse.click(p.x, p.y); await sleep(250);
|
|
const firstUp = await page.evaluate(() => TD.TOWERS.uplink.levels[1].cost);
|
|
assert((await upBtn()) === String(firstUp), `the first Uplink upgrades for the base ${firstUp}`);
|
|
await page.keyboard.press('Escape');
|
|
p = await pt(9, 5); await page.mouse.click(p.x, p.y); await sleep(250);
|
|
const secondUp = await page.evaluate(() => { const t = NW.app.ctrl.view.towers.filter((x) => x.type === 'uplink')[1]; return TD.upgradePrice('uplink', t.level, t.pm); });
|
|
assert(secondUp > firstUp * 1.2 && (await upBtn()) === String(secondUp), `the second Uplink upgrades for ${secondUp} (the same 25% more)`);
|
|
await page.keyboard.press('Escape');
|
|
p = await pt(9, 5); await page.mouse.click(p.x, p.y); await sleep(200);
|
|
|
|
// selling brings the price back down
|
|
await page.keyboard.press('Escape');
|
|
p = await pt(9, 5); await page.mouse.click(p.x, p.y); await sleep(200);
|
|
await page.click('#info [data-act="sell"]'); await sleep(250);
|
|
t = await tile();
|
|
assert(t.cost === String(second), 'after selling one the next costs what the second did');
|
|
if (errors.length) throw new Error('console errors:\n' + errors.join('\n'));
|
|
console.log('no console errors');
|
|
await ctx.close();
|
|
};
|