Skip to content

Commit

Permalink
Add breakermod to match weapons with seasonal artifact breaker mods
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper committed Jan 1, 2023
1 parent 9f6bcd5 commit c61c13a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
"Ascended": "Shows items that have an ascend node which have been ascended.",
"Unascended": "Shows items that have an ascend node which have not been ascended.",
"Breaker": "Filter by breaker type or corresponding champion type.",
"BreakerMod": "Filter by available anti-champion artifact mods for this breaker type or corresponding champion type.",
"BulkClear": "Removed tag from 1 item.",
"BulkClear_plural": "Removed tags from {{count}} items.",
"BulkRevert": "Reverted tag on 1 item.",
Expand Down
24 changes: 22 additions & 2 deletions src/app/search/search-filters/known-values.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { getEvent } from 'app/inventory/store/season';
import { getItemDamageShortName } from 'app/utils/item-utils';
import { DestinyAmmunitionType, DestinyClass, DestinyRecordState } from 'bungie-api-ts/destiny2';
import { D2EventPredicateLookup } from 'data/d2/d2-event-info';
import { BreakerTypeHashes } from 'data/d2/generated-enums';
import missingSources from 'data/d2/missing-source-info';
import D2Sources from 'data/d2/source-info';
import artifactBreakerMods from '../../../data/d2/artifact-breaker-weapon-types.json';
import { D1ItemCategoryHashes } from '../d1-known-values';
import {
breakerTypes,
Expand Down Expand Up @@ -166,11 +168,29 @@ const knownValuesFilters: FilterDefinition[] = [
suggestions: Object.keys(breakerTypes),
destinyVersion: 2,
filter: ({ filterValue }) => {
const breakerType = breakerTypes[filterValue];
const breakerType: BreakerTypeHashes[] | undefined = breakerTypes[filterValue];
if (!breakerType) {
throw new Error('Unknown breaker type ' + breakerType);
}
return (item) => breakerType.includes(item.breakerType?.hash);
return (item) => item.breakerType && breakerType.includes(item.breakerType.hash);
},
},
{
keywords: 'breakermod',
description: tl('Filter.BreakerMod'),
format: 'query',
suggestions: Object.keys(breakerTypes),
destinyVersion: 2,
filter: ({ filterValue }) => {
const breakerType: BreakerTypeHashes[] | undefined = breakerTypes[filterValue];
if (!breakerType) {
throw new Error('Unknown breaker type ' + breakerType);
}
const breakingIchs = breakerType.flatMap((ty) => artifactBreakerMods[ty] || []);
return (item) =>
Boolean(
!item.breakerType && item.itemCategoryHashes.some((ich) => breakingIchs.includes(ich))
);
},
},
{
Expand Down
15 changes: 15 additions & 0 deletions src/data/d2/artifact-breaker-weapon-types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"485622768": [
3317538576,
7
],
"2611060930": [
8,
5,
3954685534
],
"3178805705": [
6,
153950757
]
}
1 change: 1 addition & 0 deletions src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"ArmorIntrinsic": "Shows legendary armor which has an intrinsic perk, such as Artifice Armor.",
"Ascended": "Shows items that have an ascend node which have been ascended.",
"Breaker": "Filter by breaker type or corresponding champion type.",
"BreakerMod": "Filter by available anti-champion artifact mods for this breaker type or corresponding champion type.",
"BulkClear": "Removed tag from 1 item.",
"BulkClear_plural": "Removed tags from {{count}} items.",
"BulkRevert": "Reverted tag on 1 item.",
Expand Down

0 comments on commit c61c13a

Please sign in to comment.