Fix for babele and properties
This commit is contained in:
@@ -91,19 +91,6 @@ export class BaseSheetL5r5e extends ActorSheet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 (property) => {
|
|
||||||
const gameProp = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack(property.id, "Item");
|
|
||||||
if (gameProp) {
|
|
||||||
return { id: gameProp._id, name: gameProp.name };
|
|
||||||
}
|
|
||||||
return property;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Item subtype specific
|
// Item subtype specific
|
||||||
switch (item.data.type) {
|
switch (item.data.type) {
|
||||||
case "advancement": // no break
|
case "advancement": // no break
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ export class HelpersL5r5e {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (item) {
|
if (item) {
|
||||||
|
await HelpersL5r5e.refreshItemProperties(item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,15 +123,14 @@ export class HelpersL5r5e {
|
|||||||
* Make a temporary item for compendium drag n drop
|
* Make a temporary item for compendium drag n drop
|
||||||
*/
|
*/
|
||||||
static async createItemFromCompendium(data) {
|
static async createItemFromCompendium(data) {
|
||||||
if (
|
if (!["item", "armor", "weapon", "technique", "peculiarity", "property"].includes(data.type)) {
|
||||||
data instanceof ItemL5r5e ||
|
|
||||||
!["item", "armor", "weapon", "technique", "peculiarity", "property"].includes(data.type)
|
|
||||||
) {
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item;
|
let item;
|
||||||
if (game.user.hasPermission("ACTOR_CREATE")) {
|
if (data instanceof ItemL5r5e) {
|
||||||
|
item = data;
|
||||||
|
} else if (game.user.hasPermission("ACTOR_CREATE")) {
|
||||||
// Fail if a player do not have the right to create object (even if this is a temporary)
|
// Fail if a player do not have the right to create object (even if this is a temporary)
|
||||||
item = await ItemL5r5e.create(data, { temporary: true });
|
item = await ItemL5r5e.create(data, { temporary: true });
|
||||||
|
|
||||||
@@ -140,9 +140,27 @@ export class HelpersL5r5e {
|
|||||||
// Quick object
|
// Quick object
|
||||||
item = new ItemL5r5e(data);
|
item = new ItemL5r5e(data);
|
||||||
}
|
}
|
||||||
|
await HelpersL5r5e.refreshItemProperties(item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Babele and properties specific
|
||||||
|
*/
|
||||||
|
static async refreshItemProperties(item) {
|
||||||
|
if (item.data.data.properties && typeof Babele !== "undefined") {
|
||||||
|
item.data.data.properties = await Promise.all(
|
||||||
|
item.data.data.properties.map(async (property) => {
|
||||||
|
const gameProp = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack(property.id, "Item");
|
||||||
|
if (gameProp) {
|
||||||
|
return { id: gameProp._id, name: gameProp.name };
|
||||||
|
}
|
||||||
|
return property;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert (op), (ex)... to associated symbols for content/descriptions
|
* Convert (op), (ex)... to associated symbols for content/descriptions
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user