Skip to content

Commit

Permalink
refactor(readability): Use SocketCategory enums (#2173)
Browse files Browse the repository at this point in the history
  • Loading branch information
NigelBreslaw authored Jul 27, 2024
1 parent 9059438 commit 4432b68
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
10 changes: 10 additions & 0 deletions native/app/bungie/Enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ export enum SectionBuckets {
Vault = 138197802,
}

export enum SocketCategoryEnum {
INTRINSIC_TRAITS = 3956125808,
WEAPON_PERKS = 4241085061,
WEAPON_MODS = 2685412949,
ARMOR_MODS = 590099826,
ARMOR_COSMETICS = 1926152773,
ARMOR_TIER = 760375309,
ARMOR_PERKS = 3154740035,
}

export enum GGCharacterType {
Guardian = 0,
Vault = 138197802,
Expand Down
24 changes: 18 additions & 6 deletions native/app/stats/Logic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ItemType, StatType } from "@/app/bungie/Enums.ts";
import { ItemType, SocketCategoryEnum, StatType } from "@/app/bungie/Enums.ts";
import { ArmorStatInvestments } from "@/app/inventory/logic/Helpers.ts";
import type { SocketCategory, Sockets } from "@/app/inventory/logic/Sockets.ts";
import type { DestinyItem, StatsCollection } from "@/app/inventory/logic/Types.ts";
Expand Down Expand Up @@ -59,11 +59,17 @@ export function createStats(destinyItem: DestinyItem, sockets: Sockets): ItemSta
if (destinyItem.def.itemType === ItemType.Weapon) {
const stats = createBaseStats(destinyItem);

const perksCategory = sockets?.socketCategories.find((category) => category.socketCategoryHash === 4241085061);
console.log("createStats", sockets);

const perksCategory = sockets?.socketCategories.find(
(category) => category.socketCategoryHash === SocketCategoryEnum.WEAPON_PERKS,
);
if (perksCategory) {
addSocketStats(stats, perksCategory);
}
const modsCategory = sockets?.socketCategories.find((category) => category.socketCategoryHash === 2685412949);
const modsCategory = sockets?.socketCategories.find(
(category) => category.socketCategoryHash === SocketCategoryEnum.WEAPON_MODS,
);
if (modsCategory) {
addSocketStats(stats, modsCategory);
}
Expand All @@ -74,17 +80,23 @@ export function createStats(destinyItem: DestinyItem, sockets: Sockets): ItemSta
if (destinyItem.def.itemType === ItemType.Armor) {
const stats: ItemStats = new Map<number, number>();

const perksCategory = sockets?.socketCategories.find((category) => category.socketCategoryHash === 3154740035);
const perksCategory = sockets?.socketCategories.find(
(category) => category.socketCategoryHash === SocketCategoryEnum.ARMOR_PERKS,
);
if (perksCategory) {
addSocketStats(stats, perksCategory);
}

const tierCategory = sockets?.socketCategories.find((category) => category.socketCategoryHash === 760375309);
const tierCategory = sockets?.socketCategories.find(
(category) => category.socketCategoryHash === SocketCategoryEnum.ARMOR_TIER,
);
if (tierCategory) {
addSocketStats(stats, tierCategory);
}

const modsCategory = sockets?.socketCategories.find((category) => category.socketCategoryHash === 590099826);
const modsCategory = sockets?.socketCategories.find(
(category) => category.socketCategoryHash === SocketCategoryEnum.ARMOR_MODS,
);
if (modsCategory) {
addSocketStats(stats, modsCategory);
}
Expand Down

0 comments on commit 4432b68

Please sign in to comment.