mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Fix resolving formulas in weapon change effects
This commit is contained in:
parent
329d820aab
commit
bf1cc504dc
1 changed files with 22 additions and 20 deletions
|
|
@ -348,29 +348,31 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
'system.bonuses.roll.spellcast.bonus'
|
'system.bonuses.roll.spellcast.bonus'
|
||||||
];
|
];
|
||||||
|
|
||||||
return Array.from(await actor.allApplicableEffects({ noTransferArmor: true, noSelfArmor: true })).reduce(
|
const results = [];
|
||||||
(acc, effect) => {
|
const applicableEffects = await actor.allApplicableEffects({ noTransferArmor: true, noSelfArmor: true });
|
||||||
const effectData = effect.toObject();
|
for (const effect of [...applicableEffects].filter(e => !e.isSuppressed)) {
|
||||||
/* Effects on weapons only ever apply for the weapon itself, with a few defined exceptions */
|
if (effect.parent.type === 'weapon') {
|
||||||
if (effect.parent.type === 'weapon') {
|
// Effects on weapons only ever apply for the weapon itself (with a few exceptions)
|
||||||
/* Unless they're secondary - then they apply only to other primary weapons */
|
const restricted =
|
||||||
if (effect.parent.system.secondary) {
|
effect.parent.system.secondary
|
||||||
if (effectParent?.type !== 'weapon' || effectParent?.system.secondary) {
|
// Secondary applies only to other primary weapons
|
||||||
effectData.system.changes =
|
? effectParent?.type !== 'weapon' || effectParent?.system.secondary
|
||||||
effectData.system.changes.filter(x => weaponTransferredEffectKeys.includes(x.key));
|
// Primary only applies to itself
|
||||||
}
|
: effectParent?.id !== effect.parent.id;
|
||||||
} else if (effectParent?.id !== effect.parent.id) {
|
if (restricted) {
|
||||||
effectData.system.changes =
|
const sourceChanges = effect._source.system.changes;
|
||||||
effectData.system.changes.filter(x => weaponTransferredEffectKeys.includes(x.key));
|
const changes = sourceChanges.filter(x => weaponTransferredEffectKeys.includes(x.key));
|
||||||
|
if (changes.length) {
|
||||||
|
results.push(effect.clone({ 'system.changes': changes }));
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
results.push(effect);
|
||||||
|
}
|
||||||
|
|
||||||
if (!effect.isSuppressed) {
|
return results;
|
||||||
acc.push(effectData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, []);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue