Guard battle bond save arrays
This commit is contained in:
@@ -83,6 +83,7 @@ type BattleSaveValidationOptions = {
|
||||
const unitDirections = new Set<UnitDirection>(['south', 'east', 'north', 'west']);
|
||||
const maxBattleLogEntries = 10;
|
||||
const maxBattleLogEntryLength = 96;
|
||||
const maxBattleBondEntries = 128;
|
||||
const maxTriggeredBattleEventLength = 96;
|
||||
const defaultBattleSaveArrayLimit = 128;
|
||||
const maxStatusKindsPerUnit = 2;
|
||||
@@ -310,10 +311,13 @@ function isValidEquipmentProgress(level: unknown, exp: unknown) {
|
||||
function isBondArray(value: unknown, options: BattleSaveValidationOptions) {
|
||||
return (
|
||||
Array.isArray(value) &&
|
||||
value.length <= maxBattleBondEntries &&
|
||||
hasUniqueRecordStrings(value, 'id') &&
|
||||
value.every(
|
||||
(bond) =>
|
||||
isRecord(bond) &&
|
||||
typeof bond.id === 'string' &&
|
||||
bond.id.length > 0 &&
|
||||
Array.isArray(bond.unitIds) &&
|
||||
bond.unitIds.length === 2 &&
|
||||
bond.unitIds.every((unitId) => typeof unitId === 'string' && isKnownUnitId(unitId, options)) &&
|
||||
|
||||
Reference in New Issue
Block a user