From e25cf0c4cd6fc3e98f6f95ad19fd845fdbeb3b6b Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 6 Jul 2026 16:00:49 +0200 Subject: [PATCH 1/6] Fixed so that dice css uses specific results.denomation if available --- module/dice/die/baseDie.mjs | 19 +++++++++++++++++++ templates/ui/chat/parts/damage-part.hbs | 2 +- templates/ui/chat/parts/roll-part.hbs | 7 ++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/module/dice/die/baseDie.mjs b/module/dice/die/baseDie.mjs index ed44cb39..fa6086c3 100644 --- a/module/dice/die/baseDie.mjs +++ b/module/dice/die/baseDie.mjs @@ -30,4 +30,23 @@ export default class BaseDie extends foundry.dice.terms.Die { return this.continueCombo(); } + + /** @override */ + getResultCSS(result) { + const hasSuccess = result.success !== undefined; + const hasFailure = result.failure !== undefined; + const isMax = result.result === this.faces; + const isMin = result.result === 1; + return [ + this.constructor.name.toLowerCase(), + result.denomination ?? this.denomination, // Accomodating ComboDie as a result can have a different denomination than the die as a whole + result.success ? 'success' : null, + result.failure ? 'failure' : null, + result.rerolled ? 'rerolled' : null, + result.exploded ? 'exploded' : null, + result.discarded ? 'discarded' : null, + !(hasSuccess || hasFailure) && isMin ? 'min' : null, + !(hasSuccess || hasFailure) && isMax ? 'max' : null + ]; + } } \ No newline at end of file diff --git a/templates/ui/chat/parts/damage-part.hbs b/templates/ui/chat/parts/damage-part.hbs index 45b09b72..9636e066 100644 --- a/templates/ui/chat/parts/damage-part.hbs +++ b/templates/ui/chat/parts/damage-part.hbs @@ -39,7 +39,7 @@ {{#unless discarded}}
{{#if hasRerolls}}{{/if}} diff --git a/templates/ui/chat/parts/roll-part.hbs b/templates/ui/chat/parts/roll-part.hbs index cfee735f..2c5c150a 100644 --- a/templates/ui/chat/parts/roll-part.hbs +++ b/templates/ui/chat/parts/roll-part.hbs @@ -84,8 +84,13 @@ {{else}} {{#each roll.dice}} {{#each results}} + {{debug this}}
-
+
{{result}}
From 9fba3392306af822fc53b85bd283598a7e79619a Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 6 Jul 2026 19:52:15 +0200 Subject: [PATCH 2/6] Fixed DiceSoNice using the upgraded DiceSizes for 2d4c1 --- module/dice/die/baseDie.mjs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/module/dice/die/baseDie.mjs b/module/dice/die/baseDie.mjs index fa6086c3..30013586 100644 --- a/module/dice/die/baseDie.mjs +++ b/module/dice/die/baseDie.mjs @@ -11,7 +11,25 @@ export default class BaseDie extends foundry.dice.terms.Die { if (this.number !== 2) return false; const maxIncreasesDiceSize = modifier.endsWith('1'); - return this.continueCombo(maxIncreasesDiceSize); + const result = await this.continueCombo(maxIncreasesDiceSize); + + /* The flow of DiceSoNice has no way of knowign that some of the results of a Die should be a different denomination + We solve this by marking the results as hidden so they're not picked up by the auto roll of DiceSoNice. + The actual rolls are done here in place so every dice gets the correct denomination. + */ + if (game.modules.get('dice-so-nice')?.active) { + await Promise.allSettled(this.results.map(async result => { + const roll = await (new Roll(`1${result.denomination ?? this.denomination}`)).evaluate(); + roll.terms[0].results = [result]; + roll._evaluateTotal(); + return game.dice3d.showForRoll(roll, game.user, false); + })); + } + + for (const result of this.results) + result.hidden = true; + + return result; } async continueCombo(maxIncreasesDiceSize) { From 7ab7cc9787d64f190899621ed1c8422888432a0e Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 6 Jul 2026 20:03:51 +0200 Subject: [PATCH 3/6] Fixed so things are awaited properly if there are more dice to be rolled --- module/dice/die/baseDie.mjs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/module/dice/die/baseDie.mjs b/module/dice/die/baseDie.mjs index 30013586..867ee699 100644 --- a/module/dice/die/baseDie.mjs +++ b/module/dice/die/baseDie.mjs @@ -18,12 +18,22 @@ export default class BaseDie extends foundry.dice.terms.Die { The actual rolls are done here in place so every dice gets the correct denomination. */ if (game.modules.get('dice-so-nice')?.active) { - await Promise.allSettled(this.results.map(async result => { + const rolls = []; + for (const result of this.results) { const roll = await (new Roll(`1${result.denomination ?? this.denomination}`)).evaluate(); roll.terms[0].results = [result]; roll._evaluateTotal(); - return game.dice3d.showForRoll(roll, game.user, false); - })); + rolls.push(roll); + } + + /* If there are other dice that will be rolled we cannot await here. The other dice will be awaited in the normal flow */ + if (this._root.dice.length > 1) { + for (const roll of rolls) { + game.dice3d.showForRoll(roll, game.user, true); + } + } else { + await Promise.allSettled(rolls.map(roll => game.dice3d.showForRoll(roll, game.user, true))); + } } for (const result of this.results) From f9771635344c1a7d889370c35d4c598eed05dafb Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 6 Jul 2026 21:00:00 +0200 Subject: [PATCH 4/6] Swapped to registering two modifiers, c for comboStrike and cc for compoundComboStrike --- module/dice/die/baseDie.mjs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/module/dice/die/baseDie.mjs b/module/dice/die/baseDie.mjs index 867ee699..d0de4582 100644 --- a/module/dice/die/baseDie.mjs +++ b/module/dice/die/baseDie.mjs @@ -3,14 +3,22 @@ import { adjustDice } from '../../helpers/utils.mjs'; export default class BaseDie extends foundry.dice.terms.Die { static MODIFIERS = { ...foundry.dice.terms.Die.MODIFIERS, + cc: 'compoundComboDice', c: 'comboDice' }; - async comboDice(modifier) { + async compoundComboDice() { + return this.handleComboDice(true); + } + + async comboDice() { + return this.handleComboDice(false); + } + + async handleComboDice(maxIncreasesDiceSize) { /* ComboDice only works with exactly two dice and both have to be the same denomination */ if (this.number !== 2) return false; - const maxIncreasesDiceSize = modifier.endsWith('1'); const result = await this.continueCombo(maxIncreasesDiceSize); /* The flow of DiceSoNice has no way of knowign that some of the results of a Die should be a different denomination @@ -56,7 +64,7 @@ export default class BaseDie extends foundry.dice.terms.Die { this.results.push({ result: newRoll.total, denomination: denomination, active: true }); this.number += 1; - return this.continueCombo(); + return this.continueCombo(maxIncreasesDiceSize); } /** @override */ From 3b87e1d4a8f4c80a70b45e3c159dffbbc55442bb Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 6 Jul 2026 21:03:59 +0200 Subject: [PATCH 5/6] Added a warning notification if comboDice modifiers are used on anything but a pair of dice --- lang/en.json | 3 ++- module/dice/die/baseDie.mjs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lang/en.json b/lang/en.json index b9a81b29..e24eef0f 100755 --- a/lang/en.json +++ b/lang/en.json @@ -3253,7 +3253,8 @@ "knowTheTide": "Know The Tide gained a token", "lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}", "noTokenTargeted": "No token is targeted", - "behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM" + "behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM", + "comboDiceOnlyTwoDiceError": "Combo dice functionality only works on a single pair of two dice" }, "Progress": { "migrationLabel": "Performing system migration. Please wait and do not close Foundry." diff --git a/module/dice/die/baseDie.mjs b/module/dice/die/baseDie.mjs index d0de4582..0798db26 100644 --- a/module/dice/die/baseDie.mjs +++ b/module/dice/die/baseDie.mjs @@ -17,7 +17,10 @@ export default class BaseDie extends foundry.dice.terms.Die { async handleComboDice(maxIncreasesDiceSize) { /* ComboDice only works with exactly two dice and both have to be the same denomination */ - if (this.number !== 2) return false; + if (this.number !== 2) { + ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.comboDiceOnlyTwoDiceError')); + return false; + } const result = await this.continueCombo(maxIncreasesDiceSize); From e6f26deab9216aa6f134a0e05bc9a7d1b5f71a20 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 6 Jul 2026 22:22:05 +0200 Subject: [PATCH 6/6] Corrected ot Higher or Equal to for combo to continue --- module/dice/die/baseDie.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/dice/die/baseDie.mjs b/module/dice/die/baseDie.mjs index 0798db26..37c47d1d 100644 --- a/module/dice/die/baseDie.mjs +++ b/module/dice/die/baseDie.mjs @@ -56,8 +56,8 @@ export default class BaseDie extends foundry.dice.terms.Die { async continueCombo(maxIncreasesDiceSize) { const lastIndex = this.results.length - 1; - /* The Combo only continues if the latest roll was higher than the previous */ - if (this.results[lastIndex].result <= this.results[lastIndex - 1].result) return false; + /* The Combo only continues if the latest roll was higher or equal to the previous */ + if (this.results[lastIndex].result < this.results[lastIndex - 1].result) return false; const lastFaces = this.results[lastIndex].denomination?.slice(1) ?? this.faces; const increaseDiceSize = maxIncreasesDiceSize && lastFaces < 12 && this.results[lastIndex].result === lastFaces;