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

workaround for missing destinyclass #10929

Closed
Closed
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
57 changes: 55 additions & 2 deletions src/app/inventory/store/d2-item-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export function makeItem(
}

// we cannot trust the claimed class of redacted items. they all say Titan
const classType = itemDef.redacted
let classType = itemDef.redacted
? normalBucket.inArmor
? itemInstanceData?.isEquipped && owner
? // equipped armor gets marked as that character's class
Expand All @@ -446,6 +446,59 @@ export function makeItem(
DestinyClass.Unknown
: itemDef.classType;

if (classType == DestinyClass.Unknown) {
if (itemDef.collectibleHash != undefined) {
let presentationParentNode = defs.Collectible.getOptional(
itemDef.collectibleHash,
)?.parentNodeHashes;
if (presentationParentNode != undefined) {
if (
presentationParentNode.findIndex(
(x) => defs.PresentationNode.get(x).displayProperties.name == 'Warlock',
) != -1
)
classType = DestinyClass.Warlock;
if (
presentationParentNode.findIndex(
(x) => defs.PresentationNode.get(x).displayProperties.name == 'Titan',
) != -1
)
classType = DestinyClass.Titan;
if (
presentationParentNode.findIndex(
(x) => defs.PresentationNode.get(x).displayProperties.name == 'Hunter',
) != -1
)
classType = DestinyClass.Hunter;
}
}
if (classType == DestinyClass.Unknown) {
itemDef.sockets?.socketEntries.forEach((socketEntry) => {
let socketDef = defs.SocketType.getOptional(socketEntry.socketTypeHash);
if (socketDef != undefined) {
if (
socketDef.plugWhitelist.findIndex((x) => x.categoryIdentifier.includes('warlock')) != -1
) {
classType = DestinyClass.Warlock;
return;
}
if (
socketDef.plugWhitelist.findIndex((x) => x.categoryIdentifier.includes('titan')) != -1
) {
classType = DestinyClass.Titan;
return;
}
if (
socketDef.plugWhitelist.findIndex((x) => x.categoryIdentifier.includes('hunter')) != -1
) {
classType = DestinyClass.Hunter;
return;
}
}
});
}
}

const createdItem: DimItem = {
owner: owner?.id || 'unknown',
// figure out what year this item is probably from
Expand Down Expand Up @@ -486,7 +539,7 @@ export function makeItem(
maxStackSize: Math.max(itemDef.inventory!.maxStackSize, 1),
uniqueStack: Boolean(itemDef.inventory!.stackUniqueLabel?.length),
classType,
classTypeNameLocalized: getClassTypeNameLocalized(defs)(itemDef.classType),
classTypeNameLocalized: getClassTypeNameLocalized(defs)(classType),
element,
energy: itemInstanceData.energy ?? null,
lockable: normalBucket.hash !== BucketHashes.Finishers ? item.lockable : true,
Expand Down