From c2de25693f0d8c2c0ae05572b49a7419142abc91 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Sat, 2 Aug 2025 03:23:15 +0200 Subject: [PATCH] Fixed error where activeeffects were being created in the wrong place. Fixed error where characterCreation was failing subclass (#508) --- .../sheets/api/application-mixin.mjs | 18 +++++++++--------- module/data/item/subclass.mjs | 18 ++++++------------ 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index 15bcb87f..452877e6 100644 --- a/module/applications/sheets/api/application-mixin.mjs +++ b/module/applications/sheets/api/application-mixin.mjs @@ -416,17 +416,17 @@ export default function DHApplicationMixin(Base) { static async #createDoc(event, target) { const { documentClass, type, inVault, disabled } = target.dataset; const parentIsItem = this.document.documentName === 'Item'; - const parent = - this.document.parent?.type === 'character' - ? this.document.parent - : parentIsItem && documentClass === 'Item' - ? type === 'action' - ? this.document.system - : null - : this.document; + const featureOnCharacter = this.document.parent?.type === 'character' && type === 'feature'; + const parent = featureOnCharacter + ? this.document.parent + : parentIsItem && documentClass === 'Item' + ? type === 'action' + ? this.document.system + : null + : this.document; let systemData = {}; - if (parent?.type === 'character' && type === 'feature') { + if (featureOnCharacter) { systemData = { originItemType: this.document.type, originId: this.document.id, diff --git a/module/data/item/subclass.mjs b/module/data/item/subclass.mjs index 11d42e86..5ecd152c 100644 --- a/module/data/item/subclass.mjs +++ b/module/data/item/subclass.mjs @@ -47,16 +47,13 @@ export default class DHSubclass extends BaseDataItem { ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassesAlreadyPresent')); return false; } else { - if (!this.actor.system.multiclass.value) { + const multiclass = this.actor.items.find(x => x.type === 'class' && x.system.isMulticlass); + if (!multiclass) { ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingMulticlass')); return false; } - if ( - this.actor.system.multiclass.value.system.subclasses.every( - x => x.uuid !== (data.uuid ?? `Item.${data._id}`) - ) - ) { + if (multiclass.system.subclasses.every(x => x.uuid !== (data.uuid ?? `Item.${data._id}`))) { ui.notifications.error( game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInMulticlass') ); @@ -66,15 +63,12 @@ export default class DHSubclass extends BaseDataItem { await this.updateSource({ isMulticlass: true }); } } else { - if (!this.actor.system.class.value) { + const actorClass = this.actor.items.find(x => x.type === 'class' && !x.system.isMulticlass); + if (!actorClass) { ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClass')); return false; } - if ( - this.actor.system.class.value.system.subclasses.every( - x => x.uuid !== (data.uuid ?? `Item.${data._id}`) - ) - ) { + if (actorClass.system.subclasses.every(x => x.uuid !== (data.uuid ?? `Item.${data._id}`))) { ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass')); return false; }