From 82a7a99b65aa79eb24a47f157d4002f4aca1a87b Mon Sep 17 00:00:00 2001 From: Dapoolp Date: Tue, 15 Jul 2025 20:13:33 +0200 Subject: [PATCH] create DHResourceData --- lang/en.json | 7 ++++++ module/config/generalConfig.mjs | 5 +++++ module/data/action/actionDice.mjs | 34 +++++++++++++++++++++-------- module/data/action/baseAction.mjs | 6 ++--- module/data/action/damageAction.mjs | 7 +----- styles/less/global/elements.less | 2 +- templates/actionTypes/damage.hbs | 4 +++- 7 files changed, 45 insertions(+), 20 deletions(-) diff --git a/lang/en.json b/lang/en.json index b9e0fefa..6e19c47c 100755 --- a/lang/en.json +++ b/lang/en.json @@ -35,6 +35,9 @@ "Settings": { "resultBased": { "label": "Formula based on Hope/Fear result." + }, + "applyTo": { + "label": "Targeted Resource" } }, "TYPES": { @@ -647,6 +650,10 @@ "armorStack": { "name": "Armor Stack", "abbreviation": "AS" + }, + "fear": { + "name": "Fear", + "abbreviation": "FR" } }, "ItemResourceType": { diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index 54430860..2e155a4e 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -89,6 +89,11 @@ export const healingTypes = { id: 'armorStack', label: 'DAGGERHEART.CONFIG.HealingType.armorStack.name', abbreviation: 'DAGGERHEART.CONFIG.HealingType.armorStack.abbreviation' + }, + fear: { + id: 'fear', + label: 'DAGGERHEART.CONFIG.HealingType.fear.name', + abbreviation: 'DAGGERHEART.CONFIG.HealingType.fear.abbreviation' } }; diff --git a/module/data/action/actionDice.mjs b/module/data/action/actionDice.mjs index d71b390a..80115c6d 100644 --- a/module/data/action/actionDice.mjs +++ b/module/data/action/actionDice.mjs @@ -93,10 +93,32 @@ export class DHDamageField extends fields.SchemaField { } } -export class DHDamageData extends foundry.abstract.DataModel { +export class DHResourceData extends foundry.abstract.DataModel { /** @override */ static defineSchema() { return { + applyTo: new fields.StringField({ + choices: CONFIG.DH.GENERAL.healingTypes, + required: true, + blank: false, + initial: CONFIG.DH.GENERAL.healingTypes.hitPoints.id, + label: 'DAGGERHEART.ACTIONS.Settings.applyTo.label' + }), + resultBased: new fields.BooleanField({ + initial: false, + label: 'DAGGERHEART.ACTIONS.Settings.resultBased.label' + }), + value: new fields.EmbeddedDataField(DHActionDiceData), + valueAlt: new fields.EmbeddedDataField(DHActionDiceData) + } + } +} + +export class DHDamageData extends DHResourceData { + /** @override */ + static defineSchema() { + return { + ...super.defineSchema(), base: new fields.BooleanField({ initial: false, readonly: true, label: 'Base' }), type: new fields.SetField( new fields.StringField({ @@ -109,13 +131,7 @@ export class DHDamageData extends foundry.abstract.DataModel { label: 'Type', initial: 'physical' } - ), - resultBased: new fields.BooleanField({ - initial: false, - label: 'DAGGERHEART.ACTIONS.Settings.resultBased.label' - }), - value: new fields.EmbeddedDataField(DHActionDiceData), - valueAlt: new fields.EmbeddedDataField(DHActionDiceData) - }; + ) + } } } diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index a2db300f..f8927f0e 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -1,4 +1,4 @@ -import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField } from './actionDice.mjs'; +import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField, DHResourceData } from './actionDice.mjs'; import DhpActor from '../../documents/actor.mjs'; import D20RollDialog from '../../applications/dialogs/d20RollDialog.mjs'; @@ -67,7 +67,7 @@ export default class DHBaseAction extends foundry.abstract.DataModel { static defineExtraSchema() { const extraFields = { - damage: new DHDamageField({isDamage: true}), + damage: new DHDamageField(), roll: new fields.EmbeddedDataField(DHActionRollData), save: new fields.SchemaField({ trait: new fields.StringField({ @@ -96,7 +96,7 @@ export default class DHBaseAction extends foundry.abstract.DataModel { onSave: new fields.BooleanField({ initial: false }) }) ), - healing: new fields.EmbeddedDataField(DHDamageData), + healing: new fields.EmbeddedDataField(DHResourceData), beastform: new fields.SchemaField({ tierAccess: new fields.SchemaField({ exact: new fields.NumberField({ integer: true, nullable: true, initial: null }) diff --git a/module/data/action/damageAction.mjs b/module/data/action/damageAction.mjs index 388c5eb8..e39aa247 100644 --- a/module/data/action/damageAction.mjs +++ b/module/data/action/damageAction.mjs @@ -17,8 +17,7 @@ export default class DHDamageAction extends DHBaseAction { damageTypes = !damageTypes.length ? ['physical'] : damageTypes; if (!formula || formula == '') return; - let roll = { formula: formula, total: formula }, - bonusDamage = []; + let roll = { formula: formula, total: formula }; if (isNaN(formula)) formula = Roll.replaceFormulaData(formula, this.getRollData(systemData)); @@ -43,8 +42,4 @@ export default class DHDamageAction extends DHBaseAction { roll = CONFIG.Dice.daggerheart.DamageRoll.build(config); } - - // get modifiers() { - // return []; - // } } diff --git a/styles/less/global/elements.less b/styles/less/global/elements.less index 9d38e386..b9509b38 100755 --- a/styles/less/global/elements.less +++ b/styles/less/global/elements.less @@ -109,7 +109,7 @@ height: 34px; .tags { justify-content: flex-start; - margin: 5px; + margin: 4px; height: inherit; .tag { padding: 0.3rem 0.5rem; diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index cbd1f503..2a1156aa 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -22,6 +22,7 @@ {{formField ../fields.value.fields.bonus value=dmg.value.bonus name=(concat ../path "damage.parts." index ".value.bonus") localize=true classes="inline-child"}} {{/if}} + {{formField ../fields.applyTo value=dmg.applyTo name=(concat ../path "damage.parts." realIndex ".applyTo") localize=true}} {{formField ../fields.type value=dmg.type name=(concat ../path "damage.parts." index ".type") localize=true}} {{else}} {{#with (@root.getRealIndex index) as | realIndex |}} @@ -46,7 +47,8 @@ {{> formula fields=../../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" realIndex=realIndex}} {{/if}} - {{formField ../../fields.type value=dmg.type name=(concat "damage.parts." realIndex ".type") localize=true}} + {{formField ../../fields.applyTo value=dmg.applyTo name=(concat "damage.parts." realIndex ".applyTo") localize=true}} + {{formField ../../fields.type value=dmg.type name=(concat "damage.parts." realIndex ".type") localize=true}} {{#unless dmg.base}}
{{/unless}}