diff --git a/scripts/verify-campaign-save-normalization.mjs b/scripts/verify-campaign-save-normalization.mjs index b824f2c..3bd8c01 100644 --- a/scripts/verify-campaign-save-normalization.mjs +++ b/scripts/verify-campaign-save-normalization.mjs @@ -656,6 +656,7 @@ try { unlocks: [ { battleId: ' second-battle-yellow-turban-pursuit ', title: ' Next ' }, { battleId: 'second-battle-yellow-turban-pursuit', title: 'Duplicate Next' }, + { battleId: 'ghost-battle', title: 'Broken Next' }, { battleId: '', title: 'Broken' }, ...Array.from({ length: 140 }, (_, index) => ({ battleId: `battle-${index}`, title: `Battle ${index}` })) ], @@ -694,7 +695,7 @@ try { malformedReport.firstBattleReport.campaignRewards?.recruits[0].unitId === 'guan-yu' && malformedReport.firstBattleReport.campaignRewards?.recruits[0].name === 'Guan Yu' && malformedReport.firstBattleReport.campaignRewards?.recruits.filter((recruit) => recruit.unitId === 'guan-yu').length === 1 && - malformedReport.firstBattleReport.campaignRewards?.unlocks.length === 128 && + malformedReport.firstBattleReport.campaignRewards?.unlocks.length === 1 && malformedReport.firstBattleReport.campaignRewards?.unlocks[0].battleId === 'second-battle-yellow-turban-pursuit' && malformedReport.firstBattleReport.campaignRewards?.unlocks[0].title === 'Next' && malformedReport.firstBattleReport.campaignRewards?.unlocks.filter((unlock) => unlock.battleId === 'second-battle-yellow-turban-pursuit').length === 1 && @@ -757,7 +758,10 @@ try { equipment: ['Iron Sword'], reputation: 'Fame', recruits: [{ unitId: 'test-recruit', name: 'Test Recruit' }, { broken: true }], - unlocks: { corrupted: true }, + unlocks: [ + { battleId: 'ghost-battle', title: 'Ghost Battle' }, + { battleId: 'second-battle-yellow-turban-pursuit', title: 'Next Pursuit' } + ], note: 'x'.repeat(181) }, objectives: [ @@ -876,9 +880,11 @@ try { `Expected malformed battle history entries to be filtered while valid settlements are keyed by battleId: ${JSON.stringify(malformedHistory)}` ); assert( - malformedHistory.battleHistory['first-battle-zhuo-commandery']?.itemRewards.length === 1 && + malformedHistory.battleHistory['first-battle-zhuo-commandery']?.itemRewards.length === 1 && malformedHistory.battleHistory['first-battle-zhuo-commandery']?.campaignRewards?.equipment[0] === 'Iron Sword' && malformedHistory.battleHistory['first-battle-zhuo-commandery']?.campaignRewards?.recruits.length === 1 && + malformedHistory.battleHistory['first-battle-zhuo-commandery']?.campaignRewards?.unlocks.length === 1 && + malformedHistory.battleHistory['first-battle-zhuo-commandery']?.campaignRewards?.unlocks[0].battleId === 'second-battle-yellow-turban-pursuit' && malformedHistory.battleHistory['first-battle-zhuo-commandery']?.campaignRewards?.note === undefined, `Expected nested battle history rewards to normalize: ${JSON.stringify(malformedHistory)}` ); diff --git a/src/game/state/campaignState.ts b/src/game/state/campaignState.ts index af3f19d..07984d8 100644 --- a/src/game/state/campaignState.ts +++ b/src/game/state/campaignState.ts @@ -1689,7 +1689,7 @@ function cloneCampaignRewardSnapshot(rewards?: CampaignRewardSnapshot): Campaign battleId: normalizeKeyString(unlock.battleId), title: normalizeDisplayString(unlock.title) })) - .filter((unlock) => unlock.battleId && unlock.title), + .filter((unlock) => unlock.battleId && unlock.title && unlock.battleId in battleScenarios), (unlock) => unlock.battleId ) .slice(0, maxCampaignStringListEntries),