Change the critical damage max calculation (#890)

* Change the critical damage max calculation to avoid setting the rolled portion to maximum all the time.

* Change to the more neater code

* Restored package.json

---------

Co-authored-by: Chris Ryan <chrisr@blackhole>
Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
Chris Ryan 2025-08-13 18:08:43 +10:00 committed by GitHub
parent 18f3c47635
commit c4f35aef9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -137,9 +137,10 @@ export default class DamageRoll extends DHRoll {
}
if (config.isCritical && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
const tmpRoll = Roll.fromTerms(part.roll.terms)._evaluateSync({ maximize: true }),
criticalBonus = tmpRoll.total - this.constructor.calculateTotalModifiers(tmpRoll);
part.roll.terms.push(...this.formatModifier(criticalBonus));
const total = part.roll.dice.reduce((acc, term) => acc + term._faces*term._number, 0);
if (total > 0) {
part.roll.terms.push(...this.formatModifier(total));
}
}
/* To Remove When Reaction System */