Recover malformed first battle reports
This commit is contained in:
@@ -207,16 +207,76 @@ try {
|
||||
firstBattleReport: {
|
||||
battleId: 'first-battle-zhuo-commandery',
|
||||
outcome: 'victory',
|
||||
completedCampVisits: { corrupted: true }
|
||||
turnNumber: '4',
|
||||
rewardGold: '120',
|
||||
defeatedEnemies: '3',
|
||||
totalEnemies: '5',
|
||||
objectives: [
|
||||
{ id: 'village', label: 'Village', achieved: true, detail: 12, rewardGold: '80' },
|
||||
{ id: '', label: 'Broken', achieved: true }
|
||||
],
|
||||
units: [
|
||||
{
|
||||
id: 'liu-bei',
|
||||
name: 'Liu Bei',
|
||||
faction: 'ally',
|
||||
className: 'Lord',
|
||||
classKey: 'lord',
|
||||
level: '5',
|
||||
exp: '15',
|
||||
hp: '41',
|
||||
maxHp: '44',
|
||||
attack: '21',
|
||||
move: '5',
|
||||
stats: { might: '18', intelligence: '17', leadership: '20', agility: '12', luck: '11' },
|
||||
equipment: {},
|
||||
x: '2',
|
||||
y: '3'
|
||||
},
|
||||
{ id: 'broken-unit', name: 'Broken' }
|
||||
],
|
||||
bonds: [
|
||||
{ id: 'liu-bei__guan-yu', title: 'Oath Bond', unitIds: ['liu-bei', 'guan-yu'], level: '2', exp: '30', battleExp: '4' },
|
||||
{ id: 'broken-bond', title: 'Broken Bond', unitIds: ['liu-bei'] }
|
||||
],
|
||||
mvp: { unitId: 'liu-bei', name: 'Liu Bei', damageDealt: '88', defeats: '2' },
|
||||
itemRewards: ['Bean', 'Bean', 10],
|
||||
campaignRewards: {
|
||||
supplies: ['Bean', 'Bean', 20],
|
||||
equipment: ['Iron Sword'],
|
||||
reputation: ['Village Thanks'],
|
||||
recruits: [{ unitId: 'guan-yu', name: 'Guan Yu' }, { unitId: '', name: 'Broken' }],
|
||||
unlocks: [{ battleId: 'second-battle-yellow-turban-pursuit', title: 'Next' }, { battleId: '', title: 'Broken' }]
|
||||
},
|
||||
completedCampDialogues: ['intro', 'intro', 7],
|
||||
completedCampVisits: { corrupted: true },
|
||||
createdAt: 42
|
||||
}
|
||||
})
|
||||
);
|
||||
const malformedReport = loadCampaignState();
|
||||
assert(
|
||||
malformedReport.step === 'fourth-camp' && malformedReport.gold === 320,
|
||||
`Expected malformed report to be dropped without losing campaign progress: ${JSON.stringify(malformedReport)}`
|
||||
`Expected report recovery to keep campaign progress: ${JSON.stringify(malformedReport)}`
|
||||
);
|
||||
assert(
|
||||
malformedReport.firstBattleReport?.battleId === 'first-battle-zhuo-commandery' &&
|
||||
malformedReport.firstBattleReport.battleTitle.length > 0 &&
|
||||
malformedReport.firstBattleReport.turnNumber === 4 &&
|
||||
malformedReport.firstBattleReport.objectives.length === 1 &&
|
||||
malformedReport.firstBattleReport.objectives[0].rewardGold === 80 &&
|
||||
malformedReport.firstBattleReport.units.length === 1 &&
|
||||
malformedReport.firstBattleReport.units[0].level === 5 &&
|
||||
malformedReport.firstBattleReport.bonds.length === 1 &&
|
||||
malformedReport.firstBattleReport.bonds[0].battleExp === 4 &&
|
||||
malformedReport.firstBattleReport.mvp?.damageDealt === 88 &&
|
||||
malformedReport.firstBattleReport.itemRewards.length === 1 &&
|
||||
malformedReport.firstBattleReport.campaignRewards?.supplies.length === 1 &&
|
||||
malformedReport.firstBattleReport.campaignRewards?.recruits.length === 1 &&
|
||||
malformedReport.firstBattleReport.completedCampDialogues.length === 1 &&
|
||||
malformedReport.firstBattleReport.completedCampVisits.length === 0,
|
||||
`Expected malformed report fields to be normalized without discarding the report: ${JSON.stringify(malformedReport)}`
|
||||
);
|
||||
assert(malformedReport.firstBattleReport === undefined, `Expected malformed report to be discarded: ${JSON.stringify(malformedReport)}`);
|
||||
|
||||
storage.clear();
|
||||
storage.set(
|
||||
|
||||
Reference in New Issue
Block a user