/**
* Одноразовая проба: где герой и куда смотрит камера.
* Использование: node tools/probe-hero.mjs [port]
*/
import { fileURLToPath } from 'node:url';
import { launchBrowser, openGame, startDevServer } from '@rpg/engine/tools/agent-lib.mjs';
const port = Number(process.argv[2] ?? 5350);
const server = startDevServer({ port, cwd: fileURLToPath(new URL('../', import.meta.url)) });
try {
await server.waitReady;
const browser = await launchBrowser();
const client = await openGame(browser, { url: `http://localhost:${port}/` });
await client.call('startGame', false);
await client.call('setManual', true);
await client.call('stepTicks', 10);
console.log('до gotoArea:', JSON.stringify(await client.call('heroInfo')));
await client.call('gotoArea', 'meadows');
await client.call('stepTicks', 10);
console.log('после gotoArea:', JSON.stringify(await client.call('heroInfo')));
await browser.close();
} finally {
server.stop();
}
process.exit(0);