Added cancelled properties in text for props and some fixes
This commit is contained in:
@@ -75,18 +75,22 @@ export class HelpersL5r5e {
|
||||
return null;
|
||||
}
|
||||
const data = JSON.parse(json);
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
return await HelpersL5r5e.getObjectGameOrPack(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the object from Game or Pack by his ID, or null if not found
|
||||
* @param {number} id
|
||||
* @param {string} type
|
||||
* @param {string|null} data
|
||||
* @param {string|null} pack
|
||||
* @param {string} id
|
||||
* @param {string} type Type (Item, JournalEntry...)
|
||||
* @param {any[]|null} data Plain data
|
||||
* @param {string|null} pack Pack name
|
||||
* @param {string|null} parentId Used to avoid an infinite loop in properties if set
|
||||
* @return {Promise<null>}
|
||||
*/
|
||||
static async getObjectGameOrPack({ id, type, data = null, pack = null }) {
|
||||
static async getObjectGameOrPack({ id, type, data = null, pack = null, parentId = null }) {
|
||||
let document = null;
|
||||
|
||||
try {
|
||||
@@ -105,9 +109,9 @@ export class HelpersL5r5e {
|
||||
}
|
||||
|
||||
if (pack) {
|
||||
const data = await game.packs.get(pack).getDocument(id);
|
||||
if (data) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data });
|
||||
const tmpData = await game.packs.get(pack).getDocument(id);
|
||||
if (tmpData) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data: tmpData });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,9 +130,9 @@ export class HelpersL5r5e {
|
||||
continue;
|
||||
}
|
||||
|
||||
const data = await comp.getDocument(id);
|
||||
if (data) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data });
|
||||
const tmpData = await comp.getDocument(id);
|
||||
if (tmpData) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data: tmpData });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,13 +145,13 @@ export class HelpersL5r5e {
|
||||
}
|
||||
|
||||
// Care to infinite loop in properties
|
||||
if (document.type !== "property") {
|
||||
if (!parentId) {
|
||||
await HelpersL5r5e.refreshItemProperties(document);
|
||||
}
|
||||
document.prepareData();
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
console.warn("L5R5E | ", err);
|
||||
}
|
||||
return document;
|
||||
}
|
||||
@@ -195,7 +199,11 @@ export class HelpersL5r5e {
|
||||
if (document.data?.data?.properties && typeof Babele !== "undefined") {
|
||||
document.data.data.properties = await Promise.all(
|
||||
document.data.data.properties.map(async (property) => {
|
||||
const gameProp = await HelpersL5r5e.getObjectGameOrPack({ id: property.id, type: "Item" });
|
||||
const gameProp = await HelpersL5r5e.getObjectGameOrPack({
|
||||
id: property.id,
|
||||
type: "Item",
|
||||
parentId: document.data?._id || 1,
|
||||
});
|
||||
if (gameProp) {
|
||||
return { id: gameProp.id, name: gameProp.name };
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user