From c68b3045f2952dfbd7ca047e1a8318a71a7f5fd2 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Fri, 17 Jul 2026 15:48:41 +0200 Subject: [PATCH] TagTeamDialog fixes to accomodate new flat damage.types structure --- module/applications/dialogs/tagTeamDialog.mjs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/module/applications/dialogs/tagTeamDialog.mjs b/module/applications/dialogs/tagTeamDialog.mjs index e6492c50..2b865304 100644 --- a/module/applications/dialogs/tagTeamDialog.mjs +++ b/module/applications/dialogs/tagTeamDialog.mjs @@ -612,14 +612,13 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio async getCriticalDamage(origDamage) { const newDamage = origDamage ? ChatDamageData.fromJSON(JSON.stringify(origDamage)) : null; for (let key in newDamage?.types ?? {}) { - const damage = newDamage.types[key]; - const criticalDamage = await getCritDamageBonus(damage.roll.formula); + const criticalDamage = await getCritDamageBonus(newDamage.types[key].formula); if (!criticalDamage) continue; const criticalTerm = new foundry.dice.terms.NumericTerm({ number: criticalDamage, evaluated: true }); criticalTerm.evaluate(); - damage.roll = await Roll.fromTerms([ - ...origDamage.types[key].roll.terms, + newDamage.types[key] = await Roll.fromTerms([ + ...origDamage.types[key].terms, new foundry.dice.terms.OperatorTerm({ operator: '+' }), criticalTerm ]); @@ -675,10 +674,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio if (mainRoll.damageRollData) { for (const [key, damage] of Object.entries(secondaryDamage.types ?? {})) { if (key in mainRoll.damageRollData.types) { - mainRoll.damageRollData.types[key].roll = Roll.fromTerms([ - ...baseMainRoll.damageRollData.types[key].roll.terms, + mainRoll.damageRollData.types[key] = Roll.fromTerms([ + ...baseMainRoll.damageRollData.types[key].terms, new foundry.dice.terms.OperatorTerm({ operator: '+' }), - ...baseSecondaryRoll.damageRollData.types[key].roll.terms + ...baseSecondaryRoll.damageRollData.types[key].terms ]); } else { mainRoll.damageRollData.types[key] = damage; @@ -744,10 +743,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio /* This could assumably be done better. For some reason rolls don't get correctly done through rollData.toJSON */ const systemData = { ...mainRoll.options, - damage: joinedRoll.damageRollData.toJSON() + damage: joinedRoll.damageRollData?.toJSON() }; - for (const type of Object.keys(joinedRoll.damageRollData.types)) { - systemData.damage.types[type].roll = joinedRoll.damageRollData.types[type].roll.toJSON(); + for (const type of Object.keys(joinedRoll.damageRollData?.types ?? {})) { + systemData.damage.types[type] = joinedRoll.damageRollData.types[type].toJSON(); } const cls = getDocumentClass('ChatMessage'),