Skip to content

Commit

Permalink
fix: missing special orders buckethash (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
NigelBreslaw authored Mar 14, 2024
1 parent cea6d02 commit f12e354
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion native/ReleaseNotes/whatsnew-en
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Web release notes..
Web release notes...
7 changes: 6 additions & 1 deletion native/app/bungie/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export type CharacterGear = {
equipped: DestinyItem | null;
inventory: Array<DestinyItem>;
};
export type VaultBucketHash = 138197802 | 1469714392 | 3313201758;
export type VaultBucketHash = 138197802 | 1469714392 | 3313201758 | 1367666825;
export const vaultBucketHashes = [138197802, 1469714392, 3313201758, 1367666825];

export type VaultData = {
characterId: string;
Expand All @@ -33,6 +34,10 @@ export type VaultData = {
3313201758: {
items: Record<number, CharacterGear>;
};
// special orders:
1367666825: {
items: Record<number, CharacterGear>;
};
};
};

Expand Down
14 changes: 9 additions & 5 deletions native/app/core/DataService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getCustomItemDefinition } from "@/app/backend/api.ts";
import { getProfile } from "@/app/bungie/BungieApi.ts";
import { type ProfileData, getProfileSchema } from "@/app/bungie/Types.ts";
import { type ProfileData, getProfileSchema, vaultBucketHashes } from "@/app/bungie/Types.ts";
import type { CharactersAndVault, DestinyItem, VaultBucketHash } from "@/app/bungie/Types.ts";
import { type ItemDefinition, ItemDefinitionSchema, type SingleItemDefinition } from "@/app/core/Types.ts";
import type { GlobalAction } from "@/app/state/Types.ts";
Expand Down Expand Up @@ -28,6 +28,10 @@ class DataService {
3313201758: {
items: {},
},
// special orders:
1367666825: {
items: {},
},
},
},
characters: {},
Expand Down Expand Up @@ -187,23 +191,23 @@ class DataService {

for (const item of vaultInventory) {
const itemHash = item.itemHash.toString();
console.log("itemHash", itemHash);
const data = DataService.itemDefinition.items[itemHash] as SingleItemDefinition;

const bucketHashIndex = data.b;
if (bucketHashIndex) {
const definitionBucketHash = DataService.bucketTypeHashArray[bucketHashIndex];

if (definitionBucketHash) {
console.log("Found bucket", definitionBucketHash);
console.log("item.bucketHash", item.bucketHash);
if (!vaultBucketHashes.includes(item.bucketHash)) {
console.error("item.bucketHash not in vaultBucketHashes", item.bucketHash);
continue;
}
const hasBucket = Object.hasOwn(vaultItems[item.bucketHash as VaultBucketHash].items, definitionBucketHash);
if (!hasBucket) {
vaultItems[item.bucketHash as VaultBucketHash].items[definitionBucketHash] = {
equipped: null,
inventory: [],
};
console.log("Added new bucket", item.bucketHash, definitionBucketHash);
}

vaultItems[item.bucketHash as VaultBucketHash].items[definitionBucketHash]?.inventory.push(item);
Expand Down

0 comments on commit f12e354

Please sign in to comment.