From 14edc7f4ca8ac6961cd8b92ae46a560d64c5cb81 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 19 Jul 2026 16:52:23 +0200 Subject: [PATCH] Fixed so that DamageRolls are actually stored with class='DamageRoll' in the chatMessage so they don't get instantiated as BaseRoll --- module/data/chat-message/actorRoll.mjs | 2 +- module/data/chat-message/chatDamageData.mjs | 2 +- module/dice/damageRoll.mjs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module/data/chat-message/actorRoll.mjs b/module/data/chat-message/actorRoll.mjs index dd81952b..1786f30a 100644 --- a/module/data/chat-message/actorRoll.mjs +++ b/module/data/chat-message/actorRoll.mjs @@ -203,7 +203,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel { const oldRoll = damageData.parts[0]?.roll; return oldRoll ? JSON.stringify({ ...oldRoll, - class: 'BaseRoll', + class: 'DamageRoll', options: { ...oldRoll.options, damageTypes: damageData.parts[0].damageTypes ?? [] diff --git a/module/data/chat-message/chatDamageData.mjs b/module/data/chat-message/chatDamageData.mjs index 2905558b..404cda43 100644 --- a/module/data/chat-message/chatDamageData.mjs +++ b/module/data/chat-message/chatDamageData.mjs @@ -28,7 +28,7 @@ export class ChatDamageData extends foundry.abstract.DataModel { } _prepareRolls() { - this.main &&= Roll.fromData({ ...this.main, class: 'DamageRoll' }); // Temp overriding to DamageRoll. Should be properly saved on creation instead + this.main &&= Roll.fromData(this.main); for (const key of Object.keys(this.resources)) { this.resources[key] = Roll.fromData(this.resources[key]); } diff --git a/module/dice/damageRoll.mjs b/module/dice/damageRoll.mjs index b4d093bb..2ca04a06 100644 --- a/module/dice/damageRoll.mjs +++ b/module/dice/damageRoll.mjs @@ -156,7 +156,7 @@ export default class DamageRoll extends DHRoll { if (!formulaData) return null; this.options.isCritical = config.isCritical; - formulaData.roll = new Roll(Roll.replaceFormulaData(formulaData.formula, config.data)); + formulaData.roll = new this.constructor(Roll.replaceFormulaData(formulaData.formula, config.data)); formulaData.roll.terms = Roll.parse(formulaData.roll.formula, config.data); if (formulaData.extraFormula) {