diff --git a/module/documents/activeEffect.mjs b/module/documents/activeEffect.mjs index 5c9b91a5..54bf6de6 100644 --- a/module/documents/activeEffect.mjs +++ b/module/documents/activeEffect.mjs @@ -6,8 +6,9 @@ export default class DhActiveEffect extends ActiveEffect { return false; } - // First check for attachment-only effects - these should be suppressed unless attached - if (this.isAttachmentOnly && !this.isAttached) { + // First check for attachment-only effects - these should ALWAYS be suppressed on the original item + // They only work through copied versions when attached + if (this.isAttachmentOnly) { return true; } @@ -42,17 +43,12 @@ export default class DhActiveEffect extends ActiveEffect { const actor = this.parent.parent; if (!actor || !actor.items) return false; - try { - return actor.items.some(item => { - return (item.type === 'armor' || item.type === 'weapon') && - item.system?.attached && - Array.isArray(item.system.attached) && - item.system.attached.includes(this.parent.uuid); - }); - } catch (error) { - console.warn('Error checking if item is attached:', error); - return false; - } + return actor.items.some(item => { + return (item.type === 'armor' || item.type === 'weapon') && + item.system?.attached && + Array.isArray(item.system.attached) && + item.system.attached.includes(this.parent.uuid); + }); } async _preCreate(data, options, user) { diff --git a/module/helpers/attachmentHelper.mjs b/module/helpers/attachmentHelper.mjs index 132423b0..0e209881 100644 --- a/module/helpers/attachmentHelper.mjs +++ b/module/helpers/attachmentHelper.mjs @@ -191,26 +191,4 @@ export async function addAttachmentToItem({ parentItem, droppedItem, parentType } } -/** - * Remove an attachment from an item and clean up its effects - * @param {Object} options - Configuration options - * @param {Item} options.parentItem - The item (armor/weapon) that the item is attached to - * @param {string} options.attachedUuid - UUID of the attached item being removed - * @param {string} options.parentType - Type of parent item ("armor" or "weapon") - * @returns {Promise} - */ -export async function removeAttachmentFromItem({ parentItem, attachedUuid, parentType }) { - const currentAttached = parentItem.system.attached; - - // Remove the attachment from the parent item's attached array - await parentItem.update({ - 'system.attached': currentAttached.filter(uuid => uuid !== attachedUuid) - }); - - // Remove any effects that came from this attachment - await removeAttachmentEffectsFromActor({ - parentItem, - attachedUuid, - parentType - }); -} +