From 598bf733f819b68cd54061c6abdd3753fe6aad2d Mon Sep 17 00:00:00 2001 From: psitacus Date: Wed, 9 Jul 2025 00:50:14 -0600 Subject: [PATCH] remove unecessary code --- module/applications/sheets/items/armor.mjs | 49 ++++++---------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/module/applications/sheets/items/armor.mjs b/module/applications/sheets/items/armor.mjs index 8af832c3..15d6b9e5 100644 --- a/module/applications/sheets/items/armor.mjs +++ b/module/applications/sheets/items/armor.mjs @@ -1,4 +1,5 @@ import DHBaseItemSheet from '../api/base-item.mjs'; +import { copyAttachmentEffectsToActor, removeAttachmentEffectsFromActor } from '../../../helpers/attachmentHelper.mjs'; export default class ArmorSheet extends DHBaseItemSheet { /**@inheritdoc */ @@ -111,32 +112,14 @@ export default class ArmorSheet extends DHBaseItemSheet { 'system.attached': updatedAttached }); - // Copy ALL effects from attached item to actor (only if armor is equipped) - // Both attachment-only and regular effects should be copied when attached const actor = this.document.parent; if (actor && item.effects.size > 0 && this.document.system.equipped) { - const effectsToCreate = []; - for (const effect of item.effects) { - // Copy ALL effects when item is attached - attachment-only flag only matters for non-attached items - const effectData = effect.toObject(); - effectData.origin = `${this.document.uuid}:${newUUID}`; // Track which armor and which item this came from - effectData.flags = { - ...effectData.flags, - daggerheart: { - ...effectData.flags?.daggerheart, - attachmentSource: { - armorUuid: this.document.uuid, - itemUuid: newUUID, - originalEffectId: effect.id - } - } - }; - effectsToCreate.push(effectData); - } - - if (effectsToCreate.length > 0) { - await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate); - } + await copyAttachmentEffectsToActor({ + parentItem: this.document, + attachedItem: item, + attachedUuid: newUUID, + parentType: 'armor' + }); } } @@ -153,18 +136,10 @@ export default class ArmorSheet extends DHBaseItemSheet { 'system.attached': currentAttached.filter(attachedUuid => attachedUuid !== uuid) }); - const actor = this.document.parent; - if (actor) { - const effectsToRemove = actor.effects.filter(effect => { - const attachmentSource = effect.flags?.daggerheart?.attachmentSource; - return attachmentSource && - attachmentSource.armorUuid === this.document.uuid && - attachmentSource.itemUuid === uuid; - }); - - if (effectsToRemove.length > 0) { - await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id)); - } - } + await removeAttachmentEffectsFromActor({ + parentItem: this.document, + attachedUuid: uuid, + parentType: 'armor' + }); } }