Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(readability): Use SocketCategory enums #2173

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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