1794 - Include Item Damage (#1827)

* Went ahead and made IncludeItemDamage work again, smashing the formulas together

* .

* Lint fix
This commit is contained in:
WBHarry 2026-04-23 00:22:08 +02:00 committed by GitHub
parent e6d5a2f7d3
commit fae05c24a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 52 additions and 55 deletions

View file

@ -119,8 +119,7 @@
"deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?", "deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?",
"advantageState": "Advantage State", "advantageState": "Advantage State",
"damageOnSave": "Damage on Save", "damageOnSave": "Damage on Save",
"useDefaultItemValues": "Use default Item values", "useDefaultItemValues": "Use default Item values"
"itemDamageIsUsed": "Item Damage Is Used"
}, },
"RollField": { "RollField": {
"diceRolling": { "diceRolling": {
@ -135,7 +134,7 @@
"attackModifier": "Attack Modifier", "attackModifier": "Attack Modifier",
"attackName": "Attack Name", "attackName": "Attack Name",
"criticalThreshold": "Critical Threshold", "criticalThreshold": "Critical Threshold",
"includeBase": { "label": "Use Item Damage" }, "includeBase": { "label": "Include Item Damage" },
"groupAttack": { "label": "Group Attack" }, "groupAttack": { "label": "Group Attack" },
"multiplier": "Multiplier", "multiplier": "Multiplier",
"saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.", "saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.",

View file

@ -72,8 +72,8 @@ export default class ActionSelectionDialog extends HandlebarsApplicationMixin(Ap
static async #onChooseAction(event, button) { static async #onChooseAction(event, button) {
const { actionId } = button.dataset; const { actionId } = button.dataset;
this.action = this.item.system.actionsList.find(a => a._id === actionId); this.#action = this.item.system.actionsList.find(a => a._id === actionId);
Object.defineProperty(this.event, 'shiftKey', { Object.defineProperty(this.#event, 'shiftKey', {
get() { get() {
return event.shiftKey; return event.shiftKey;
} }

View file

@ -156,7 +156,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
context.openSection = this.openSection; context.openSection = this.openSection;
context.tabs = this._getTabs(this.constructor.TABS); context.tabs = this._getTabs(this.constructor.TABS);
context.config = CONFIG.DH; context.config = CONFIG.DH;
if (this.action.hasDamage) { if (this.action.damage) {
context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length; context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length;
if (this.action.damage.hasOwnProperty('includeBase') && this.action.type === 'attack') if (this.action.damage.hasOwnProperty('includeBase') && this.action.type === 'attack')
@ -302,7 +302,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
static addDamage(_event) { static addDamage(_event) {
if (!this.action.damage.parts) return; if (!this.action.damage.parts) return;
const choices = getUnusedDamageTypes(this.action.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'),
choices, choices,

View file

@ -1,4 +1,3 @@
import { DHDamageData } from '../fields/action/damageField.mjs';
import DHDamageAction from './damageAction.mjs'; import DHDamageAction from './damageAction.mjs';
export default class DHAttackAction extends DHDamageAction { export default class DHAttackAction extends DHDamageAction {
@ -12,8 +11,19 @@ export default class DHAttackAction extends DHDamageAction {
super.prepareData(); super.prepareData();
if (!!this.item?.system?.attack) { if (!!this.item?.system?.attack) {
if (this.damage.includeBase) { if (this.damage.includeBase) {
const baseDamage = this.getParentDamage(); const baseDamage = this.getParentHitPointDamage();
this.damage.parts.hitPoints = new DHDamageData(baseDamage); if (baseDamage) {
if (!this.damage.parts.hitPoints) {
this.damage.parts.hitPoints = baseDamage;
} else {
for (const type of baseDamage.type) this.damage.parts.hitPoints.type.add(type);
this.damage.parts.hitPoints.value.custom = {
enabled: true,
formula: `${baseDamage.value.getFormula()} + ${this.damage.parts.hitPoints.value.getFormula()}`
};
}
}
} }
if (this.roll.useDefault) { if (this.roll.useDefault) {
this.roll.trait = this.item.system.attack.roll.trait; this.roll.trait = this.item.system.attack.roll.trait;
@ -22,16 +32,8 @@ export default class DHAttackAction extends DHDamageAction {
} }
} }
getParentDamage() { getParentHitPointDamage() {
return { return this.item?.system?.attack.damage.parts.hitPoints;
value: {
multiplier: 'prof',
dice: this.item?.system?.attack.damage.parts.hitPoints.value.dice,
bonus: this.item?.system?.attack.damage.parts.hitPoints.value.bonus ?? 0
},
type: this.item?.system?.attack.damage.parts.hitPoints.type,
base: true
};
} }
get damageFormula() { get damageFormula() {

View file

@ -31,44 +31,40 @@
{{/unless}} {{/unless}}
</legend> </legend>
{{#unless (and @root.source.damage.includeBase (eq key 'hitPoints'))}} {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base))}}
{{#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 "damage.parts." dmg.applyTo ".resultBased") localize=true classes="checkbox"}} {{/if}}
{{/if}} {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base) dmg.resultBased)}}
{{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base) dmg.resultBased)}} <div class="nest-inputs">
<div class="nest-inputs">
<fieldset class="one-column">
<legend>{{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.hope")}}</legend>
{{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}}
</fieldset>
<fieldset class="one-column">
<legend>{{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.fear")}}</legend>
{{> formula fields=../fields.valueAlt.fields type=../fields.type dmg=dmg source=dmg.valueAlt target="valueAlt" key=dmg.applyTo path=../path}}
</fieldset>
</div>
{{else}}
{{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}}
{{/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}}
{{/if}}
{{#if ../horde}}
<fieldset class="one-column"> <fieldset class="one-column">
<legend>{{localize "DAGGERHEART.ACTORS.Adversary.hordeDamage"}}</legend> <legend>{{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.hope")}}</legend>
<div class="nest-inputs"> {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}}
<input type="hidden" name="{{../path}}damage.parts.{{dmg.applyTo}}.valueAlt.multiplier" value="flat">
{{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"}}
</div>
</fieldset> </fieldset>
{{/if}} <fieldset class="one-column">
<input type="hidden" name="{{concat ../path "damage.parts." dmg.applyTo ".base"}}" value="{{dmg.base}}"> <legend>{{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.fear")}}</legend>
{{> formula fields=../fields.valueAlt.fields type=../fields.type dmg=dmg source=dmg.valueAlt target="valueAlt" key=dmg.applyTo path=../path}}
</fieldset>
</div>
{{else}} {{else}}
<span class="hint">{{localize "DAGGERHEART.ACTIONS.Config.itemDamageIsUsed"}}</span> {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}}
{{/unless}} {{/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}}
{{/if}}
{{#if ../horde}}
<fieldset class="one-column">
<legend>{{localize "DAGGERHEART.ACTORS.Adversary.hordeDamage"}}</legend>
<div class="nest-inputs">
<input type="hidden" name="{{../path}}damage.parts.{{dmg.applyTo}}.valueAlt.multiplier" value="flat">
{{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"}}
</div>
</fieldset>
{{/if}}
<input type="hidden" name="{{concat ../path "damage.parts." dmg.applyTo ".base"}}" value="{{dmg.base}}">
</fieldset> </fieldset>
</div> </div>
{{/each}} {{/each}}