mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
[Fix] Weapon Spellcasting Active Effects (#2032)
* . * . * Apply suggestion from @CarlosFdez --------- Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
This commit is contained in:
parent
1492491998
commit
8e93025947
5 changed files with 32 additions and 15 deletions
|
|
@ -518,7 +518,7 @@ export default function DHApplicationMixin(Base) {
|
||||||
const doc = await getDocFromElement(target),
|
const doc = await getDocFromElement(target),
|
||||||
action = doc?.system?.attack ?? doc;
|
action = doc?.system?.attack ?? doc;
|
||||||
const config = action.prepareConfig(event);
|
const config = action.prepareConfig(event);
|
||||||
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(
|
config.effects = await game.system.api.data.actions.actionsTypes.base.getActionRelevantEffects(
|
||||||
this.document,
|
this.document,
|
||||||
doc
|
doc
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
||||||
const doc = await getDocFromElement(target),
|
const doc = await getDocFromElement(target),
|
||||||
action = doc?.system?.attack ?? doc;
|
action = doc?.system?.attack ?? doc;
|
||||||
const config = action.prepareConfig(event);
|
const config = action.prepareConfig(event);
|
||||||
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(
|
config.effects = await game.system.api.data.actions.actionsTypes.base.getActionRelevantEffects(
|
||||||
this.document,
|
this.document,
|
||||||
doc
|
doc
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
let config = this.prepareConfig(event, configOptions);
|
let config = this.prepareConfig(event, configOptions);
|
||||||
if (!config) return;
|
if (!config) return;
|
||||||
|
|
||||||
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(this.actor, this.item);
|
config.effects =
|
||||||
|
await game.system.api.data.actions.actionsTypes.base.getActionRelevantEffects(this.actor, this.item);
|
||||||
|
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
|
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
|
||||||
|
|
||||||
|
|
@ -333,27 +334,43 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the all potentially applicable effects on the actor
|
* Get the all potentially applicable effects on the actor for the action's RollDialog
|
||||||
* @param {DHActor} actor The actor performing the action
|
* @param {DHActor} actor The actor performing the action
|
||||||
* @param {DHItem|DhActor} effectParent The parent of the effect
|
* @param {DHItem|DhActor} effectParent The parent of the effect
|
||||||
* @returns {DhActiveEffect[]}
|
* @returns {DhActiveEffect[]}
|
||||||
*/
|
*/
|
||||||
static async getEffects(actor, effectParent) {
|
static async getActionRelevantEffects(actor, effectParent) {
|
||||||
if (!actor) return [];
|
if (!actor) return [];
|
||||||
|
|
||||||
return Array.from(await actor.allApplicableEffects({ noTransferArmor: true, noSelfArmor: true })).filter(
|
// Changes on weapon effects are not typically only applicable to show in the roll dialog for the weapon itself
|
||||||
effect => {
|
// The exemptions to this rule are listed below
|
||||||
/* Effects on weapons only ever apply for the weapon itself */
|
const weaponTransferredEffectKeys = [
|
||||||
|
'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') {
|
if (effect.parent.type === 'weapon') {
|
||||||
/* Unless they're secondary - then they apply only to other primary weapons */
|
/* Unless they're secondary - then they apply only to other primary weapons */
|
||||||
if (effect.parent.system.secondary) {
|
if (effect.parent.system.secondary) {
|
||||||
if (effectParent?.type !== 'weapon' || effectParent?.system.secondary) return false;
|
if (effectParent?.type !== 'weapon' || effectParent?.system.secondary) {
|
||||||
} else if (effectParent?.id !== effect.parent.id) return false;
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !effect.isSuppressed;
|
if (!effect.isSuppressed) {
|
||||||
|
acc.push(effectData);
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -549,7 +549,7 @@ export default class DhpActor extends Actor {
|
||||||
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
||||||
ability: abilityLabel
|
ability: abilityLabel
|
||||||
}),
|
}),
|
||||||
effects: await game.system.api.data.actions.actionsTypes.base.getEffects(this),
|
effects: await game.system.api.data.actions.actionsTypes.base.getActionRelevantEffects(this),
|
||||||
roll: {
|
roll: {
|
||||||
trait: trait,
|
trait: trait,
|
||||||
type: 'trait'
|
type: 'trait'
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
||||||
if (this.system.action) {
|
if (this.system.action) {
|
||||||
const actor = await foundry.utils.fromUuid(config.source.actor);
|
const actor = await foundry.utils.fromUuid(config.source.actor);
|
||||||
const item = actor?.items.get(config.source.item) ?? null;
|
const item = actor?.items.get(config.source.item) ?? null;
|
||||||
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(actor, item);
|
config.effects = await game.system.api.data.actions.actionsTypes.base.getActionRelevantEffects(actor, item);
|
||||||
await this.system.action.workflow.get('damage')?.execute(config, this._id, true);
|
await this.system.action.workflow.get('damage')?.execute(config, this._id, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue