mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
refactor code for review comments
This commit is contained in:
parent
001abcadf4
commit
5065a609ac
6 changed files with 128 additions and 438 deletions
|
|
@ -9,46 +9,6 @@ export default class DHItem extends foundry.documents.Item {
|
|||
for (const action of this.system.actions ?? []) action.prepareData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async _preUpdate(changed, options, user) {
|
||||
const result = await super._preUpdate(changed, options, user);
|
||||
|
||||
// Store the previous equipped status for attachment handling
|
||||
if (changed.system?.equipped !== undefined) {
|
||||
options.previousEquipped = this.system.equipped;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async _onUpdate(changed, options, user) {
|
||||
await super._onUpdate(changed, options, user);
|
||||
|
||||
// Handle attachment effects when equipped status changes
|
||||
if (changed.system?.equipped !== undefined && options.previousEquipped !== changed.system.equipped) {
|
||||
const newEquippedStatus = changed.system.equipped;
|
||||
const parentType = this.type === 'armor' ? 'armor' : this.type === 'weapon' ? 'weapon' : null;
|
||||
|
||||
if (parentType) {
|
||||
try {
|
||||
const { handleAttachmentEffectsOnEquipChange } = await import('../helpers/attachmentHelper.mjs');
|
||||
await handleAttachmentEffectsOnEquipChange({
|
||||
parentItem: this,
|
||||
newEquippedStatus,
|
||||
parentType
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('DH | Error in handleAttachmentEffectsOnEquipChange:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @param {object} options - Options which modify the getRollData method.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue