/**
* Смоук перехода луга -> Звенец: герой идёт через мост к триггеру (26,14).
* Запуск: node tools/smoke-zvenets.mjs [url] [скриншот]
*/
import { openGame } from './agent-lib.mjs';
const url = process.argv[2] ?? 'http://localhost:5199/';
const shot = process.argv[3] ?? '/tmp/rpg_zvenets.png';
const { browser, page, agent, consoleLogs } = await openGame({ url, newGame: true });
page.on('pageerror', (err) => console.log(`[ошибка страницы] ${err.message}`));
// Усыпить сгустков на лугах: путь героя не должен прерываться уроном.
await page.evaluate(() => {
const g = window.__game;
for (const [, en] of g.scenes.current.combat.enemies) en.brain.putToSleep(9999);
});
// Через мост: маршрут A* до триггера (26,14) — клики в юнитах.
const arrived = await agent.walkTo(26, 14);
if (!arrived) console.log(' ! герой не дошёл до (26,14)');
await agent.waitFor('s.area === "zvenets"', { timeoutTicks: 300 });
const area = await agent.currentArea();
console.log(`Локация после перехода: ${area}`);
await page.screenshot({ path: shot });
console.log(`Скриншот: ${shot}`);
if (!consoleLogs.some((l) => l.includes('[location] zvenets'))) {
console.log(' ! маяк [location] zvenets не найден');
}
await browser.close();