Validate campaign unlock flow links
This commit is contained in:
@@ -13,6 +13,7 @@ const battleStepRules = extractCampaignBattleSteps(campaignStateSource);
|
|||||||
const sortieFlowKeys = extractSortieFlowKeys(campaignFlowSource, battleScenarioIds);
|
const sortieFlowKeys = extractSortieFlowKeys(campaignFlowSource, battleScenarioIds);
|
||||||
const sortieFlowCampaignSteps = extractSortieFlowCampaignSteps(campaignFlowSource);
|
const sortieFlowCampaignSteps = extractSortieFlowCampaignSteps(campaignFlowSource);
|
||||||
const sortieFlowNextBattleIds = extractSortieFlowNextBattleIds(campaignFlowSource, battleScenarioIds);
|
const sortieFlowNextBattleIds = extractSortieFlowNextBattleIds(campaignFlowSource, battleScenarioIds);
|
||||||
|
const campaignRewardUnlockBattleIds = extractCampaignRewardUnlockBattleIds(battlesSource, battleScenarioIds);
|
||||||
|
|
||||||
const failures = [];
|
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}`);
|
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) {
|
for (const step of campaignSteps) {
|
||||||
if (step.endsWith('-battle')) {
|
if (step.endsWith('-battle')) {
|
||||||
assert(routedBattleSteps.has(step), `Battle campaign step has no routing entry: ${step}`);
|
assert(routedBattleSteps.has(step), `Battle campaign step has no routing entry: ${step}`);
|
||||||
@@ -142,6 +153,19 @@ function extractSortieFlowNextBattleIds(source, scenarioIds) {
|
|||||||
return entries;
|
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) {
|
function extractSortieFlowProperty(source, propertyPattern) {
|
||||||
const objectSource = extractConstObject(source, 'sortieFlows');
|
const objectSource = extractConstObject(source, 'sortieFlows');
|
||||||
const entries = new Map();
|
const entries = new Map();
|
||||||
|
|||||||
Reference in New Issue
Block a user