From e8da2f46cb831562f4dffc0df559afe6c14fb257 Mon Sep 17 00:00:00 2001 From: Chris Ryan Date: Sat, 27 Dec 2025 11:52:37 +1000 Subject: [PATCH] Start on Guaranteed Critical for Blaze of Glory --- module/data/actor/character.mjs | 3 +++ module/dice/dualityRoll.mjs | 26 +++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index 448fba98..d46ddcc6 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -286,6 +286,9 @@ export default class DhCharacter extends BaseDataActor { runeWard: new fields.BooleanField({ initial: false }), burden: new fields.SchemaField({ ignore: new fields.BooleanField() + }), + roll: new fields.SchemaField({ + guaranteedCritical: new fields.BooleanField() }) }) }; diff --git a/module/dice/dualityRoll.mjs b/module/dice/dualityRoll.mjs index 91c0a197..8a4364fb 100644 --- a/module/dice/dualityRoll.mjs +++ b/module/dice/dualityRoll.mjs @@ -12,6 +12,8 @@ export default class DualityRoll extends D20Roll { constructor(formula, data = {}, options = {}) { super(formula, data, options); this.rallyChoices = this.setRallyChoices(); + this.guaranteedCritical = this.setGuaranteedCritical(); + console.log("guaranteedCritical", this.guaranteedCritical); } static messageType = 'dualityRoll'; @@ -70,6 +72,18 @@ export default class DualityRoll extends D20Roll { this._advantageNumber = Number(value); } + setGuaranteedCritical() { + console.log("setGuaranteedCritical", this); + return this.data?.parent?.appliedEffects.reduce((a, c) => { + console.log("a,c", a,c); + + const change = c.changes.find(ch => ch.key === 'system.rules.role.guaranteedCritical'); + console.log("change", change); + if (change) a.push({ value: c.id, label: change.value }); + return a; + }, false); + } + setRallyChoices() { return this.data?.parent?.appliedEffects.reduce((a, c) => { const change = c.changes.find(ch => ch.key === 'system.bonuses.rally'); @@ -90,6 +104,11 @@ export default class DualityRoll extends D20Roll { } get isCritical() { + if (this.guaranteedCritical) { + this.dHope.total = this.dice[0]?.faces ?? 12; + this.dFear.total = this.dice[1]?.faces ?? 12; + return true; + } if (!this.dHope._evaluated || !this.dFear._evaluated) return; return this.dHope.total === this.dFear.total; } @@ -105,11 +124,8 @@ export default class DualityRoll extends D20Roll { } get totalLabel() { - const label = this.withHope - ? 'DAGGERHEART.GENERAL.hope' - : this.withFear - ? 'DAGGERHEART.GENERAL.fear' - : 'DAGGERHEART.GENERAL.criticalSuccess'; + const label = this.isCritical ? 'DAGGERHEART.GENERAL.criticalSuccess' : + this.withHope ? 'DAGGERHEART.GENERAL.hope' : 'DAGGERHEART.GENERAL.fear'; return game.i18n.localize(label); }