parent
4837213b89
commit
dfa10b9f92
|
@ -902,14 +902,14 @@ class CompendiumBrowser extends Application {
|
|||
const matchedClass = [];
|
||||
const reqString = item.requirements?.replace(/\d/g, "").trim();
|
||||
if (reqString) {
|
||||
for (const [classId, classData] of Object.entries(this.provider.classes)) {
|
||||
for (const classData of Object.values(this.provider.classes)) {
|
||||
const isClassMatch = classData.label.includes(reqString);
|
||||
const isSubclassMatch = !isClassMatch && Object.values(classData.subclasses).some(
|
||||
(label) => reqString.includes(label)
|
||||
);
|
||||
|
||||
if (isClassMatch || isSubclassMatch) {
|
||||
matchedClass.push(classId);
|
||||
matchedClass.push(classData.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1335,12 +1335,9 @@ class CompendiumBrowser extends Application {
|
|||
|
||||
_sortPackValues(packValue) {
|
||||
const sortable = Object.entries(packValue)
|
||||
.filter(([key, data]) => key !== undefined && data !== undefined)
|
||||
.map(([key, data]) => {
|
||||
if (typeof data === "string") return [key, game.i18n.localize(data)];
|
||||
if (!data) {
|
||||
console.error(`Compendium Browser | Pack Value "${key}" has no data.`);
|
||||
return [key, ""];
|
||||
}
|
||||
return [key, data.label];
|
||||
})
|
||||
.sort((a, b) => a[1].localeCompare(b[1]));
|
||||
|
|
|
@ -10,7 +10,7 @@ export class dnd5eProvider {
|
|||
for (let pack of game.packs) {
|
||||
if (pack.documentName === "Item") {
|
||||
const indexes = await pack.getIndex({ fields: ["system.identifier", "system.classIdentifier"] });
|
||||
const classes = indexes.filter((entry) => entry.type === "class");
|
||||
const classes = indexes.filter((entry) => entry.type === "class" && entry.system.identifier);
|
||||
if (classes.length) {
|
||||
classes.map((entry) => {
|
||||
return {
|
||||
|
@ -25,7 +25,7 @@ export class dnd5eProvider {
|
|||
};
|
||||
});
|
||||
}
|
||||
const _subclasses = indexes.filter((entry) => entry.type === "subclass");
|
||||
const _subclasses = indexes.filter((entry) => entry.type === "subclass" && entry.system.classIdentifier);
|
||||
if (_subclasses.length) {
|
||||
_subclasses.map((entry) => {
|
||||
return {
|
||||
|
@ -49,6 +49,9 @@ export class dnd5eProvider {
|
|||
}
|
||||
}
|
||||
this.classes = foundry.utils.mergeObject(this.classes, subclasses);
|
||||
this.classes = Object.fromEntries(
|
||||
Object.entries(this.classes).filter(([classId, classData]) => classData.label)
|
||||
);
|
||||
}
|
||||
|
||||
static classList = {
|
||||
|
|
Loading…
Reference in New Issue