From ff735173880fe4fc5838887599d93e83b0ba6ec9 Mon Sep 17 00:00:00 2001 From: dragoni7 Date: Wed, 4 Sep 2024 15:16:45 -0700 Subject: [PATCH] Reduced manifest types. Added required manifest information to db --- src/features/profile/destiny-profile.ts | 4 ++-- src/lib/bungie_api/constants.ts | 19 ++++++++-------- src/lib/bungie_api/manifest.ts | 29 ++++++++++++------------- src/store/LoadoutReducer.tsx | 6 ++--- src/store/db.ts | 28 +++++++++++------------- src/types/manifest-types.ts | 20 +++++------------ 6 files changed, 47 insertions(+), 59 deletions(-) diff --git a/src/features/profile/destiny-profile.ts b/src/features/profile/destiny-profile.ts index 3926d4b..7031e71 100644 --- a/src/features/profile/destiny-profile.ts +++ b/src/features/profile/destiny-profile.ts @@ -5,7 +5,7 @@ import { DAMAGE_TYPE, EMPTY_ASPECT, EMPTY_FRAGMENT, - EMPTY_MANIFEST_PLUG, + EMPTY_SUBCLASS_MOD, PRIMARY_STATS, SOCKET_HASH, STAT_HASH, @@ -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, diff --git a/src/lib/bungie_api/constants.ts b/src/lib/bungie_api/constants.ts index 5614497..54e60cc 100644 --- a/src/lib/bungie_api/constants.ts +++ b/src/lib/bungie_api/constants.ts @@ -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 = { @@ -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]; diff --git a/src/lib/bungie_api/manifest.ts b/src/lib/bungie_api/manifest.ts index 140f433..25285c7 100644 --- a/src/lib/bungie_api/manifest.ts +++ b/src/lib/bungie_api/manifest.ts @@ -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, }); } @@ -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), @@ -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( @@ -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 === @@ -164,11 +163,11 @@ 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')) { @@ -176,11 +175,10 @@ export async function updateManifest() { 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( @@ -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 ( @@ -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), }); diff --git a/src/store/LoadoutReducer.tsx b/src/store/LoadoutReducer.tsx index f60dbeb..a99cab7 100644 --- a/src/store/LoadoutReducer.tsx +++ b/src/store/LoadoutReducer.tsx @@ -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'; @@ -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, @@ -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) => { diff --git a/src/store/db.ts b/src/store/db.ts index b850ead..2d9acbb 100644 --- a/src/store/db.ts +++ b/src/store/db.ts @@ -10,17 +10,16 @@ import { ManifestArmorStatMod, ManifestAspect, ManifestStatPlug, - ManifestSandboxPerk, - ManifestIntrinsicMod, + ManifestEntry, } from '../types/manifest-types'; const db = new Dexie('manifestDb') as Dexie & { - manifestSandboxPerkDef: EntityTable; + manifestSandboxPerkDef: EntityTable; manifestArmorDef: EntityTable; manifestExoticArmorCollection: EntityTable; manifestEmblemDef: EntityTable; manifestArmorModDef: EntityTable; - manifestIntrinsicModDef: EntityTable; + manifestIntrinsicModDef: EntityTable; manifestArmorStatModDef: EntityTable; manifestSubclassModDef: EntityTable; manifestSubclassAspectsDef: EntityTable; @@ -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 }; diff --git a/src/types/manifest-types.ts b/src/types/manifest-types.ts index bd2d8ca..2129993 100644 --- a/src/types/manifest-types.ts +++ b/src/types/manifest-types.ts @@ -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 { @@ -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 { @@ -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; } @@ -53,7 +45,7 @@ export interface ManifestStatPlug extends ManifestPlug { } export interface ManifestAspect extends ManifestPlug { - energyCapacity?: number; + energyCapacity: number; } export interface ManifestArmorMod extends ManifestPlug {