mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Added overrides to modifierTotal and total getters in DamageRoll to addin critical damage when applicable
This commit is contained in:
parent
14edc7f4ca
commit
c0fe127df4
3 changed files with 13 additions and 3 deletions
|
|
@ -7,6 +7,11 @@ export class ChatDamageData extends foundry.abstract.DataModel {
|
||||||
this._prepareRolls();
|
this._prepareRolls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isCritical() {
|
||||||
|
const roll = Roll.fromJSON(this.parent.parent._source.rolls[0]);
|
||||||
|
return roll.isCritical;
|
||||||
|
}
|
||||||
|
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
|
|
@ -28,7 +33,7 @@ export class ChatDamageData extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_prepareRolls() {
|
_prepareRolls() {
|
||||||
this.main &&= Roll.fromData(this.main);
|
this.main &&= Roll.fromData({ ...this.main, options: { ...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]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ export default class DamageField extends fields.SchemaField {
|
||||||
if (configDamage.main) {
|
if (configDamage.main) {
|
||||||
const multiplier = config.actionActor?.system.rules?.attack?.damage?.hpDamageMultiplier ?? 1;
|
const multiplier = config.actionActor?.system.rules?.attack?.damage?.hpDamageMultiplier ?? 1;
|
||||||
const takenMultiplier = actor.system.rules?.attack?.damage?.hpDamageTakenMultiplier;
|
const takenMultiplier = actor.system.rules?.attack?.damage?.hpDamageTakenMultiplier;
|
||||||
configDamage.main.total = Math.ceil(configDamage.main.total * multiplier * takenMultiplier);
|
configDamage.main.total = Math.ceil(config.damage.main.total * multiplier * takenMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
damagePromises.push(
|
damagePromises.push(
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export default class DamageRoll extends DHRoll {
|
||||||
}
|
}
|
||||||
|
|
||||||
get isCritical() {
|
get isCritical() {
|
||||||
return true;
|
return this.options.isCritical;
|
||||||
}
|
}
|
||||||
|
|
||||||
get modifierTotal() {
|
get modifierTotal() {
|
||||||
|
|
@ -16,6 +16,11 @@ export default class DamageRoll extends DHRoll {
|
||||||
return super.modifierTotal + criticalDamageBonus;
|
return super.modifierTotal + criticalDamageBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get total() {
|
||||||
|
const criticalDamageBonus = this.isCritical ? getCritDamageBonus(this.terms) : 0;
|
||||||
|
return super.total + criticalDamageBonus;
|
||||||
|
}
|
||||||
|
|
||||||
static DefaultDialog = DamageDialog;
|
static DefaultDialog = DamageDialog;
|
||||||
|
|
||||||
static createRollInstance(config) {
|
static createRollInstance(config) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue