/**
* Одноразовая проба (трек 27): герой идёт по мировой диагонали (экранный
* стик (1,0) = (+x,−z)/√2), камера на герое — кубы должны быть повёрнуты
* вместе с моделью, без «пилы» углами. Кадр: /tmp/t26_diag.png
*/
import { fileURLToPath } from 'node:url';
import { AgentClient, launchBrowser, startDevServer, parseArgs } from '@rpg/engine/tools/agent-lib.mjs';
const args = parseArgs(process.argv.slice(2));
const port = Number(args.port ?? 5331);
const server = startDevServer({ port, cwd: fileURLToPath(new URL('../', import.meta.url)) });
try {
await server.waitReady;
const browser = await launchBrowser();
try {
const page = await browser.newPage();
const pageErrors = [];
page.on('pageerror', (e) => pageErrors.push(String(e)));
await page.goto(`http://localhost:${port}/`, { waitUntil: 'domcontentloaded', timeout: 60000 });
await page.waitForFunction('window.__beacon === true', { timeout: 60000 });
await new Promise((r) => setTimeout(r, 1200));
const client = new AgentClient(page);
client.pageErrors = pageErrors;
await client.call('startGame', false);
await client.call('setManual', true);
await client.call('setAsh', false);
await client.call('setFauna', false);
const hero = await client.call('heroInfo');
const c = await client.call('tileCenter', hero.tile.x, hero.tile.y);
await client.call('setCam', c.x, c.z);
await client.call('setInput', 1, 0); // мировая диагональ
await client.call('stepTicks', 6);
const info = await client.call('heroInfo');
console.log('yaw:', info.yaw, 'pos:', info.pos);
await client.call('setInput', null, null);
await client.screenshot('/tmp/t26_diag.png');
console.log('снимок: /tmp/t26_diag.png');
} finally {
await browser.close();
}
} catch (e) {
console.error(e);
process.exit(1);
}
process.exit(0);