Skip to content

Commit

Permalink
Merge pull request #33 from dragoni7/32-add-equipping-class-armor-logic
Browse files Browse the repository at this point in the history
Added equipping class armor
  • Loading branch information
dragoni7 authored Aug 27, 2024
2 parents 060e14d + ca0c640 commit 8371f68
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
17 changes: 6 additions & 11 deletions src/features/armor/components/ArmorConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ const ArmorConfig: React.FC<ArmorConfigProps> = ({ armor, statMods, artificeMods
);
};

const onSelectMod = async (
mod: ManifestArmorMod | ManifestArmorStatMod,
slot: number,
socketIndex: number
) => {
const onSelectMod = async (mod: ManifestArmorMod | ManifestArmorStatMod, slot: number) => {
let totalCost = mod.energyCost;

for (const key in selectedMods) {
if (Number(key) !== slot) {
let statEnergyCost = armorMods.find(
Expand Down Expand Up @@ -79,36 +74,36 @@ const ArmorConfig: React.FC<ArmorConfigProps> = ({ armor, statMods, artificeMods
selected={selectedMods[0]}
mods={statMods}
onSelectMod={(mod: ManifestArmorMod) => {
onSelectMod(mod, 0, 0);
onSelectMod(mod, 0);
}}
/>
<ArmorModSelector
selected={selectedMods[1]}
mods={armorMods}
onSelectMod={(mod: ManifestArmorMod) => {
onSelectMod(mod, 1, 1);
onSelectMod(mod, 1);
}}
/>
<ArmorModSelector
selected={selectedMods[2]}
mods={armorMods}
onSelectMod={(mod: ManifestArmorMod) => {
onSelectMod(mod, 2, 2);
onSelectMod(mod, 2);
}}
/>
<ArmorModSelector
selected={selectedMods[3]}
mods={armorMods}
onSelectMod={(mod: ManifestArmorMod) => {
onSelectMod(mod, 3, 3);
onSelectMod(mod, 3);
}}
/>
{armor.artifice === true ? (
<ArmorModSelector
selected={selectedMods[4]}
mods={artificeMods}
onSelectMod={(mod: ManifestArmorMod) => {
onSelectMod(mod, 4, 11);
onSelectMod(mod, 4);
}}
/>
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/features/armor/components/ArmorModSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ManifestArmorMod, ManifestArmorStatMod } from '../../../types/manifest-
interface ModSelectorProps {
selected: ManifestArmorMod | ManifestArmorStatMod;
mods: ManifestArmorMod[];
onSelectMod: (mod: ManifestArmorMod) => void;
onSelectMod: (mod: ManifestArmorMod | ManifestArmorStatMod) => void;
}

const ArmorModSelector: React.FC<ModSelectorProps> = ({ selected, mods, onSelectMod }) => {
Expand Down
3 changes: 1 addition & 2 deletions src/features/armor/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function getModsBySlot(slot: string): Promise<ManifestArmorMod[]> {
? PLUG_CATEGORY_HASH.ARMOR_MODS.CHEST_ARMOR_MODS
: slot === 'legs'
? PLUG_CATEGORY_HASH.ARMOR_MODS.LEG_ARMOR_MODS
: slot === 'classItem'
: slot === 'class'
? PLUG_CATEGORY_HASH.ARMOR_MODS.CLASS_ARMOR_MODS
: 0
)
Expand All @@ -25,7 +25,6 @@ export async function getModsBySlot(slot: string): Promise<ManifestArmorMod[]> {
}

export function getSelectedModsBySlot(slot: string): (ManifestArmorMod | ManifestArmorStatMod)[] {
console.log(slot);
switch (slot) {
case 'helmet': {
return store.getState().loadoutConfig.loadout.helmetMods;
Expand Down
7 changes: 4 additions & 3 deletions src/features/loadouts/components/EquipLoadout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ const EquipLoadout: React.FC = () => {
lg={12}
textAlign="center"
sx={{ backgroundColor: 'rgba(48,48,48,0.8)' }}
height={'10%'}
>
<FadeIn>
<h2>{equipStep}</h2>
</FadeIn>
</Grid>
)}
<Grid container item md={12} lg={12} spacing={3} py={4}>
<Grid container item md={12} lg={12} spacing={1} py={2}>
{processing.map((item, index) => (
<>
{results[index] !== undefined ? (
Expand Down Expand Up @@ -108,8 +109,8 @@ const EquipLoadout: React.FC = () => {
<Tooltip title={result.message}>
<img
src={result.subject.icon}
width={72}
height={72}
width={74}
height={74}
style={{
border: `4px solid ${
result.status === STATUS.SUCCESS ? 'green' : 'red'
Expand Down
2 changes: 1 addition & 1 deletion src/features/loadouts/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export enum STATUS {
FAIL = 0,
}

export const ARMOR_ARRAY: armor[] = ['helmet', 'gauntlets', 'chestArmor', 'legArmor'];
export const ARMOR_ARRAY: armor[] = ['helmet', 'gauntlets', 'chestArmor', 'legArmor', 'classArmor'];
9 changes: 7 additions & 2 deletions src/features/loadouts/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ export type EquipResult = {
subject: any;
};

export type armor = 'helmet' | 'gauntlets' | 'chestArmor' | 'legArmor';
export type armor = 'helmet' | 'gauntlets' | 'chestArmor' | 'legArmor' | 'classArmor';

export type armorMods = 'helmetMods' | 'gauntletMods' | 'chestArmorMods' | 'legArmorMods';
export type armorMods =
| 'helmetMods'
| 'gauntletMods'
| 'chestArmorMods'
| 'legArmorMods'
| 'classArmorMods';

export type setState = (value: React.SetStateAction<any | string[]>) => void;
2 changes: 1 addition & 1 deletion src/store/LoadoutReducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const loadoutConfigSlice = createSlice({
state.loadout.legArmorMods[action.payload.slot] = action.payload.plug;
break;
}
case 'classItem': {
case 'class': {
state.loadout.classArmorMods[action.payload.slot] = action.payload.plug;
break;
}
Expand Down

0 comments on commit 8371f68

Please sign in to comment.