From 22c3212e5efaa703ea0ff77685781ab0da5346cc Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 28 May 2026 18:38:36 +0200 Subject: [PATCH] Fixed --- module/data/fields/action/rollField.mjs | 19 +++++++++++++++++++ module/dice/d20Roll.mjs | 24 +----------------------- module/dice/dhRoll.mjs | 1 + module/dice/dualityRoll.mjs | 8 +------- 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/module/data/fields/action/rollField.mjs b/module/data/fields/action/rollField.mjs index a1c813c6..63d48990 100644 --- a/module/data/fields/action/rollField.mjs +++ b/module/data/fields/action/rollField.mjs @@ -78,6 +78,24 @@ 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) { @@ -127,6 +145,7 @@ 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 346f6b87..2cc6baf6 100644 --- a/module/dice/d20Roll.mjs +++ b/module/dice/d20Roll.mjs @@ -128,30 +128,8 @@ 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 = this.getBaseModifiers(); + const modifiers = foundry.utils.deepClone(this.options.roll.baseModifiers) ?? []; modifiers.push( ...this.getBonus( diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index d6975f71..6cda50ae 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -85,6 +85,7 @@ export default class DHRoll extends Roll { static postEvaluate(roll, config = {}) { return { + ...roll.options.roll, total: roll.total, formula: roll.formula, dice: roll.dice.map(d => ({ diff --git a/module/dice/dualityRoll.mjs b/module/dice/dualityRoll.mjs index 63f21667..6042ae3d 100644 --- a/module/dice/dualityRoll.mjs +++ b/module/dice/dualityRoll.mjs @@ -132,13 +132,7 @@ export default class DualityRoll extends D20Roll { } createBaseDice() { - if ( - this.dice[0] instanceof game.system.api.dice.diceTypes.HopeDie && - this.dice[1] instanceof game.system.api.dice.diceTypes.FearDie - ) { - this.terms = [this.terms[0], this.terms[1], this.terms[2]]; - return; - } + this.terms = [this.terms[0], this.terms[1], this.terms[2]]; this.terms[0] = new game.system.api.dice.diceTypes.HopeDie({ faces: this.data.rules.dualityRoll?.defaultHopeDice ?? 12