17,101
edits
(Update custom localizations for stronghold bosses) |
(Support further data modifications) |
||
Line 628: | Line 628: | ||
case 'dungeons': | case 'dungeons': | ||
case 'equipmentSlots': | case 'equipmentSlots': | ||
case 'items': | |||
case 'modifiers': | case 'modifiers': | ||
case 'shopUpgradeChains': | case 'shopUpgradeChains': | ||
Line 640: | Line 641: | ||
} | } | ||
return undefined; | return undefined; | ||
} | |||
applyModifierModifications(objToModify, modifierAdjustments) { | |||
Object.keys(modifierAdjustments) | |||
.forEach((adjType) => { | |||
if (adjType === 'add') { | |||
Object.entries(modifierAdjustments[adjType]) | |||
.forEach(([chgKey, chgVal]) => { | |||
if (objToModify.modifiers[chgKey] === undefined) { | |||
objToModify.modifiers[chgKey] = chgVal; | |||
} | |||
else if (Array.isArray(chgVal)) { | |||
objToModify.modifiers[chgKey].push(...chgVal); | |||
} | |||
else { | |||
objToModify.modifiers[chgKey] += chgVal; | |||
} | |||
}); | |||
} | |||
else { | |||
console.warn( | |||
`Could not apply data modification: Unhandled modifier adjustment "${adjType}"` | |||
); | |||
} | |||
}); | |||
} | } | ||
applyDataModifications(modData) { | applyDataModifications(modData) { | ||
Line 806: | Line 831: | ||
}); | }); | ||
} | } | ||
break; | |||
case 'items': | |||
case 'pets': | |||
Object.keys(modItem) | |||
.filter((k) => k !== 'id') | |||
.forEach((k) => { | |||
if (k === 'modifiers') { | |||
this.applyModifierModifications(objToModify, modItem[k]); | |||
} | |||
else if (k === 'consumesOn') { | |||
Object.keys(modItem[k]) | |||
.forEach((adjType) => { | |||
if (adjType === 'add') { | |||
if (objToModify[k] === undefined) { | |||
objToModify[k] = modItem[k][adjType]; | |||
} | |||
else { | |||
objToModify[k].push(...modItem[k][adjType]); | |||
} | |||
} | |||
else { | |||
console.warn( | |||
`Could not apply data modification: Unhandled adjustment type "${adjType}" for category "${modCat}", object "${modObjID}, property ${k}"` | |||
); | |||
} | |||
}); | |||
} | |||
else { | |||
console.warn( | |||
`Could not apply data modification: Unhandled key "${k}" for category "${modCat}", object "${modObjID}"` | |||
); | |||
} | |||
} | |||
); | |||
break; | |||
case 'pets': | |||
Object.keys(modItem) | |||
.filter((k) => k !== 'id') | |||
.forEach((k) => { | |||
if (k === 'modifiers') { | |||
this.applyModifierModifications(objToModify, modItem[k]); | |||
} | |||
else { | |||
console.warn( | |||
`Could not apply data modification: Unhandled key "${k}" for category "${modCat}", object "${modObjID}"` | |||
); | |||
} | |||
} | |||
); | |||
break; | break; | ||
// case 'equipmentSlots': | // case 'equipmentSlots': |