Normalize malformed campaign bonds
This commit is contained in:
@@ -69,7 +69,11 @@ try {
|
||||
activeSaveSlot: '2',
|
||||
gold: '410',
|
||||
roster: { corrupted: true },
|
||||
bonds: { corrupted: true },
|
||||
bonds: [
|
||||
{ id: 'broken-bond', title: 'Broken Bond', unitIds: { corrupted: true }, level: 3, exp: 12, battleExp: 2 },
|
||||
{ id: 'oath-bond', title: 'Oath Bond', unitIds: ['liu-bei', 'guan-yu'], level: '2', exp: '14', battleExp: '5' },
|
||||
9
|
||||
],
|
||||
completedCampDialogues: ['dialogue-a', 17, 'dialogue-a', ''],
|
||||
completedCampVisits: 'visit-a',
|
||||
inventory: { bean: '3', wine: -2, empty: 0 },
|
||||
@@ -86,7 +90,14 @@ try {
|
||||
assert(malformed.step === 'third-camp', `Expected malformed save progress to survive: ${JSON.stringify(malformed)}`);
|
||||
assert(malformed.activeSaveSlot === 2 && malformed.gold === 410, `Expected malformed numeric fields to normalize: ${JSON.stringify(malformed)}`);
|
||||
assert(Array.isArray(malformed.roster) && malformed.roster.length === 0, `Expected malformed roster to reset to an array: ${JSON.stringify(malformed)}`);
|
||||
assert(Array.isArray(malformed.bonds) && malformed.bonds.length === 0, `Expected malformed bonds to reset to an array: ${JSON.stringify(malformed)}`);
|
||||
assert(
|
||||
Array.isArray(malformed.bonds) &&
|
||||
malformed.bonds.length === 1 &&
|
||||
malformed.bonds[0].id === 'oath-bond' &&
|
||||
malformed.bonds[0].level === 2 &&
|
||||
malformed.bonds[0].unitIds.length === 2,
|
||||
`Expected malformed bond entries to be filtered while valid bonds normalize: ${JSON.stringify(malformed)}`
|
||||
);
|
||||
assert(
|
||||
malformed.completedCampDialogues.length === 1 &&
|
||||
malformed.completedCampDialogues[0] === 'dialogue-a' &&
|
||||
@@ -203,7 +214,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 recovery, unknown-step/report/history recovery, unsupported-version rejection, and slotted fallback.');
|
||||
console.log('Verified campaign save normalization, malformed-field/bond recovery, unknown-step/report/history recovery, unsupported-version rejection, and slotted fallback.');
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user