diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index be7224cd..944d373b 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -469,6 +469,22 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel return acc; }, {}); } + + if (source.damage && source.damage.resources === undefined) { + source.damage.resources = {}; + for (const [partKey, part] of Object.entries(source.damage.parts)) { + if (partKey === 'hitPoints') { + source.damage.main = { + ...part, + includeBase: source.damage.includeBase, + direct: source.damage.direct, + groupAttack: source.damage.groupAttack + }; + } else { + source.damage.resources[partKey] = part; + } + } + } } } diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index b39c64aa..53581e79 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -838,7 +838,7 @@ export default class DhCharacter extends DhCreature { isReversed: true }; - this.attack.damage.parts.hitPoints.value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`; + this.attack.damage.main.value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`; // Clamp resources (must be done last to ensure all updates occur) this.resources.clamp(); diff --git a/module/data/chat-message/chatDamageData.mjs b/module/data/chat-message/chatDamageData.mjs index b866ddaf..0de9ea9e 100644 --- a/module/data/chat-message/chatDamageData.mjs +++ b/module/data/chat-message/chatDamageData.mjs @@ -11,7 +11,8 @@ export class ChatDamageData extends foundry.abstract.DataModel { const fields = foundry.data.fields; return { - types: new fields.TypedObjectField(new fields.JSONField({validate: ChatDamageData.#validateRoll})) + damage: new fields.JSONField({validate: ChatDamageData.#validateRoll}), + resources: new fields.TypedObjectField(new fields.JSONField({validate: ChatDamageData.#validateRoll})) }; } diff --git a/module/data/fields/action/damageField.mjs b/module/data/fields/action/damageField.mjs index c4295e0d..72933c60 100644 --- a/module/data/fields/action/damageField.mjs +++ b/module/data/fields/action/damageField.mjs @@ -13,17 +13,8 @@ export default class DamageField extends fields.SchemaField { /** @inheritDoc */ constructor(options, context = {}) { const damageFields = { - parts: new IterableTypedObjectField(DHDamageData), - includeBase: new fields.BooleanField({ - initial: false, - label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label' - }), - direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }), - groupAttack: new fields.StringField({ - choices: CONFIG.DH.GENERAL.groupAttackRange, - blank: true, - label: 'DAGGERHEART.ACTIONS.Settings.groupAttack.label' - }) + main: new fields.EmbeddedDataField(DHDamageData), + resources: new IterableTypedObjectField(DHResourceData) }; super(damageFields, options, context); } @@ -287,6 +278,18 @@ export class DHResourceData extends foundry.abstract.DataModel { /** @override */ static defineSchema() { return { + base: new fields.BooleanField({ initial: false, readonly: true, label: 'Base' }), + type: new fields.SetField( + new fields.StringField({ + choices: CONFIG.DH.GENERAL.damageTypes, + initial: 'physical', + nullable: false, + required: true + }), + { + label: game.i18n.localize('DAGGERHEART.GENERAL.type') + } + ), applyTo: new fields.StringField({ choices: CONFIG.DH.GENERAL.healingTypes, required: true, @@ -309,18 +312,16 @@ export class DHDamageData extends DHResourceData { static defineSchema() { return { ...super.defineSchema(), - base: new fields.BooleanField({ initial: false, readonly: true, label: 'Base' }), - type: new fields.SetField( - new fields.StringField({ - choices: CONFIG.DH.GENERAL.damageTypes, - initial: 'physical', - nullable: false, - required: true - }), - { - label: game.i18n.localize('DAGGERHEART.GENERAL.type') - } - ) + includeBase: new fields.BooleanField({ + initial: false, + label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label' + }), + direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }), + groupAttack: new fields.StringField({ + choices: CONFIG.DH.GENERAL.groupAttackRange, + blank: true, + label: 'DAGGERHEART.ACTIONS.Settings.groupAttack.label' + }) }; } }