Filter invalid campaign reward unlocks

This commit is contained in:
2026-07-05 14:26:04 +09:00
parent c702bfdfb0
commit 16cbcf2c9a
2 changed files with 10 additions and 4 deletions

View File

@@ -656,6 +656,7 @@ try {
unlocks: [ unlocks: [
{ battleId: ' second-battle-yellow-turban-pursuit ', title: ' Next ' }, { battleId: ' second-battle-yellow-turban-pursuit ', title: ' Next ' },
{ battleId: 'second-battle-yellow-turban-pursuit', title: 'Duplicate Next' }, { battleId: 'second-battle-yellow-turban-pursuit', title: 'Duplicate Next' },
{ battleId: 'ghost-battle', title: 'Broken Next' },
{ battleId: '', title: 'Broken' }, { battleId: '', title: 'Broken' },
...Array.from({ length: 140 }, (_, index) => ({ battleId: `battle-${index}`, title: `Battle ${index}` })) ...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].unitId === 'guan-yu' &&
malformedReport.firstBattleReport.campaignRewards?.recruits[0].name === '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?.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].battleId === 'second-battle-yellow-turban-pursuit' &&
malformedReport.firstBattleReport.campaignRewards?.unlocks[0].title === 'Next' && malformedReport.firstBattleReport.campaignRewards?.unlocks[0].title === 'Next' &&
malformedReport.firstBattleReport.campaignRewards?.unlocks.filter((unlock) => unlock.battleId === 'second-battle-yellow-turban-pursuit').length === 1 && malformedReport.firstBattleReport.campaignRewards?.unlocks.filter((unlock) => unlock.battleId === 'second-battle-yellow-turban-pursuit').length === 1 &&
@@ -757,7 +758,10 @@ try {
equipment: ['Iron Sword'], equipment: ['Iron Sword'],
reputation: 'Fame', reputation: 'Fame',
recruits: [{ unitId: 'test-recruit', name: 'Test Recruit' }, { broken: true }], 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) note: 'x'.repeat(181)
}, },
objectives: [ objectives: [
@@ -876,9 +880,11 @@ try {
`Expected malformed battle history entries to be filtered while valid settlements are keyed by battleId: ${JSON.stringify(malformedHistory)}` `Expected malformed battle history entries to be filtered while valid settlements are keyed by battleId: ${JSON.stringify(malformedHistory)}`
); );
assert( 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?.equipment[0] === 'Iron Sword' &&
malformedHistory.battleHistory['first-battle-zhuo-commandery']?.campaignRewards?.recruits.length === 1 && 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, malformedHistory.battleHistory['first-battle-zhuo-commandery']?.campaignRewards?.note === undefined,
`Expected nested battle history rewards to normalize: ${JSON.stringify(malformedHistory)}` `Expected nested battle history rewards to normalize: ${JSON.stringify(malformedHistory)}`
); );

View File

@@ -1689,7 +1689,7 @@ function cloneCampaignRewardSnapshot(rewards?: CampaignRewardSnapshot): Campaign
battleId: normalizeKeyString(unlock.battleId), battleId: normalizeKeyString(unlock.battleId),
title: normalizeDisplayString(unlock.title) title: normalizeDisplayString(unlock.title)
})) }))
.filter((unlock) => unlock.battleId && unlock.title), .filter((unlock) => unlock.battleId && unlock.title && unlock.battleId in battleScenarios),
(unlock) => unlock.battleId (unlock) => unlock.battleId
) )
.slice(0, maxCampaignStringListEntries), .slice(0, maxCampaignStringListEntries),