remove unecessary code

This commit is contained in:
psitacus 2025-07-09 00:50:14 -06:00
parent 7e8dc9121e
commit 598bf733f8

View file

@ -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;
await removeAttachmentEffectsFromActor({
parentItem: this.document,
attachedUuid: uuid,
parentType: 'armor'
});
if (effectsToRemove.length > 0) {
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
}
}
}
}