mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
change armor and weapon to be attachableItem
This commit is contained in:
parent
1fc136c81b
commit
a78e1533d7
5 changed files with 82 additions and 19 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import BaseDataItem from './base.mjs';
|
||||
import { handleAttachmentEffectsOnEquipChange } from '../../helpers/attachmentHelper.mjs';
|
||||
|
||||
export default class AttachableItem extends BaseDataItem {
|
||||
static defineSchema() {
|
||||
|
|
@ -8,4 +9,18 @@ export default class AttachableItem extends BaseDataItem {
|
|||
attached: new fields.ArrayField(new fields.DocumentUUIDField({ type: "Item", nullable: true }))
|
||||
};
|
||||
}
|
||||
|
||||
async _preUpdate(changes, options, user) {
|
||||
const allowed = await super._preUpdate(changes, options, user);
|
||||
if (allowed === false) return false;
|
||||
|
||||
// Handle equipped status changes for attachment effects
|
||||
if (changes.system?.equipped !== undefined && changes.system.equipped !== this.equipped) {
|
||||
await handleAttachmentEffectsOnEquipChange({
|
||||
parentItem: this.parent,
|
||||
newEquippedStatus: changes.system.equipped,
|
||||
parentType: this.parent.type
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue