Changed task triggers to be stored differently so that attribute check and damage triggers don't overlap
This commit is contained in:
@@ -9,31 +9,40 @@ export default function computeTrigger(computation, node) {
|
||||
|
||||
// Link triggers to all the properties that would fire them when applied
|
||||
const tagTargets = getEffectTagTargets(prop, computation);
|
||||
switch (prop.event) {
|
||||
case 'doActionProperty':
|
||||
tagTargets.forEach(targetId => {
|
||||
const targetProp = computation.propsById[targetId];
|
||||
for (const targetId of tagTargets) {
|
||||
const targetProp = computation.propsById[targetId];
|
||||
switch (prop.event) {
|
||||
case 'doActionProperty':
|
||||
// Only apply if the trigger matches this property type
|
||||
if (targetProp.type !== prop.actionPropertyType) return;
|
||||
setTrigger(prop, targetProp);
|
||||
});
|
||||
break;
|
||||
case 'damageProperty':
|
||||
tagTargets.forEach(targetId => {
|
||||
const targetProp = computation.propsById[targetId];
|
||||
if (targetProp.type === prop.actionPropertyType) {
|
||||
setTrigger(prop, targetProp, 'triggerIds');
|
||||
}
|
||||
// Or on an item used as ammo
|
||||
else if (prop.actionPropertyType === 'ammo' && targetProp.type === 'item') {
|
||||
setTrigger(prop, targetProp, 'ammoTriggerIds');
|
||||
}
|
||||
break;
|
||||
case 'damageProperty':
|
||||
// Only apply to attributes
|
||||
if (targetProp.type !== 'attribute') return;
|
||||
setTrigger(prop, targetProp);
|
||||
});
|
||||
break;
|
||||
if (targetProp.type === 'attribute') {
|
||||
setTrigger(prop, targetProp, 'damageTriggerIds');
|
||||
}
|
||||
break;
|
||||
case 'check':
|
||||
// Only apply to attributes and skills
|
||||
if (targetProp.type === 'attribute' || targetProp.type === 'skill') {
|
||||
setTrigger(prop, targetProp, 'checkTriggerIds');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setTrigger(prop, targetProp) {
|
||||
let triggerIdArray = get(targetProp, `triggerIds.${prop.timing}`);
|
||||
function setTrigger(prop, targetProp, field = 'triggerIds') {
|
||||
let triggerIdArray = get(targetProp, `${field}.${prop.timing}`);
|
||||
if (!triggerIdArray) {
|
||||
triggerIdArray = [];
|
||||
set(targetProp, `triggerIds.${prop.timing}`, triggerIdArray);
|
||||
set(targetProp, `${field}.${prop.timing}`, triggerIdArray);
|
||||
}
|
||||
triggerIdArray.push(prop._id);
|
||||
}
|
||||
Reference in New Issue
Block a user