mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Fixed so that the forced critical toggle in the DamageDialog sets damageRoll.options.isCritical
This commit is contained in:
parent
c0fe127df4
commit
cfb6bc2479
3 changed files with 22 additions and 4 deletions
|
|
@ -121,7 +121,14 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
||||||
}
|
}
|
||||||
|
|
||||||
static async submitRoll() {
|
static async submitRoll() {
|
||||||
|
const isCritical = this.config.isCritical;
|
||||||
const { damageFormula, resourceFormulas } = this.roll.constructFormulas({ ...this.config, isCritical: false });
|
const { damageFormula, resourceFormulas } = this.roll.constructFormulas({ ...this.config, isCritical: false });
|
||||||
|
/* Sideeffect occuring in constructFormulas that sets this.config.isCritical to the false value. Can remove the below if it can be prevented */
|
||||||
|
this.config.isCritical = isCritical;
|
||||||
|
damageFormula.roll.options.isCritical = isCritical;
|
||||||
|
for (const formula of resourceFormulas)
|
||||||
|
formula.roll.options.isCritical = isCritical;
|
||||||
|
|
||||||
this.config.damageFormula = damageFormula;
|
this.config.damageFormula = damageFormula;
|
||||||
this.config.resourceFormulas = resourceFormulas;
|
this.config.resourceFormulas = resourceFormulas;
|
||||||
await this.close({ submitted: true });
|
await this.close({ submitted: true });
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ export class ChatDamageData extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
get isCritical() {
|
get isCritical() {
|
||||||
|
if (!this.parent?.parent) return false;
|
||||||
|
|
||||||
const roll = Roll.fromJSON(this.parent.parent._source.rolls[0]);
|
const roll = Roll.fromJSON(this.parent.parent._source.rolls[0]);
|
||||||
return roll.isCritical;
|
return roll.isCritical;
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +35,14 @@ export class ChatDamageData extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_prepareRolls() {
|
_prepareRolls() {
|
||||||
this.main &&= Roll.fromData({ ...this.main, options: { ...this.main.options, isCritical: this.isCritical } });
|
this.main &&= Roll.fromData({
|
||||||
|
...this.main,
|
||||||
|
options: {
|
||||||
|
...this.main.options,
|
||||||
|
isCritical: this.main.options.isCritical || this.isCritical
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
for (const key of Object.keys(this.resources)) {
|
for (const key of Object.keys(this.resources)) {
|
||||||
this.resources[key] = Roll.fromData(this.resources[key]);
|
this.resources[key] = Roll.fromData(this.resources[key]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export default class DamageRoll extends DHRoll {
|
||||||
|
|
||||||
const evaluateRoll = async roll => {
|
const evaluateRoll = async roll => {
|
||||||
await roll.roll.evaluate();
|
await roll.roll.evaluate();
|
||||||
roll.roll.options = { damageTypes: roll.damageTypes ? [...roll.damageTypes] : [] };
|
roll.roll.options = { ...roll.roll.options, damageTypes: roll.damageTypes ? [...roll.damageTypes] : [] };
|
||||||
return roll.roll;
|
return roll.roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +41,9 @@ export default class DamageRoll extends DHRoll {
|
||||||
|
|
||||||
if (config.damageFormula) {
|
if (config.damageFormula) {
|
||||||
config.damage.main = await evaluateRoll(config.damageFormula);
|
config.damage.main = await evaluateRoll(config.damageFormula);
|
||||||
config.damage.main.options = { damageTypes:
|
config.damage.main.options = {
|
||||||
|
...config.damage.main.options,
|
||||||
|
damageTypes:
|
||||||
config.damageFormula.damageTypes ? [...config.damageFormula.damageTypes] : []
|
config.damageFormula.damageTypes ? [...config.damageFormula.damageTypes] : []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue