Fix for babele and props

This commit is contained in:
Vlyan
2020-12-25 21:50:11 +01:00
parent 334c206907
commit 74ee70d73a

View File

@@ -38,7 +38,7 @@ export class BaseSheetL5r5e extends ActorSheet {
/**
* Handle dropped data on the Actor sheet
*/
_onDrop(event) {
async _onDrop(event) {
// Check item type and subtype
const item = game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event);
if (
@@ -70,8 +70,30 @@ export class BaseSheetL5r5e extends ActorSheet {
// TODO dropped a item with same id as one owned, add qte instead
// Ok add item
return super._onDrop(event);
// Babele and properties specific
if (item.data.data.properties && typeof Babele !== "undefined") {
item.data.data.properties = await Promise.all(
item.data.data.properties.map(async (prop) => {
let gameProp = game.items.get(prop.id);
if (gameProp) {
// Live item
return { id: gameProp.id, name: gameProp.name };
} else {
// Pack item
gameProp = await game.packs.get(CONFIG.l5r5e.packsIds.properties.core).getEntry(prop.id);
if (gameProp) {
return { id: gameProp._id, name: gameProp.name };
}
}
return prop;
})
);
}
// Ok add item - Foundry override cause props
const allowed = Hooks.call("dropActorSheetData", this.actor, this, item);
if (allowed === false) return;
return this._onDropItem(event, item);
}
/**