Skip to content

Commit

Permalink
Merge pull request #94 from dragoni7/generation
Browse files Browse the repository at this point in the history
Mod Combos Generation
  • Loading branch information
dragoni7 authored Sep 17, 2024
2 parents 2511abc + c650448 commit 5d26a79
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 597 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"generate": "npx tsx src/generated/generate-mod-combos.ts",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
Expand Down
69 changes: 36 additions & 33 deletions src/features/armor-optimization/PermutationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const StyledCard = styled(Card)(({ theme }) => ({
backgroundColor: 'rgba(0, 0, 0, 0.5)',
backdropFilter: 'blur(10px)',
alignItems: 'center',
justifyContent: 'center',
}));

const ArmorRow = styled(Grid)(({ theme }) => ({
Expand Down Expand Up @@ -236,39 +237,41 @@ const PermutationsList: React.FC<PermutationsListProps> = ({
onPermutationClick(perm);
}}
>
<ArmorRow container spacing={0}>
{perm.permutation.map((item, idx) => (
<Grid item md={2} key={idx}>
<Tooltip title={`${item.name}\n${formatArmorStats(item)}`}>
<Box>
<ArmorIcon armor={item} />
</Box>
</Tooltip>
</Grid>
))}
</ArmorRow>
<StatsRow container spacing={1} alignItems="center" justifyContent="center">
{(STATS as StatName[]).map((stat) => (
<Grid item md={1} key={stat}>
<StatContainer>
<StatIcon src={statIcons[stat]} alt={stat} />
<StatValue variant="body2">{calculateTotal(perm, stat)}</StatValue>
</StatContainer>
</Grid>
))}
</StatsRow>
<Stack direction="row" alignItems="start" justifyContent="center" spacing={0.5}>
{(STATS as StatName[]).map((stat) =>
perm.modsArray[stat].length !== 0 ? (
<>
{renderStatModCount(perm, stat, 10)}
{renderStatModCount(perm, stat, 5)}
{renderStatModCount(perm, stat, 3)}
</>
) : (
false
)
)}
<Stack justifyContent="center" alignItems="center" height="100%">
<ArmorRow container spacing={0}>
{perm.permutation.map((item, idx) => (
<Grid item md={2} key={idx}>
<Tooltip title={`${item.name}\n${formatArmorStats(item)}`}>
<Box>
<ArmorIcon armor={item} />
</Box>
</Tooltip>
</Grid>
))}
</ArmorRow>
<StatsRow container spacing={1} alignItems="center" justifyContent="center">
{(STATS as StatName[]).map((stat) => (
<Grid item md={1} key={stat}>
<StatContainer>
<StatIcon src={statIcons[stat]} alt={stat} />
<StatValue variant="body2">{calculateTotal(perm, stat)}</StatValue>
</StatContainer>
</Grid>
))}
</StatsRow>
<Stack direction="row" alignItems="start" justifyContent="center" spacing={0.5}>
{(STATS as StatName[]).map((stat) =>
perm.modsArray[stat].length !== 0 ? (
<>
{renderStatModCount(perm, stat, 10)}
{renderStatModCount(perm, stat, 5)}
{renderStatModCount(perm, stat, 3)}
</>
) : (
false
)
)}
</Stack>
</Stack>
</StyledCard>
))}
Expand Down
4 changes: 2 additions & 2 deletions src/features/armor-optimization/filter-permutations.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { generatedModCombos } from '../../generated/generated-mod-combos';
import { STATS } from '../../lib/bungie_api/constants';
import {
DecodedLoadoutData,
Expand All @@ -6,7 +7,6 @@ import {
StatName,
FragmentStatModifications,
} from '../../types/d2l-types';
import { precalculatedModCombinations } from './precalculatedModCombinations';

interface SelectedThresholds {
[key: string]: number;
Expand Down Expand Up @@ -56,7 +56,7 @@ export const filterPermutations = (
return tryModCombination(statIndex + 1, artificeUsed, regularModsUsed);
}

const combinations = precalculatedModCombinations[deficit] || [];
const combinations = generatedModCombos[deficit] || [];
for (const [artifice, minor, major] of combinations) {
if (artifice <= artificeCount - artificeUsed && minor + major <= 5 - regularModsUsed) {
modsArray[stat.toLowerCase() as keyof FilteredPermutation['modsArray']] = [
Expand Down
Loading

0 comments on commit 5d26a79

Please sign in to comment.