mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 21:21:08 +01:00
Fixed so that dropping on class/subclass...creates the item on the character (#803)
This commit is contained in:
parent
10b871d4c3
commit
4603e7e40c
2 changed files with 49 additions and 18 deletions
|
|
@ -129,6 +129,7 @@ export default function DHApplicationMixin(Base) {
|
||||||
|
|
||||||
const docs = [];
|
const docs = [];
|
||||||
for (const docData of this.relatedDocs) {
|
for (const docData of this.relatedDocs) {
|
||||||
|
if (!docData) continue;
|
||||||
const doc = await foundry.utils.fromUuid(docData.uuid);
|
const doc = await foundry.utils.fromUuid(docData.uuid);
|
||||||
docs.push(doc);
|
docs.push(doc);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,12 +181,18 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
static async #deleteFeature(_, element) {
|
static async #deleteFeature(_, element) {
|
||||||
const target = element.closest('[data-item-uuid]');
|
const target = element.closest('[data-item-uuid]');
|
||||||
const feature = await getDocFromElement(target);
|
const feature = await getDocFromElement(target);
|
||||||
if (!feature) return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureIsMissing'));
|
if (!feature) {
|
||||||
await this.document.update({
|
await this.document.update({
|
||||||
'system.features': this.document.system.features
|
'system.features': this.document.system.features
|
||||||
.filter(x => target.dataset.type !== x.type || x.item.uuid !== feature.uuid)
|
.filter(x => x.item)
|
||||||
.map(x => ({ ...x, item: x.item.uuid }))
|
.map(x => ({ ...x, item: x.item.uuid }))
|
||||||
});
|
});
|
||||||
|
} else
|
||||||
|
await this.document.update({
|
||||||
|
'system.features': this.document.system.features
|
||||||
|
.filter(x => target.dataset.type !== x.type || x.item.uuid !== feature.uuid)
|
||||||
|
.map(x => ({ ...x, item: x.item.uuid }))
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -259,21 +265,45 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
if (data.fromInternal) return;
|
if (data.fromInternal) return;
|
||||||
|
|
||||||
const target = event.target.closest('fieldset.drop-section');
|
const target = event.target.closest('fieldset.drop-section');
|
||||||
const item = await fromUuid(data.uuid);
|
let item = await fromUuid(data.uuid);
|
||||||
if (item?.type === 'feature') {
|
if (item?.type === 'feature') {
|
||||||
|
const cls = foundry.documents.Item.implementation;
|
||||||
|
|
||||||
|
if (this.document.parent?.type === 'character') {
|
||||||
|
const itemData = item.toObject();
|
||||||
|
item = await cls.create(
|
||||||
|
{
|
||||||
|
...itemData,
|
||||||
|
system: {
|
||||||
|
...itemData.system,
|
||||||
|
originItemType: this.document.type,
|
||||||
|
originId: this.document.id,
|
||||||
|
identifier: this.document.system.isMulticlass ? 'multiclass' : null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ parent: this.document.parent }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (target.dataset.type) {
|
if (target.dataset.type) {
|
||||||
await this.document.update({
|
await this.document.update(
|
||||||
'system.features': [...this.document.system.features, { type: target.dataset.type, item }].map(
|
{
|
||||||
x => ({
|
'system.features': [...this.document.system.features, { type: target.dataset.type, item }].map(
|
||||||
...x,
|
x => ({
|
||||||
item: x.item?.uuid
|
...x,
|
||||||
})
|
item: x.item?.uuid
|
||||||
)
|
})
|
||||||
});
|
)
|
||||||
|
},
|
||||||
|
{ parent: this.document.parent?.type === 'character' ? this.document.parent : undefined }
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
await this.document.update({
|
await this.document.update(
|
||||||
'system.features': [...this.document.system.features, item].map(x => x.uuid)
|
{
|
||||||
});
|
'system.features': [...this.document.system.features, item].map(x => x.uuid)
|
||||||
|
},
|
||||||
|
{ parent: this.document.parent?.type === 'character' ? this.document.parent : undefined }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue