Add second battle pursuit chapter
This commit is contained in:
@@ -280,6 +280,74 @@ try {
|
||||
throw new Error(`Expected sortie preparation overlay to close: ${JSON.stringify(campStateAfterSortieClose)}`);
|
||||
}
|
||||
|
||||
await page.mouse.click(1120, 38);
|
||||
await page.waitForTimeout(120);
|
||||
await page.mouse.click(938, 596);
|
||||
await page.waitForFunction(() => {
|
||||
const activeScenes = window.__HEROS_DEBUG__?.activeScenes() ?? [];
|
||||
return activeScenes.includes('StoryScene');
|
||||
});
|
||||
|
||||
for (let i = 0; i < 8; i += 1) {
|
||||
const isSecondBattleActive = await page.evaluate(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.scene === 'BattleScene' && state?.battleId === 'second-battle-yellow-turban-pursuit';
|
||||
});
|
||||
|
||||
if (isSecondBattleActive) {
|
||||
break;
|
||||
}
|
||||
|
||||
await page.keyboard.press('Space');
|
||||
await page.waitForTimeout(220);
|
||||
}
|
||||
|
||||
await page.waitForFunction(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.scene === 'BattleScene' && state?.battleId === 'second-battle-yellow-turban-pursuit' && state?.battleOutcome === null && state?.phase === 'idle';
|
||||
});
|
||||
await page.screenshot({ path: 'dist/verification-second-battle.png', fullPage: true });
|
||||
|
||||
const secondBattleState = await page.evaluate(() => window.__HEROS_DEBUG__?.battle());
|
||||
const secondEnemies = secondBattleState.units.filter((unit) => unit.faction === 'enemy');
|
||||
const secondEnemyBehaviors = new Set(secondEnemies.map((unit) => unit.ai));
|
||||
if (
|
||||
secondBattleState.camera?.mapWidth !== 24 ||
|
||||
secondBattleState.camera?.mapHeight !== 20 ||
|
||||
secondEnemies.length < 10 ||
|
||||
!secondEnemyBehaviors.has('aggressive') ||
|
||||
!secondEnemyBehaviors.has('guard') ||
|
||||
!secondEnemyBehaviors.has('hold')
|
||||
) {
|
||||
throw new Error(`Expected expanded second battle map and mixed enemy AI: ${JSON.stringify(secondBattleState)}`);
|
||||
}
|
||||
|
||||
await page.evaluate(() => window.__HEROS_DEBUG__?.forceBattleOutcome('victory'));
|
||||
await page.waitForFunction(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.battleOutcome === 'victory' && state?.phase === 'resolved' && state?.resultVisible === true;
|
||||
});
|
||||
|
||||
await page.mouse.click(738, 642);
|
||||
await page.waitForFunction(() => {
|
||||
const activeScenes = window.__HEROS_DEBUG__?.activeScenes() ?? [];
|
||||
return activeScenes.includes('CampScene');
|
||||
});
|
||||
|
||||
const campaignSaveAfterSecondBattle = await page.evaluate(() => {
|
||||
const raw = window.localStorage.getItem('heros-web:campaign-state');
|
||||
return raw ? JSON.parse(raw) : undefined;
|
||||
});
|
||||
if (
|
||||
!campaignSaveAfterSecondBattle ||
|
||||
campaignSaveAfterSecondBattle.step !== 'second-camp' ||
|
||||
campaignSaveAfterSecondBattle.latestBattleId !== 'second-battle-yellow-turban-pursuit' ||
|
||||
!campaignSaveAfterSecondBattle.battleHistory?.['second-battle-yellow-turban-pursuit'] ||
|
||||
!campaignSaveAfterSecondBattle.completedCampDialogues?.length
|
||||
) {
|
||||
throw new Error(`Expected campaign save to persist second battle victory: ${JSON.stringify(campaignSaveAfterSecondBattle)}`);
|
||||
}
|
||||
|
||||
await page.evaluate(() => window.__HEROS_GAME__?.scene.start('TitleScene'));
|
||||
await page.waitForFunction(() => {
|
||||
const activeScenes = window.__HEROS_DEBUG__?.activeScenes() ?? [];
|
||||
@@ -291,25 +359,7 @@ try {
|
||||
return activeScenes.includes('CampScene');
|
||||
});
|
||||
|
||||
await page.evaluate(() => window.__HEROS_DEBUG__?.goToBattle());
|
||||
await page.waitForFunction(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.scene === 'BattleScene' && state?.battleOutcome === null && state?.phase === 'idle';
|
||||
});
|
||||
|
||||
await page.evaluate(() => window.__HEROS_DEBUG__?.forceBattleOutcome('defeat'));
|
||||
await page.waitForFunction(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.battleOutcome === 'defeat' && state?.phase === 'resolved' && state?.resultVisible === true;
|
||||
});
|
||||
|
||||
const defeatState = await page.evaluate(() => window.__HEROS_DEBUG__?.battle());
|
||||
const liuBei = defeatState.units.find((unit) => unit.id === 'liu-bei');
|
||||
if (!liuBei || liuBei.hp > 0) {
|
||||
throw new Error(`Expected Liu Bei to be defeated after forced defeat: ${JSON.stringify(liuBei)}`);
|
||||
}
|
||||
|
||||
console.log(`Verified title-to-battle flow, result states, and debug API at ${targetUrl}`);
|
||||
console.log(`Verified title-to-second-battle flow, result states, and debug API at ${targetUrl}`);
|
||||
} finally {
|
||||
await browser?.close();
|
||||
if (serverProcess && !serverProcess.killed) {
|
||||
|
||||
Reference in New Issue
Block a user