mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +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,14 +397,16 @@ export default class DhCharacter extends BaseDataActor {
|
|||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.class.id) {
|
||||
classFeatures.push(item);
|
||||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.subclass.id) {
|
||||
const subclassState = this.class.subclass.system.featureState;
|
||||
const subType = item.system.subType;
|
||||
if (
|
||||
subType === CONFIG.DH.ITEM.featureSubTypes.foundation ||
|
||||
(subType === CONFIG.DH.ITEM.featureSubTypes.specialization && subclassState >= 2) ||
|
||||
(subType === CONFIG.DH.ITEM.featureSubTypes.mastery && subclassState >= 3)
|
||||
) {
|
||||
subclassFeatures.push(item);
|
||||
if (this.class.subclass) {
|
||||
const subclassState = this.class.subclass.system.featureState;
|
||||
const subType = item.system.subType;
|
||||
if (
|
||||
subType === CONFIG.DH.ITEM.featureSubTypes.foundation ||
|
||||
(subType === CONFIG.DH.ITEM.featureSubTypes.specialization && subclassState >= 2) ||
|
||||
(subType === CONFIG.DH.ITEM.featureSubTypes.mastery && subclassState >= 3)
|
||||
) {
|
||||
subclassFeatures.push(item);
|
||||
}
|
||||
}
|
||||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.companion.id) {
|
||||
companionFeatures.push(item);
|
||||
|
|
|
|||
|
|
@ -123,26 +123,21 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
|
||||
this.updateSource({ actions: [action] });
|
||||
}
|
||||
}
|
||||
|
||||
_onCreate(data, _, userId) {
|
||||
if (userId !== game.user.id) return;
|
||||
|
||||
if (!this.actor || this.actor.type !== 'character' || !this.features) return;
|
||||
|
||||
this.actor.createEmbeddedDocuments(
|
||||
'Item',
|
||||
this.features.map(feature => ({
|
||||
...(feature.item ?? feature),
|
||||
system: {
|
||||
...(feature.item?.system ?? feature.system),
|
||||
originItemType: this.parent.type,
|
||||
originId: data._id,
|
||||
identifier: feature.identifier,
|
||||
subType: feature.item ? feature.type : undefined
|
||||
}
|
||||
}))
|
||||
);
|
||||
if (this.actor && this.actor.type === 'character' && this.features) {
|
||||
for (let f of this.features) {
|
||||
const feature = f.item ?? f;
|
||||
const createData = foundry.utils.mergeObject(feature.toObject(), {
|
||||
system: {
|
||||
originItemType: this.parent.type,
|
||||
originId: data._id,
|
||||
identifier: feature.identifier,
|
||||
subType: feature.item ? feature.type : undefined
|
||||
}
|
||||
}, { inplace: false });
|
||||
await this.actor.createEmbeddedDocuments('Item', [createData]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue