Added default tags to properties

#type, damageType, skillType, attributeType, reset
This commit is contained in:
Stefan Zermatten
2022-03-05 17:52:15 +02:00
parent a8ebf6a1de
commit 782f2cdc73

View File

@@ -20,16 +20,28 @@ export default class CreatureComputation {
// Store by id
this.propsById[prop._id] = prop;
// Store tags
const storePropOnTag = (prop, tag) => {
if (!tag) return;
if (this.propsWithTag[tag]){
this.propsWithTag[tag].push(prop._id);
} else {
this.propsWithTag[tag] = [prop._id];
}
}
// 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];
}
storePropOnTag(prop, tag);
});
}
// Store tags for the property type
storePropOnTag(prop, `#${prop.type}`);
// Store tags for some string properties
storePropOnTag(prop, prop.damageType);
storePropOnTag(prop, prop.skillType);
storePropOnTag(prop, prop.attributeType);
storePropOnTag(prop, prop.reset);
// Store the prop in the dependency graph
this.dependencyGraph.addNode(prop._id, prop);