mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
[BUG] Feature Actions/Effects Lost On Creation (#457)
* Fixed so that features get their actions and effects * . * Refactor features creations --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
This commit is contained in:
parent
2c4d3bd4a3
commit
18fac18df3
2 changed files with 24 additions and 27 deletions
|
|
@ -397,6 +397,7 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.class.id) {
|
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.class.id) {
|
||||||
classFeatures.push(item);
|
classFeatures.push(item);
|
||||||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.subclass.id) {
|
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.subclass.id) {
|
||||||
|
if (this.class.subclass) {
|
||||||
const subclassState = this.class.subclass.system.featureState;
|
const subclassState = this.class.subclass.system.featureState;
|
||||||
const subType = item.system.subType;
|
const subType = item.system.subType;
|
||||||
if (
|
if (
|
||||||
|
|
@ -406,6 +407,7 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
) {
|
) {
|
||||||
subclassFeatures.push(item);
|
subclassFeatures.push(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.companion.id) {
|
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.companion.id) {
|
||||||
companionFeatures.push(item);
|
companionFeatures.push(item);
|
||||||
} else if (item.type === 'feature' && !item.system.type) {
|
} else if (item.type === 'feature' && !item.system.type) {
|
||||||
|
|
|
||||||
|
|
@ -123,26 +123,21 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
||||||
|
|
||||||
this.updateSource({ actions: [action] });
|
this.updateSource({ actions: [action] });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_onCreate(data, _, userId) {
|
if (this.actor && this.actor.type === 'character' && this.features) {
|
||||||
if (userId !== game.user.id) return;
|
for (let f of this.features) {
|
||||||
|
const feature = f.item ?? f;
|
||||||
if (!this.actor || this.actor.type !== 'character' || !this.features) return;
|
const createData = foundry.utils.mergeObject(feature.toObject(), {
|
||||||
|
|
||||||
this.actor.createEmbeddedDocuments(
|
|
||||||
'Item',
|
|
||||||
this.features.map(feature => ({
|
|
||||||
...(feature.item ?? feature),
|
|
||||||
system: {
|
system: {
|
||||||
...(feature.item?.system ?? feature.system),
|
|
||||||
originItemType: this.parent.type,
|
originItemType: this.parent.type,
|
||||||
originId: data._id,
|
originId: data._id,
|
||||||
identifier: feature.identifier,
|
identifier: feature.identifier,
|
||||||
subType: feature.item ? feature.type : undefined
|
subType: feature.item ? feature.type : undefined
|
||||||
}
|
}
|
||||||
}))
|
}, { inplace: false });
|
||||||
);
|
await this.actor.createEmbeddedDocuments('Item', [createData]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _preDelete() {
|
async _preDelete() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue