From dbb08fec8c73d672344c2e3f33ef96a73fba90f8 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Tue, 28 Apr 2026 20:30:32 +0200 Subject: [PATCH 1/8] Initial --- lang/en.json | 3 +- .../sheets-configs/action-base-config.mjs | 35 ++++++++++++++++ module/data/fields/action/damageField.mjs | 40 ++++++++++++++++--- styles/less/sheets/actions/actions.less | 19 +++++++++ .../action-settings/configuration.hbs | 4 +- .../action-settings/effect.hbs | 16 ++++++-- .../sheets-settings/action-settings/range.hbs | 8 ++++ 7 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 templates/sheets-settings/action-settings/range.hbs diff --git a/lang/en.json b/lang/en.json index b4b1410e..0d09acf9 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2347,7 +2347,8 @@ "triggers": "Triggers", "deathMoves": "Deathmoves", "sources": "Sources", - "packs": "Packs" + "packs": "Packs", + "range": "Range" }, "Tiers": { "singular": "Tier", diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index 7406b084..a20cc251 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -62,6 +62,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) id: 'configuration', template: 'systems/daggerheart/templates/sheets-settings/action-settings/configuration.hbs' }, + configuration: { + id: 'range', + template: 'systems/daggerheart/templates/sheets-settings/action-settings/range.hbs' + }, effect: { id: 'effect', template: 'systems/daggerheart/templates/sheets-settings/action-settings/effect.hbs' @@ -89,6 +93,14 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) icon: null, label: 'DAGGERHEART.GENERAL.Tabs.configuration' }, + range: { + active: false, + cssClass: '', + group: 'primary', + id: 'range', + icon: null, + label: 'DAGGERHEART.GENERAL.Tabs.range' + }, effect: { active: false, cssClass: '', @@ -107,6 +119,25 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) } }; + static OUTCOME_TABS = { + successWithHope: { + active: true, + cssClass: '', + group: 'outcomes', + id: 'successWithHope', + icon: null, + label: 'Success With Hope' + }, + successWithFear: { + active: false, + cssClass: '', + group: 'outcomes', + id: 'successWithFear', + icon: null, + label: 'Success With Fear' + }, + }; + static CLEAN_ARRAYS = ['cost', 'effects', 'summon']; _getTabs(tabs) { @@ -155,6 +186,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) context.openSection = this.openSection; context.tabs = this._getTabs(this.constructor.TABS); + + context.outcomeTabs = this._getTabs(this.constructor.OUTCOME_TABS); + context.outcomeData = context.outcomeTabs.successWithHope.active ? context.source.damage : context.source.damage.altOutcomes.successWithFear; + context.config = CONFIG.DH; if (this.action.damage) { context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length; diff --git a/module/data/fields/action/damageField.mjs b/module/data/fields/action/damageField.mjs index 30a5ad7c..ba8277ef 100644 --- a/module/data/fields/action/damageField.mjs +++ b/module/data/fields/action/damageField.mjs @@ -4,6 +4,15 @@ import IterableTypedObjectField from '../iterableTypedObjectField.mjs'; const fields = foundry.data.fields; +const getDamageBaseFields = () => ({ + 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' }), +}); + export default class DamageField extends fields.SchemaField { /** * Action Workflow order @@ -13,12 +22,13 @@ 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' + ...getDamageBaseFields(), + altOutcomes: new fields.SchemaField({ + successFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), + failureHope: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), + failureFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), + critical: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }) }), - direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }), groupAttack: new fields.StringField({ choices: CONFIG.DH.GENERAL.groupAttackRange, blank: true, @@ -28,6 +38,12 @@ export default class DamageField extends fields.SchemaField { super(damageFields, options, context); } + getDamageData(outcome) { + if (outcome === 'successHope') return this; + + return this.altOutcomes[outcome].data; + } + /** * Roll Damage/Healing Action Workflow part. * Must be called within Action context or similar. @@ -326,3 +342,17 @@ export class DHDamageData extends DHResourceData { }; } } + +class AltDamageOutcome extends foundry.abstract.DataModel { + static defineSchema() { + return { + copyStandard: new fields.BooleanField({ required: true, initial: true }), + ...getDamageBaseFields(), + /* Stuff */ + } + } + + get data() { + return this.copyStandard ? this.parent : {}; // If not copying, return data from the this alternate outcome + } +} \ No newline at end of file diff --git a/styles/less/sheets/actions/actions.less b/styles/less/sheets/actions/actions.less index 485f8e91..19912a98 100644 --- a/styles/less/sheets/actions/actions.less +++ b/styles/less/sheets/actions/actions.less @@ -153,4 +153,23 @@ align-items: center; gap: 4px; } + + .inner-tabs { + justify-content: left; + + .inner-tab { + line-height: 1.5; + border: 1px solid light-dark(@beige, @beige); + border-radius: 6px; + padding: 0 4px; + background: light-dark(@beige, @dark-blue); + color: light-dark(@dark-blue, @beige); + + a { + &.active { + + } + } + } + } } diff --git a/templates/sheets-settings/action-settings/configuration.hbs b/templates/sheets-settings/action-settings/configuration.hbs index 8df528c9..9fb54cc8 100644 --- a/templates/sheets-settings/action-settings/configuration.hbs +++ b/templates/sheets-settings/action-settings/configuration.hbs @@ -3,8 +3,8 @@ data-group="primary" data-tab="config" > + {{#if fields.roll}}{{> 'systems/daggerheart/templates/actionTypes/roll.hbs' fields=fields.roll.fields source=source.roll}}{{/if}} + {{#if fields.save}}{{> 'systems/daggerheart/templates/actionTypes/save.hbs' fields=fields.save.fields source=source.save}}{{/if}} {{> 'systems/daggerheart/templates/actionTypes/uses.hbs' fields=fields.uses.fields source=source.uses}} {{> 'systems/daggerheart/templates/actionTypes/cost.hbs' fields=fields.cost.element.fields source=source.cost costOptions=costOptions}} - {{> 'systems/daggerheart/templates/actionTypes/range-target.hbs' fields=(object range=fields.range target=fields.target.fields) source=(object target=source.target range=source.range)}} - {{> 'systems/daggerheart/templates/actionTypes/areas.hbs' fields=fields.areas.element.fields source=source.areas}} \ No newline at end of file diff --git a/templates/sheets-settings/action-settings/effect.hbs b/templates/sheets-settings/action-settings/effect.hbs index 567cb81c..aa22a28e 100644 --- a/templates/sheets-settings/action-settings/effect.hbs +++ b/templates/sheets-settings/action-settings/effect.hbs @@ -1,11 +1,19 @@ -
- {{#if fields.roll}}{{> 'systems/daggerheart/templates/actionTypes/roll.hbs' fields=fields.roll.fields source=source.roll}}{{/if}} - {{#if fields.save}}{{> 'systems/daggerheart/templates/actionTypes/save.hbs' fields=fields.save.fields source=source.save}}{{/if}} - {{#if fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=source.damage baseFields=fields.damage.fields }}{{/if}} + + + {{#if fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=outcomeData baseFields=fields.damage.fields }}{{/if}} {{#if fields.macro}}{{> 'systems/daggerheart/templates/actionTypes/macro.hbs' fields=fields.macro source=source.macro}}{{/if}} {{#if fields.effects}}{{> 'systems/daggerheart/templates/actionTypes/effect.hbs' fields=fields.effects.element.fields source=source.effects}}{{/if}} {{#if fields.beastform}}{{> 'systems/daggerheart/templates/actionTypes/beastform.hbs' fields=fields.beastform.fields source=source.beastform}}{{/if}} diff --git a/templates/sheets-settings/action-settings/range.hbs b/templates/sheets-settings/action-settings/range.hbs new file mode 100644 index 00000000..273e89c9 --- /dev/null +++ b/templates/sheets-settings/action-settings/range.hbs @@ -0,0 +1,8 @@ +
+ {{> 'systems/daggerheart/templates/actionTypes/range-target.hbs' fields=(object range=fields.range target=fields.target.fields) source=(object target=source.target range=source.range)}} + {{> 'systems/daggerheart/templates/actionTypes/areas.hbs' fields=fields.areas.element.fields source=source.areas}} +
\ No newline at end of file From 3c9951966027e3f88e3e68844bdeb278a0d35a7e Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 3 May 2026 19:04:44 +0200 Subject: [PATCH 2/8] Start of different outcomes --- .../sheets-configs/action-base-config.mjs | 26 +++++++++++++------ module/data/fields/action/damageField.mjs | 10 ++++--- templates/actionTypes/damage.hbs | 4 +-- .../action-settings/effect.hbs | 17 +++++++++++- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index a20cc251..51243f39 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -1,3 +1,4 @@ +import { AltDamageOutcome } from '../../data/fields/action/damageField.mjs'; import { getUnusedDamageTypes } from '../../helpers/utils.mjs'; import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs'; @@ -62,7 +63,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) id: 'configuration', template: 'systems/daggerheart/templates/sheets-settings/action-settings/configuration.hbs' }, - configuration: { + range: { id: 'range', template: 'systems/daggerheart/templates/sheets-settings/action-settings/range.hbs' }, @@ -120,19 +121,19 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) }; static OUTCOME_TABS = { - successWithHope: { + successHope: { active: true, cssClass: '', group: 'outcomes', - id: 'successWithHope', + id: 'successHope', icon: null, label: 'Success With Hope' }, - successWithFear: { + successFear: { active: false, cssClass: '', group: 'outcomes', - id: 'successWithFear', + id: 'successFear', icon: null, label: 'Success With Fear' }, @@ -188,7 +189,6 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) context.tabs = this._getTabs(this.constructor.TABS); context.outcomeTabs = this._getTabs(this.constructor.OUTCOME_TABS); - context.outcomeData = context.outcomeTabs.successWithHope.active ? context.source.damage : context.source.damage.altOutcomes.successWithFear; context.config = CONFIG.DH; if (this.action.damage) { @@ -334,9 +334,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); } - static addDamage(_event) { + static addDamage(_event, button) { if (!this.action.damage.parts) return; + const outcome = button.dataset.outcome; const choices = getUnusedDamageTypes(this.action._source.damage.parts); const content = new foundry.data.fields.StringField({ label: game.i18n.localize('Damage Type'), @@ -360,7 +361,16 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) part.type = this.action.schema.fields.damage.fields.parts.element.fields.type.element.initial; - data.damage.parts[type] = part; + if (outcome === 'successHope') + data.damage.parts[type] = part; + else { + if (!data.damage.altOutcomes[outcome]) { + data.damage.altOutcomes[outcome] = new AltDamageOutcome(); + } + + data.damage.altOutcomes[outcome].parts[type] = part; + } + this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); }; diff --git a/module/data/fields/action/damageField.mjs b/module/data/fields/action/damageField.mjs index ba8277ef..6c0d2a88 100644 --- a/module/data/fields/action/damageField.mjs +++ b/module/data/fields/action/damageField.mjs @@ -343,16 +343,18 @@ export class DHDamageData extends DHResourceData { } } -class AltDamageOutcome extends foundry.abstract.DataModel { +export class AltDamageOutcome extends foundry.abstract.DataModel { static defineSchema() { return { - copyStandard: new fields.BooleanField({ required: true, initial: true }), + useStandardHitPointDamage: new fields.BooleanField({ required: true, initial: true }), ...getDamageBaseFields(), - /* Stuff */ } } get data() { - return this.copyStandard ? this.parent : {}; // If not copying, return data from the this alternate outcome + return { + ...this.parent, + ...this, + } } } \ No newline at end of file diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index 03300840..f1952c78 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -6,7 +6,7 @@ {{else}} {{localize "DAGGERHEART.GENERAL.damage"}} {{/if}} - {{#unless (eq path 'system.attack.')}}{{/unless}} + {{#unless (eq path 'system.attack.')}}{{/unless}}
{{#if @root.hasBaseDamage}} @@ -19,7 +19,7 @@ {{formField baseFields.groupAttack value=source.groupAttack name=(concat path "damage.groupAttack") localize=true classes="select"}} {{/if}}
- + {{!-- Handlebars uses Symbol.Iterator to produce index|key. This isn't compatible with our parts object, so we instead use applyTo, which is the same value --}} {{#each source.parts as |dmg key|}}
diff --git a/templates/sheets-settings/action-settings/effect.hbs b/templates/sheets-settings/action-settings/effect.hbs index aa22a28e..ea30eddf 100644 --- a/templates/sheets-settings/action-settings/effect.hbs +++ b/templates/sheets-settings/action-settings/effect.hbs @@ -12,8 +12,23 @@
{{/each}} + + {{#each outcomeTabs as |tab|}} +
+ {{#if (eq tab.id 'successHope')}} + {{#if ../fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=../fields.damage.fields.parts.element.fields source=../source.damage baseFields=../fields.damage.fields outcome=tab.id }}{{/if}} + {{else}} + {{#with (lookup ../fields.damage.fields.altOutcomes.fields tab.id) as |field|}} + {{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=field.fields.parts.element.fields source=(lookup ../../source.damage.altOutcomes ../id) baseFields=field.fields outcome=../id }} + {{/with }} + {{/if}} +
+ {{/each}} - {{#if fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=outcomeData baseFields=fields.damage.fields }}{{/if}} {{#if fields.macro}}{{> 'systems/daggerheart/templates/actionTypes/macro.hbs' fields=fields.macro source=source.macro}}{{/if}} {{#if fields.effects}}{{> 'systems/daggerheart/templates/actionTypes/effect.hbs' fields=fields.effects.element.fields source=source.effects}}{{/if}} {{#if fields.beastform}}{{> 'systems/daggerheart/templates/actionTypes/beastform.hbs' fields=fields.beastform.fields source=source.beastform}}{{/if}} From ec404a61d9ddba60869e832cb6614830d4cb095a Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 14 May 2026 18:51:14 +0200 Subject: [PATCH 3/8] More work on actionConfig outcomes --- lang/en.json | 7 + .../sheets-configs/action-base-config.mjs | 124 ++++++++++++++---- .../sheets-configs/action-config.mjs | 25 ++++ module/config/actionConfig.mjs | 19 +++ module/data/fields/action/damageField.mjs | 15 +-- templates/actionTypes/damage.hbs | 42 +++--- .../action-settings/effect.hbs | 6 +- 7 files changed, 180 insertions(+), 58 deletions(-) diff --git a/lang/en.json b/lang/en.json index 3eea7444..881ad4e8 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1275,6 +1275,13 @@ "diceValue": "Dice Value", "die": "Die" }, + "OutcomeType": { + "successHope": "Success/ Hope", + "successFear": "Success/ Fear", + "failureHope": "Failure/ Hope", + "failureFear": "Failure/ Fear", + "simpleOutcome": "Outcome" + }, "Range": { "self": { "name": "Self", diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index 51243f39..88c6d343 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -10,12 +10,87 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) this.action = action; this.openSection = null; this.openTrigger = this.action.triggers.length > 0 ? 0 : null; + + this.outcomeTabs = DHActionBaseConfig.getOutcomeTabs(action); } get title() { return `${game.i18n.localize('DAGGERHEART.GENERAL.Tabs.settings')}: ${this.action.name}`; } + /* Needs to consider effect altOutcomes aswell */ + static getOutcomeTabs(action) { + const outcomeKeys = [ + 'successHope', + ...Object.keys(action.damage?.altOutcomes ?? {}).filter(key => action.damage.altOutcomes[key]) + ]; + return outcomeKeys.reduce((acc, key, index) => { + acc[key] = { + active: index === 0, + cssClass: '', + group: 'outcomes', + id: key, + icon: null, + label: + outcomeKeys.length === 1 + ? game.i18n.localize('DAGGERHEART.CONFIG.OutcomeType.simpleOutcome') + : game.i18n.localize(CONFIG.DH.ACTIONS.outcomeTypes[key].label) + }; + return acc; + }, {}); + } + + /* Needs to consider effect altOutcomes aswell */ + static selectOutcome(action, callback) { + const choices = Object.entries(CONFIG.DH.ACTIONS.outcomeTypes).reduce((acc, [key, value]) => { + if (key !== 'successHope' && action.damage.altOutcomes[key] === null) + acc.push({ id: key, label: game.i18n.localize(value.label) }); + + return acc; + }, []); + const content = new foundry.data.fields.StringField({ + label: game.i18n.localize('Outcome'), + choices, + required: true + }).toFormGroup( + {}, + { + name: 'outcome', + localize: true, + nameAttr: 'value', + labelAttr: 'label' + } + ).outerHTML; + + const callbackWrapper = (_, button) => { + const choiceIndex = button.form.elements.outcome.value; + callback(choices[choiceIndex]?.id); + }; + + const typeDialog = new foundry.applications.api.DialogV2({ + buttons: [ + foundry.utils.mergeObject( + { + action: 'ok', + label: 'Confirm', + icon: 'fas fa-check', + default: true + }, + { callback: callbackWrapper } + ) + ], + content: content, + rejectClose: false, + modal: false, + window: { + title: game.i18n.localize('Add Outcome') + }, + position: { width: 300 } + }); + + typeDialog.render(true); + } + static DEFAULT_OPTIONS = { tag: 'form', classes: ['daggerheart', 'dh-style', 'action-config', 'dialog', 'max-800'], @@ -31,6 +106,8 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) addElement: this.addElement, removeElement: this.removeElement, removeTransformActor: this.removeTransformActor, + addOutcome: this.addOutcome, + removeOutcome: this.removeOutcome, editEffect: this.editEffect, addDamage: this.addDamage, removeDamage: this.removeDamage, @@ -120,25 +197,6 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) } }; - static OUTCOME_TABS = { - successHope: { - active: true, - cssClass: '', - group: 'outcomes', - id: 'successHope', - icon: null, - label: 'Success With Hope' - }, - successFear: { - active: false, - cssClass: '', - group: 'outcomes', - id: 'successFear', - icon: null, - label: 'Success With Fear' - }, - }; - static CLEAN_ARRAYS = ['cost', 'effects', 'summon']; _getTabs(tabs) { @@ -187,8 +245,9 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) context.openSection = this.openSection; context.tabs = this._getTabs(this.constructor.TABS); - - context.outcomeTabs = this._getTabs(this.constructor.OUTCOME_TABS); + + context.outcomeTabs = this._getTabs(this.outcomeTabs); + context.allOutcomesAssigned = Object.keys(this.outcomeTabs).length >= 4; context.config = CONFIG.DH; if (this.action.damage) { @@ -338,7 +397,11 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) if (!this.action.damage.parts) return; const outcome = button.dataset.outcome; - const choices = getUnusedDamageTypes(this.action._source.damage.parts); + const outcomeParts = + outcome === 'successHope' + ? this.action._source.damage.parts + : this.action._source.damage.altOutcomes[outcome].parts; + const choices = getUnusedDamageTypes(outcomeParts); const content = new foundry.data.fields.StringField({ label: game.i18n.localize('Damage Type'), choices, @@ -361,8 +424,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) part.type = this.action.schema.fields.damage.fields.parts.element.fields.type.element.initial; - if (outcome === 'successHope') - data.damage.parts[type] = part; + if (outcome === 'successHope') data.damage.parts[type] = part; else { if (!data.damage.altOutcomes[outcome]) { data.damage.altOutcomes[outcome] = new AltDamageOutcome(); @@ -401,9 +463,15 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) static removeDamage(_event, button) { if (!this.action.damage.parts) return; const data = this.action.toObject(); - const key = button.dataset.key; - delete data.damage.parts[key]; - data.damage.parts[`${key}`] = _del; + const { key, outcome } = button.dataset; + if (outcome === 'successHope') { + delete data.damage.parts[key]; + data.damage.parts[`${key}`] = _del; + } else { + delete data.damage.altOutcomes[outcome].parts[key]; + data.damage.altOutcomes[outcome].parts[`${key}`] = _del; + } + this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); } @@ -494,6 +562,8 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) } /** Specific implementation in extending classes **/ + static addOutcome(_event) {} + static removeOutcome(_event) {} static async addEffect(_event) {} static removeEffect(_event, _button) {} static editEffect(_event) {} diff --git a/module/applications/sheets-configs/action-config.mjs b/module/applications/sheets-configs/action-config.mjs index ef529e9b..833c3ebd 100644 --- a/module/applications/sheets-configs/action-config.mjs +++ b/module/applications/sheets-configs/action-config.mjs @@ -1,3 +1,4 @@ +import { AltDamageOutcome } from '../../data/fields/action/damageField.mjs'; import DHActionBaseConfig from './action-base-config.mjs'; export default class DHActionConfig extends DHActionBaseConfig { @@ -5,6 +6,8 @@ export default class DHActionConfig extends DHActionBaseConfig { ...DHActionBaseConfig.DEFAULT_OPTIONS, actions: { ...DHActionBaseConfig.DEFAULT_OPTIONS.actions, + addOutcome: this.addOutcome, + removeOutcome: this.removeOutcome, addEffect: this.addEffect, removeEffect: this.removeEffect, editEffect: this.editEffect @@ -19,6 +22,28 @@ export default class DHActionConfig extends DHActionBaseConfig { return context; } + static addOutcome() { + const data = this.action.toObject(); + + DHActionBaseConfig.selectOutcome(this.action, key => { + if (!key) return; + + data.damage.altOutcomes[key] = new AltDamageOutcome(); + this.outcomeTabs = DHActionBaseConfig.getOutcomeTabs(data); + this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); + }); + } + + static removeOutcome(_event, button) { + const { outcome } = button.dataset; + const data = this.action.toObject(); + + data.damage.altOutcomes[outcome] = null; + this.outcomeTabs = DHActionBaseConfig.getOutcomeTabs(data); + + this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); + } + static async addEffect(event) { const { areaIndex } = event.target.dataset; if (!this.action.effects) return; diff --git a/module/config/actionConfig.mjs b/module/config/actionConfig.mjs index a6c04e18..012ca4c6 100644 --- a/module/config/actionConfig.mjs +++ b/module/config/actionConfig.mjs @@ -122,3 +122,22 @@ export const areaTypes = { label: 'Placed Area' } }; + +export const outcomeTypes = { + successHope: { + key: 'successHope', + label: 'DAGGERHEART.CONFIG.OutcomeType.successHope' + }, + successFear: { + key: 'successFear', + label: 'DAGGERHEART.CONFIG.OutcomeType.successFear' + }, + failureHope: { + key: 'failureHope', + label: 'DAGGERHEART.CONFIG.OutcomeType.failureHope' + }, + failureFear: { + key: 'failureFear', + label: 'DAGGERHEART.CONFIG.OutcomeType.failureFear' + } +}; diff --git a/module/data/fields/action/damageField.mjs b/module/data/fields/action/damageField.mjs index 6c0d2a88..6da3f188 100644 --- a/module/data/fields/action/damageField.mjs +++ b/module/data/fields/action/damageField.mjs @@ -10,7 +10,7 @@ const getDamageBaseFields = () => ({ initial: false, label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label' }), - direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }), + direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }) }); export default class DamageField extends fields.SchemaField { @@ -26,8 +26,7 @@ export default class DamageField extends fields.SchemaField { altOutcomes: new fields.SchemaField({ successFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), failureHope: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), - failureFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), - critical: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }) + failureFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }) }), groupAttack: new fields.StringField({ choices: CONFIG.DH.GENERAL.groupAttackRange, @@ -347,14 +346,14 @@ export class AltDamageOutcome extends foundry.abstract.DataModel { static defineSchema() { return { useStandardHitPointDamage: new fields.BooleanField({ required: true, initial: true }), - ...getDamageBaseFields(), - } + ...getDamageBaseFields() + }; } get data() { return { ...this.parent, - ...this, - } + ...this + }; } -} \ No newline at end of file +} diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index f1952c78..fef6591e 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -10,13 +10,13 @@
{{#if @root.hasBaseDamage}} - {{formField @root.fields.damage.fields.includeBase value=@root.source.damage.includeBase name="damage.includeBase" classes="checkbox" localize=true }} + {{formField @root.fields.damage.fields.includeBase value=@root.source.damage.includeBase name=(concat basePath ".includeBase") classes="checkbox" localize=true }} {{/if}} {{#unless (eq @root.source.type 'healing')}} - {{formField baseFields.direct value=source.direct name=(concat path "damage.direct") localize=true classes="checkbox"}} + {{formField baseFields.direct value=source.direct name=(concat path basePath ".direct") localize=true classes="checkbox"}} {{/unless}} {{#if (and @root.isNPC (not (eq path 'system.attack.')))}} - {{formField baseFields.groupAttack value=source.groupAttack name=(concat path "damage.groupAttack") localize=true classes="select"}} + {{formField baseFields.groupAttack value=source.groupAttack name=(concat path basePath ".groupAttack") localize=true classes="select"}} {{/if}}
@@ -27,44 +27,44 @@ {{localize (concat "DAGGERHEART.CONFIG.HealingType." dmg.applyTo ".name")}} {{#unless (or dmg.base ../path)}} - + {{/unless}} {{#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"}} + {{formField ../fields.resultBased value=dmg.resultBased name=(concat ../basePath ".parts." dmg.applyTo ".resultBased") localize=true classes="checkbox"}} {{/if}} {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base) dmg.resultBased)}}
{{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.hope")}} - {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}} + {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path outcomePath=../outcomePath}}
{{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.fear")}} - {{> formula fields=../fields.valueAlt.fields type=../fields.type dmg=dmg source=dmg.valueAlt target="valueAlt" key=dmg.applyTo path=../path}} + {{> formula fields=../fields.valueAlt.fields type=../fields.type dmg=dmg source=dmg.valueAlt target="valueAlt" key=dmg.applyTo path=../path outcomePath=../outcomePath}}
{{else}} - {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}} + {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path outcomePath=../outcomePath}} {{/if}} {{#if (and (eq dmg.applyTo 'hitPoints') (ne @root.source.type 'healing'))}} - {{formField ../fields.type value=dmg.type name=(concat ../path "damage.parts." dmg.applyTo ".type") localize=true}} + {{formField ../fields.type value=dmg.type name=(concat ../path ../basePath ".parts." dmg.applyTo ".type") localize=true}} {{/if}} {{#if ../horde}}
{{localize "DAGGERHEART.ACTORS.Adversary.hordeDamage"}}
- - {{formField ../fields.valueAlt.fields.flatMultiplier value=dmg.valueAlt.flatMultiplier name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.flatMultiplier") label="DAGGERHEART.ACTIONS.Settings.multiplier" classes="inline-child" localize=true }} - {{formField ../fields.valueAlt.fields.dice value=dmg.valueAlt.dice name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.dice") classes="inline-child" localize=true}} - {{formField ../fields.valueAlt.fields.bonus value=dmg.valueAlt.bonus name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.bonus") localize=true classes="inline-child"}} + + {{formField ../fields.valueAlt.fields.flatMultiplier value=dmg.valueAlt.flatMultiplier name=(concat ../path ../basePath ".parts." dmg.applyTo ".valueAlt.flatMultiplier") label="DAGGERHEART.ACTIONS.Settings.multiplier" classes="inline-child" localize=true }} + {{formField ../fields.valueAlt.fields.dice value=dmg.valueAlt.dice name=(concat ../path ../basePath ".parts." dmg.applyTo ".valueAlt.dice") classes="inline-child" localize=true}} + {{formField ../fields.valueAlt.fields.bonus value=dmg.valueAlt.bonus name=(concat ../path ../basePath ".parts." dmg.applyTo ".valueAlt.bonus") localize=true classes="inline-child"}}
{{/if}} - + {{/each}} @@ -72,21 +72,21 @@ {{#*inline "formula"}} {{#unless dmg.base}} - {{formField fields.custom.fields.enabled value=source.custom.enabled name=(concat path "damage.parts." key "." target ".custom.enabled") classes="checkbox" localize=true}} + {{formField fields.custom.fields.enabled value=source.custom.enabled name=(concat path outcomePath ".parts." key "." target ".custom.enabled") classes="checkbox" localize=true}} {{/unless}} {{#if source.custom.enabled}} - {{formField fields.custom.fields.formula value=source.custom.formula name=(concat path "damage.parts." key "." target ".custom.formula") localize=true}} + {{formField fields.custom.fields.formula value=source.custom.formula name=(concat path outcomePath ".parts." key "." target ".custom.formula") localize=true}} {{else}}
{{#unless @root.isNPC}} - {{formField fields.multiplier value=source.multiplier name=(concat path "damage.parts." key "." target ".multiplier") localize=true}} + {{formField fields.multiplier value=source.multiplier name=(concat path outcomePath ".parts." key "." target ".multiplier") localize=true}} {{/unless}} - {{#if (eq source.multiplier 'flat')}}{{formField fields.flatMultiplier value=source.flatMultiplier name=(concat path "damage.parts." key "." target ".flatMultiplier") localize=true }}{{/if}} - {{formField fields.dice value=source.dice name=(concat path "damage.parts." key "." target ".dice") localize=true}} - {{formField fields.bonus value=source.bonus name=(concat path "damage.parts." key "." target ".bonus") localize=true}} + {{#if (eq source.multiplier 'flat')}}{{formField fields.flatMultiplier value=source.flatMultiplier name=(concat path outcomePath ".parts." key "." target ".flatMultiplier") localize=true }}{{/if}} + {{formField fields.dice value=source.dice name=(concat path outcomePath ".parts." key "." target ".dice") localize=true}} + {{formField fields.bonus value=source.bonus name=(concat path outcomePath ".parts." key "." target ".bonus") localize=true}}
{{/if}} {{#if @root.isNPC}} - + {{/if}} {{/inline}} \ No newline at end of file diff --git a/templates/sheets-settings/action-settings/effect.hbs b/templates/sheets-settings/action-settings/effect.hbs index ea30eddf..ab03b7ea 100644 --- a/templates/sheets-settings/action-settings/effect.hbs +++ b/templates/sheets-settings/action-settings/effect.hbs @@ -9,8 +9,10 @@ {{localize tab.label}} + {{#unless (eq tab.id 'successHope')}}{{/unless}} {{/each}} + {{#each outcomeTabs as |tab|}} @@ -20,10 +22,10 @@ data-tab="{{tab.id}}" > {{#if (eq tab.id 'successHope')}} - {{#if ../fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=../fields.damage.fields.parts.element.fields source=../source.damage baseFields=../fields.damage.fields outcome=tab.id }}{{/if}} + {{#if ../fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=../fields.damage.fields.parts.element.fields source=../source.damage baseFields=../fields.damage.fields outcome=tab.id outcomePath="damage" }}{{/if}} {{else}} {{#with (lookup ../fields.damage.fields.altOutcomes.fields tab.id) as |field|}} - {{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=field.fields.parts.element.fields source=(lookup ../../source.damage.altOutcomes ../id) baseFields=field.fields outcome=../id }} + {{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=field.fields.parts.element.fields source=(lookup ../../source.damage.altOutcomes ../id) baseFields=field.fields outcome=../id outcomePath=(concat "damage.altOutcomes." tab.id) }} {{/with }} {{/if}}
From e12d5ce851809222ab4ba9648a7637b9df57be50 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 14 May 2026 21:13:33 +0200 Subject: [PATCH 4/8] Changed to use DefaultOutcome and added successHope as an alt outcome --- lang/en.json | 9 ++++++--- .../sheets-configs/action-base-config.mjs | 18 +++++++----------- module/config/actionConfig.mjs | 4 ++++ module/data/fields/action/damageField.mjs | 12 +++++++++++- templates/actionTypes/damage.hbs | 3 +++ .../sheets-settings/action-settings/effect.hbs | 17 ++++++++++------- 6 files changed, 41 insertions(+), 22 deletions(-) diff --git a/lang/en.json b/lang/en.json index fcce504d..28323898 100755 --- a/lang/en.json +++ b/lang/en.json @@ -136,6 +136,8 @@ "criticalThreshold": "Critical Threshold", "includeBase": { "label": "Include Item Damage" }, "groupAttack": { "label": "Group Attack" }, + "inheritDefaultDamage": { "label": "Inherit Default Damage" }, + "inheritDefaultEffects": { "label": "Inherit Default Effects" }, "multiplier": "Multiplier", "saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.", "resultBased": { @@ -1280,11 +1282,11 @@ "die": "Die" }, "OutcomeType": { + "default": "Default Outcome", "successHope": "Success/ Hope", "successFear": "Success/ Fear", "failureHope": "Failure/ Hope", - "failureFear": "Failure/ Fear", - "simpleOutcome": "Outcome" + "failureFear": "Failure/ Fear" }, "Range": { "self": { @@ -2359,7 +2361,8 @@ "deathMoves": "Deathmoves", "sources": "Sources", "packs": "Packs", - "range": "Range" + "range": "Range", + "outcomes": "Outcomes" }, "Tiers": { "singular": "Tier", diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index 88c6d343..49aa36fb 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -21,7 +21,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) /* Needs to consider effect altOutcomes aswell */ static getOutcomeTabs(action) { const outcomeKeys = [ - 'successHope', + 'default', ...Object.keys(action.damage?.altOutcomes ?? {}).filter(key => action.damage.altOutcomes[key]) ]; return outcomeKeys.reduce((acc, key, index) => { @@ -31,10 +31,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) group: 'outcomes', id: key, icon: null, - label: - outcomeKeys.length === 1 - ? game.i18n.localize('DAGGERHEART.CONFIG.OutcomeType.simpleOutcome') - : game.i18n.localize(CONFIG.DH.ACTIONS.outcomeTypes[key].label) + label: game.i18n.localize(CONFIG.DH.ACTIONS.outcomeTypes[key].label) }; return acc; }, {}); @@ -43,8 +40,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) /* Needs to consider effect altOutcomes aswell */ static selectOutcome(action, callback) { const choices = Object.entries(CONFIG.DH.ACTIONS.outcomeTypes).reduce((acc, [key, value]) => { - if (key !== 'successHope' && action.damage.altOutcomes[key] === null) - acc.push({ id: key, label: game.i18n.localize(value.label) }); + if (action.damage.altOutcomes[key] === null) acc.push({ id: key, label: game.i18n.localize(value.label) }); return acc; }, []); @@ -185,7 +181,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) group: 'primary', id: 'effect', icon: null, - label: 'DAGGERHEART.GENERAL.Tabs.effects' + label: 'DAGGERHEART.GENERAL.Tabs.outcomes' }, trigger: { active: false, @@ -398,7 +394,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) const outcome = button.dataset.outcome; const outcomeParts = - outcome === 'successHope' + outcome === 'default' ? this.action._source.damage.parts : this.action._source.damage.altOutcomes[outcome].parts; const choices = getUnusedDamageTypes(outcomeParts); @@ -424,7 +420,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) part.type = this.action.schema.fields.damage.fields.parts.element.fields.type.element.initial; - if (outcome === 'successHope') data.damage.parts[type] = part; + if (outcome === 'default') data.damage.parts[type] = part; else { if (!data.damage.altOutcomes[outcome]) { data.damage.altOutcomes[outcome] = new AltDamageOutcome(); @@ -464,7 +460,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) if (!this.action.damage.parts) return; const data = this.action.toObject(); const { key, outcome } = button.dataset; - if (outcome === 'successHope') { + if (outcome === 'default') { delete data.damage.parts[key]; data.damage.parts[`${key}`] = _del; } else { diff --git a/module/config/actionConfig.mjs b/module/config/actionConfig.mjs index 012ca4c6..83a2d669 100644 --- a/module/config/actionConfig.mjs +++ b/module/config/actionConfig.mjs @@ -124,6 +124,10 @@ export const areaTypes = { }; export const outcomeTypes = { + default: { + key: 'default', + label: 'DAGGERHEART.CONFIG.OutcomeType.default' + }, successHope: { key: 'successHope', label: 'DAGGERHEART.CONFIG.OutcomeType.successHope' diff --git a/module/data/fields/action/damageField.mjs b/module/data/fields/action/damageField.mjs index 6da3f188..abf2f9a6 100644 --- a/module/data/fields/action/damageField.mjs +++ b/module/data/fields/action/damageField.mjs @@ -24,6 +24,7 @@ export default class DamageField extends fields.SchemaField { const damageFields = { ...getDamageBaseFields(), altOutcomes: new fields.SchemaField({ + successHope: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), successFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), failureHope: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }), failureFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }) @@ -345,7 +346,16 @@ export class DHDamageData extends DHResourceData { export class AltDamageOutcome extends foundry.abstract.DataModel { static defineSchema() { return { - useStandardHitPointDamage: new fields.BooleanField({ required: true, initial: true }), + inheritDefaultDamage: new fields.BooleanField({ + required: true, + initial: true, + label: 'DAGGERHEART.ACTIONS.Settings.inheritDefaultDamage.label' + }), + inheritDefaultEffects: new fields.BooleanField({ + required: true, + initial: true, + label: 'DAGGERHEART.ACTIONS.Settings.inheritDefaultEffects.label' + }), ...getDamageBaseFields() }; } diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index fef6591e..9e9541de 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -18,6 +18,9 @@ {{#if (and @root.isNPC (not (eq path 'system.attack.')))}} {{formField baseFields.groupAttack value=source.groupAttack name=(concat path basePath ".groupAttack") localize=true classes="select"}} {{/if}} + {{#unless isDefaultDamage}} + {{formField @root.fields.damage.fields.altOutcomes.fields.successFear.fields.inheritDefaultDamage name=(concat path basePath ".inheritDefaultDamage") localize=true classes="checkbox"}} + {{/unless}} {{!-- Handlebars uses Symbol.Iterator to produce index|key. This isn't compatible with our parts object, so we instead use applyTo, which is the same value --}} diff --git a/templates/sheets-settings/action-settings/effect.hbs b/templates/sheets-settings/action-settings/effect.hbs index ab03b7ea..3d91fc1f 100644 --- a/templates/sheets-settings/action-settings/effect.hbs +++ b/templates/sheets-settings/action-settings/effect.hbs @@ -9,7 +9,7 @@ {{localize tab.label}} - {{#unless (eq tab.id 'successHope')}}{{/unless}} + {{#unless (eq tab.id 'default')}}{{/unless}} {{/each}} @@ -21,13 +21,16 @@ data-group="outcomes" data-tab="{{tab.id}}" > - {{#if (eq tab.id 'successHope')}} - {{#if ../fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=../fields.damage.fields.parts.element.fields source=../source.damage baseFields=../fields.damage.fields outcome=tab.id outcomePath="damage" }}{{/if}} - {{else}} - {{#with (lookup ../fields.damage.fields.altOutcomes.fields tab.id) as |field|}} - {{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=field.fields.parts.element.fields source=(lookup ../../source.damage.altOutcomes ../id) baseFields=field.fields outcome=../id outcomePath=(concat "damage.altOutcomes." tab.id) }} - {{/with }} + {{#if ../fields.damage}} + {{#if (eq tab.id 'default')}} + {{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=../fields.damage.fields.parts.element.fields source=../source.damage baseFields=../fields.damage.fields outcome=tab.id outcomePath="damage" isDefaultDamage="true" }} + {{else}} + {{#with (lookup ../fields.damage.fields.altOutcomes.fields tab.id) as |field|}} + {{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=field.fields.parts.element.fields source=(lookup ../../source.damage.altOutcomes ../id) baseFields=field.fields outcome=../id outcomePath=(concat "damage.altOutcomes." tab.id) }} + {{/with }} + {{/if}} {{/if}} + {{/each}} From 12119bfbfc037cd9f5537315a39713f878ebcb8c Mon Sep 17 00:00:00 2001 From: WBHarry Date: Fri, 15 May 2026 09:07:46 +0200 Subject: [PATCH 5/8] Removed inherit --- lang/en.json | 2 -- module/data/fields/action/damageField.mjs | 10 ---------- templates/actionTypes/damage.hbs | 3 --- 3 files changed, 15 deletions(-) diff --git a/lang/en.json b/lang/en.json index 28323898..624ec525 100755 --- a/lang/en.json +++ b/lang/en.json @@ -136,8 +136,6 @@ "criticalThreshold": "Critical Threshold", "includeBase": { "label": "Include Item Damage" }, "groupAttack": { "label": "Group Attack" }, - "inheritDefaultDamage": { "label": "Inherit Default Damage" }, - "inheritDefaultEffects": { "label": "Inherit Default Effects" }, "multiplier": "Multiplier", "saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.", "resultBased": { diff --git a/module/data/fields/action/damageField.mjs b/module/data/fields/action/damageField.mjs index abf2f9a6..78c27774 100644 --- a/module/data/fields/action/damageField.mjs +++ b/module/data/fields/action/damageField.mjs @@ -346,16 +346,6 @@ export class DHDamageData extends DHResourceData { export class AltDamageOutcome extends foundry.abstract.DataModel { static defineSchema() { return { - inheritDefaultDamage: new fields.BooleanField({ - required: true, - initial: true, - label: 'DAGGERHEART.ACTIONS.Settings.inheritDefaultDamage.label' - }), - inheritDefaultEffects: new fields.BooleanField({ - required: true, - initial: true, - label: 'DAGGERHEART.ACTIONS.Settings.inheritDefaultEffects.label' - }), ...getDamageBaseFields() }; } diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index 9e9541de..fef6591e 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -18,9 +18,6 @@ {{#if (and @root.isNPC (not (eq path 'system.attack.')))}} {{formField baseFields.groupAttack value=source.groupAttack name=(concat path basePath ".groupAttack") localize=true classes="select"}} {{/if}} - {{#unless isDefaultDamage}} - {{formField @root.fields.damage.fields.altOutcomes.fields.successFear.fields.inheritDefaultDamage name=(concat path basePath ".inheritDefaultDamage") localize=true classes="checkbox"}} - {{/unless}} {{!-- Handlebars uses Symbol.Iterator to produce index|key. This isn't compatible with our parts object, so we instead use applyTo, which is the same value --}} From 13a9ddba46adee5740effa43051fe8a6e3377c18 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Fri, 15 May 2026 18:39:44 -0400 Subject: [PATCH 6/8] Update file organization a bit --- .../sheets-configs/action-base-config.mjs | 158 ++++++++---------- .../sheets-configs/action-config.mjs | 8 +- 2 files changed, 77 insertions(+), 89 deletions(-) diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index 49aa36fb..dda9a2b4 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -18,75 +18,6 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) return `${game.i18n.localize('DAGGERHEART.GENERAL.Tabs.settings')}: ${this.action.name}`; } - /* Needs to consider effect altOutcomes aswell */ - static getOutcomeTabs(action) { - const outcomeKeys = [ - 'default', - ...Object.keys(action.damage?.altOutcomes ?? {}).filter(key => action.damage.altOutcomes[key]) - ]; - return outcomeKeys.reduce((acc, key, index) => { - acc[key] = { - active: index === 0, - cssClass: '', - group: 'outcomes', - id: key, - icon: null, - label: game.i18n.localize(CONFIG.DH.ACTIONS.outcomeTypes[key].label) - }; - return acc; - }, {}); - } - - /* Needs to consider effect altOutcomes aswell */ - static selectOutcome(action, callback) { - const choices = Object.entries(CONFIG.DH.ACTIONS.outcomeTypes).reduce((acc, [key, value]) => { - if (action.damage.altOutcomes[key] === null) acc.push({ id: key, label: game.i18n.localize(value.label) }); - - return acc; - }, []); - const content = new foundry.data.fields.StringField({ - label: game.i18n.localize('Outcome'), - choices, - required: true - }).toFormGroup( - {}, - { - name: 'outcome', - localize: true, - nameAttr: 'value', - labelAttr: 'label' - } - ).outerHTML; - - const callbackWrapper = (_, button) => { - const choiceIndex = button.form.elements.outcome.value; - callback(choices[choiceIndex]?.id); - }; - - const typeDialog = new foundry.applications.api.DialogV2({ - buttons: [ - foundry.utils.mergeObject( - { - action: 'ok', - label: 'Confirm', - icon: 'fas fa-check', - default: true - }, - { callback: callbackWrapper } - ) - ], - content: content, - rejectClose: false, - modal: false, - window: { - title: game.i18n.localize('Add Outcome') - }, - position: { width: 300 } - }); - - typeDialog.render(true); - } - static DEFAULT_OPTIONS = { tag: 'form', classes: ['daggerheart', 'dh-style', 'action-config', 'dialog', 'max-800'], @@ -97,16 +28,11 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) position: { width: 600, height: 'auto' }, actions: { toggleSection: this.toggleSection, - addEffect: this.addEffect, - removeEffect: this.removeEffect, addElement: this.addElement, removeElement: this.removeElement, removeTransformActor: this.removeTransformActor, - addOutcome: this.addOutcome, - removeOutcome: this.removeOutcome, - editEffect: this.editEffect, - addDamage: this.addDamage, - removeDamage: this.removeDamage, + addDamage: this.onAddDamage, + removeDamage: this.onRemoveDamage, editDoc: this.editDoc, addTrigger: this.addTrigger, removeTrigger: this.removeTrigger, @@ -195,6 +121,75 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) static CLEAN_ARRAYS = ['cost', 'effects', 'summon']; + /* Needs to consider effect altOutcomes aswell */ + static getOutcomeTabs(action) { + const outcomeKeys = [ + 'default', + ...Object.keys(action.damage?.altOutcomes ?? {}).filter(key => action.damage.altOutcomes[key]) + ]; + return outcomeKeys.reduce((acc, key, index) => { + acc[key] = { + active: index === 0, + cssClass: '', + group: 'outcomes', + id: key, + icon: null, + label: game.i18n.localize(CONFIG.DH.ACTIONS.outcomeTypes[key].label) + }; + return acc; + }, {}); + } + + /* Needs to consider effect altOutcomes aswell */ + static selectOutcome(action, callback) { + const choices = Object.entries(CONFIG.DH.ACTIONS.outcomeTypes).reduce((acc, [key, value]) => { + if (action.damage.altOutcomes[key] === null) acc.push({ id: key, label: game.i18n.localize(value.label) }); + + return acc; + }, []); + const content = new foundry.data.fields.StringField({ + label: game.i18n.localize('Outcome'), + choices, + required: true + }).toFormGroup( + {}, + { + name: 'outcome', + localize: true, + nameAttr: 'value', + labelAttr: 'label' + } + ).outerHTML; + + const callbackWrapper = (_, button) => { + const choiceIndex = button.form.elements.outcome.value; + callback(choices[choiceIndex]?.id); + }; + + const typeDialog = new foundry.applications.api.DialogV2({ + buttons: [ + foundry.utils.mergeObject( + { + action: 'ok', + label: 'Confirm', + icon: 'fas fa-check', + default: true + }, + { callback: callbackWrapper } + ) + ], + content: content, + rejectClose: false, + modal: false, + window: { + title: game.i18n.localize('Add Outcome') + }, + position: { width: 300 } + }); + + typeDialog.render(true); + } + _getTabs(tabs) { for (const v of Object.values(tabs)) { v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active; @@ -389,7 +384,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); } - static addDamage(_event, button) { + static onAddDamage(_event, button) { if (!this.action.damage.parts) return; const outcome = button.dataset.outcome; @@ -456,7 +451,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) typeDialog.render(true); } - static removeDamage(_event, button) { + static onRemoveDamage(_event, button) { if (!this.action.damage.parts) return; const data = this.action.toObject(); const { key, outcome } = button.dataset; @@ -557,13 +552,6 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); } - /** Specific implementation in extending classes **/ - static addOutcome(_event) {} - static removeOutcome(_event) {} - static async addEffect(_event) {} - static removeEffect(_event, _button) {} - static editEffect(_event) {} - async close(options) { this.tabGroups.primary = 'base'; await super.close(options); diff --git a/module/applications/sheets-configs/action-config.mjs b/module/applications/sheets-configs/action-config.mjs index 833c3ebd..a4b0a6c4 100644 --- a/module/applications/sheets-configs/action-config.mjs +++ b/module/applications/sheets-configs/action-config.mjs @@ -6,8 +6,8 @@ export default class DHActionConfig extends DHActionBaseConfig { ...DHActionBaseConfig.DEFAULT_OPTIONS, actions: { ...DHActionBaseConfig.DEFAULT_OPTIONS.actions, - addOutcome: this.addOutcome, - removeOutcome: this.removeOutcome, + addOutcome: this.onAddOutcome, + removeOutcome: this.onRemoveOutcome, addEffect: this.addEffect, removeEffect: this.removeEffect, editEffect: this.editEffect @@ -22,7 +22,7 @@ export default class DHActionConfig extends DHActionBaseConfig { return context; } - static addOutcome() { + static onAddOutcome() { const data = this.action.toObject(); DHActionBaseConfig.selectOutcome(this.action, key => { @@ -34,7 +34,7 @@ export default class DHActionConfig extends DHActionBaseConfig { }); } - static removeOutcome(_event, button) { + static onRemoveOutcome(_event, button) { const { outcome } = button.dataset; const data = this.action.toObject(); From 1af377ba2ce0a48f27decf9db5f012602a158003 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Fri, 15 May 2026 20:23:59 -0400 Subject: [PATCH 7/8] Cleanup of damage outcomes add/remove --- .../sheets-configs/action-base-config.mjs | 45 ++++++------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index dda9a2b4..7625d018 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -388,10 +388,8 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) if (!this.action.damage.parts) return; const outcome = button.dataset.outcome; - const outcomeParts = - outcome === 'default' - ? this.action._source.damage.parts - : this.action._source.damage.altOutcomes[outcome].parts; + const source = this.action._source; + const outcomeParts = outcome === 'default' ? source.damage.parts : source.damage.altOutcomes[outcome].parts; const choices = getUnusedDamageTypes(outcomeParts); const content = new foundry.data.fields.StringField({ label: game.i18n.localize('Damage Type'), @@ -412,32 +410,23 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) const type = choices[button.form.elements.type.value].value; const part = this.action.schema.fields.damage.fields.parts.element.getInitialValue(); part.applyTo = type; - if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) + if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) { part.type = this.action.schema.fields.damage.fields.parts.element.fields.type.element.initial; - - if (outcome === 'default') data.damage.parts[type] = part; - else { - if (!data.damage.altOutcomes[outcome]) { - data.damage.altOutcomes[outcome] = new AltDamageOutcome(); - } - - data.damage.altOutcomes[outcome].parts[type] = part; } - + if (outcome !== 'default') data.damage.altOutcomes[outcome] ??= new AltDamageOutcome(); + (outcome === 'default' ? data.damage : data.damage.altOutcomes[outcome]).parts[type] = part; this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); }; const typeDialog = new foundry.applications.api.DialogV2({ buttons: [ - foundry.utils.mergeObject( - { - action: 'ok', - label: 'Confirm', - icon: 'fas fa-check', - default: true - }, - { callback: callback } - ) + { + action: 'ok', + label: 'Confirm', + icon: 'fas fa-check', + default: true, + callback + } ], content: content, rejectClose: false, @@ -455,14 +444,8 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) if (!this.action.damage.parts) return; const data = this.action.toObject(); const { key, outcome } = button.dataset; - if (outcome === 'default') { - delete data.damage.parts[key]; - data.damage.parts[`${key}`] = _del; - } else { - delete data.damage.altOutcomes[outcome].parts[key]; - data.damage.altOutcomes[outcome].parts[`${key}`] = _del; - } - + const parts = outcome === 'default' ? data.damage.parts : data.damage.altOutcomes[outcome].parts; + parts[key] = _del; this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) }); } From 2cc6b2ef8483dbe8148ce7b1bb103231c0ffb24e Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Fri, 15 May 2026 21:29:27 -0400 Subject: [PATCH 8/8] Rename effects tab to outcomes --- .../applications/sheets-configs/action-base-config.mjs | 10 +++++----- .../action-settings/{effect.hbs => outcomes.hbs} | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) rename templates/sheets-settings/action-settings/{effect.hbs => outcomes.hbs} (97%) diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index 7625d018..d09e464f 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -66,9 +66,9 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) id: 'range', template: 'systems/daggerheart/templates/sheets-settings/action-settings/range.hbs' }, - effect: { - id: 'effect', - template: 'systems/daggerheart/templates/sheets-settings/action-settings/effect.hbs' + outcomes: { + id: 'outcomes', + template: 'systems/daggerheart/templates/sheets-settings/action-settings/outcomes.hbs' }, trigger: { id: 'trigger', @@ -101,11 +101,11 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) icon: null, label: 'DAGGERHEART.GENERAL.Tabs.range' }, - effect: { + outcomes: { active: false, cssClass: '', group: 'primary', - id: 'effect', + id: 'outcomes', icon: null, label: 'DAGGERHEART.GENERAL.Tabs.outcomes' }, diff --git a/templates/sheets-settings/action-settings/effect.hbs b/templates/sheets-settings/action-settings/outcomes.hbs similarity index 97% rename from templates/sheets-settings/action-settings/effect.hbs rename to templates/sheets-settings/action-settings/outcomes.hbs index 3d91fc1f..442333a4 100644 --- a/templates/sheets-settings/action-settings/effect.hbs +++ b/templates/sheets-settings/action-settings/outcomes.hbs @@ -1,7 +1,7 @@