Validate campaign unlock flow links

This commit is contained in:
2026-07-05 15:05:17 +09:00
parent ea8e9a5252
commit 2ebabac498

View File

@@ -13,6 +13,7 @@ const battleStepRules = extractCampaignBattleSteps(campaignStateSource);
const sortieFlowKeys = extractSortieFlowKeys(campaignFlowSource, battleScenarioIds);
const sortieFlowCampaignSteps = extractSortieFlowCampaignSteps(campaignFlowSource);
const sortieFlowNextBattleIds = extractSortieFlowNextBattleIds(campaignFlowSource, battleScenarioIds);
const campaignRewardUnlockBattleIds = extractCampaignRewardUnlockBattleIds(battlesSource, battleScenarioIds);
const failures = [];
@@ -40,6 +41,16 @@ for (const [flowKey, nextBattleId] of sortieFlowNextBattleIds.entries()) {
assert(battleIds.has(nextBattleId), `Sortie flow ${flowKey} references unknown next battle id: ${nextBattleId}`);
}
for (const [battleId, unlockBattleId] of campaignRewardUnlockBattleIds.entries()) {
const nextBattleId = sortieFlowNextBattleIds.get(battleId);
assert(battleIds.has(unlockBattleId), `Battle ${battleId} campaign reward unlocks unknown battle id: ${unlockBattleId}`);
assert(nextBattleId, `Battle ${battleId} campaign reward unlocks ${unlockBattleId} but has no sortie flow next battle`);
assert(
nextBattleId === unlockBattleId,
`Battle ${battleId} campaign reward unlock ${unlockBattleId} does not match sortie flow next battle ${nextBattleId}`
);
}
for (const step of campaignSteps) {
if (step.endsWith('-battle')) {
assert(routedBattleSteps.has(step), `Battle campaign step has no routing entry: ${step}`);
@@ -142,6 +153,19 @@ function extractSortieFlowNextBattleIds(source, scenarioIds) {
return entries;
}
function extractCampaignRewardUnlockBattleIds(source, scenarioIds) {
const entries = new Map();
const declarationPattern = /export const (\w+BattleScenario)\b[\s\S]*?^\};/gm;
for (const match of source.matchAll(declarationPattern)) {
const battleId = scenarioIds.get(match[1]);
const unlockMatch = /unlockBattleId:\s*'([^']+)'/.exec(match[0]);
if (battleId && unlockMatch) {
entries.set(battleId, unlockMatch[1]);
}
}
return entries;
}
function extractSortieFlowProperty(source, propertyPattern) {
const objectSource = extractConstObject(source, 'sortieFlows');
const entries = new Map();