Start of different outcomes

This commit is contained in:
WBHarry 2026-05-03 19:04:44 +02:00
parent 482f712086
commit 3c99519660
4 changed files with 42 additions and 15 deletions

View file

@ -1,3 +1,4 @@
import { AltDamageOutcome } from '../../data/fields/action/damageField.mjs';
import { getUnusedDamageTypes } from '../../helpers/utils.mjs'; import { getUnusedDamageTypes } from '../../helpers/utils.mjs';
import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs'; import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs';
@ -62,7 +63,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
id: 'configuration', id: 'configuration',
template: 'systems/daggerheart/templates/sheets-settings/action-settings/configuration.hbs' template: 'systems/daggerheart/templates/sheets-settings/action-settings/configuration.hbs'
}, },
configuration: { range: {
id: 'range', id: 'range',
template: 'systems/daggerheart/templates/sheets-settings/action-settings/range.hbs' template: 'systems/daggerheart/templates/sheets-settings/action-settings/range.hbs'
}, },
@ -120,19 +121,19 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
}; };
static OUTCOME_TABS = { static OUTCOME_TABS = {
successWithHope: { successHope: {
active: true, active: true,
cssClass: '', cssClass: '',
group: 'outcomes', group: 'outcomes',
id: 'successWithHope', id: 'successHope',
icon: null, icon: null,
label: 'Success With Hope' label: 'Success With Hope'
}, },
successWithFear: { successFear: {
active: false, active: false,
cssClass: '', cssClass: '',
group: 'outcomes', group: 'outcomes',
id: 'successWithFear', id: 'successFear',
icon: null, icon: null,
label: 'Success With Fear' label: 'Success With Fear'
}, },
@ -188,7 +189,6 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
context.tabs = this._getTabs(this.constructor.TABS); context.tabs = this._getTabs(this.constructor.TABS);
context.outcomeTabs = this._getTabs(this.constructor.OUTCOME_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; context.config = CONFIG.DH;
if (this.action.damage) { 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) }); 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; if (!this.action.damage.parts) return;
const outcome = button.dataset.outcome;
const choices = getUnusedDamageTypes(this.action._source.damage.parts); const choices = getUnusedDamageTypes(this.action._source.damage.parts);
const content = new foundry.data.fields.StringField({ const content = new foundry.data.fields.StringField({
label: game.i18n.localize('Damage Type'), 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) if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id)
part.type = this.action.schema.fields.damage.fields.parts.element.fields.type.element.initial; 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) }); this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}; };

View file

@ -343,16 +343,18 @@ export class DHDamageData extends DHResourceData {
} }
} }
class AltDamageOutcome extends foundry.abstract.DataModel { export class AltDamageOutcome extends foundry.abstract.DataModel {
static defineSchema() { static defineSchema() {
return { return {
copyStandard: new fields.BooleanField({ required: true, initial: true }), useStandardHitPointDamage: new fields.BooleanField({ required: true, initial: true }),
...getDamageBaseFields(), ...getDamageBaseFields(),
/* Stuff */
} }
} }
get data() { get data() {
return this.copyStandard ? this.parent : {}; // If not copying, return data from the this alternate outcome return {
...this.parent,
...this,
}
} }
} }

View file

@ -6,7 +6,7 @@
{{else}} {{else}}
{{localize "DAGGERHEART.GENERAL.damage"}} {{localize "DAGGERHEART.GENERAL.damage"}}
{{/if}} {{/if}}
{{#unless (eq path 'system.attack.')}}<a data-action="addDamage" {{#if @root.allDamageTypesUsed}}disabled{{/if}}><i class="fa-solid fa-plus icon-button"></i></a>{{/unless}} {{#unless (eq path 'system.attack.')}}<a data-action="addDamage" data-outcome="{{outcome}}" {{#if @root.allDamageTypesUsed}}disabled{{/if}}><i class="fa-solid fa-plus icon-button"></i></a>{{/unless}}
</legend> </legend>
<div class="nest-inputs"> <div class="nest-inputs">
{{#if @root.hasBaseDamage}} {{#if @root.hasBaseDamage}}

View file

@ -13,7 +13,22 @@
{{/each}} {{/each}}
</nav> </nav>
{{#if fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=outcomeData baseFields=fields.damage.fields }}{{/if}} {{#each outcomeTabs as |tab|}}
<section
class="tab {{lookup (lookup ../outcomeTabs tab.id) 'cssClass'}}"
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 }}{{/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}}
</section>
{{/each}}
{{#if fields.macro}}{{> 'systems/daggerheart/templates/actionTypes/macro.hbs' fields=fields.macro source=source.macro}}{{/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.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}} {{#if fields.beastform}}{{> 'systems/daggerheart/templates/actionTypes/beastform.hbs' fields=fields.beastform.fields source=source.beastform}}{{/if}}