mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 16:09:03 +01:00
Fixed removal of features/items propagating
This commit is contained in:
parent
30f31e77dd
commit
6a7f19363d
2 changed files with 21 additions and 15 deletions
|
|
@ -1318,8 +1318,7 @@ export const itemLinkFeatureTypes = {
|
|||
class: 'class',
|
||||
foundation: 'foundation',
|
||||
specialization: 'specialization',
|
||||
mastery: 'mastery',
|
||||
subclass: 'subclass'
|
||||
mastery: 'mastery'
|
||||
};
|
||||
|
||||
export const itemLinkItemTypes = {
|
||||
|
|
@ -1332,6 +1331,7 @@ export const itemLinkItemTypes = {
|
|||
};
|
||||
|
||||
export const itemLinkTypes = {
|
||||
subclass: 'subclass',
|
||||
...itemLinkFeatureTypes,
|
||||
...itemLinkItemTypes
|
||||
};
|
||||
|
|
|
|||
|
|
@ -171,18 +171,24 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
);
|
||||
}
|
||||
|
||||
// if (this.metadata.isItemLinkable) {
|
||||
// const linkEntries = Object.entries(this.itemLinks);
|
||||
// for (let [uuid, type] of linkEntries) {
|
||||
// const item = await foundry.utils.fromUuid(uuid);
|
||||
// const path = CONFIG.DH.ITEM.itemLinkFeatureTypes[type] ? 'system.features' : 'system.linkedItems';
|
||||
// await item.update({
|
||||
// [path]: foundry.utils
|
||||
// .getProperty(item, path)
|
||||
// .filter(x => x.uuid !== this.parent.uuid)
|
||||
// .map(x => x.uuid)
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
if (this.metadata.isItemLinkable) {
|
||||
const linkEntries = Object.entries(this.itemLinks);
|
||||
for (let [type, uuidList] of linkEntries) {
|
||||
for (let uuid of uuidList) {
|
||||
const item = await foundry.utils.fromUuid(uuid);
|
||||
const path = CONFIG.DH.ITEM.itemLinkFeatureTypes[type]
|
||||
? 'system.features'
|
||||
: CONFIG.DH.ITEM.itemLinkItemTypes[type]
|
||||
? 'system.linkedItems'
|
||||
: 'system.subclasses';
|
||||
await item.update({
|
||||
[path]: foundry.utils
|
||||
.getProperty(item, path)
|
||||
.filter(x => x.uuid !== this.parent.uuid)
|
||||
.map(x => x.uuid)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue