Skip to content

Commit

Permalink
Merge pull request #53 from dragoni7/add-perk-info
Browse files Browse the repository at this point in the history
Reduced manifest types. Added required manifest information to db
  • Loading branch information
dragoni7 authored Sep 4, 2024
2 parents 2a98d82 + ff73517 commit abaa386
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 59 deletions.
4 changes: 2 additions & 2 deletions src/features/profile/destiny-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DAMAGE_TYPE,
EMPTY_ASPECT,
EMPTY_FRAGMENT,
EMPTY_MANIFEST_PLUG,
EMPTY_SUBCLASS_MOD,
PRIMARY_STATS,
SOCKET_HASH,
STAT_HASH,
Expand Down Expand Up @@ -420,7 +420,7 @@ async function buildSubclassConfig(item: any, character: Character, itemComponen
character.subclasses[subclass.damageType] = {
subclass: s,
damageType: subclass.damageType as DamageType,
super: EMPTY_MANIFEST_PLUG,
super: EMPTY_SUBCLASS_MOD,
aspects: [EMPTY_ASPECT, EMPTY_ASPECT],
fragments: [EMPTY_FRAGMENT, EMPTY_FRAGMENT, EMPTY_FRAGMENT, EMPTY_FRAGMENT, EMPTY_FRAGMENT],
classAbility: null,
Expand Down
19 changes: 9 additions & 10 deletions src/lib/bungie_api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ export enum API_CREDENTIALS {
CLIENT_SECRET = import.meta.env.VITE_CLIENT_SECRET,
}

export const EMPTY_MANIFEST_PLUG: ManifestPlug = {
perkName: '',
perkDescription: '',
perkIcon: '',
export const EMPTY_SUBCLASS_MOD: ManifestPlug = {
perks: [],
category: 0,
isOwned: false,
itemHash: 0,
name: '',
icon: '',
secondaryIcon: '',
description: '',
};

export const EMPTY_ASPECT: ManifestAspect = {
energyCapacity: 0,
perkName: '',
perkDescription: '',
perkIcon: '',
perks: [],
category: 0,
isOwned: false,
itemHash: 0,
name: '',
icon: '',
secondaryIcon: '',
flavorText: '',
};

export const EMPTY_FRAGMENT: ManifestStatPlug = {
Expand All @@ -39,14 +39,13 @@ export const EMPTY_FRAGMENT: ManifestStatPlug = {
disciplineMod: 0,
intellectMod: 0,
strengthMod: 0,
perkName: '',
perkDescription: '',
perkIcon: '',
perks: [],
category: 0,
isOwned: false,
itemHash: 0,
name: '',
icon: '',
secondaryIcon: '',
};

export const COLLECTIBLE_OWNED: number[] = [0, 16, 64, 80];
Expand Down
29 changes: 14 additions & 15 deletions src/lib/bungie_api/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export async function updateManifest() {
secondarySpecial: urlPrefix + current.secondarySpecial,
name: current.displayProperties.name,
icon: urlPrefix + current.displayProperties.icon,
secondaryIcon: urlPrefix + current.secondaryIcon,
});
}

Expand All @@ -71,7 +72,9 @@ export async function updateManifest() {
itemHash: Number(itemHash),
name: current.displayProperties.name,
icon: urlPrefix + current.displayProperties.icon,
secondaryIcon: urlPrefix + current.displayProperties.highResIcon,
screenshot: urlPrefix + current.screenshot,
flavorText: current.flavorText,
damageType: current.talentGrid.hudDamageType,
isOwned: false,
class: getManifestItemClass(current.classType),
Expand Down Expand Up @@ -105,9 +108,7 @@ export async function updateManifest() {
category: current.plug.plugCategoryHash,
isOwned: true,
collectibleHash: -1,
perkName: '',
perkDescription: '',
perkIcon: '',
perks: current.perks.map((p: any) => p.perkHash),
mobilityMod:
0 |
current.investmentStats.find(
Expand Down Expand Up @@ -148,9 +149,7 @@ export async function updateManifest() {
category: current.plug.plugCategoryHash,
isOwned: true,
collectibleHash: -1,
perkName: '',
perkDescription: '',
perkIcon: '',
perks: current.perks.map((p: any) => p.perkHash),
unique: current.tooltipNotifications.some(
(notification: any) =>
notification.displayString ===
Expand All @@ -164,23 +163,22 @@ export async function updateManifest() {
itemHash: Number(itemHash),
name: current.displayProperties.name,
icon: urlPrefix + current.displayProperties.icon,
secondaryIcon: urlPrefix + current.secondaryIcon,
flavorText: current.flavorText,
category: current.plug.plugCategoryHash,
isOwned: true,
perkName: '',
perkDescription: '',
perkIcon: '',
perks: current.perks.map((p: any) => p.perkHash),
energyCapacity: current.investmentStats[0].value,
});
} else if (current.itemTypeDisplayName.includes('Fragment')) {
await db.manifestSubclassFragmentsDef.add({
itemHash: Number(itemHash),
name: current.displayProperties.name,
icon: urlPrefix + current.displayProperties.icon,
secondaryIcon: urlPrefix + current.secondaryIcon,
category: current.plug.plugCategoryHash,
isOwned: true,
perkName: '',
perkDescription: '',
perkIcon: '',
perks: current.perks.map((p: any) => p.perkHash),
mobilityMod:
0 |
current.investmentStats.find(
Expand Down Expand Up @@ -216,12 +214,12 @@ export async function updateManifest() {
await db.manifestSubclassModDef.add({
itemHash: Number(itemHash),
name: current.displayProperties.name,
description: current.displayProperties.description,
icon: urlPrefix + current.displayProperties.icon,
secondaryIcon: urlPrefix + current.secondaryIcon,
category: current.plug.plugCategoryHash,
isOwned: true,
perkName: '',
perkDescription: '',
perkIcon: '',
perks: current.perks.map((p: any) => p.perkHash),
});
}
} else if (
Expand All @@ -230,6 +228,7 @@ export async function updateManifest() {
await db.manifestIntrinsicModDef.add({
itemHash: Number(itemHash),
name: current.displayProperties.name,
description: current.displayProperties.description,
icon: urlPrefix + current.displayProperties.icon,
perks: current.perks.map((p: any) => p.perkHash),
});
Expand Down
6 changes: 3 additions & 3 deletions src/store/LoadoutReducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import {
EMPTY_ASPECT,
EMPTY_FRAGMENT,
EMPTY_MANIFEST_PLUG,
EMPTY_SUBCLASS_MOD,
EMPTY_SOCKETS,
} from '../lib/bungie_api/constants';
import { ManifestArmorMod, ManifestArmorStatMod } from '../types/manifest-types';
Expand Down Expand Up @@ -134,7 +134,7 @@ const initialState: InitialState = {
icon: '',
},
damageType: 1,
super: EMPTY_MANIFEST_PLUG,
super: EMPTY_SUBCLASS_MOD,
aspects: [EMPTY_ASPECT, EMPTY_ASPECT],
fragments: [EMPTY_FRAGMENT, EMPTY_FRAGMENT, EMPTY_FRAGMENT, EMPTY_FRAGMENT, EMPTY_FRAGMENT],
classAbility: null,
Expand Down Expand Up @@ -213,7 +213,7 @@ export const loadoutConfigSlice = createSlice({

switch (category) {
case 'SUPERS':
state.loadout.subclassConfig.super = mods[0] || EMPTY_MANIFEST_PLUG;
state.loadout.subclassConfig.super = mods[0] || EMPTY_SUBCLASS_MOD;
break;
case 'ASPECTS':
mods.forEach((mod, index) => {
Expand Down
28 changes: 13 additions & 15 deletions src/store/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import {
ManifestArmorStatMod,
ManifestAspect,
ManifestStatPlug,
ManifestSandboxPerk,
ManifestIntrinsicMod,
ManifestEntry,
} from '../types/manifest-types';

const db = new Dexie('manifestDb') as Dexie & {
manifestSandboxPerkDef: EntityTable<ManifestSandboxPerk, 'itemHash'>;
manifestSandboxPerkDef: EntityTable<ManifestEntry, 'itemHash'>;
manifestArmorDef: EntityTable<ManifestArmor, 'itemHash'>;
manifestExoticArmorCollection: EntityTable<ManifestExoticArmor, 'itemHash'>;
manifestEmblemDef: EntityTable<ManifestEmblem, 'itemHash'>;
manifestArmorModDef: EntityTable<ManifestArmorMod, 'itemHash'>;
manifestIntrinsicModDef: EntityTable<ManifestIntrinsicMod, 'itemHash'>;
manifestIntrinsicModDef: EntityTable<ManifestEntry, 'itemHash'>;
manifestArmorStatModDef: EntityTable<ManifestArmorStatMod, 'itemHash'>;
manifestSubclassModDef: EntityTable<ManifestPlug, 'itemHash'>;
manifestSubclassAspectsDef: EntityTable<ManifestAspect, 'itemHash'>;
Expand All @@ -29,22 +28,21 @@ const db = new Dexie('manifestDb') as Dexie & {
};

db.version(1).stores({
manifestSandboxPerkDef: 'itemHash, name, icon, description',
manifestSandboxPerkDef: 'itemHash, name, description, icon',
manifestArmorDef: 'itemHash, name, icon, isExotic, class, slot',
manifestExoticArmorCollection: 'itemHash, name, icon, class, slot, isOwned, collectibleHash',
manifestEmblemDef: 'itemHash, name, icon, secondaryOverlay, secondarySpecial',
manifestArmorModDef:
'itemHash, name, icon, category, perkName, perkDescription, perkIcon, isOwned, unique, collectibleHash',
manifestIntrinsicModDef: 'itemHash, name, icon, perks',
manifestEmblemDef: 'itemHash, name, icon, secondaryIcon, secondaryOverlay, secondarySpecial',
manifestArmorModDef: 'itemHash, name, icon, category, perks, isOwned, unique, collectibleHash',
manifestIntrinsicModDef: 'itemHash, name, description, icon, perks',
manifestArmorStatModDef:
'itemHash, name, icon, category, perkName, perkDescription, perkIcon, isOwned, collectibleHash, mobilityMod, resilienceMod, recoveryMod, disciplineMod, intellectMod, strengthMod',
manifestSubclassModDef:
'itemHash, name, icon, category, perkName, perkDescription, perkIcon, isOwned',
'itemHash, name, icon, category, perks, isOwned, collectibleHash, mobilityMod, resilienceMod, recoveryMod, disciplineMod, intellectMod, strengthMod',
manifestSubclassModDef: 'itemHash, name, description, icon, secondaryIcon, category, isOwned',
manifestSubclassAspectsDef:
'itemHash, name, icon, category, perkName, perkDescription, perkIcon, isOwned, energyCapacity',
'itemHash, name, icon, secondaryIcon, flavorText, category, perks, isOwned, energyCapacity',
manifestSubclassFragmentsDef:
'itemHash, name, icon, category, perkName, perkDescription, perkIcon, isOwned, mobilityMod, resilienceMod, recoveryMod, disciplineMod, intellectMod, strengthMod',
manifestSubclass: 'itemHash, name, icon, highResIcon, screenshot, damageType, class, isOwned',
'itemHash, name, icon, secondaryIcon, category, perks, isOwned, mobilityMod, resilienceMod, recoveryMod, disciplineMod, intellectMod, strengthMod',
manifestSubclass:
'itemHash, name, icon, secondaryIcon, screenshot, flavorText, damageType, class, isOwned',
});

export { db };
20 changes: 6 additions & 14 deletions src/types/manifest-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ export interface ManifestEntry {
itemHash: number;
name: string;
icon: string;
}

export interface ManifestSandboxPerk extends ManifestEntry {
description: string;
}

export interface ManifestIntrinsicMod extends ManifestEntry {
perks: number[];
secondaryIcon?: string;
description?: string;
flavorText?: string;
perks?: number[];
}

export interface ManifestArmor extends ManifestEntry {
Expand All @@ -21,10 +17,10 @@ export interface ManifestArmor extends ManifestEntry {
}

export interface ManifestExoticArmor extends ManifestEntry {
collectibleHash: number;
isOwned: boolean;
class: CharacterClass;
slot: string;
collectibleHash: number;
}

export interface ManifestSubclass extends ManifestEntry {
Expand All @@ -35,10 +31,6 @@ export interface ManifestSubclass extends ManifestEntry {
}

export interface ManifestPlug extends ManifestEntry {
perkName: string;
perkDescription: string;
perkIcon: string;
secondaryIcon?: string;
category: number;
isOwned: boolean;
}
Expand All @@ -53,7 +45,7 @@ export interface ManifestStatPlug extends ManifestPlug {
}

export interface ManifestAspect extends ManifestPlug {
energyCapacity?: number;
energyCapacity: number;
}

export interface ManifestArmorMod extends ManifestPlug {
Expand Down

0 comments on commit abaa386

Please sign in to comment.