Reject unknown campaign battle reports
This commit is contained in:
@@ -494,6 +494,37 @@ try {
|
||||
`Expected malformed report fields to be normalized without discarding the report: ${JSON.stringify(malformedReport)}`
|
||||
);
|
||||
|
||||
storage.clear();
|
||||
storage.set(
|
||||
campaignStorageKey,
|
||||
JSON.stringify({
|
||||
version: 1,
|
||||
updatedAt: '2026-07-04T00:30:00.000Z',
|
||||
step: 'fourth-camp',
|
||||
firstBattleReport: {
|
||||
battleId: 'unknown-battle-id',
|
||||
battleTitle: 'Unknown Battle',
|
||||
outcome: 'victory',
|
||||
turnNumber: 4,
|
||||
rewardGold: 120,
|
||||
defeatedEnemies: 3,
|
||||
totalEnemies: 5,
|
||||
objectives: [],
|
||||
units: [],
|
||||
bonds: [],
|
||||
itemRewards: [],
|
||||
completedCampDialogues: [],
|
||||
completedCampVisits: [],
|
||||
createdAt: '2026-07-04T00:30:00.000Z'
|
||||
}
|
||||
})
|
||||
);
|
||||
const unknownReport = loadCampaignState();
|
||||
assert(
|
||||
unknownReport.step === 'fourth-camp' && unknownReport.firstBattleReport === undefined,
|
||||
`Expected first battle report with unknown battle id to be discarded safely: ${JSON.stringify(unknownReport)}`
|
||||
);
|
||||
|
||||
storage.clear();
|
||||
storage.set(
|
||||
campaignStorageKey,
|
||||
@@ -552,6 +583,19 @@ try {
|
||||
],
|
||||
completedAt: '2026-07-04T01:00:00.000Z'
|
||||
},
|
||||
'unknown-battle-key': {
|
||||
battleId: 'unknown-battle-id',
|
||||
battleTitle: 'Unknown Battle',
|
||||
outcome: 'victory',
|
||||
rewardGold: 999,
|
||||
itemRewards: [],
|
||||
campaignRewards: { supplies: [], equipment: [], reputation: [], recruits: [], unlocks: [] },
|
||||
objectives: [],
|
||||
units: [],
|
||||
bonds: [],
|
||||
reserveTraining: [],
|
||||
completedAt: '2026-07-04T02:00:00.000Z'
|
||||
},
|
||||
corrupted: 'not-a-settlement'
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user