mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
remove unecessary code
This commit is contained in:
parent
7e8dc9121e
commit
598bf733f8
1 changed files with 12 additions and 37 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import DHBaseItemSheet from '../api/base-item.mjs';
|
import DHBaseItemSheet from '../api/base-item.mjs';
|
||||||
|
import { copyAttachmentEffectsToActor, removeAttachmentEffectsFromActor } from '../../../helpers/attachmentHelper.mjs';
|
||||||
|
|
||||||
export default class ArmorSheet extends DHBaseItemSheet {
|
export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
/**@inheritdoc */
|
/**@inheritdoc */
|
||||||
|
|
@ -111,32 +112,14 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
'system.attached': updatedAttached
|
'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;
|
const actor = this.document.parent;
|
||||||
if (actor && item.effects.size > 0 && this.document.system.equipped) {
|
if (actor && item.effects.size > 0 && this.document.system.equipped) {
|
||||||
const effectsToCreate = [];
|
await copyAttachmentEffectsToActor({
|
||||||
for (const effect of item.effects) {
|
parentItem: this.document,
|
||||||
// Copy ALL effects when item is attached - attachment-only flag only matters for non-attached items
|
attachedItem: item,
|
||||||
const effectData = effect.toObject();
|
attachedUuid: newUUID,
|
||||||
effectData.origin = `${this.document.uuid}:${newUUID}`; // Track which armor and which item this came from
|
parentType: 'armor'
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,18 +136,10 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
'system.attached': currentAttached.filter(attachedUuid => attachedUuid !== uuid)
|
'system.attached': currentAttached.filter(attachedUuid => attachedUuid !== uuid)
|
||||||
});
|
});
|
||||||
|
|
||||||
const actor = this.document.parent;
|
await removeAttachmentEffectsFromActor({
|
||||||
if (actor) {
|
parentItem: this.document,
|
||||||
const effectsToRemove = actor.effects.filter(effect => {
|
attachedUuid: uuid,
|
||||||
const attachmentSource = effect.flags?.daggerheart?.attachmentSource;
|
parentType: 'armor'
|
||||||
return attachmentSource &&
|
});
|
||||||
attachmentSource.armorUuid === this.document.uuid &&
|
|
||||||
attachmentSource.itemUuid === uuid;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (effectsToRemove.length > 0) {
|
|
||||||
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue