fix: make it possible to add embedded effects/items to items and actors in packs

This commit is contained in:
Johannes Loher 2021-09-22 02:34:50 +02:00
parent 756c512c20
commit bdea7de7f3
3 changed files with 5 additions and 8 deletions

View file

@ -95,14 +95,11 @@ export class DS4ActiveEffect extends ActiveEffect {
* @param context The context for the creation of the effect, requiring a parent {@link DS4Actor} or {@link DS4Item}. * @param context The context for the creation of the effect, requiring a parent {@link DS4Actor} or {@link DS4Item}.
* @returns A promise that resolved to the created effect or udifined of the creation was prevented. * @returns A promise that resolved to the created effect or udifined of the creation was prevented.
*/ */
static async createDefault( static async createDefault(parent: DS4Actor | DS4Item): Promise<DS4ActiveEffect[]> {
context: DocumentModificationContext & { parent: DS4Actor | DS4Item },
): Promise<DS4ActiveEffect | undefined> {
const createData = { const createData = {
label: getGame().i18n.localize(`DS4.NewEffectLabel`), label: getGame().i18n.localize(`DS4.NewEffectLabel`),
icon: this.FALLBACK_ICON, icon: this.FALLBACK_ICON,
}; };
return parent.createEmbeddedDocuments("ActiveEffect", [createData]) as Promise<DS4ActiveEffect[]>;
return this.create(createData, context);
} }
} }

View file

@ -141,7 +141,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
type: type, type: type,
data: data, data: data,
}; };
Item.create(itemData, { parent: this.actor }); this.actor.createEmbeddedDocuments("Item", [itemData]);
} }
/** /**
@ -205,7 +205,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
* @param event - The originating click event * @param event - The originating click event
*/ */
protected onCreateEffect(): void { protected onCreateEffect(): void {
DS4ActiveEffect.createDefault({ parent: this.actor }); DS4ActiveEffect.createDefault(this.actor);
} }
/** /**

View file

@ -99,7 +99,7 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData>
* Create a new ActiveEffect for the item using default data. * Create a new ActiveEffect for the item using default data.
*/ */
protected createActiveEffect(): void { protected createActiveEffect(): void {
DS4ActiveEffect.createDefault({ parent: this.item }); DS4ActiveEffect.createDefault(this.item);
} }
} }