Files
DiceCloud/app/imports/api/creature/computation/newEngine/computeComputation/computeVariable.js
2021-09-10 19:51:03 +02:00

34 lines
1.0 KiB
JavaScript

import aggregate from '/imports/api/creature/computation/newEngine/computeComputation/aggregateProps/index.js';
export default function computeVariable(graph, node){
if (!node.data) node.data = {};
aggregateLinks(graph, node);
}
function aggregateLinks(graph, node){
let definingProp;
let overridenProps = [];
graph.forEachLinkedNode(
node.id,
(linkedNode, link) => {
if (!linkedNode.data) linkedNode.data = {};
// Ignore inactive props
if (linkedNode.data.inactive) return;
// Apply all the aggregations
let arg = {node, linkedNode, link};
aggregate.definitions(arg);
aggregate.baseValue(arg);
aggregate.damageMultipliers(arg);
aggregate.effects(arg);
aggregate.proficiencies(arg);
aggregate.skills(arg);
aggregate.toggles(arg);
},
true // enumerate only outbound links
);
// store the defining and overriden props on the node
if (!node.data) node.data = {};
node.data.definingProp = definingProp;
node.data.overridenProps = overridenProps;
}