/**
* Сценарий zoom — зум камеры: действие, ходьба и диалог не ломаются при z=2.
* Проверки в Звенце (там NPC): 1) клавиша debugZoom: worldRoot.scale = 2;
* 2) действие E у NPC при зуме открывает диалог;
* 3) walkTo при зуме доходит (culling /z);
* 4) возврат на z=1: масштаб как до зума.
* Запуск: node tools/agent.mjs run tools/checks/zoom.mjs
*/
import { withChecks } from '../lib.mjs';
export default async function ({ pretty }) {
return withChecks(
'zoom',
async (t) => {
const { c } = t;
const worldRoot = () => t.ctx.page.evaluate(() => window.__agent.worldRootView());
await c.run('включение зума: scale=2', async () => {
await t.boot();
await t.sleepEnemies();
await t.goToArea('zvenets', { x: 26, y: 14 });
const before = await worldRoot();
c.expect(before.scale === 1, 'стартовый зум не 1', before.scale);
await t.ctx.agent.press('debugZoom');
// scale ставится в Camera.apply на рендер-кадре — даём кадры.
await t.ctx.agent.step(3, { render: true });
const after = await worldRoot();
c.expect(after.scale === 2, 'после debugZoom scale не 2', after.scale);
return null;
});
await c.run('действие E у NPC при зуме открывает диалог', async () => {
const s = await t.ctx.agent.snapshot();
const npc = s.npcs?.[0];
c.expect(!!npc, 'в области нет NPC', s.npcs);
// Герой подходит сам (interactAt) и открывает диалог.
const talked = await t.talkTo(npc.id);
c.expect(talked, 'не подошли к NPC при зуме');
const d = await t.ctx.agent.runDialogue(900);
c.expect(d, 'диалог с NPC при зуме не открылся');
return null;
});
await c.run('walkTo при зуме доходит до цели', async () => {
const s = await t.ctx.agent.snapshot();
const target = { x: s.hero.tile.x + 3, y: s.hero.tile.y + 3 };
const walked = await t.ctx.agent.walkTo(target.x, target.y, { timeoutTicks: 1500 });
c.expect(walked, `walkTo(${target.x},${target.y}) при зуме не дошёл`);
return null;
});
await c.run('возврат на z=1: масштаб как до зума', async () => {
await t.ctx.agent.press('debugZoom');
await t.ctx.agent.step(3, { render: true });
const after = await worldRoot();
c.expect(after.scale === 1, 'повторный debugZoom не вернул scale=1', after.scale);
return null;
});
},
{ pretty }
);
}