Chargement depuis les compendium sélectionnés
Fix, les compendiums systèmes n'étaient pas utilisés pour les herbes et les compétences
This commit is contained in:
@ -55,6 +55,29 @@ export class SystemCompendiums extends FormApplication {
|
||||
return [];
|
||||
}
|
||||
|
||||
static async getCompetences(actorType) {
|
||||
switch (actorType ?? 'personnage') {
|
||||
case 'personnage': return await SystemCompendiums.getWorldOrCompendiumItems('competence', 'competences');
|
||||
case 'creature': return await SystemCompendiums.getWorldOrCompendiumItems('competencecreature', 'competences-creatures');
|
||||
case 'entite': return await SystemCompendiums.getWorldOrCompendiumItems('competencecreature', 'competences-entites');
|
||||
case 'vehicule': return [];
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static async getWorldOrCompendiumItems(itemType, compendium) {
|
||||
let items = game.items.filter(it => it.type == itemType);
|
||||
if (compendium) {
|
||||
const ids = items.map(it => it.id);
|
||||
const names = items.map(it => it.name.toLowerCase());
|
||||
const compendiumItems = await SystemCompendiums.getItems(compendium);
|
||||
items = items.concat(compendiumItems
|
||||
.filter(it => it.type == itemType)
|
||||
.filter(it => !ids.includes(it.id))
|
||||
.filter(it => !names.includes(it.name.toLowerCase())));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
static async getItems(compendium, itemType = undefined) {
|
||||
const items = await SystemCompendiums.getContent(compendium, 'Item');
|
||||
return itemType ? items.filter(it => it.type == itemType) : items;
|
||||
|
Reference in New Issue
Block a user