Add third campaign battle path
This commit is contained in:
@@ -418,6 +418,78 @@ try {
|
||||
throw new Error(`Expected campaign save to persist second battle victory: ${JSON.stringify(campaignSaveAfterSecondBattle)}`);
|
||||
}
|
||||
|
||||
await page.mouse.click(1120, 38);
|
||||
await page.waitForTimeout(160);
|
||||
const secondCampSortieState = await page.evaluate(() => window.__HEROS_DEBUG__?.camp());
|
||||
if (!secondCampSortieState?.sortieVisible) {
|
||||
throw new Error(`Expected second camp sortie preparation overlay: ${JSON.stringify(secondCampSortieState)}`);
|
||||
}
|
||||
await page.mouse.click(938, 596);
|
||||
await page.waitForFunction(() => {
|
||||
const activeScenes = window.__HEROS_DEBUG__?.activeScenes() ?? [];
|
||||
return activeScenes.includes('StoryScene');
|
||||
});
|
||||
|
||||
for (let i = 0; i < 14; i += 1) {
|
||||
const isThirdBattleActive = await page.evaluate(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.scene === 'BattleScene' && state?.battleId === 'third-battle-guangzong-road';
|
||||
});
|
||||
|
||||
if (isThirdBattleActive) {
|
||||
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 === 'third-battle-guangzong-road' && state?.battleOutcome === null && state?.phase === 'idle';
|
||||
});
|
||||
await page.screenshot({ path: 'dist/verification-third-battle.png', fullPage: true });
|
||||
|
||||
const thirdBattleState = await page.evaluate(() => window.__HEROS_DEBUG__?.battle());
|
||||
const thirdEnemies = thirdBattleState.units.filter((unit) => unit.faction === 'enemy');
|
||||
const thirdEnemyBehaviors = new Set(thirdEnemies.map((unit) => unit.ai));
|
||||
if (
|
||||
thirdBattleState.camera?.mapWidth !== 24 ||
|
||||
thirdBattleState.camera?.mapHeight !== 20 ||
|
||||
thirdBattleState.victoryConditionLabel !== '전령 마원 격파' ||
|
||||
thirdEnemies.length < 10 ||
|
||||
!thirdEnemyBehaviors.has('aggressive') ||
|
||||
!thirdEnemyBehaviors.has('guard') ||
|
||||
!thirdEnemyBehaviors.has('hold')
|
||||
) {
|
||||
throw new Error(`Expected third battle map, objective, and mixed enemy AI: ${JSON.stringify(thirdBattleState)}`);
|
||||
}
|
||||
|
||||
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 campaignSaveAfterThirdBattle = await page.evaluate(() => {
|
||||
const raw = window.localStorage.getItem('heros-web:campaign-state');
|
||||
return raw ? JSON.parse(raw) : undefined;
|
||||
});
|
||||
if (
|
||||
!campaignSaveAfterThirdBattle ||
|
||||
campaignSaveAfterThirdBattle.step !== 'third-camp' ||
|
||||
campaignSaveAfterThirdBattle.latestBattleId !== 'third-battle-guangzong-road' ||
|
||||
!campaignSaveAfterThirdBattle.battleHistory?.['third-battle-guangzong-road']
|
||||
) {
|
||||
throw new Error(`Expected campaign save to persist third battle victory: ${JSON.stringify(campaignSaveAfterThirdBattle)}`);
|
||||
}
|
||||
|
||||
await page.evaluate(() => window.__HEROS_GAME__?.scene.start('TitleScene'));
|
||||
await page.waitForFunction(() => {
|
||||
const activeScenes = window.__HEROS_DEBUG__?.activeScenes() ?? [];
|
||||
@@ -429,7 +501,7 @@ try {
|
||||
return activeScenes.includes('CampScene');
|
||||
});
|
||||
|
||||
console.log(`Verified title-to-second-battle flow, result states, and debug API at ${targetUrl}`);
|
||||
console.log(`Verified title-to-third-battle flow, result states, and debug API at ${targetUrl}`);
|
||||
} finally {
|
||||
await browser?.close();
|
||||
if (serverProcess && !serverProcess.killed) {
|
||||
|
||||
Reference in New Issue
Block a user