Added new dialog settings to configure default skill list.
Added uuid compatibility for tooltips
This commit is contained in:
@@ -15,6 +15,53 @@ export class HelpersL5r5e {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default skill list for settings
|
||||
* @returns {string[]}
|
||||
*/
|
||||
static getDefaultSkillsUuidFromPack() {
|
||||
return Array.from({length: 24}, (_, i) => "Compendium.l5r5e.core-skills.L5RCoreSkl" + ('' +(i + 1)).padStart(6, "0"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return default skill items list
|
||||
* @returns {Promise<Item[]>}
|
||||
*/
|
||||
static async getDefaultSkillsItems() {
|
||||
let skillList = game.settings.get(CONFIG.l5r5e.systemName, "defaultSkillsList") || [];
|
||||
|
||||
// If empty, refill with default values
|
||||
if (foundry.utils.isEmpty(skillList)) {
|
||||
skillList = HelpersL5r5e.getDefaultSkillsUuidFromPack();
|
||||
await game.settings.set(CONFIG.l5r5e.systemName, "defaultSkillsList", skillList);
|
||||
}
|
||||
|
||||
return await Promise.all(skillList.map(async uuid => await fromUuid(uuid)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Split Skills item by categories, and sort them alphabetically
|
||||
* @param {Item[]} itemsList
|
||||
* @return {{catName: Item[]}}
|
||||
*/
|
||||
static splitSkillByCategory(itemsList) {
|
||||
const skill = CONFIG.l5r5e.skillCategories.reduce((acc,curr) => (acc[curr] = [], acc), {});
|
||||
|
||||
itemsList.forEach((item) => {
|
||||
if (item.type === "skill") {
|
||||
const cat = item.system.category ?? "artisan";
|
||||
skill[cat].push(item);
|
||||
}
|
||||
});
|
||||
|
||||
// Sort Items by name
|
||||
Object.values(skill).forEach(section => {
|
||||
section.sort((a, b) => a.name.localeCompare(b.name));
|
||||
});
|
||||
|
||||
return skill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Skills for List / Select with groups
|
||||
* @param {boolean} useGroup
|
||||
@@ -573,12 +620,15 @@ export class HelpersL5r5e {
|
||||
static async getEmbedItemByEvent(event, actor) {
|
||||
const current = $(event.currentTarget);
|
||||
const itemId = current.data("item-id");
|
||||
const itemUuid = current.data("item-uuid");
|
||||
const propertyId = current.data("property-id");
|
||||
const itemParentId = current.data("item-parent-id");
|
||||
|
||||
let item;
|
||||
if (propertyId) {
|
||||
item = await HelpersL5r5e.getObjectGameOrPack({ id: propertyId, type: "Item" });
|
||||
} else if (itemUuid) {
|
||||
item = await fromUuid(itemUuid);
|
||||
} else if (itemParentId) {
|
||||
// Embed Item
|
||||
let parentItem;
|
||||
|
||||
Reference in New Issue
Block a user