Skip to content

Commit

Permalink
dynamic fragment slots depending on aspect
Browse files Browse the repository at this point in the history
  • Loading branch information
Rorschach7552 committed Aug 25, 2024
1 parent f426715 commit 81787b0
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/features/subclass/AbilitiesModification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,17 @@ const AbilitiesModification: React.FC<AbilitiesModificationProps> = ({ subclass

updatedMods[index!] = mod as (typeof updatedMods)[number];

// If updating aspects, we need to check if we need to empty any fragment slots
if (category === 'ASPECTS') {
const newAspects = updatedMods as ManifestAspect[];
const newAvailableSlots = newAspects.reduce(
(total, aspect) => total + (aspect.energyCapacity || 0),
0
);

// Update fragments, emptying any that exceed the new available slots
const updatedFragments = loadout.fragments.map((fragment, idx) =>
idx < newAvailableSlots ? fragment : EMPTY_FRAGMENT
);

// Dispatch updates for both aspects and fragments
dispatch(
updateSubclassMods({
category: 'ASPECTS',
Expand All @@ -302,11 +299,10 @@ const AbilitiesModification: React.FC<AbilitiesModificationProps> = ({ subclass
mods: updatedFragments,
})
);
return; // Exit the function early as we've already dispatched the updates
return;
}
}

// For all other cases, dispatch the update as before
dispatch(
updateSubclassMods({
category,
Expand Down

0 comments on commit 81787b0

Please sign in to comment.