diff --git a/scripts/verify-campaign-save-normalization.mjs b/scripts/verify-campaign-save-normalization.mjs index 90d071b..da198fb 100644 --- a/scripts/verify-campaign-save-normalization.mjs +++ b/scripts/verify-campaign-save-normalization.mjs @@ -287,6 +287,7 @@ try { bonds: [ { id: 'broken-bond', title: 'Broken Bond', unitIds: { corrupted: true }, level: 3, exp: 12, battleExp: 2 }, { id: 'self-bond', title: 'Self Bond', unitIds: ['liu-bei', 'liu-bei'], level: 2, exp: 12, battleExp: 2 }, + { id: 'zero-bond', title: 'Zero Bond', unitIds: ['liu-bei', 'guan-yu'], level: 0, exp: '999', battleExp: 2 }, { id: 'oath-bond', title: 'Oath Bond', unitIds: ['liu-bei', 'guan-yu'], level: '2', exp: '999', battleExp: '5' }, 9 ], @@ -320,11 +321,9 @@ try { 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 === 1 && - malformed.bonds[0].id === 'oath-bond' && - malformed.bonds[0].level === 2 && - malformed.bonds[0].exp === 99 && - malformed.bonds[0].unitIds.length === 2, + malformed.bonds.length === 2 && + malformed.bonds.some((bond) => bond.id === 'zero-bond' && bond.level === 1 && bond.exp === 99 && bond.unitIds.length === 2) && + malformed.bonds.some((bond) => bond.id === 'oath-bond' && bond.level === 2 && bond.exp === 99 && bond.unitIds.length === 2), `Expected malformed bond entries to be filtered while valid bonds normalize: ${JSON.stringify(malformed)}` ); assert( @@ -810,7 +809,7 @@ try { })) ], bonds: [ - { id: firstScenario.bonds[0].id, title: firstScenario.bonds[0].title, level: '2', exp: '22', battleExp: '4' }, + { id: firstScenario.bonds[0].id, title: firstScenario.bonds[0].title, level: '0', exp: '200', battleExp: '4' }, { id: '', title: 'Broken Bond' }, ...Array.from({ length: 120 }, (_, index) => ({ id: `history-bond-${index}`, @@ -912,6 +911,8 @@ try { malformedHistory.battleHistory['first-battle-zhuo-commandery']?.units[0].equipment.armor.itemId === 'cloth-armor' && malformedHistory.battleHistory['first-battle-zhuo-commandery']?.units[0].equipment.accessory.itemId === 'grain-pouch' && malformedHistory.battleHistory['first-battle-zhuo-commandery']?.bonds.length === 1 && + malformedHistory.battleHistory['first-battle-zhuo-commandery']?.bonds[0].level === 1 && + malformedHistory.battleHistory['first-battle-zhuo-commandery']?.bonds[0].exp === 99 && malformedHistory.battleHistory['first-battle-zhuo-commandery']?.bonds[0].battleExp === 4 && malformedHistory.battleHistory['first-battle-zhuo-commandery']?.reserveTraining?.length === 1 && malformedHistory.battleHistory['first-battle-zhuo-commandery']?.reserveTraining?.[0].focusId === 'balanced', diff --git a/src/game/state/campaignState.ts b/src/game/state/campaignState.ts index 07696e6..7512085 100644 --- a/src/game/state/campaignState.ts +++ b/src/game/state/campaignState.ts @@ -983,7 +983,7 @@ function normalizeCharacterExpForLevel(level: number, value: unknown) { } function normalizeBondLevel(value: unknown) { - return Math.min(100, normalizeNonNegativeInteger(value)); + return Math.min(100, Math.max(1, normalizeNonNegativeInteger(value))); } function normalizeBondExpForLevel(level: number, value: unknown) {