Add Guangzong camp battle and camp events

This commit is contained in:
2026-06-22 23:44:05 +09:00
parent 97f8efc2e1
commit 421b95011e
10 changed files with 803 additions and 57 deletions

View File

@@ -302,6 +302,18 @@ try {
throw new Error(`Expected bean supply to be consumed: ${JSON.stringify(campStateAfterSupply.campaign?.inventory)}`);
}
const goldBeforeMerchant = campStateAfterSupply.campaign?.gold ?? 0;
await page.mouse.click(702, 386);
await page.waitForTimeout(220);
const campStateAfterMerchant = await page.evaluate(() => window.__HEROS_DEBUG__?.camp());
if (
(campStateAfterMerchant.campaign?.inventory?.['콩'] ?? 0) !== 1 ||
campStateAfterMerchant.campaign?.gold !== goldBeforeMerchant - 40
) {
throw new Error(`Expected merchant purchase to add bean and spend gold: ${JSON.stringify({ goldBeforeMerchant, campStateAfterMerchant })}`);
}
await page.mouse.click(830, 38);
await page.waitForTimeout(120);
await page.mouse.click(974, 482);
@@ -358,7 +370,7 @@ try {
return activeScenes.includes('StoryScene');
});
for (let i = 0; i < 14; i += 1) {
for (let i = 0; i < 24; i += 1) {
const isSecondBattleActive = await page.evaluate(() => {
const state = window.__HEROS_DEBUG__?.battle();
return state?.scene === 'BattleScene' && state?.battleId === 'second-battle-yellow-turban-pursuit';
@@ -369,7 +381,7 @@ try {
}
await page.keyboard.press('Space');
await page.waitForTimeout(220);
await page.waitForTimeout(320);
}
await page.waitForFunction(() => {
@@ -430,7 +442,7 @@ try {
return activeScenes.includes('StoryScene');
});
for (let i = 0; i < 14; i += 1) {
for (let i = 0; i < 24; i += 1) {
const isThirdBattleActive = await page.evaluate(() => {
const state = window.__HEROS_DEBUG__?.battle();
return state?.scene === 'BattleScene' && state?.battleId === 'third-battle-guangzong-road';
@@ -441,7 +453,7 @@ try {
}
await page.keyboard.press('Space');
await page.waitForTimeout(220);
await page.waitForTimeout(320);
}
await page.waitForFunction(() => {
@@ -490,6 +502,78 @@ try {
throw new Error(`Expected campaign save to persist third battle victory: ${JSON.stringify(campaignSaveAfterThirdBattle)}`);
}
await page.mouse.click(1120, 38);
await page.waitForTimeout(160);
const thirdCampSortieState = await page.evaluate(() => window.__HEROS_DEBUG__?.camp());
if (!thirdCampSortieState?.sortieVisible) {
throw new Error(`Expected third camp sortie preparation overlay: ${JSON.stringify(thirdCampSortieState)}`);
}
await page.mouse.click(938, 596);
await page.waitForFunction(() => {
const activeScenes = window.__HEROS_DEBUG__?.activeScenes() ?? [];
return activeScenes.includes('StoryScene');
});
for (let i = 0; i < 26; i += 1) {
const isFourthBattleActive = await page.evaluate(() => {
const state = window.__HEROS_DEBUG__?.battle();
return state?.scene === 'BattleScene' && state?.battleId === 'fourth-battle-guangzong-camp';
});
if (isFourthBattleActive) {
break;
}
await page.keyboard.press('Space');
await page.waitForTimeout(320);
}
await page.waitForFunction(() => {
const state = window.__HEROS_DEBUG__?.battle();
return state?.scene === 'BattleScene' && state?.battleId === 'fourth-battle-guangzong-camp' && state?.battleOutcome === null && state?.phase === 'idle';
});
await page.screenshot({ path: 'dist/verification-fourth-battle.png', fullPage: true });
const fourthBattleState = await page.evaluate(() => window.__HEROS_DEBUG__?.battle());
const fourthEnemies = fourthBattleState.units.filter((unit) => unit.faction === 'enemy');
const fourthEnemyBehaviors = new Set(fourthEnemies.map((unit) => unit.ai));
if (
fourthBattleState.camera?.mapWidth !== 24 ||
fourthBattleState.camera?.mapHeight !== 20 ||
fourthBattleState.victoryConditionLabel !== '장각 격파' ||
fourthEnemies.length < 12 ||
!fourthEnemyBehaviors.has('aggressive') ||
!fourthEnemyBehaviors.has('guard') ||
!fourthEnemyBehaviors.has('hold')
) {
throw new Error(`Expected fourth battle map, objective, and mixed enemy AI: ${JSON.stringify(fourthBattleState)}`);
}
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 campaignSaveAfterFourthBattle = await page.evaluate(() => {
const raw = window.localStorage.getItem('heros-web:campaign-state');
return raw ? JSON.parse(raw) : undefined;
});
if (
!campaignSaveAfterFourthBattle ||
campaignSaveAfterFourthBattle.step !== 'fourth-camp' ||
campaignSaveAfterFourthBattle.latestBattleId !== 'fourth-battle-guangzong-camp' ||
!campaignSaveAfterFourthBattle.battleHistory?.['fourth-battle-guangzong-camp']
) {
throw new Error(`Expected campaign save to persist fourth battle victory: ${JSON.stringify(campaignSaveAfterFourthBattle)}`);
}
await page.evaluate(() => window.__HEROS_GAME__?.scene.start('TitleScene'));
await page.waitForFunction(() => {
const activeScenes = window.__HEROS_DEBUG__?.activeScenes() ?? [];
@@ -501,7 +585,7 @@ try {
return activeScenes.includes('CampScene');
});
console.log(`Verified title-to-third-battle flow, result states, and debug API at ${targetUrl}`);
console.log(`Verified title-to-fourth-battle flow, result states, and debug API at ${targetUrl}`);
} finally {
await browser?.close();
if (serverProcess && !serverProcess.killed) {