Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiECd9RWGMKV7n3K1mdy8T
58 lines
3.4 KiB
JavaScript
58 lines
3.4 KiB
JavaScript
// La Smarronata del 1993 nel browser vero: lo spiazzo sotto il Ponte sulla Sieve, la macchina del tempo, il cruscotto,
|
|
// la festa sotto il ponte, il tendone e il ritorno al 2007. npm run browser:smarronata — schermate in /tmp/regolo-smarronata.
|
|
import { chromium } from 'playwright';
|
|
import { mkdirSync } from 'node:fs';
|
|
import assert from 'node:assert/strict';
|
|
import { staticServer } from './helpers.mjs';
|
|
|
|
const out = process.env.OUT ?? '/tmp/regolo-smarronata';
|
|
mkdirSync(out, { recursive: true });
|
|
const server = await staticServer();
|
|
let browser;
|
|
const errors = [];
|
|
try {
|
|
browser = await chromium.launch({ args: ['--autoplay-policy=no-user-gesture-required', '--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader'] });
|
|
const page = await browser.newPage({ viewport: { width: 1280, height: 860 } });
|
|
page.on('pageerror', e => { errors.push(e.message); console.log('ERR', e.message); });
|
|
await page.goto(`http://127.0.0.1:${server.port}/`);
|
|
await page.click('#splash'); await page.click('#new-game'); await page.click('#rione [data-rione="campomigliaio"]'); await page.click('#skip-intro');
|
|
const settle = () => page.evaluate(async () => { const { settle } = await import('/tests/helpers.mjs'); settle(game); });
|
|
// Si salta tutto quello che si può: viaggio, corse, battute (il tempo nel gioco va veloce).
|
|
const run = () => page.evaluate(async () => {
|
|
const { settle } = await import('/tests/helpers.mjs');
|
|
for (let i = 0; i < 3000 && (game.closeup || game.speech || game.queue.length || game.walking); i++) { if (game.speech) game.skip(); else game.update(0.1); }
|
|
settle(game);
|
|
});
|
|
await run();
|
|
await page.evaluate(() => { game.go('ponte_sieve', [250, 320]); });
|
|
await run();
|
|
// Il cartello sul lampione si apre ingrandito; un tocco, e arriva la macchina.
|
|
await page.evaluate(() => game.act('look', 'cartello_smarronata'));
|
|
await page.waitForFunction(() => game.closeup?.id === 'manifesto_smarronata' && game.closeup.t > 0.6, null, { timeout: 15000 });
|
|
await page.screenshot({ path: `${out}/0-cartello.png` });
|
|
await page.evaluate(() => game.closeupTap());
|
|
await run();
|
|
assert.ok(await page.evaluate(() => game.state.flags.macchina_ponte), 'la macchina compare');
|
|
await page.waitForTimeout(800);
|
|
await page.screenshot({ path: `${out}/1-ponte-macchina.png` });
|
|
await page.evaluate(() => game.act('use', 'macchina_ponte'));
|
|
await page.waitForFunction(() => game.closeup?.id === 'viaggio_1993', null, { timeout: 15000 });
|
|
await page.waitForTimeout(1500);
|
|
await page.screenshot({ path: `${out}/2-cruscotto.png` });
|
|
await run();
|
|
assert.equal(await page.evaluate(() => game.state.scene), 'smarronata_1993');
|
|
await page.waitForTimeout(1200);
|
|
await page.screenshot({ path: `${out}/3-smarronata.png` });
|
|
await page.evaluate(() => game.act('walk', 'tendone'));
|
|
await run();
|
|
assert.equal(await page.evaluate(() => game.state.scene), 'smarronata_tendone');
|
|
await page.waitForTimeout(1200);
|
|
await page.screenshot({ path: `${out}/4-tendone.png` });
|
|
await page.evaluate(() => game.goBack());
|
|
await run();
|
|
assert.equal(await page.evaluate(() => game.state.scene), 'ponte_sieve');
|
|
assert.ok(!await page.evaluate(() => game.state.flags.macchina_ponte), 'tornati, la macchina sparisce');
|
|
assert.deepEqual(errors, []);
|
|
console.log(`ok: schermate in ${out}`);
|
|
} finally { await browser?.close(); server.kill(); }
|