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