parent
4f5533d1f4
commit
411c92a394
|
@ -31,7 +31,7 @@ class CompendiumBrowser extends Application {
|
||||||
this.changeTabs = null;
|
this.changeTabs = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setup() {
|
async ready() {
|
||||||
await this.provider.getFilters();
|
await this.provider.getFilters();
|
||||||
this.addSpellFilters();
|
this.addSpellFilters();
|
||||||
this.addFeatFilters();
|
this.addFeatFilters();
|
||||||
|
@ -395,8 +395,6 @@ class CompendiumBrowser extends Application {
|
||||||
// 0.4.1: Load and filter just one of spells, feats, and items (specified by browserTab)
|
// 0.4.1: Load and filter just one of spells, feats, and items (specified by browserTab)
|
||||||
let numItemsLoaded = 0;
|
let numItemsLoaded = 0;
|
||||||
let compactItems = {};
|
let compactItems = {};
|
||||||
const FeatureList = ["feat", "class", "subclass", "background", "race"];
|
|
||||||
const NotItemList = ["spell", "feat", "class", "subclass", "background", "race"];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Filter the full list, but only save the core compendium information + displayed info
|
// Filter the full list, but only save the core compendium information + displayed info
|
||||||
|
@ -409,7 +407,7 @@ class CompendiumBrowser extends Application {
|
||||||
query = { type: "spell" };
|
query = { type: "spell" };
|
||||||
break;
|
break;
|
||||||
case "feat":
|
case "feat":
|
||||||
query = { type__in: ["feat", "subclass"] };
|
query = { type__in: ["feat", "class", "subclass", "background", "race"] };
|
||||||
break;
|
break;
|
||||||
case "item":
|
case "item":
|
||||||
query = { type__in: ["consumable", "backpack", "equipment", "loot", "tool", "weapon"] };
|
query = { type__in: ["consumable", "backpack", "equipment", "loot", "tool", "weapon"] };
|
||||||
|
@ -474,7 +472,6 @@ class CompendiumBrowser extends Application {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
decoratedItem
|
decoratedItem
|
||||||
&& FeatureList.includes(decoratedItem.type)
|
|
||||||
&& this.passesFilter(decoratedItem, this.featFilters.activeFilters)
|
&& this.passesFilter(decoratedItem, this.featFilters.activeFilters)
|
||||||
) {
|
) {
|
||||||
itemsList[item5e.id] = {
|
itemsList[item5e.id] = {
|
||||||
|
@ -507,9 +504,6 @@ class CompendiumBrowser extends Application {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
decoratedItem
|
decoratedItem
|
||||||
&& !NotItemList.includes(
|
|
||||||
decoratedItem.type
|
|
||||||
)
|
|
||||||
&& this.passesFilter(decoratedItem, this.itemFilters.activeFilters)
|
&& this.passesFilter(decoratedItem, this.itemFilters.activeFilters)
|
||||||
) {
|
) {
|
||||||
itemsList[item5e.id] = {
|
itemsList[item5e.id] = {
|
||||||
|
@ -892,16 +886,14 @@ class CompendiumBrowser extends Application {
|
||||||
const matchedClass = [];
|
const matchedClass = [];
|
||||||
const reqString = item.requirements?.replace(/\d/g, "").trim();
|
const reqString = item.requirements?.replace(/\d/g, "").trim();
|
||||||
if (reqString) {
|
if (reqString) {
|
||||||
const reqStringLower = reqString.toLowerCase();
|
for (const [classId, classData] of Object.entries(this.provider.classes)) {
|
||||||
for (const [className, classInfo] of Object.entries(this.provider.classes)) {
|
const isClassMatch = classData.label.includes(reqString);
|
||||||
const isClassMatch = reqStringLower && className.toLowerCase().includes(reqStringLower);
|
const isSubclassMatch = !isClassMatch && Object.values(classData.subclasses).some(
|
||||||
const isSubclassMatch = classInfo.subclasses.some(
|
(label) => reqString.includes(label)
|
||||||
// TODO compare with id and label
|
|
||||||
(subClass) => reqString.includes(subClass)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isClassMatch || isSubclassMatch) {
|
if (isClassMatch || isSubclassMatch) {
|
||||||
matchedClass.push(className);
|
matchedClass.push(classId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1550,14 +1542,20 @@ class CompendiumBrowser extends Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Hooks.once("init", async () => {
|
Hooks.once("init", () => {
|
||||||
await preloadTemplates();
|
|
||||||
game.compendiumBrowser = new CompendiumBrowser();
|
game.compendiumBrowser = new CompendiumBrowser();
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.once("setup", async () => {
|
Hooks.once("init", async () => {
|
||||||
|
await preloadTemplates();
|
||||||
|
});
|
||||||
|
|
||||||
|
Hooks.once("setup", () => {
|
||||||
registerSettings();
|
registerSettings();
|
||||||
await game.compendiumBrowser.setup();
|
});
|
||||||
|
|
||||||
|
Hooks.once("ready", async () => {
|
||||||
|
await game.compendiumBrowser.ready();
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on("changeSidebarTab", (app) => {
|
Hooks.on("changeSidebarTab", (app) => {
|
||||||
|
|
|
@ -21,7 +21,7 @@ export class dnd5eProvider {
|
||||||
.forEach((c) => {
|
.forEach((c) => {
|
||||||
this.classes[c.identifier] = {
|
this.classes[c.identifier] = {
|
||||||
label: c.label,
|
label: c.label,
|
||||||
subclasses: []
|
subclasses: {}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -29,17 +29,19 @@ export class dnd5eProvider {
|
||||||
if (_subclasses.length) {
|
if (_subclasses.length) {
|
||||||
_subclasses.map((entry) => {
|
_subclasses.map((entry) => {
|
||||||
return {
|
return {
|
||||||
|
name: entry.name,
|
||||||
identifier: entry.system.identifier,
|
identifier: entry.system.identifier,
|
||||||
classId: entry.system.classIdentifier
|
classId: entry.system.classIdentifier
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.forEach((subclass) => {
|
.forEach((subclass) => {
|
||||||
if (subclasses[subclass.classId]) {
|
if (subclasses[subclass.classId]) {
|
||||||
subclasses[subclass.classId].subclasses.push(subclass.identifier);
|
subclasses[subclass.classId].subclasses[subclass.identifier] = subclass.name;
|
||||||
} else {
|
} else {
|
||||||
subclasses[subclass.classId] = {
|
subclasses[subclass.classId] = {
|
||||||
// TODO change to object with {label, id} pair
|
subclasses: {
|
||||||
subclasses: [subclass.identifier]
|
[subclass.identifier]: subclass.name
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue