mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 15:03:37 +02:00
[v14] Add toggle for critical damage (#1762)
* Fix rolling critical damage after rerolling into a crit * Add toggle for critical damage --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
e3b433cce9
commit
2b8e4cb2fa
6 changed files with 51 additions and 2 deletions
|
|
@ -22,6 +22,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
},
|
||||
actions: {
|
||||
toggleSelectedEffect: this.toggleSelectedEffect,
|
||||
toggleCritical: this.toggleCritical,
|
||||
submitRoll: this.submitRoll
|
||||
},
|
||||
form: {
|
||||
|
|
@ -53,6 +54,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
context.hasHealing = this.config.hasHealing;
|
||||
context.directDamage = this.config.directDamage;
|
||||
context.selectedMessageMode = this.config.selectedMessageMode;
|
||||
context.isCritical = this.config.isCritical;
|
||||
context.rollModes = Object.entries(CONFIG.ChatMessage.modes).map(([action, { label, icon }]) => ({
|
||||
action,
|
||||
label,
|
||||
|
|
@ -74,6 +76,11 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
this.render();
|
||||
}
|
||||
|
||||
static toggleCritical() {
|
||||
this.config.isCritical = !this.config.isCritical;
|
||||
this.render();
|
||||
}
|
||||
|
||||
static toggleSelectedEffect(_event, button) {
|
||||
this.selectedEffects[button.dataset.key].selected = !this.selectedEffects[button.dataset.key].selected;
|
||||
this.render();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ export default class DamageRoll extends DHRoll {
|
|||
super(formula, data, options);
|
||||
}
|
||||
|
||||
get isCritical() {
|
||||
return !!this.options.isCritical;
|
||||
}
|
||||
|
||||
static DefaultDialog = DamageDialog;
|
||||
|
||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||
|
|
@ -138,6 +142,7 @@ export default class DamageRoll extends DHRoll {
|
|||
}
|
||||
|
||||
constructFormula(config) {
|
||||
this.options.isCritical = config.isCritical;
|
||||
for (const [index, part] of this.options.roll.entries()) {
|
||||
part.roll = new Roll(Roll.replaceFormulaData(part.formula, config.data));
|
||||
part.roll.terms = Roll.parse(part.roll.formula, config.data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue