Newer
Older
rpg / tools / smoke-ponds.mjs
/**
 * Смоук перехода луга -> Серые пруды: герой идёт через мост к триггеру (2,2).
 * Запуск: node tools/smoke-ponds.mjs [url] [скриншот]
 */
import { openGame } from './agent-lib.mjs';

const url = process.argv[2] ?? 'http://localhost:5199/';
const shot = process.argv[3] ?? '/tmp/rpg_ponds.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* до триггера (2,2) — клики в юнитах, видимость не важна.
const arrived = await agent.walkTo(2, 2);
if (!arrived) console.log('  ! герой не дошёл до (2,2)');

// Fade-переход и enter() новой сцены.
await agent.waitFor('s.area === "ponds"', { 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] ponds'))) {
    console.log('  ! маяк [location] ponds не найден');
}
await browser.close();