- Move all DataModel item files to a new 'items' subfolder for better organization

- Add _module.mjs file to simplify imports
- Update all import paths
- Rename class for use the new acronym DH
This commit is contained in:
Joaquin Pereyra 2025-05-30 16:56:00 -03:00
parent e57db2fdc8
commit d6eef9da47
13 changed files with 79 additions and 49 deletions

View file

@ -35,18 +35,9 @@ Hooks.once('init', () => {
})); }));
CONFIG.Item.documentClass = documents.DhpItem; CONFIG.Item.documentClass = documents.DhpItem;
CONFIG.Item.dataModels = {
ancestry: models.DhpAncestry, //Registering the Item DataModel
community: models.DhpCommunity, CONFIG.Item.dataModels = models.items.config;
class: models.DhpClass,
subclass: models.DhpSubclass,
feature: models.DhpFeature,
domainCard: models.DhpDomainCard,
miscellaneous: models.DhpMiscellaneous,
consumable: models.DhpConsumable,
weapon: models.DhpWeapon,
armor: models.DhpArmor
};
const { Items, Actors } = foundry.documents.collections; const { Items, Actors } = foundry.documents.collections;
Items.unregisterSheet('core', foundry.appv1.sheets.ItemSheet); Items.unregisterSheet('core', foundry.appv1.sheets.ItemSheet);
@ -103,7 +94,7 @@ Hooks.once('init', () => {
return preloadHandlebarsTemplates(); return preloadHandlebarsTemplates();
}); });
Hooks.once('dicesoniceready', () => {}); Hooks.once('dicesoniceready', () => { });
Hooks.on(socketEvent.GMUpdate, async (action, uuid, update) => { Hooks.on(socketEvent.GMUpdate, async (action, uuid, update) => {
if (game.user.isGM) { if (game.user.isGM) {
@ -204,8 +195,8 @@ Hooks.on('chatMessage', (_, message) => {
const title = attributeValue const title = attributeValue
? game.i18n.format('DAGGERHEART.Chat.DualityRoll.AbilityCheckTitle', { ? game.i18n.format('DAGGERHEART.Chat.DualityRoll.AbilityCheckTitle', {
ability: game.i18n.localize(abilities[attributeValue].label) ability: game.i18n.localize(abilities[attributeValue].label)
}) })
: game.i18n.localize('DAGGERHEART.General.Duality'); : game.i18n.localize('DAGGERHEART.General.Duality');
const hopeAndFearRoll = `1${rollCommand.hope ?? 'd12'}+1${rollCommand.fear ?? 'd12'}`; const hopeAndFearRoll = `1${rollCommand.hope ?? 'd12'}+1${rollCommand.fear ?? 'd12'}`;
@ -224,9 +215,9 @@ Hooks.on('chatMessage', (_, message) => {
roll, roll,
attribute: attribute attribute: attribute
? { ? {
value: attribute.data.value, value: attribute.data.value,
label: `${game.i18n.localize(abilities[attributeValue].label)} ${attribute.data.value >= 0 ? `+` : ``}${attribute.data.value}` label: `${game.i18n.localize(abilities[attributeValue].label)} ${attribute.data.value >= 0 ? `+` : ``}${attribute.data.value}`
} }
: undefined, : undefined,
title title
}); });

View file

@ -1,19 +1,11 @@
export { default as DhpPC } from './pc.mjs'; export { default as DhpPC } from './pc.mjs';
export { default as DhpClass } from './class.mjs';
export { default as DhpSubclass } from './subclass.mjs';
export { default as DhpCombat } from './combat.mjs'; export { default as DhpCombat } from './combat.mjs';
export { default as DhpCombatant } from './combatant.mjs'; export { default as DhpCombatant } from './combatant.mjs';
export { default as DhpAdversary } from './adversary.mjs'; export { default as DhpAdversary } from './adversary.mjs';
export { default as DhpFeature } from './feature.mjs';
export { default as DhpDomainCard } from './domainCard.mjs';
export { default as DhpAncestry } from './ancestry.mjs';
export { default as DhpCommunity } from './community.mjs';
export { default as DhpMiscellaneous } from './miscellaneous.mjs';
export { default as DhpConsumable } from './consumable.mjs';
export { default as DhpWeapon } from './weapon.mjs';
export { default as DhpArmor } from './armor.mjs';
export { default as DhpDualityRoll } from './dualityRoll.mjs'; export { default as DhpDualityRoll } from './dualityRoll.mjs';
export { default as DhpAdversaryRoll } from './adversaryRoll.mjs'; export { default as DhpAdversaryRoll } from './adversaryRoll.mjs';
export { default as DhpDamageRoll } from './damageRoll.mjs'; export { default as DhpDamageRoll } from './damageRoll.mjs';
export { default as DhpAbilityUse } from './abilityUse.mjs'; export { default as DhpAbilityUse } from './abilityUse.mjs';
export { default as DhpEnvironment } from './environment.mjs'; export { default as DhpEnvironment } from './environment.mjs';
export * as items from "./items/_module.mjs";

View file

@ -0,0 +1,36 @@
import DHAncestry from './ancestry.mjs';
import DHArmor from './armor.mjs';
import DHClass from './class.mjs';
import DHCommunity from './community.mjs';
import DHConsumable from './consumable.mjs';
import DHDomainCard from './domainCard.mjs';
import DHFeature from './feature.mjs';
import DHMiscellaneous from './miscellaneous.mjs';
import DHSubclass from './subclass.mjs';
import DHWeapon from './weapon.mjs';
export {
DHAncestry,
DHArmor,
DHClass,
DHCommunity,
DHConsumable,
DHDomainCard,
DHFeature,
DHMiscellaneous,
DHSubclass,
DHWeapon,
}
export const config = {
ancestry: DHAncestry,
armor: DHArmor,
class: DHClass,
community: DHCommunity,
consumable: DHConsumable,
domainCard: DHDomainCard,
feature: DHFeature,
miscellaneous: DHMiscellaneous,
subclass: DHSubclass,
weapon: DHWeapon,
};

View file

@ -1,6 +1,7 @@
import featuresSchema from './interface/featuresSchema.mjs'; import featuresSchema from '../interface/featuresSchema.mjs';
export default class DhpCommunity extends foundry.abstract.TypeDataModel { export default class DHAncestry extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {

View file

@ -1,4 +1,6 @@
export default class DhpArmor extends foundry.abstract.TypeDataModel {
export default class DHArmor extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {
@ -26,6 +28,9 @@ export default class DhpArmor extends foundry.abstract.TypeDataModel {
return this.feature ? CONFIG.daggerheart.ITEM.armorFeatures[this.feature] : null; return this.feature ? CONFIG.daggerheart.ITEM.armorFeatures[this.feature] : null;
} }
/* --------------------------------------------- */
/** @inheritDoc */
prepareDerivedData() { prepareDerivedData() {
if (this.parent.parent) { if (this.parent.parent) {
this.applyLevels(); this.applyLevels();

View file

@ -1,7 +1,7 @@
import { getTier } from '../helpers/utils.mjs'; import { getTier } from '../../helpers/utils.mjs';
import DhpFeature from './feature.mjs';
export default class DhpClass extends foundry.abstract.TypeDataModel { export default class DHClass extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {

View file

@ -1,6 +1,7 @@
import featuresSchema from './interface/featuresSchema.mjs'; import featuresSchema from '../interface/featuresSchema.mjs';
export default class DhpAncestry extends foundry.abstract.TypeDataModel { export default class DHCommunity extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {

View file

@ -1,4 +1,5 @@
export default class DhpConsumable extends foundry.abstract.TypeDataModel { export default class DHConsumable extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {

View file

@ -1,6 +1,7 @@
import DaggerheartAction from './action.mjs'; import DaggerheartAction from "../action.mjs";
export default class DhpDomainCard extends foundry.abstract.TypeDataModel { export default class DHDomainCard extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {

View file

@ -1,8 +1,9 @@
import { getTier } from '../helpers/utils.mjs'; import { getTier } from '../../helpers/utils.mjs';
import DaggerheartAction from './action.mjs'; import DaggerheartAction from '../action.mjs';
import DhpEffect from './interface/effects.mjs'; import DhpEffects from '../interface/effects.mjs';
export default class DhpFeature extends DhpEffect { export default class DHFeature extends DhpEffects {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return foundry.utils.mergeObject( return foundry.utils.mergeObject(

View file

@ -1,4 +1,5 @@
export default class DhpMiscellaneous extends foundry.abstract.TypeDataModel { export default class DHMiscellaneous extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {

View file

@ -1,8 +1,7 @@
import { getTier } from '../helpers/utils.mjs'; import { getTier } from '../../helpers/utils.mjs';
import featuresSchema from './interface/featuresSchema.mjs';
import DaggerheartFeature from './feature.mjs';
export default class DhpSubclass extends foundry.abstract.TypeDataModel { export default class DHSubclass extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {

View file

@ -1,4 +1,5 @@
export default class DhpWeapon extends foundry.abstract.TypeDataModel { export default class DHWeapon extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {