mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Fix resolving formulas in weapon change effects (#2035)
This commit is contained in:
parent
329d820aab
commit
9f29229c94
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'
|
||||
];
|
||||
|
||||
return Array.from(await actor.allApplicableEffects({ noTransferArmor: true, noSelfArmor: true })).reduce(
|
||||
(acc, effect) => {
|
||||
const effectData = effect.toObject();
|
||||
/* Effects on weapons only ever apply for the weapon itself, with a few defined exceptions */
|
||||
if (effect.parent.type === 'weapon') {
|
||||
/* Unless they're secondary - then they apply only to other primary weapons */
|
||||
if (effect.parent.system.secondary) {
|
||||
if (effectParent?.type !== 'weapon' || effectParent?.system.secondary) {
|
||||
effectData.system.changes =
|
||||
effectData.system.changes.filter(x => weaponTransferredEffectKeys.includes(x.key));
|
||||
}
|
||||
} else if (effectParent?.id !== effect.parent.id) {
|
||||
effectData.system.changes =
|
||||
effectData.system.changes.filter(x => weaponTransferredEffectKeys.includes(x.key));
|
||||
const results = [];
|
||||
const applicableEffects = await actor.allApplicableEffects({ noTransferArmor: true, noSelfArmor: true });
|
||||
for (const effect of [...applicableEffects].filter(e => !e.isSuppressed)) {
|
||||
if (effect.parent.type === 'weapon') {
|
||||
// Effects on weapons only ever apply for the weapon itself (with a few exceptions)
|
||||
const restricted =
|
||||
effect.parent.system.secondary
|
||||
// Secondary applies only to other primary weapons
|
||||
? effectParent?.type !== 'weapon' || effectParent?.system.secondary
|
||||
// Primary only applies to itself
|
||||
: effectParent?.id !== effect.parent.id;
|
||||
if (restricted) {
|
||||
const sourceChanges = effect._source.system.changes;
|
||||
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) {
|
||||
acc.push(effectData);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue