17,101
edits
(Fix Alt. Magic spell IDs (in a less than elegant way)) |
(Retrieve fully-generated attack descriptions) |
||
Line 89: | Line 89: | ||
const newData = structuredClone(entity); | const newData = structuredClone(entity); | ||
newData.forEach((i) => { | newData.forEach((i) => { | ||
i.spellBook = 'altMagic'; | i.spellBook = 'altMagic'; | ||
}); | }); | ||
return newData; | return newData; | ||
} | |||
}, | |||
attacks: function(ns, entityType, entity) { | |||
if (entityType !== 'attacks') { | |||
return entity; | |||
} | |||
else { | |||
entity.forEach((attDef) => { | |||
const nsAttID = ns + ':' + attDef.id; | |||
const att = game.specialAttacks.getObjectByID(nsAttID); | |||
attDef.description = att.description; | |||
}); | |||
return entity; | |||
} | } | ||
} | } | ||
Line 189: | Line 201: | ||
} | } | ||
transformDataNode(ns, categoryName, parentNode, nodeKey) { | transformDataNode(ns, categoryName, parentNode, nodeKey) { | ||
let dataNode = parentNode[nodeKey]; | |||
const transformFunc = this.dataPropTransforms[nodeKey]; | const transformFunc = this.dataPropTransforms[nodeKey]; | ||
if (transformFunc !== undefined) { | if (transformFunc !== undefined) { | ||
// A transformation function is defined for this node | // A transformation function is defined for this node | ||
parentNode[nodeKey] = transformFunc(ns, categoryName, dataNode); | parentNode[nodeKey] = transformFunc(ns, categoryName, dataNode); | ||
dataNode = parentNode[nodeKey]; | |||
} | } | ||
if (Array.isArray(dataNode)) { | |||
// Recursive call to ensure all data is transformed, regardless of its depth | // Recursive call to ensure all data is transformed, regardless of its depth | ||
dataNode.forEach((entity, idx) => this.transformDataNode(ns, categoryName, dataNode, idx)); | dataNode.forEach((entity, idx) => this.transformDataNode(ns, categoryName, dataNode, idx)); |