diff --git a/daggerheart.mjs b/daggerheart.mjs index 94f243b8..4641c34a 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -24,7 +24,7 @@ import TokenManager from './module/documents/tokenManager.mjs'; CONFIG.DH = SYSTEM; CONFIG.TextEditor.enrichers.push(...enricherConfig); -CONFIG.Dice.rolls = [BaseRoll, Roll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll]; +CONFIG.Dice.rolls = [Roll = BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll]; CONFIG.Dice.daggerheart = { DHRoll: DHRoll, DualityRoll: DualityRoll, diff --git a/module/data/chat-message/actorRoll.mjs b/module/data/chat-message/actorRoll.mjs index 376e7e3a..16c7f2b6 100644 --- a/module/data/chat-message/actorRoll.mjs +++ b/module/data/chat-message/actorRoll.mjs @@ -188,8 +188,8 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel { } static migrateData(source) { - const { main, resources, ...flatDamageKeys } = source.damage; - if (!main && !resources) { + const { main, resources, ...flatDamageKeys } = source.damage ?? {}; + if (source.damage && !main && !resources) { source.damage.main = null; source.damage.resources = {}; diff --git a/module/dice/damageRoll.mjs b/module/dice/damageRoll.mjs index c78a42e9..c5b01438 100644 --- a/module/dice/damageRoll.mjs +++ b/module/dice/damageRoll.mjs @@ -150,27 +150,8 @@ export default class DamageRoll extends DHRoll { if (!formulaData) return null; this.options.isCritical = config.isCritical; - const isHitpointPart = formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id; formulaData.roll = new Roll(Roll.replaceFormulaData(formulaData.formula, config.data)); formulaData.roll.terms = Roll.parse(formulaData.roll.formula, config.data); - if (formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) { - formulaData.modifiers = this.applyBaseBonus(formulaData); - this.addModifiers(formulaData); - formulaData.modifiers?.forEach(m => { - formulaData.roll.terms.push(...this.formatModifier(m.value)); - }); - } - - /* To Remove When Reaction System */ - if (isDamage && formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) { - for (const mod in config.modifiers) { - const modifier = config.modifiers[mod]; - if ( - modifier.beforeCrit === true && - (modifier.enabled || modifier.value) - ) modifier.callback(formulaData); - } - } if (formulaData.extraFormula) { formulaData.roll.terms.push( @@ -179,28 +160,43 @@ export default class DamageRoll extends DHRoll { ); } - if (config.damageOptions.groupAttack?.numAttackers > 1 && isHitpointPart) { - const damageTypes = [foundry.dice.terms.Die, foundry.dice.terms.NumericTerm]; - for (const term of formulaData.roll.terms) { - if (damageTypes.some(type => term instanceof type)) { - term.number *= config.damageOptions.groupAttack.numAttackers; - } - } - } - - if (config.isCritical && isHitpointPart) { - const total = formulaData.roll.dice.reduce((acc, term) => acc + term._faces * term._number, 0); - if (total > 0) { - formulaData.roll.terms.push(...this.formatModifier(total)); - } - } - - /* To Remove When Reaction System */ if (isDamage && formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) { + formulaData.modifiers = this.applyBaseBonus(formulaData); + this.addModifiers(formulaData); + formulaData.modifiers?.forEach(m => { + formulaData.roll.terms.push(...this.formatModifier(m.value)); + }); + + /* To Remove When Reaction System */ + for (const mod in config.modifiers) { + const modifier = config.modifiers[mod]; + if ( + modifier.beforeCrit === true && + (modifier.enabled || modifier.value) + ) modifier.callback(formulaData); + } + + /* To Remove When Reaction System */ for (const mod in config.modifiers) { const modifier = config.modifiers[mod]; if (!modifier.beforeCrit && (modifier.enabled || modifier.value)) modifier.callback(formulaData); } + + if (config.damageOptions.groupAttack?.numAttackers > 1) { + const damageTypes = [foundry.dice.terms.Die, foundry.dice.terms.NumericTerm]; + for (const term of formulaData.roll.terms) { + if (damageTypes.some(type => term instanceof type)) { + term.number *= config.damageOptions.groupAttack.numAttackers; + } + } + } + + if (config.isCritical) { + const total = formulaData.roll.dice.reduce((acc, term) => acc + term._faces * term._number, 0); + if (total > 0) { + formulaData.roll.terms.push(...this.formatModifier(total)); + } + } } formulaData.roll._formula = this.constructor.getFormula(formulaData.roll.terms); diff --git a/module/helpers/handlebarsHelper.mjs b/module/helpers/handlebarsHelper.mjs index 7f30d970..dbcc50dc 100644 --- a/module/helpers/handlebarsHelper.mjs +++ b/module/helpers/handlebarsHelper.mjs @@ -48,9 +48,8 @@ export default class RegisterHandlebarsHelpers { return formula; } - static damageSymbols(damageParts) { - const allTypes = [...new Set([...damageParts].flatMap(x => Array.from(x.type)))]; - const symbols = allTypes.map(p => CONFIG.DH.GENERAL.damageTypes[p].icon); + static damageSymbols(damageData) { + const symbols = damageData.type.map(p => CONFIG.DH.GENERAL.damageTypes[p].icon); return new Handlebars.SafeString(Array.from(symbols).map(symbol => ``)); } diff --git a/styles/less/dialog/damage-selection/sheet.less b/styles/less/dialog/damage-selection/sheet.less index cb2c14e5..0bb0f2be 100644 --- a/styles/less/dialog/damage-selection/sheet.less +++ b/styles/less/dialog/damage-selection/sheet.less @@ -21,6 +21,7 @@ font-size: var(--font-size-20); color: light-dark(@dark, @beige); text-align: center; + margin-bottom: -12px; } .bonuses { diff --git a/templates/dialogs/dice-roll/damageSelection.hbs b/templates/dialogs/dice-roll/damageSelection.hbs index 117df634..ccda8f9c 100644 --- a/templates/dialogs/dice-roll/damageSelection.hbs +++ b/templates/dialogs/dice-roll/damageSelection.hbs @@ -43,25 +43,23 @@ {{/with}} {{/if}} -
- {{#unless (empty @root.resourceFormulas)}} -
{{localize "Resource Drain"}}
- {{/unless}} + {{#unless (empty @root.resourceFormulas)}} +
{{localize "Resource Drain"}}
+ {{/unless}} - {{#each @root.resourceFormulas}} -
- {{localize "DAGGERHEART.GENERAL.formula"}}: {{roll.formula}} - - {{#with (lookup @root.config.GENERAL.healingTypes applyTo)}} - {{localize label}} - {{/with}} - -
-
- -
- {{/each}} -
+ {{#each @root.resourceFormulas}} +
+ {{localize "DAGGERHEART.GENERAL.formula"}}: {{roll.formula}} + + {{#with (lookup @root.config.GENERAL.healingTypes applyTo)}} + {{localize label}} + {{/with}} + +
+
+ +
+ {{/each}} {{#if damageOptions.groupAttack}}
diff --git a/templates/ui/tooltip/attack.hbs b/templates/ui/tooltip/attack.hbs index 8e4a1bb0..903c13a5 100644 --- a/templates/ui/tooltip/attack.hbs +++ b/templates/ui/tooltip/attack.hbs @@ -23,7 +23,7 @@ {{/if}}
- {{{damageFormula attack}}} {{{damageSymbols attack.damage.parts}}} + {{{damageFormula attack}}} {{{damageSymbols attack.damage.main}}}
{{#if description}} diff --git a/templates/ui/tooltip/weapon.hbs b/templates/ui/tooltip/weapon.hbs index 4adb9c46..10889015 100644 --- a/templates/ui/tooltip/weapon.hbs +++ b/templates/ui/tooltip/weapon.hbs @@ -23,7 +23,7 @@ {{/with}}
- {{{damageFormula item.system.attack}}} {{{damageSymbols item.system.attack.damage.parts}}} + {{{damageFormula item.system.attack}}} {{{damageSymbols item.system.attack.damage.main}}}
{{#if description}}