Tag targeting attributes and skills with effects
now works like normal effects would
This commit is contained in:
@@ -128,10 +128,21 @@ function linkEffects(dependencyGraph, prop, computation){
|
||||
if (prop.targetByTags){
|
||||
getEffectTagTargets(prop, computation).forEach(targetId => {
|
||||
const targetProp = computation.propsById[targetId];
|
||||
const key = prop.targetField || getDefaultCalculationField(targetProp);
|
||||
const calcObj = get(targetProp, key);
|
||||
if (calcObj && calcObj.calculation){
|
||||
dependencyGraph.addLink(`${targetProp._id}.${key}`, prop._id , 'effect');
|
||||
if (
|
||||
(targetProp.type === 'attribute' || targetProp.type === 'skill')
|
||||
&& targetProp.variableName
|
||||
&& !prop.targetField
|
||||
) {
|
||||
// If the field wasn't specified and we're targeting an attribute or
|
||||
// skill, just treat it like a normal effect on its variable name
|
||||
dependencyGraph.addLink(targetProp.variableName, prop._id, 'effect');
|
||||
} else {
|
||||
// Otherwise target a field on that property
|
||||
const key = prop.targetField || getDefaultCalculationField(targetProp);
|
||||
const calcObj = get(targetProp, key);
|
||||
if (calcObj && calcObj.calculation){
|
||||
dependencyGraph.addLink(`${targetProp._id}.${key}`, prop._id , 'effect');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -71,6 +71,8 @@ export default function computeVariableAsSkill(computation, node, prop){
|
||||
prop.fail = aggregator.fail;
|
||||
// Rollbonus
|
||||
prop.rollBonuses = aggregator.rollBonus;
|
||||
// Store effects
|
||||
prop.effects = node.data.effects;
|
||||
}
|
||||
|
||||
function aggregateAbilityEffects({computation, skillNode, abilityNode}){
|
||||
|
||||
@@ -145,6 +145,15 @@ let ComputedOnlyAttributeSchema = createPropertySchema({
|
||||
optional: true,
|
||||
removeBeforeCompute: true,
|
||||
},
|
||||
// A list of effect ids targeting this attribute
|
||||
effects: {
|
||||
type: Array,
|
||||
optional: true,
|
||||
},
|
||||
'effects.$': {
|
||||
type: Object,
|
||||
blackbox: true,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedAttributeSchema = new SimpleSchema()
|
||||
|
||||
@@ -131,6 +131,15 @@ let ComputedOnlySkillSchema = createPropertySchema({
|
||||
optional: true,
|
||||
removeBeforeCompute: true,
|
||||
},
|
||||
// A list of effect ids targeting this skill
|
||||
effects: {
|
||||
type: Array,
|
||||
optional: true,
|
||||
},
|
||||
'effects.$': {
|
||||
type: Object,
|
||||
blackbox: true,
|
||||
},
|
||||
})
|
||||
|
||||
const ComputedSkillSchema = new SimpleSchema()
|
||||
|
||||
@@ -232,18 +232,10 @@
|
||||
return [];
|
||||
}
|
||||
},
|
||||
effects(){
|
||||
if (this.context.creatureId && this.model.variableName){
|
||||
let creatureId = this.context.creatureId;
|
||||
return CreatureProperties.find({
|
||||
'ancestors.id': creatureId,
|
||||
'stats': this.model.variableName,
|
||||
removed: {$ne: true},
|
||||
inactive: {$ne: true},
|
||||
});
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
effects() {
|
||||
return CreatureProperties.find({
|
||||
_id: { $in: this.model.effects?.map(e => e._id) || [] }
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -210,19 +210,10 @@ export default {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
effects(){
|
||||
if (this.context.creatureId && this.model.variableName){
|
||||
let creatureId = this.context.creatureId;
|
||||
return CreatureProperties.find({
|
||||
'ancestors.id': creatureId,
|
||||
stats: this.model.variableName,
|
||||
type: 'effect',
|
||||
removed: {$ne: true},
|
||||
inactive: {$ne: true},
|
||||
}).fetch();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
effects() {
|
||||
return CreatureProperties.find({
|
||||
_id: { $in: this.model.effects?.map(e => e._id) || [] }
|
||||
});
|
||||
},
|
||||
baseProficiencies(){
|
||||
if (this.context.creatureId){
|
||||
|
||||
Reference in New Issue
Block a user