diff --git a/module/config/actorConfig.mjs b/module/config/actorConfig.mjs index 99d075c2..54bf0143 100644 --- a/module/config/actorConfig.mjs +++ b/module/config/actorConfig.mjs @@ -140,18 +140,6 @@ export const companionResources = { ...companionBaseResources }; -export const getScrollingTextResources = actorType => ({ - armor: { - label: 'DAGGERHEART.GENERAL.armor', - reverse: true - }, - ...(actorType === 'character' - ? characterResources - : actorType === 'adversary' - ? adversaryResources - : companionResources) -}); - export const featureProperties = { agility: { name: 'DAGGERHEART.CONFIG.Traits.agility.name', diff --git a/module/data/actor/base.mjs b/module/data/actor/base.mjs index 913bdc5e..e2f910a0 100644 --- a/module/data/actor/base.mjs +++ b/module/data/actor/base.mjs @@ -213,7 +213,7 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel { const textData = Object.keys(changes.system.resources).reduce((acc, key) => { const resource = changes.system.resources[key]; if (resource.value !== undefined && resource.value !== this.resources[key].value) { - acc.push(getScrollTextData(this.resources, resource, key, this.parent.type)); + acc.push(getScrollTextData(this.parent, resource, key)); } return acc; diff --git a/module/data/item/base.mjs b/module/data/item/base.mjs index 3b11e945..748d292f 100644 --- a/module/data/item/base.mjs +++ b/module/data/item/base.mjs @@ -225,10 +225,9 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel { changed.system?.marks?.value !== undefined && changed.system.marks.value !== this.marks.value; if (armorChanged && autoSettings.resourceScrollTexts && this.parent.parent?.type === 'character') { const armorData = getScrollTextData( - this.parent.parent.system.resources, + this.parent.parent, changed.system.marks, 'armor', - this.parent.parent.type ); options.scrollingTextData = [armorData]; } diff --git a/module/helpers/utils.mjs b/module/helpers/utils.mjs index bdb72586..be213f4a 100644 --- a/module/helpers/utils.mjs +++ b/module/helpers/utils.mjs @@ -1,3 +1,4 @@ +import { adversaryResources, characterResources, companionResources } from '../config/actorConfig.mjs'; import { diceTypes, getDiceSoNicePresets, getDiceSoNicePreset, range } from '../config/generalConfig.mjs'; import Tagify from '@yaireo/tagify'; @@ -378,8 +379,21 @@ export const arraysEqual = (a, b) => export const setsEqual = (a, b) => a.size === b.size && [...a].every(value => b.has(value)); -export function getScrollTextData(resources, resource, key, actorType) { - const { reverse, label } = CONFIG.DH.ACTOR.getScrollingTextResources(actorType)[key]; +export function getScrollTextData(actor, resource, key) { + const actorType = actor.type; + const resources = actor.system.resources; + const { reverse, label } = { + armor: { + label: 'DAGGERHEART.GENERAL.armor', + reverse: true + }, + ...(actorType === 'character' + ? characterResources + : actorType === 'adversary' + ? adversaryResources + : companionResources) + }[key]; + const { BOTTOM, TOP } = CONST.TEXT_ANCHOR_POINTS; const increased = resources[key].value < resource.value; const value = -1 * (resources[key].value - resource.value);