From 505cc634d356e903f2057c993d5fde5282dba584 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Wed, 27 May 2026 20:56:07 +0200 Subject: [PATCH] Fixed d20 modifiers --- module/data/fields/action/rollField.mjs | 19 ------------------- module/dice/d20Roll.mjs | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/module/data/fields/action/rollField.mjs b/module/data/fields/action/rollField.mjs index 63d48990..a1c813c6 100644 --- a/module/data/fields/action/rollField.mjs +++ b/module/data/fields/action/rollField.mjs @@ -78,24 +78,6 @@ export class DHActionRollData extends foundry.abstract.DataModel { return formula; } - getModifier() { - const modifiers = []; - if (!this.parent?.actor) return modifiers; - switch (this.parent.actor.type) { - case 'companion': - case 'adversary': - if (this.type === CONFIG.DH.GENERAL.rollTypes.attack.id) - modifiers.push({ - label: 'Bonus to Hit', - value: this.bonus ?? this.parent.actor.system.attack.roll.bonus ?? 0 - }); - break; - default: - break; - } - return modifiers; - } - get rollTrait() { if (this.parent?.actor?.type !== 'character') return null; switch (this.type) { @@ -145,7 +127,6 @@ export default class RollField extends fields.EmbeddedDataField { config.dialog.configure = RollField.getAutomation() ? !config.dialog.configure : config.dialog.configure; const roll = { - baseModifiers: this.roll.getModifier(), label: 'Attack', type: this.roll?.type, trait: this.roll?.rollTrait, diff --git a/module/dice/d20Roll.mjs b/module/dice/d20Roll.mjs index 2cc6baf6..346f6b87 100644 --- a/module/dice/d20Roll.mjs +++ b/module/dice/d20Roll.mjs @@ -128,8 +128,30 @@ export default class D20Roll extends DHRoll { } } + getBaseModifiers() { + const modifiers = []; + const actor = foundry.utils.fromUuidSync(this.options.source.actor); + if (!actor) return modifiers; + switch (actor.type) { + case 'companion': + case 'adversary': + if ( + this.options.roll.type === CONFIG.DH.GENERAL.rollTypes.attack.id || + this.options.source.action === actor.system.attack.id + ) + modifiers.push({ + label: 'Bonus to Hit', + value: this.data.attack.roll.bonus ?? 0 + }); + break; + default: + break; + } + return modifiers; + } + applyBaseBonus() { - const modifiers = foundry.utils.deepClone(this.options.roll.baseModifiers) ?? []; + const modifiers = this.getBaseModifiers(); modifiers.push( ...this.getBonus(