mirror of
https://github.com/Kornstalx/5etools-mirror-2.github.io.git
synced 2025-10-28 20:45:35 -05:00
v1.198.1
This commit is contained in:
86
js/filter-deities.js
Normal file
86
js/filter-deities.js
Normal file
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
class PageFilterDeities extends PageFilter {
|
||||
static unpackAlignment (g) {
|
||||
g.alignment.sort(SortUtil.alignmentSort);
|
||||
if (g.alignment.length === 2 && g.alignment.includes("N")) {
|
||||
const out = [...g.alignment];
|
||||
if (out[0] === "N") out[0] = "NX";
|
||||
else out[1] = "NY";
|
||||
return out;
|
||||
}
|
||||
return MiscUtil.copy(g.alignment);
|
||||
}
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
this._pantheonFilter = new Filter({header: "Pantheon", items: []});
|
||||
this._categoryFilter = new Filter({header: "Category", items: [VeCt.STR_NONE]});
|
||||
this._alignmentFilter = new Filter({
|
||||
header: "Alignment",
|
||||
items: ["L", "NX", "C", "G", "NY", "E", "N"],
|
||||
displayFn: it => Parser.alignmentAbvToFull(it).toTitleCase(),
|
||||
itemSortFn: null,
|
||||
});
|
||||
this._domainFilter = new Filter({
|
||||
header: "Domain",
|
||||
items: ["Death", "Knowledge", "Life", "Light", "Nature", VeCt.STR_NONE, "Tempest", "Trickery", "War"],
|
||||
});
|
||||
this._miscFilter = new Filter({
|
||||
header: "Miscellaneous",
|
||||
items: ["Grants Piety Features", "Has Info", "Has Images", "Reprinted", "SRD", "Basic Rules"],
|
||||
displayFn: StrUtil.uppercaseFirst,
|
||||
deselFn: (it) => it === "Reprinted",
|
||||
isMiscFilter: true,
|
||||
});
|
||||
}
|
||||
|
||||
static mutateForFilters (g) {
|
||||
g._fAlign = g.alignment ? PageFilterDeities.unpackAlignment(g) : [];
|
||||
if (!g.category) g.category = VeCt.STR_NONE;
|
||||
if (!g.domains) g.domains = [VeCt.STR_NONE];
|
||||
g.domains.sort(SortUtil.ascSort);
|
||||
|
||||
g._fMisc = [];
|
||||
if (g.reprinted) g._fMisc.push("Reprinted");
|
||||
if (g.srd) g._fMisc.push("SRD");
|
||||
if (g.basicRules) g._fMisc.push("Basic Rules");
|
||||
if (g.entries) g._fMisc.push("Has Info");
|
||||
if (g.symbolImg) g._fMisc.push("Has Images");
|
||||
if (g.piety) g._fMisc.push("Grants Piety Features");
|
||||
}
|
||||
|
||||
addToFilters (g, isExcluded) {
|
||||
if (isExcluded) return;
|
||||
|
||||
this._sourceFilter.addItem(g.source);
|
||||
this._domainFilter.addItem(g.domains);
|
||||
this._pantheonFilter.addItem(g.pantheon);
|
||||
this._categoryFilter.addItem(g.category);
|
||||
}
|
||||
|
||||
async _pPopulateBoxOptions (opts) {
|
||||
opts.filters = [
|
||||
this._sourceFilter,
|
||||
this._alignmentFilter,
|
||||
this._pantheonFilter,
|
||||
this._categoryFilter,
|
||||
this._domainFilter,
|
||||
this._miscFilter,
|
||||
];
|
||||
}
|
||||
|
||||
toDisplay (values, g) {
|
||||
return this._filterBox.toDisplay(
|
||||
values,
|
||||
g.source,
|
||||
g._fAlign,
|
||||
g.pantheon,
|
||||
g.category,
|
||||
g.domains,
|
||||
g._fMisc,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.PageFilterDeities = PageFilterDeities;
|
||||
Reference in New Issue
Block a user