diff --git a/daggerheart.mjs b/daggerheart.mjs
index 05b57ac9..fa4fff56 100644
--- a/daggerheart.mjs
+++ b/daggerheart.mjs
@@ -97,6 +97,68 @@ Hooks.once('init', () => {
fields
};
+ CONFIG.DH.ACTOR.characterResources.basic = {
+ id: 'basic',
+ initial: 0,
+ max: 4,
+ reverse: false,
+ label: 'Basic'
+ };
+
+ CONFIG.DH.ACTOR.characterResources.corruption = {
+ id: 'corruption',
+ initial: 0,
+ max: 4,
+ reverse: false,
+ label: 'Corruption',
+ images: {
+ full: {
+ value: 'systems/daggerheart/assets/icons/domains/sage.svg',
+ isPath: true
+ },
+ empty: {
+ value: 'systems/daggerheart/assets/icons/domains/sage.svg',
+ isPath: true
+ }
+ }
+ };
+
+ CONFIG.DH.ACTOR.characterResources.fire = {
+ id: 'fire',
+ initial: 0,
+ max: 6,
+ reverse: false,
+ label: 'On Fire',
+ images: {
+ full: {
+ value: 'icons/magic/fire/barrier-wall-explosion-orange.webp',
+ isPath: true,
+ noColorFilter: true
+ },
+ empty: {
+ value: 'icons/magic/fire/barrier-wall-flame-ring-blue.webp',
+ isPath: true,
+ noColorFilter: true
+ }
+ }
+ };
+
+ CONFIG.DH.ACTOR.characterResources.hunger = {
+ id: 'hunger',
+ initial: 0,
+ max: 6,
+ reverse: false,
+ label: 'Hunger',
+ images: {
+ full: {
+ value: 'fa-solid fa-burger'
+ },
+ empty: {
+ value: 'fa-regular fa-burger'
+ }
+ }
+ };
+
game.system.registeredTriggers = new game.system.api.data.RegisteredTriggers();
const { DocumentSheetConfig } = foundry.applications.apps;
diff --git a/lang/en.json b/lang/en.json
index 4e15c362..c9d21944 100755
--- a/lang/en.json
+++ b/lang/en.json
@@ -2266,7 +2266,6 @@
"identify": "Identity",
"imagePath": "Image Path",
"inactiveEffects": "Inactive Effects",
- "initial": "Initial",
"inventory": "Inventory",
"itemResource": "Item Resource",
"itemQuantity": "Item Quantity",
@@ -2644,8 +2643,6 @@
"resetMovesText": "Are you sure you want to reset?",
"deleteItemTitle": "Delete Homebrew Item",
"deleteItemText": "Are you sure you want to delete the item?",
- "deleteResourceTitle": "Delete Homebrew Resource",
- "deleteResourceText": "Are you sure you want to delete the resource?",
"FIELDS": {
"maxFear": { "label": "Max Fear" },
"maxHope": { "label": "Max Hope" },
@@ -2654,13 +2651,6 @@
"label": "Max Cards in Loadout",
"hint": "Set to blank or 0 for unlimited maximum"
},
- "resources": {
- "resources": {
- "value": { "label": "Icon" },
- "isIcon": { "label": "Font Awesome Icon" },
- "noColorFilter": { "label": "Disable Color Filter" }
- }
- },
"maxDomains": { "label": "Max Class Domains", "hint": "Max domains you can set on a class" }
},
"currency": {
@@ -2689,13 +2679,6 @@
"adversaryType": {
"title": "Custom Adversary Types",
"newType": "Adversary Type"
- },
- "resources": {
- "typeTitle": "{type} Resources",
- "filledIcon": "Filled Icon",
- "emptyIcon": "Empty Icon",
- "resourceIdentifier": "Resource Identifier",
- "setResourceIdentifier": "Set Resource Identifier"
}
},
"Menu": {
diff --git a/module/applications/settings/homebrewSettings.mjs b/module/applications/settings/homebrewSettings.mjs
index 9cc0ecb1..083c468f 100644
--- a/module/applications/settings/homebrewSettings.mjs
+++ b/module/applications/settings/homebrewSettings.mjs
@@ -1,5 +1,4 @@
import { DhHomebrew } from '../../data/settings/_module.mjs';
-import { Resource } from '../../data/settings/Homebrew.mjs';
import { slugify } from '../../helpers/utils.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@@ -45,9 +44,6 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
addAdversaryType: this.addAdversaryType,
deleteAdversaryType: this.deleteAdversaryType,
selectAdversaryType: this.selectAdversaryType,
- addResource: this.addResource,
- removeResource: this.removeResource,
- resetResourceImage: this.resetResourceImage,
save: this.save,
resetTokenSizes: this.resetTokenSizes,
reset: this.reset
@@ -60,10 +56,6 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
settings: { template: 'systems/daggerheart/templates/settings/homebrew-settings/settings.hbs' },
domains: { template: 'systems/daggerheart/templates/settings/homebrew-settings/domains.hbs' },
types: { template: 'systems/daggerheart/templates/settings/homebrew-settings/types.hbs' },
- resources: {
- template: 'systems/daggerheart/templates/settings/homebrew-settings/resources.hbs',
- scrollable: ['.resource-types-container']
- },
itemTypes: { template: 'systems/daggerheart/templates/settings/homebrew-settings/itemFeatures.hbs' },
downtime: { template: 'systems/daggerheart/templates/settings/homebrew-settings/downtime.hbs' },
footer: { template: 'systems/daggerheart/templates/settings/homebrew-settings/footer.hbs' }
@@ -72,14 +64,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
/** @inheritdoc */
static TABS = {
main: {
- tabs: [
- { id: 'settings' },
- { id: 'domains' },
- { id: 'types' },
- { id: 'resources' },
- { id: 'itemFeatures' },
- { id: 'downtime' }
- ],
+ tabs: [{ id: 'settings' }, { id: 'domains' }, { id: 'types' }, { id: 'itemFeatures' }, { id: 'downtime' }],
initial: 'settings',
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
}
@@ -92,17 +77,9 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
this.render();
}
- _attachPartListeners(partId, htmlElement, options) {
- super._attachPartListeners(partId, htmlElement, options);
-
- for (const element of htmlElement.querySelectorAll('.path-field input'))
- element.addEventListener('change', this.toggleResourceIsIcon.bind(this));
- }
-
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.settingFields = this.settings;
- context.schemaFields = context.settingFields.schema.fields;
return context;
}
@@ -126,8 +103,6 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
? { id: this.selected.adversaryType, ...this.settings.adversaryTypes[this.selected.adversaryType] }
: null;
break;
- case 'resources':
- break;
case 'downtime':
context.restOptions = {
shortRest: CONFIG.DH.GENERAL.defaultRestOptions.shortRest(),
@@ -149,33 +124,6 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
this.render();
}
- async toggleResourceIsIcon(event) {
- const element = event.target.closest('.resource-icon-container');
- const { actorType, resourceKey, imageKey } = element.dataset;
-
- const current = this.settings.resources[actorType].resources[resourceKey].images[imageKey];
- await this.settings.updateSource({
- [`resources.${actorType}.resources.${resourceKey}.images.${imageKey}`]: {
- isIcon: !current.isIcon,
- value: ''
- }
- });
-
- this.render();
- }
-
- static async resetResourceImage(_event, button) {
- const element = button.closest('.resource-icon-container');
- const { actorType, resourceKey, imageKey } = element.dataset;
-
- await this.settings.updateSource({
- [`resources.${actorType}.resources.${resourceKey}.images.${imageKey}`]:
- Resource.getDefaultImageData(imageKey)
- });
-
- this.render();
- }
-
static async changeCurrencyIcon(_, target) {
const type = target.dataset.currency;
const currentIcon = this.settings.currency[type].icon;
@@ -518,58 +466,6 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
this.render();
}
- static async addResource(_, target) {
- const { actorType } = target.dataset;
- const content = new foundry.data.fields.StringField({
- label: game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.resources.resourceIdentifier'),
- required: true
- }).toFormGroup({}, { name: 'identifier', localize: true }).outerHTML;
-
- async function callback(_, button) {
- const identifier = button.form.elements.identifier.value;
- if (!identifier) return;
-
- const sluggedIdentifier = slugify(identifier);
-
- await this.settings.updateSource({
- [`resources.${actorType}.resources.${sluggedIdentifier}`]: Resource.getDefaultResourceData(identifier)
- });
-
- game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, this.settings.toObject());
- this.render();
- }
-
- await foundry.applications.api.DialogV2.prompt({
- content: content,
- rejectClose: false,
- modal: true,
- ok: { callback: callback.bind(this) },
- window: {
- title: game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.resources.setResourceIdentifier')
- },
- position: { width: 400 }
- });
- }
-
- static async removeResource(_, target) {
- const confirmed = await foundry.applications.api.DialogV2.confirm({
- window: {
- title: game.i18n.localize(`DAGGERHEART.SETTINGS.Homebrew.deleteResourceTitle`)
- },
- content: game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.deleteResourceText')
- });
-
- if (!confirmed) return;
-
- const { actorType, resourceKey } = target.dataset;
- await this.settings.updateSource({
- [`resources.${actorType}.resources.-=${resourceKey}`]: null
- });
-
- game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, this.settings.toObject());
- this.render();
- }
-
static async save() {
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, this.settings.toObject());
this.close();
diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs
index 537a8713..e2a8d723 100644
--- a/module/applications/sheets/actors/character.mjs
+++ b/module/applications/sheets/actors/character.mjs
@@ -245,8 +245,8 @@ export default class CharacterSheet extends DHBaseActorSheet {
}
async _prepareHeaderContext(context, _options) {
- context.hasExtraResources = Object.keys(CONFIG.DH.RESOURCE.allCharacterResources()).some(
- key => !CONFIG.DH.RESOURCE.characterBaseResources[key]
+ context.hasExtraResources = Object.keys(CONFIG.DH.ACTOR.characterResources).some(
+ key => !CONFIG.DH.ACTOR.characterBaseResources[key]
);
}
@@ -960,8 +960,8 @@ export default class CharacterSheet extends DHBaseActorSheet {
return;
}
- const extraResources = Object.values(CONFIG.DH.RESOURCE.allCharacterResources()).reduce((acc, resource) => {
- if (CONFIG.DH.RESOURCE.characterBaseResources[resource.id]) return acc;
+ const extraResources = Object.values(CONFIG.DH.ACTOR.characterResources).reduce((acc, resource) => {
+ if (CONFIG.DH.ACTOR.characterBaseResources[resource.id]) return acc;
const resourceData = this.document.system.resources[resource.id];
acc[resource.id] = {
@@ -969,8 +969,8 @@ export default class CharacterSheet extends DHBaseActorSheet {
label: game.i18n.localize(resource.label),
value: resourceData.value,
max: resourceData.max,
- fullIcon: resource.images?.full ?? { value: 'fa-solid fa-circle', isIcon: true },
- emptyIcon: resource.images?.empty ?? { value: 'fa-regular fa-circle', isIcon: true }
+ fullIcon: resource.images?.full ?? { value: 'fa-solid fa-circle' },
+ emptyIcon: resource.images?.empty ?? { value: 'fa-regular fa-circle' }
};
return acc;
@@ -1003,10 +1003,10 @@ export default class CharacterSheet extends DHBaseActorSheet {
});
for (const element of html.querySelectorAll('.resource-value'))
- element.addEventListener('click', this.onUpdateResource.bind(this));
+ element.addEventListener('click', this.updateResource.bind(this));
}
- async onUpdateResource(event) {
+ async updateResource(event) {
const target = event.target.closest('.resource-value');
const { resource, value: textValue } = target.dataset;
diff --git a/module/config/_module.mjs b/module/config/_module.mjs
index 7a725f54..560f3fec 100644
--- a/module/config/_module.mjs
+++ b/module/config/_module.mjs
@@ -11,4 +11,3 @@ export * as settingsConfig from './settingsConfig.mjs';
export * as systemConfig from './system.mjs';
export * as itemBrowserConfig from './itemBrowserConfig.mjs';
export * as triggerConfig from './triggerConfig.mjs';
-export * as resourceConfig from './resourceConfig.mjs';
diff --git a/module/config/actorConfig.mjs b/module/config/actorConfig.mjs
index 43795a0b..99d075c2 100644
--- a/module/config/actorConfig.mjs
+++ b/module/config/actorConfig.mjs
@@ -1,5 +1,3 @@
-import { allAdversaryResources, allCharacterResources, allCompanionResources } from './resourceConfig.mjs';
-
export const abilities = {
agility: {
id: 'agility',
@@ -57,6 +55,103 @@ export const abilities = {
}
};
+/**
+ * Full custom typing:
+ * id
+ * initial
+ * max
+ * reverse
+ * label
+ * images {
+ * full { value, isPath, noColorFilter }
+ * empty { value, isPath noColorFilter }
+ * }
+ */
+
+export const characterBaseResources = {
+ hitPoints: {
+ id: 'hitPoints',
+ initial: 0,
+ max: 0,
+ reverse: true,
+ label: 'DAGGERHEART.GENERAL.HitPoints.plural',
+ maxLabel: 'DAGGERHEART.ACTORS.Character.maxHPBonus'
+ },
+ stress: {
+ id: 'stress',
+ initial: 0,
+ max: 6,
+ reverse: true,
+ label: 'DAGGERHEART.GENERAL.stress'
+ },
+ hope: {
+ id: 'hope',
+ initial: 2,
+ min: 0,
+ reverse: false,
+ label: 'DAGGERHEART.GENERAL.hope'
+ }
+};
+
+export const characterResources = {
+ ...characterBaseResources
+};
+
+export const adversaryBaseResources = {
+ hitPoints: {
+ id: 'hitPoints',
+ initial: 0,
+ max: 0,
+ reverse: true,
+ label: 'DAGGERHEART.GENERAL.HitPoints.plural',
+ maxLabel: 'DAGGERHEART.ACTORS.Character.maxHPBonus'
+ },
+ stress: {
+ id: 'stress',
+ initial: 0,
+ max: 0,
+ reverse: true,
+ label: 'DAGGERHEART.GENERAL.stress'
+ }
+};
+
+export const adversaryResources = {
+ ...adversaryBaseResources
+};
+
+export const companionBaseResources = {
+ stress: {
+ id: 'stress',
+ initial: 0,
+ max: 0,
+ reverse: true,
+ label: 'DAGGERHEART.GENERAL.stress'
+ },
+ hope: {
+ id: 'hope',
+ initial: 0,
+ min: 0,
+ reverse: false,
+ label: 'DAGGERHEART.GENERAL.hope'
+ }
+};
+
+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/config/resourceConfig.mjs b/module/config/resourceConfig.mjs
deleted file mode 100644
index 1f594b39..00000000
--- a/module/config/resourceConfig.mjs
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * Full custom typing:
- * id
- * initial
- * max
- * reverse
- * label
- * images {
- * full { value, isIcon, noColorFilter }
- * empty { value, isIcon noColorFilter }
- * }
- */
-
-export const characterBaseResources = {
- hitPoints: {
- id: 'hitPoints',
- initial: 0,
- max: 0,
- reverse: true,
- label: 'DAGGERHEART.GENERAL.HitPoints.plural',
- maxLabel: 'DAGGERHEART.ACTORS.Character.maxHPBonus'
- },
- stress: {
- id: 'stress',
- initial: 0,
- max: 6,
- reverse: true,
- label: 'DAGGERHEART.GENERAL.stress'
- },
- hope: {
- id: 'hope',
- initial: 2,
- min: 0,
- reverse: false,
- label: 'DAGGERHEART.GENERAL.hope'
- }
-};
-
-export const characterResources = {
- ...characterBaseResources
-};
-
-export const allCharacterResources = () => {
- const resources = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).resources.character
- .resources;
- return {
- ...Object.keys(resources).reduce((acc, key) => {
- acc[key] = { ...resources[key].toObject(), id: key };
- return acc;
- }, {}),
- ...characterResources
- };
-};
-
-export const adversaryBaseResources = {
- hitPoints: {
- id: 'hitPoints',
- initial: 0,
- max: 0,
- reverse: true,
- label: 'DAGGERHEART.GENERAL.HitPoints.plural',
- maxLabel: 'DAGGERHEART.ACTORS.Character.maxHPBonus'
- },
- stress: {
- id: 'stress',
- initial: 0,
- max: 0,
- reverse: true,
- label: 'DAGGERHEART.GENERAL.stress'
- }
-};
-
-export const adversaryResources = {
- ...adversaryBaseResources
-};
-
-export const allAdversaryResources = () => adversaryResources;
-
-export const companionBaseResources = {
- stress: {
- id: 'stress',
- initial: 0,
- max: 0,
- reverse: true,
- label: 'DAGGERHEART.GENERAL.stress'
- },
- hope: {
- id: 'hope',
- initial: 0,
- min: 0,
- reverse: false,
- label: 'DAGGERHEART.GENERAL.hope'
- }
-};
-
-export const companionResources = {
- ...companionBaseResources
-};
-
-export const allCompanionResources = () => companionResources;
diff --git a/module/config/system.mjs b/module/config/system.mjs
index 31dba518..47a41e8d 100644
--- a/module/config/system.mjs
+++ b/module/config/system.mjs
@@ -2,7 +2,6 @@ import * as GENERAL from './generalConfig.mjs';
import * as DOMAIN from './domainConfig.mjs';
import * as ENCOUNTER from './encounterConfig.mjs';
import * as ACTOR from './actorConfig.mjs';
-import * as RESOURCE from './resourceConfig.mjs';
import * as ITEM from './itemConfig.mjs';
import * as SETTINGS from './settingsConfig.mjs';
import * as EFFECTS from './effectConfig.mjs';
@@ -20,7 +19,6 @@ export const SYSTEM = {
GENERAL,
DOMAIN,
ACTOR,
- RESOURCE,
ITEM,
SETTINGS,
EFFECTS,
diff --git a/module/data/actor/adversary.mjs b/module/data/actor/adversary.mjs
index 2053ac99..62bed7c7 100644
--- a/module/data/actor/adversary.mjs
+++ b/module/data/actor/adversary.mjs
@@ -187,7 +187,6 @@ export default class DhpAdversary extends DhCreature {
}
prepareDerivedData() {
- super.prepareDerivedData();
this.attack.roll.isStandardAttack = true;
}
diff --git a/module/data/actor/base.mjs b/module/data/actor/base.mjs
index e2f910a0..913bdc5e 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.parent, resource, key));
+ acc.push(getScrollTextData(this.resources, resource, key, this.parent.type));
}
return acc;
diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs
index cc9801a3..c606e17b 100644
--- a/module/data/actor/character.mjs
+++ b/module/data/actor/character.mjs
@@ -658,7 +658,6 @@ export default class DhCharacter extends DhCreature {
}
prepareDerivedData() {
- super.prepareDerivedData();
let baseHope = this.resources.hope.value;
if (this.companion) {
for (let levelKey in this.companion.system.levelData.levelups) {
@@ -678,7 +677,6 @@ export default class DhCharacter extends DhCreature {
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
this.resources.armor = {
- label: 'DAGGERHEART.GENERAL.armor',
value: this.armor?.system?.marks?.value ?? 0,
max: this.armorScore,
isReversed: true
diff --git a/module/data/actor/companion.mjs b/module/data/actor/companion.mjs
index ae85ff69..45bd8395 100644
--- a/module/data/actor/companion.mjs
+++ b/module/data/actor/companion.mjs
@@ -157,7 +157,6 @@ export default class DhCompanion extends DhCreature {
}
prepareDerivedData() {
- super.prepareDerivedData();
/* Partner Related Setup */
if (this.partner) {
this.levelData.level.changed = this.partner.system.levelData.level.current;
diff --git a/module/data/actor/creature.mjs b/module/data/actor/creature.mjs
index e12c645d..33b47415 100644
--- a/module/data/actor/creature.mjs
+++ b/module/data/actor/creature.mjs
@@ -9,34 +9,32 @@ export default class DhCreature extends BaseDataActor {
return {
...super.defineSchema(),
resources: new fields.SchemaField({
- ...Object.values(CONFIG.DH.RESOURCE[`all${this.metadata.type.capitalize()}Resources`]()).reduce(
- (acc, resource) => {
- if (resource.max !== undefined) {
- acc[resource.id] = resourceField(
- resource.max,
- resource.initial,
- resource.label,
- resource.maxLabel
- );
- } else {
- acc[resource.id] = new fields.SchemaField(
- {
- value: new fields.NumberField({
- initial: resource.initial,
- min: resource.min,
- integer: true,
- label: resource.label
- }),
- isReversed: new fields.BooleanField({ initial: resource.reverse })
- },
- { label: resource.label }
- );
- }
+ ...Object.values(CONFIG.DH.ACTOR[`${this.metadata.type}Resources`]).reduce((acc, resource) => {
+ if (resource.max !== undefined) {
+ acc[resource.id] = resourceField(
+ resource.max,
+ resource.initial,
+ resource.label,
+ resource.reverse,
+ resource.maxLabel
+ );
+ } else {
+ acc[resource.id] = new fields.SchemaField(
+ {
+ value: new fields.NumberField({
+ initial: resource.initial,
+ min: resource.min,
+ integer: true,
+ label: resource.label
+ }),
+ isReversed: new fields.BooleanField({ initial: resource.reverse })
+ },
+ { label: resource.label }
+ );
+ }
- return acc;
- },
- {}
- )
+ return acc;
+ }, {})
}),
advantageSources: new fields.ArrayField(new fields.StringField(), {
label: 'DAGGERHEART.ACTORS.Character.advantageSources.label',
@@ -56,17 +54,6 @@ export default class DhCreature extends BaseDataActor {
return !vulnerableAppliedByOther;
}
- prepareDerivedData() {
- super.prepareDerivedData();
- const resources = CONFIG.DH.RESOURCE[`all${this.parent.type.capitalize()}Resources`]();
- if (resources) {
- for (const [key, value] of Object.entries(this.resources)) {
- value.label = resources[key]?.label;
- value.isReversed = resources[key]?.reverse;
- }
- }
- }
-
async _preUpdate(changes, options, userId) {
const allowed = await super._preUpdate(changes, options, userId);
if (allowed === false) return;
diff --git a/module/data/fields/actorField.mjs b/module/data/fields/actorField.mjs
index 2c9bb83d..db1faad4 100644
--- a/module/data/fields/actorField.mjs
+++ b/module/data/fields/actorField.mjs
@@ -6,7 +6,7 @@ const attributeField = label =>
tierMarked: new fields.BooleanField({ initial: false })
});
-const resourceField = (max = 0, initial = 0, label, maxLabel) =>
+const resourceField = (max = 0, initial = 0, label, reverse = false, maxLabel) =>
new fields.SchemaField(
{
value: new fields.NumberField({ initial: initial, min: 0, integer: true, label }),
@@ -16,7 +16,8 @@ const resourceField = (max = 0, initial = 0, label, maxLabel) =>
label:
maxLabel ??
game.i18n.format('DAGGERHEART.GENERAL.maxWithThing', { thing: game.i18n.localize(label) })
- })
+ }),
+ isReversed: new fields.BooleanField({ initial: reverse })
},
{ label }
);
diff --git a/module/data/item/base.mjs b/module/data/item/base.mjs
index 6f3256e3..3b11e945 100644
--- a/module/data/item/base.mjs
+++ b/module/data/item/base.mjs
@@ -224,7 +224,12 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
const armorChanged =
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, changed.system.marks, 'armor');
+ const armorData = getScrollTextData(
+ this.parent.parent.system.resources,
+ changed.system.marks,
+ 'armor',
+ this.parent.parent.type
+ );
options.scrollingTextData = [armorData];
}
diff --git a/module/data/settings/Homebrew.mjs b/module/data/settings/Homebrew.mjs
index c525cabd..b8804fa7 100644
--- a/module/data/settings/Homebrew.mjs
+++ b/module/data/settings/Homebrew.mjs
@@ -145,16 +145,6 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
description: new fields.StringField()
})
),
- resources: new fields.TypedObjectField(
- new fields.SchemaField({
- resources: new fields.TypedObjectField(new fields.EmbeddedDataField(Resource))
- }),
- {
- initial: {
- character: { resources: {} }
- }
- }
- ),
itemFeatures: new fields.SchemaField({
weaponFeatures: new fields.TypedObjectField(
new fields.SchemaField({
@@ -196,64 +186,3 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
return source;
}
}
-
-export class Resource extends foundry.abstract.DataModel {
- static defineSchema() {
- const fields = foundry.data.fields;
- return {
- initial: new fields.NumberField({
- required: true,
- integer: true,
- initial: 0,
- min: 0,
- label: 'DAGGERHEART.GENERAL.initial'
- }),
- max: new fields.NumberField({
- nullable: true,
- initial: null,
- min: 0,
- label: 'DAGGERHEART.GENERAL.max'
- }),
- label: new fields.StringField({ label: 'DAGGERHEART.GENERAL.label' }),
- images: new fields.SchemaField({
- full: imageIconField('fa solid fa-circle'),
- empty: imageIconField('fa-regular fa-circle')
- })
- };
- }
-
- static getDefaultResourceData = label => {
- const images = Resource.schema.fields.images.getInitialValue();
- return {
- initial: 0,
- max: 0,
- label: label ?? '',
- images
- };
- };
-
- static getDefaultImageData = imageKey => {
- return Resource.schema.fields.images.fields[imageKey].getInitialValue();
- };
-}
-
-const imageIconField = defaultValue =>
- new foundry.data.fields.SchemaField(
- {
- value: new foundry.data.fields.StringField({
- initial: defaultValue,
- label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.resources.resources.value.label'
- }),
- isIcon: new foundry.data.fields.BooleanField({
- required: true,
- initial: true,
- label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.resources.resources.isIcon.label'
- }),
- noColorFilter: new foundry.data.fields.BooleanField({
- required: true,
- initial: false,
- label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.resources.resources.noColorFilter.label'
- })
- },
- { required: true }
- );
diff --git a/module/helpers/utils.mjs b/module/helpers/utils.mjs
index 5704b891..bdb72586 100644
--- a/module/helpers/utils.mjs
+++ b/module/helpers/utils.mjs
@@ -378,18 +378,17 @@ export const arraysEqual = (a, b) =>
export const setsEqual = (a, b) => a.size === b.size && [...a].every(value => b.has(value));
-export function getScrollTextData(actor, resource, key) {
+export function getScrollTextData(resources, resource, key, actorType) {
+ const { reverse, label } = CONFIG.DH.ACTOR.getScrollingTextResources(actorType)[key];
const { BOTTOM, TOP } = CONST.TEXT_ANCHOR_POINTS;
-
- const resources = actor.system.resources;
const increased = resources[key].value < resource.value;
const value = -1 * (resources[key].value - resource.value);
- const { label, isReversed } = resources[key];
const text = `${game.i18n.localize(label)} ${value.signedString()}`;
- const stroke = increased ? (isReversed ? 0xffffff : 0x000000) : isReversed ? 0x000000 : 0xffffff;
- const fill = increased ? (isReversed ? 0x0032b1 : 0xffe760) : isReversed ? 0xffe760 : 0x0032b1;
- const direction = increased ? (isReversed ? BOTTOM : TOP) : isReversed ? TOP : BOTTOM;
+
+ const stroke = increased ? (reverse ? 0xffffff : 0x000000) : reverse ? 0x000000 : 0xffffff;
+ const fill = increased ? (reverse ? 0x0032b1 : 0xffe760) : reverse ? 0xffe760 : 0x0032b1;
+ const direction = increased ? (reverse ? BOTTOM : TOP) : reverse ? TOP : BOTTOM;
return { text, stroke, fill, direction };
}
diff --git a/styles/less/ui/index.less b/styles/less/ui/index.less
index 5a6e5878..065e43c5 100644
--- a/styles/less/ui/index.less
+++ b/styles/less/ui/index.less
@@ -27,7 +27,6 @@
@import './settings/settings.less';
@import './settings/homebrew-settings/domains.less';
@import './settings/homebrew-settings/types.less';
-@import './settings/homebrew-settings/resources.less';
@import './sidebar/tabs.less';
@import './sidebar/daggerheartMenu.less';
diff --git a/styles/less/ui/settings/homebrew-settings/resources.less b/styles/less/ui/settings/homebrew-settings/resources.less
deleted file mode 100644
index 5333e54d..00000000
--- a/styles/less/ui/settings/homebrew-settings/resources.less
+++ /dev/null
@@ -1,87 +0,0 @@
-.daggerheart.dh-style.setting.homebrew-settings .resources.tab {
- .resource-types-container {
- display: flex;
- flex-direction: column;
- gap: 16px;
- overflow: auto;
- max-height: 570px;
-
- fieldset legend {
- display: flex;
- align-items: center;
- gap: 4px;
- }
-
- .resource-type-container {
- width: 100%;
-
- .resources-container {
- display: flex;
- flex-direction: column;
- gap: 4px;
-
- .resource-container {
- .resource-icons-container {
- display: flex;
- justify-content: space-between;
- gap: 8px;
- width: 100%;
-
- .resource-icon-container {
- display: flex;
- flex-direction: column;
- gap: 4px;
- flex: 1;
-
- .resource-icon-title-container {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 4px;
-
- &::before,
- &::after {
- color: @dark-blue;
- content: '';
- flex: 1;
- height: 2px;
- }
-
- &::before {
- background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, @golden 100%);
- }
-
- &::after {
- background: linear-gradient(90deg, @golden 0%, rgba(0, 0, 0, 0) 100%);
- }
-
- .resource-icon-title {
- font-size: var(--font-size-16);
- white-space: nowrap;
- display: flex;
- align-items: center;
- gap: 4px;
- color: light-dark(@dark-blue, @golden);
-
- i {
- font-size: 14px;
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- .two-columns {
- width: 100%;
- }
-
- .form-group.vertical {
- > * {
- flex: 0 0 100%;
- }
- }
-}
diff --git a/styles/less/ux/tooltip/resource-management.less b/styles/less/ux/tooltip/resource-management.less
index ff1f4dd2..a5d6d51b 100644
--- a/styles/less/ux/tooltip/resource-management.less
+++ b/styles/less/ux/tooltip/resource-management.less
@@ -35,8 +35,8 @@
}
img {
- width: 14px;
- height: 14px;
+ width: 18px;
+ height: 18px;
&.empty {
opacity: 0.4;
diff --git a/templates/settings/homebrew-settings/resources.hbs b/templates/settings/homebrew-settings/resources.hbs
deleted file mode 100644
index 7f3dee3e..00000000
--- a/templates/settings/homebrew-settings/resources.hbs
+++ /dev/null
@@ -1,78 +0,0 @@
-