Recover malformed roster equipment
This commit is contained in:
@@ -180,6 +180,54 @@ try {
|
||||
`Expected stale bonds to be filtered against the recovered roster while valid bonds survive: ${JSON.stringify(staleBonds)}`
|
||||
);
|
||||
|
||||
storage.clear();
|
||||
storage.set(
|
||||
campaignStorageKey,
|
||||
JSON.stringify({
|
||||
version: 1,
|
||||
updatedAt: '2026-07-03T14:00:00.000Z',
|
||||
step: 'third-camp',
|
||||
activeSaveSlot: 1,
|
||||
roster: [
|
||||
{
|
||||
id: 'liu-bei',
|
||||
name: 'Liu Bei',
|
||||
faction: 'ally',
|
||||
className: 'Lord',
|
||||
classKey: 'lost-class',
|
||||
level: '6',
|
||||
exp: '18',
|
||||
hp: '42',
|
||||
maxHp: '45',
|
||||
attack: '22',
|
||||
move: '5',
|
||||
stats: { might: '19', intelligence: '17', leadership: '21', agility: '13', luck: '12' },
|
||||
equipment: {
|
||||
weapon: { itemId: 'short-bow', level: '3', exp: '14' },
|
||||
armor: { itemId: 'short-bow', level: '2', exp: '9' },
|
||||
accessory: { itemId: 'grain-pouch', level: '0', exp: '7' }
|
||||
},
|
||||
x: '2',
|
||||
y: '3'
|
||||
},
|
||||
{ id: 'ghost-unit', name: 'Ghost', faction: 'neutral' }
|
||||
]
|
||||
})
|
||||
);
|
||||
const malformedRoster = loadCampaignState();
|
||||
assert(
|
||||
malformedRoster.roster.length === 1 &&
|
||||
malformedRoster.roster[0].id === 'liu-bei' &&
|
||||
malformedRoster.roster[0].classKey === 'infantry' &&
|
||||
malformedRoster.roster[0].level === 6 &&
|
||||
malformedRoster.roster[0].equipment.weapon.itemId === 'short-bow' &&
|
||||
malformedRoster.roster[0].equipment.weapon.level === 3 &&
|
||||
malformedRoster.roster[0].equipment.armor.itemId === 'cloth-armor' &&
|
||||
malformedRoster.roster[0].equipment.accessory.itemId === 'grain-pouch' &&
|
||||
malformedRoster.roster[0].equipment.accessory.level === 1,
|
||||
`Expected malformed roster units and equipment to be normalized safely: ${JSON.stringify(malformedRoster)}`
|
||||
);
|
||||
|
||||
storage.clear();
|
||||
storage.set(
|
||||
campaignStorageKey,
|
||||
@@ -391,7 +439,7 @@ try {
|
||||
const fallback = loadCampaignState();
|
||||
assert(fallback.step === 'second-camp' && fallback.activeSaveSlot === 2, `Expected valid slotted save fallback: ${JSON.stringify(fallback)}`);
|
||||
|
||||
console.log('Verified campaign save normalization, malformed-field/bond-roster/sortie-roster/latest-history/detail recovery, unknown-step/report/history recovery, unsupported-version rejection, and slotted fallback.');
|
||||
console.log('Verified campaign save normalization, malformed-field/roster-equipment/bond-roster/sortie-roster/latest-history/detail recovery, unknown-step/report/history recovery, unsupported-version rejection, and slotted fallback.');
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user