Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dragoni7/d2loadouts
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoni7 committed Sep 19, 2024
2 parents 32380a4 + 9062ad4 commit 9bdb967
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/components/HoverCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ const HoverCard: React.FC<HoverCardProps> = ({ item, children }) => {
});
return;
}

console.log('Item not found in any table');
} catch (error) {
console.error('Error fetching item data:', error);
}
Expand Down
13 changes: 13 additions & 0 deletions src/features/armor-optimization/filter-permutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import {
FragmentStatModifications,
} from '../../types/d2l-types';

/**
* Finds the stat deficit by considering the total armor in each permutation and the fragment modifications.
* Then, it tries pre-calculated mod combinations to meet the required threshold.
* It returns a sorted, filtered permutation array based on the lowest number of mods used.
*/

interface SelectedThresholds {
[key: string]: number;
}
Expand Down Expand Up @@ -99,6 +105,13 @@ function calculateTotalCost(perm: FilteredPermutation): number {
return total;
}

/**
* The algorithm for the ShareLoadout link to find optimal armor from the receiving user's armor pool.
* It starts with the highest priority stat at its maximum threshold and decrements
* the threshold until a permutation is found. This allows us to find the best or closest
* possible armor from the receiving user's armor pool.
*/

export function filterFromSharedLoadout(
decodedLoadout: DecodedLoadoutData,
permutations: DestinyArmor[][],
Expand Down
6 changes: 5 additions & 1 deletion src/features/armor-optimization/generate-permutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
ExoticClassCombo,
FragmentStatModifications,
} from '../../types/d2l-types';

/**
* This function generates all possible permutations of armor based on class, selected exotic item (if any),
* and fragment modifications. It tracks and stores the top 30,000 permutations in a max heap based on the total stats.
* The function returns a sorted array of permutations of type DestinyArmor[].
*/
export function generatePermutations(
armorClass: ArmorBySlot,
selectedExoticItem: { itemHash: number | null; slot: armor | null } = {
Expand Down

0 comments on commit 9bdb967

Please sign in to comment.