Skip to content

Commit 39ee42b

Browse files
Filter on any weapon bonus in the faction armory.
1 parent 290a0b5 commit 39ee42b

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

extension/changelog.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
{ "message": "Disable OC1 timer when detecting OC 2 data.", "contributor": "DeKleineKobini" },
2222
{ "message": "Disable Faction OC timer when detecting OC 2 data.", "contributor": "DeKleineKobini" },
2323
{ "message": "Better note about external services.", "contributor": "DeKleineKobini" },
24-
{ "message": "Show FF scouter gauge on more pages when honor bars are disabled.", "contributor": "DeKleineKobini" }
24+
{ "message": "Show FF scouter gauge on more pages when honor bars are disabled.", "contributor": "DeKleineKobini" },
25+
{ "message": "Filter on any weapon bonus in the faction armory.", "contributor": "DeKleineKobini" }
2526
],
2627
"removed": []
2728
}

extension/scripts/features/armory-filter/ttArmoryFilter.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@
114114
type: "Weapon Bonus",
115115
callback: applyFilters,
116116
defaults: filters.factionArmory[itemType].weaponBonus,
117+
configuration: {
118+
anyWeaponBonus: true,
119+
},
117120
});
118121
filterContent.appendChild(bonusFilter.element);
119122
localFilters.weaponBonus = { getValues: bonusFilter.getValues };
@@ -276,9 +279,14 @@
276279
value: description.getNumber(),
277280
}));
278281

279-
const hasBonuses = toFilterBonus.every(
280-
({ bonus, value }) => foundBonuses.filter((found) => found.bonus === bonus && (!value || found.value >= value)).length > 0
281-
);
282+
let hasBonuses;
283+
if (toFilterBonus.some(({ bonus }) => bonus === "any")) {
284+
hasBonuses = foundBonuses.length;
285+
} else {
286+
hasBonuses = toFilterBonus.every(
287+
({ bonus, value }) => foundBonuses.filter((found) => found.bonus === bonus && (!value || found.value >= value)).length > 0
288+
);
289+
}
282290

283291
if (!hasBonuses) {
284292
hide("weapon-bonus");

extension/scripts/global/functions/filters.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ function createFilterSection(options) {
5252
orientation: "column",
5353
noTitle: false,
5454
style: {},
55+
configuration: {
56+
anyWeaponBonus: false,
57+
...(options.configuration ?? {}),
58+
},
5559
...options,
5660
};
5761

@@ -191,7 +195,11 @@ function createFilterSection(options) {
191195
}
192196

193197
if (isWeaponBonus) {
194-
const selectOptions = [{ value: "", description: "None" }, ...WEAPON_BONUSES.map((bonus) => ({ value: bonus.toLowerCase(), description: bonus }))];
198+
const selectOptions = [
199+
{ value: "", description: "None" },
200+
options.configuration.anyWeaponBonus ? { value: "any", description: "Any" } : undefined,
201+
...WEAPON_BONUSES.map((bonus) => ({ value: bonus.toLowerCase(), description: bonus })),
202+
].filter((option) => !!option);
195203

196204
const select1 = createSelect(selectOptions);
197205
const value1 = createTextbox({ type: "number", style: { width: "40px" } });

0 commit comments

Comments
 (0)