Change to uuid approach

This commit is contained in:
Carlos Fernandez 2026-05-02 17:58:48 -04:00
parent 20f42e8a0d
commit a5db9371c6
8 changed files with 44 additions and 73 deletions

View file

@ -41,22 +41,27 @@ export default class SubclassSheet extends DHBaseItemSheet {
return this.document.system.features.map(x => x.item);
}
async _prepareContext(options) {
const context = await super._prepareContext(options);
if (this.document.system.linkedClass) {
context.class = (await fromUuid(this.document.system.linkedClass)) ?? {
name: 'Missing Class',
img: 'systems/daggerheart/assets/icons/documents/items/laurel-crown.svg',
missing: true
};
}
return context;
}
async _onDrop(event) {
event.stopPropagation();
const data = TextEditor.getDragEventData(event);
const item = await fromUuid(data.uuid);
const itemType = data.type === 'ActiveEffect' ? data.type : item.type;
if (itemType === 'class') {
const identifier = item.system.identifier;
if (!identifier) {
return ui.notifications.error(
game.i18n.localize('DAGGERHEART.UI.Notifications.classMissingIdentifier')
);
}
if (this.document.system.classLink.identifier !== identifier) {
const { img, name } = item;
await this.document.update({ 'system.classLink': { identifier, img, name } });
const uuid = item._stats.compendiumSource ?? item.uuid;
if (this.document.system.linkedClass !== uuid) {
await this.document.update({ 'system.linkedClass': uuid });
}
return;
}