This commit is contained in:
WBHarry 2026-04-28 20:30:32 +02:00
parent 1cece731ee
commit dbb08fec8c
7 changed files with 113 additions and 12 deletions

View file

@ -2347,7 +2347,8 @@
"triggers": "Triggers",
"deathMoves": "Deathmoves",
"sources": "Sources",
"packs": "Packs"
"packs": "Packs",
"range": "Range"
},
"Tiers": {
"singular": "Tier",

View file

@ -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;

View file

@ -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
}
}

View file

@ -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 {
}
}
}
}
}

View file

@ -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}}
</section>

View file

@ -1,11 +1,19 @@
<section
<section
class="tab {{this.tabs.effect.cssClass}}"
data-group="primary"
data-tab="effect"
>
{{#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}}
<nav class='inner-tabs tabs' data-group='outcomes'>
{{#each outcomeTabs as |tab|}}
<div class="inner-tab">
<a class='{{tab.id}} {{tab.cssClass}}' data-action='tab' data-group='{{tab.group}}' data-tab='{{tab.id}}'>
{{localize tab.label}}
</a>
</div>
{{/each}}
</nav>
{{#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}}

View file

@ -0,0 +1,8 @@
<section
class="tab {{this.tabs.range.cssClass}}"
data-group="primary"
data-tab="range"
>
{{> '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}}
</section>