From fae05c24a8bbd1f8d921f596e8a438b5708b5e30 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Thu, 23 Apr 2026 00:22:08 +0200 Subject: [PATCH] 1794 - Include Item Damage (#1827) * Went ahead and made IncludeItemDamage work again, smashing the formulas together * . * Lint fix --- lang/en.json | 5 +- .../dialogs/actionSelectionDialog.mjs | 4 +- .../sheets-configs/action-base-config.mjs | 4 +- module/data/action/attackAction.mjs | 28 ++++---- templates/actionTypes/damage.hbs | 66 +++++++++---------- 5 files changed, 52 insertions(+), 55 deletions(-) diff --git a/lang/en.json b/lang/en.json index 2efd6d7b..99a75f83 100755 --- a/lang/en.json +++ b/lang/en.json @@ -119,8 +119,7 @@ "deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?", "advantageState": "Advantage State", "damageOnSave": "Damage on Save", - "useDefaultItemValues": "Use default Item values", - "itemDamageIsUsed": "Item Damage Is Used" + "useDefaultItemValues": "Use default Item values" }, "RollField": { "diceRolling": { @@ -135,7 +134,7 @@ "attackModifier": "Attack Modifier", "attackName": "Attack Name", "criticalThreshold": "Critical Threshold", - "includeBase": { "label": "Use Item Damage" }, + "includeBase": { "label": "Include Item Damage" }, "groupAttack": { "label": "Group Attack" }, "multiplier": "Multiplier", "saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.", diff --git a/module/applications/dialogs/actionSelectionDialog.mjs b/module/applications/dialogs/actionSelectionDialog.mjs index 995c4894..6123c970 100644 --- a/module/applications/dialogs/actionSelectionDialog.mjs +++ b/module/applications/dialogs/actionSelectionDialog.mjs @@ -72,8 +72,8 @@ export default class ActionSelectionDialog extends HandlebarsApplicationMixin(Ap static async #onChooseAction(event, button) { const { actionId } = button.dataset; - this.action = this.item.system.actionsList.find(a => a._id === actionId); - Object.defineProperty(this.event, 'shiftKey', { + this.#action = this.item.system.actionsList.find(a => a._id === actionId); + Object.defineProperty(this.#event, 'shiftKey', { get() { return event.shiftKey; } diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index a94abb26..7406b084 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -156,7 +156,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) context.openSection = this.openSection; context.tabs = this._getTabs(this.constructor.TABS); context.config = CONFIG.DH; - if (this.action.hasDamage) { + if (this.action.damage) { context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length; if (this.action.damage.hasOwnProperty('includeBase') && this.action.type === 'attack') @@ -302,7 +302,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) static addDamage(_event) { if (!this.action.damage.parts) return; - const choices = getUnusedDamageTypes(this.action.damage.parts); + const choices = getUnusedDamageTypes(this.action._source.damage.parts); const content = new foundry.data.fields.StringField({ label: game.i18n.localize('Damage Type'), choices, diff --git a/module/data/action/attackAction.mjs b/module/data/action/attackAction.mjs index 15cc1696..c4d07c25 100644 --- a/module/data/action/attackAction.mjs +++ b/module/data/action/attackAction.mjs @@ -1,4 +1,3 @@ -import { DHDamageData } from '../fields/action/damageField.mjs'; import DHDamageAction from './damageAction.mjs'; export default class DHAttackAction extends DHDamageAction { @@ -12,8 +11,19 @@ export default class DHAttackAction extends DHDamageAction { super.prepareData(); if (!!this.item?.system?.attack) { if (this.damage.includeBase) { - const baseDamage = this.getParentDamage(); - this.damage.parts.hitPoints = new DHDamageData(baseDamage); + const baseDamage = this.getParentHitPointDamage(); + if (baseDamage) { + if (!this.damage.parts.hitPoints) { + this.damage.parts.hitPoints = baseDamage; + } else { + for (const type of baseDamage.type) this.damage.parts.hitPoints.type.add(type); + + this.damage.parts.hitPoints.value.custom = { + enabled: true, + formula: `${baseDamage.value.getFormula()} + ${this.damage.parts.hitPoints.value.getFormula()}` + }; + } + } } if (this.roll.useDefault) { this.roll.trait = this.item.system.attack.roll.trait; @@ -22,16 +32,8 @@ export default class DHAttackAction extends DHDamageAction { } } - getParentDamage() { - return { - value: { - multiplier: 'prof', - dice: this.item?.system?.attack.damage.parts.hitPoints.value.dice, - bonus: this.item?.system?.attack.damage.parts.hitPoints.value.bonus ?? 0 - }, - type: this.item?.system?.attack.damage.parts.hitPoints.type, - base: true - }; + getParentHitPointDamage() { + return this.item?.system?.attack.damage.parts.hitPoints; } get damageFormula() { diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index 454d0413..03300840 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -31,44 +31,40 @@ {{/unless}} - {{#unless (and @root.source.damage.includeBase (eq key 'hitPoints'))}} - {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base))}} - {{formField ../fields.resultBased value=dmg.resultBased name=(concat "damage.parts." dmg.applyTo ".resultBased") localize=true classes="checkbox"}} - {{/if}} - {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base) dmg.resultBased)}} -