Effects targeting calculations by tag now work in the engine and actions

This commit is contained in:
Stefan Zermatten
2022-02-15 15:59:41 +02:00
parent e0f621cc44
commit 378da71f5d
19 changed files with 454 additions and 98 deletions

View File

@@ -6,6 +6,7 @@ export default class CreatureComputation {
// Set up fields
this.originalPropsById = {};
this.propsById = {};
this.propsWithTag = {};
this.scope = {};
this.props = properties;
this.dependencyGraph = createGraph();
@@ -18,6 +19,17 @@ export default class CreatureComputation {
// Store by id
this.propsById[prop._id] = prop;
// Store sets of ids in each tag
if (prop.tags){
prop.tags.forEach(tag => {
if (this.propsWithTag[tag]){
this.propsWithTag[tag].push(prop._id);
} else {
this.propsWithTag[tag] = [prop._id];
}
});
}
// Store the prop in the dependency graph
this.dependencyGraph.addNode(prop._id, prop);
});