Skip to content

Commit

Permalink
Merge pull request #10546 from dghost/loadout_display
Browse files Browse the repository at this point in the history
Fix bug in the displayed calculated loadout power
  • Loading branch information
bhollis authored Jun 14, 2024
2 parents 9f0baf6 + 9f2bdce commit e965d5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Next
* Add `light:` filter to the loadout search, for searching loadouts that equip all weapon and armor slots.
* Fix issue where light level displayed in the Loadouts views was calculated using all weapons and armor in the loadout, instead of just the weapons and armor to be equipped.
* Add `light:` filter to the Loadouts search. Only works with loadouts that equip an item for all weapon and armor slots.


## 8.23.0 <span class="changelog-date">(2024-06-09)</span>

Expand Down
10 changes: 5 additions & 5 deletions src/app/loadout/LoadoutView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Loadout, LoadoutItem, ResolvedLoadoutItem } from 'app/loadout/loadout-t
import AppIcon from 'app/shell/icons/AppIcon';
import { useIsPhonePortrait } from 'app/shell/selectors';
import { useStreamDeckSelection } from 'app/stream-deck/stream-deck';
import { count, filterMap } from 'app/utils/collections';
import { filterMap } from 'app/utils/collections';
import { emptyObject } from 'app/utils/empty';
import { itemCanBeEquippedBy } from 'app/utils/item-utils';
import { addDividers } from 'app/utils/react';
Expand Down Expand Up @@ -217,14 +217,14 @@ export default function LoadoutView({
export function loadoutPower(store: DimStore, categories: _.Dictionary<ResolvedLoadoutItem[]>) {
const isEquipped = (li: ResolvedLoadoutItem) =>
Boolean(!li.missing && li.item.power && li.loadoutItem.equip);
const showPower =
count(categories.Weapons ?? [], isEquipped) === 3 &&
count(categories.Armor ?? [], isEquipped) === 5;
const equippedWeapons = categories.Weapons.filter(isEquipped);
const equippedArmor = categories.Armor.filter(isEquipped);
const showPower = equippedWeapons.length === 3 && equippedArmor.length === 5;
const power = showPower
? Math.floor(
getLight(
store,
[...categories.Weapons, ...categories.Armor].map((li) => li.item),
[...equippedWeapons, ...equippedArmor].map((li) => li.item),
),
)
: 0;
Expand Down

0 comments on commit e965d5e

Please sign in to comment.