mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
* Fixed translation of TrackedAttributeChoices * Styling improvements * Added hints * fix autocomplete style, fix tagify style, fix magical and physical tag style and fix lang in details adversary settings * Removed commented out code * Some companion fixes --------- Co-authored-by: moliloo <dev.murilobrito@gmail.com>
54 lines
1.9 KiB
JavaScript
54 lines
1.9 KiB
JavaScript
import DamageDialog from '../applications/dialogs/damageDialog.mjs';
|
|
import DHRoll from './dhRoll.mjs';
|
|
|
|
export default class DamageRoll extends DHRoll {
|
|
constructor(formula, data = {}, options = {}) {
|
|
super(formula, data, options);
|
|
}
|
|
|
|
static messageType = 'damageRoll';
|
|
|
|
static DefaultDialog = DamageDialog;
|
|
|
|
static async postEvaluate(roll, config = {}) {
|
|
super.postEvaluate(roll, config);
|
|
config.roll.type = config.type;
|
|
config.roll.modifierTotal = this.calculateTotalModifiers(roll);
|
|
}
|
|
|
|
static async buildPost(roll, config, message) {
|
|
await super.buildPost(roll, config, message);
|
|
if (config.source?.message) {
|
|
const chatMessage = ui.chat.collection.get(config.source.message);
|
|
chatMessage.update({ 'system.damage': config });
|
|
}
|
|
}
|
|
|
|
applyBaseBonus() {
|
|
const modifiers = [],
|
|
type = this.options.messageType ?? 'damage';
|
|
|
|
modifiers.push(...this.getBonus(`${type}`, `${type.capitalize()} Bonus`));
|
|
this.options.damageTypes?.forEach(t => {
|
|
modifiers.push(...this.getBonus(`${type}.${t}`, `${t.capitalize()} ${type.capitalize()} Bonus`));
|
|
});
|
|
const weapons = ['primaryWeapon', 'secondaryWeapon'];
|
|
weapons.forEach(w => {
|
|
if (this.options.source.item && this.options.source.item === this.data[w]?.id)
|
|
modifiers.push(...this.getBonus(`${type}.${w}`, 'Weapon Bonus'));
|
|
});
|
|
|
|
return modifiers;
|
|
}
|
|
|
|
constructFormula(config) {
|
|
super.constructFormula(config);
|
|
|
|
if (config.isCritical) {
|
|
const tmpRoll = new Roll(this._formula)._evaluateSync({ maximize: true }),
|
|
criticalBonus = tmpRoll.total - this.constructor.calculateTotalModifiers(tmpRoll);
|
|
this.terms.push(...this.formatModifier(criticalBonus));
|
|
}
|
|
return (this._formula = this.constructor.getFormula(this.terms));
|
|
}
|
|
}
|