Fix stand-still commands and ally pathing

This commit is contained in:
2026-06-22 23:09:57 +09:00
parent 3de598511c
commit e06b8dab58
2 changed files with 95 additions and 5 deletions

View File

@@ -105,6 +105,76 @@ try {
throw new Error('Expected all unit action textures to be loaded.');
}
const movementBlockingState = await page.evaluate(() => {
const scene = window.__HEROS_GAME__?.scene.getScene('BattleScene');
const state = window.__HEROS_DEBUG__?.battle();
const liuBei = state?.units?.find((unit) => unit.id === 'liu-bei');
const guanYu = state?.units?.find((unit) => unit.id === 'guan-yu');
const enemy = state?.units?.find((unit) => unit.faction === 'enemy');
if (!scene || !liuBei || !guanYu || !enemy) {
throw new Error('Expected battle scene and movement test units.');
}
return {
allyBlocksPath: scene.isMovementBlocked(liuBei, guanYu.x, guanYu.y),
enemyBlocksPath: scene.isMovementBlocked(liuBei, enemy.x, enemy.y),
allyStopTileReachable: scene.reachableTiles(liuBei).some((tile) => tile.x === guanYu.x && tile.y === guanYu.y)
};
});
if (
movementBlockingState.allyBlocksPath ||
!movementBlockingState.enemyBlocksPath ||
movementBlockingState.allyStopTileReachable
) {
throw new Error(`Expected allies to be passable path blockers only as stop tiles, and enemies to block movement: ${JSON.stringify(movementBlockingState)}`);
}
const liuBeiScreen = await page.evaluate(() => {
const scene = window.__HEROS_GAME__?.scene.getScene('BattleScene');
const state = window.__HEROS_DEBUG__?.battle();
const liuBei = state?.units?.find((unit) => unit.id === 'liu-bei');
if (!scene || !liuBei) {
throw new Error('Expected Liu Bei and battle scene for stand-still command test.');
}
return {
x: scene.tileCenterX(liuBei.x),
y: scene.tileCenterY(liuBei.y)
};
});
await page.mouse.click(liuBeiScreen.x, liuBeiScreen.y);
await page.waitForTimeout(140);
await page.mouse.click(liuBeiScreen.x, liuBeiScreen.y);
await page.waitForTimeout(180);
const standStillCommandState = await page.evaluate(() => window.__HEROS_DEBUG__?.battle());
if (
standStillCommandState?.phase !== 'command' ||
standStillCommandState.selectedUnitId !== 'liu-bei' ||
standStillCommandState.pendingMove?.unitId !== 'liu-bei' ||
standStillCommandState.pendingMove.from.x !== standStillCommandState.pendingMove.to.x ||
standStillCommandState.pendingMove.from.y !== standStillCommandState.pendingMove.to.y
) {
throw new Error(`Expected Liu Bei to open commands without moving: ${JSON.stringify(standStillCommandState)}`);
}
await page.evaluate(() => {
const scene = window.__HEROS_GAME__?.scene.getScene('BattleScene');
if (!scene) {
return;
}
scene.selectedUnit = undefined;
scene.pendingMove = undefined;
scene.targetingAction = undefined;
scene.selectedUsable = undefined;
scene.phase = 'idle';
scene.clearMarkers();
scene.hideCommandMenu();
scene.hideMapMenu();
});
await page.waitForTimeout(700);
await page.mouse.click(260, 300, { button: 'right' });
await page.waitForTimeout(120);