diff --git a/src/app/routes/Dashboard.tsx b/src/app/routes/Dashboard.tsx index 8d19e14..75b55f1 100644 --- a/src/app/routes/Dashboard.tsx +++ b/src/app/routes/Dashboard.tsx @@ -9,13 +9,7 @@ import { updateProfileData } from '../../store/ProfileReducer'; import { useDispatch, useSelector } from 'react-redux'; import { generatePermutations } from '../../features/armor-optimization/generate-permutations'; import { filterPermutations } from '../../features/armor-optimization/filter-permutations'; -import { - DestinyArmor, - Character, - FilteredPermutation, - DamageType, - SubclassConfig, -} from '../../types/d2l-types'; +import { DestinyArmor, Character, FilteredPermutation } from '../../types/d2l-types'; import StatsTable from '../../features/armor-optimization/StatsTable'; import { RootState } from '../../store'; import HeaderComponent from '../../components/HeaderComponent'; @@ -26,7 +20,7 @@ import ArmorCustomization from '../../features/armor/components/ArmorCustomizati import { resetLoadout, updateLoadoutCharacter, updateSubclass } from '../../store/LoadoutReducer'; import { ManifestSubclass } from '../../types/manifest-types'; import SubclassCustomizationWrapper from '../../features/subclass/SubclassCustomizationWrapper'; -import { updateManifest } from '../../lib/bungie_api/Manifest'; +import { updateManifest } from '../../lib/bungie_api/manifest'; const PageContainer = styled('div')({ display: 'flex', diff --git a/src/components/ArmorIcon.tsx b/src/components/ArmorIcon.tsx index 93d0209..7ea0359 100644 --- a/src/components/ArmorIcon.tsx +++ b/src/components/ArmorIcon.tsx @@ -1,4 +1,4 @@ -import { Box, styled } from '@mui/system'; +import { styled } from '@mui/system'; import { DestinyArmor } from '../types/d2l-types'; const MasterworkedIconContainer = styled('img')({ diff --git a/src/features/armor/components/ArmorModSelector.tsx b/src/features/armor/components/ArmorModSelector.tsx index b1ca77d..144972d 100644 --- a/src/features/armor/components/ArmorModSelector.tsx +++ b/src/features/armor/components/ArmorModSelector.tsx @@ -7,6 +7,9 @@ interface ModSelectorProps { onSelectMod: (mod: ManifestArmorMod | ManifestArmorStatMod) => void; } +const lockedModIcon = + 'https://www.bungie.net/common/destiny2_content/icons/1426b518acd10943c31171c99222e6fd.png'; + const ArmorModSelector: React.FC = ({ selected, mods, onSelectMod }) => { return ( = ({ selected, mods, onSelect
{ - if (selected.itemHash !== mod.itemHash) { + if (selected.itemHash !== mod.itemHash && mod.isOwned) { onSelectMod(mod); } }} diff --git a/src/features/profile/destiny-profile.ts b/src/features/profile/destiny-profile.ts index 75b048d..95184e0 100644 --- a/src/features/profile/destiny-profile.ts +++ b/src/features/profile/destiny-profile.ts @@ -7,17 +7,14 @@ import { PRIMARY_STATS, SOCKET_HASH, STAT_HASH, - SUBCLASS_PLUG_SETS, } from '../../lib/bungie_api/constants'; import { getProfileDataRequest } from '../../lib/bungie_api/requests'; import { db } from '../../store/db'; import { Character, CharacterClass, - DamageType, DestinyArmor, Emblem, - Plug, ProfileData, Subclass, } from '../../types/d2l-types'; @@ -36,7 +33,6 @@ export async function getProfileData(): Promise { const characterInventories = response.data.Response.characterInventories.data; const characterEquipment = response.data.Response.characterEquipment.data; const characterData = response.data.Response.characters.data; - const profilePlugSets = response.data.Response.profilePlugSets.data.plugs; const profileCollectibles = response.data.Response.profileCollectibles.data.collectibles; for (const key in characterData) { @@ -313,16 +309,6 @@ export async function getProfileData(): Promise { } } - // check character plugs for stasis grenade state - if (plugSets[SUBCLASS_PLUG_SETS.GRENADES.STASIS]) { - for (const plug of plugSets[SUBCLASS_PLUG_SETS.GRENADES.STASIS]) { - await db.manifestSubclassModDef - .where('itemHash') - .equals(plug.plugItemHash) - .modify({ isOwned: true }); - } - } - profile.characters.push(character); } @@ -405,95 +391,6 @@ export async function getProfileData(): Promise { } } - // iterate profile plugs - let abilityPlugSets: number[] = [ - SUBCLASS_PLUG_SETS.FRAGMENTS.ARC, - SUBCLASS_PLUG_SETS.FRAGMENTS.SOLAR, - SUBCLASS_PLUG_SETS.FRAGMENTS.VOID, - SUBCLASS_PLUG_SETS.FRAGMENTS.STASIS, - SUBCLASS_PLUG_SETS.FRAGMENTS.STRAND, - SUBCLASS_PLUG_SETS.FRAGMENTS.PRISMATIC, - - SUBCLASS_PLUG_SETS.GRENADES.ARC, - SUBCLASS_PLUG_SETS.GRENADES.SOLAR, - SUBCLASS_PLUG_SETS.GRENADES.VOID, - SUBCLASS_PLUG_SETS.GRENADES.STASIS, - SUBCLASS_PLUG_SETS.GRENADES.STRAND, - SUBCLASS_PLUG_SETS.GRENADES.PRISMATIC_HUNTER, - SUBCLASS_PLUG_SETS.GRENADES.PRISMATIC_WARLOCK, - - SUBCLASS_PLUG_SETS.ASPECTS.HUNTER.ARC, - SUBCLASS_PLUG_SETS.ASPECTS.HUNTER.VOID, - SUBCLASS_PLUG_SETS.ASPECTS.HUNTER.SOLAR, - SUBCLASS_PLUG_SETS.ASPECTS.HUNTER.PRISMATIC, - - SUBCLASS_PLUG_SETS.ASPECTS.TITAN.ARC, - SUBCLASS_PLUG_SETS.ASPECTS.TITAN.VOID, - SUBCLASS_PLUG_SETS.ASPECTS.TITAN.SOLAR, - - SUBCLASS_PLUG_SETS.ASPECTS.WARLOCK.ARC, - SUBCLASS_PLUG_SETS.ASPECTS.WARLOCK.VOID, - SUBCLASS_PLUG_SETS.ASPECTS.WARLOCK.SOLAR, - SUBCLASS_PLUG_SETS.ASPECTS.WARLOCK.STASIS, - SUBCLASS_PLUG_SETS.ASPECTS.WARLOCK.STRAND, - SUBCLASS_PLUG_SETS.ASPECTS.WARLOCK.PRISMATIC, - - SUBCLASS_PLUG_SETS.SUPERS.HUNTER.ARC, - SUBCLASS_PLUG_SETS.SUPERS.HUNTER.VOID, - SUBCLASS_PLUG_SETS.SUPERS.HUNTER.SOLAR, - SUBCLASS_PLUG_SETS.SUPERS.HUNTER.PRISMATIC, - - SUBCLASS_PLUG_SETS.SUPERS.TITAN.ARC, - SUBCLASS_PLUG_SETS.SUPERS.TITAN.VOID, - SUBCLASS_PLUG_SETS.SUPERS.TITAN.SOLAR, - - SUBCLASS_PLUG_SETS.SUPERS.WARLOCK.ARC, - SUBCLASS_PLUG_SETS.SUPERS.WARLOCK.VOID, - SUBCLASS_PLUG_SETS.SUPERS.WARLOCK.SOLAR, - SUBCLASS_PLUG_SETS.SUPERS.WARLOCK.STASIS, - SUBCLASS_PLUG_SETS.SUPERS.WARLOCK.STRAND, - SUBCLASS_PLUG_SETS.SUPERS.WARLOCK.PRISMATIC, - - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.HUNTER.ARC, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.HUNTER.VOID, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.HUNTER.SOLAR, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.HUNTER.PRISMATIC, - - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.TITAN.ARC, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.TITAN.VOID, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.TITAN.SOLAR, - - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.WARLOCK.ARC, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.WARLOCK.VOID, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.WARLOCK.SOLAR, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.WARLOCK.STASIS, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.WARLOCK.STRAND, - SUBCLASS_PLUG_SETS.MELEE_ABILITIES.WARLOCK.PRISMATIC, - ]; - - for (const key of abilityPlugSets) { - if (profilePlugSets[key]) { - for (const plug of profilePlugSets[key]) { - if (plug.enabled) { - await db.manifestSubclassModDef - .where('itemHash') - .equals(plug.plugItemHash) - .modify({ isOwned: true }); - - await db.manifestSubclassAspectsDef - .where('itemHash') - .equals(plug.plugItemHash) - .modify({ isOwned: true }); - - await db.manifestSubclassFragmentsDef - .where('itemHash') - .equals(plug.plugItemHash) - .modify({ isOwned: true }); - } - } - } - } - // iterate profile collectibles for (const collectible in profileCollectibles) { const exoticCollectable = await db.manifestExoticArmorCollection @@ -501,29 +398,34 @@ export async function getProfileData(): Promise { .equals(Number(collectible)) .first(); - if ( - exoticCollectable && - COLLECTIBLE_OWNED.includes(Number(profileCollectibles[collectible].state)) - ) { - await db.manifestExoticArmorCollection - .where('collectibleHash') - .equals(Number(collectible)) - .modify({ isOwned: true }); - } - const armorModDef = await db.manifestArmorModDef .where('collectibleHash') .equals(Number(collectible)) .first(); - if ( - armorModDef && - COLLECTIBLE_OWNED.includes(Number(profileCollectibles[collectible].state)) - ) { - await db.manifestArmorModDef - .where('collectibleHash') - .equals(Number(collectible)) - .modify({ isOwned: true }); + const armorStatModDef = await db.manifestArmorStatModDef + .where('collectibleHash') + .equals(Number(collectible)) + .first(); + + if (exoticCollectable) { + if (COLLECTIBLE_OWNED.includes(Number(profileCollectibles[collectible].state))) + await db.manifestExoticArmorCollection + .where('collectibleHash') + .equals(Number(collectible)) + .modify({ isOwned: true }); + } else if (armorModDef) { + if (!COLLECTIBLE_OWNED.includes(Number(profileCollectibles[collectible].state))) + await db.manifestArmorModDef + .where('collectibleHash') + .equals(Number(collectible)) + .modify({ isOwned: false }); + } else if (armorStatModDef) { + if (!COLLECTIBLE_OWNED.includes(Number(profileCollectibles[collectible].state))) + await db.manifestArmorStatModDef + .where('collectibleHash') + .equals(Number(collectible)) + .modify({ isOwned: false }); } } diff --git a/src/lib/bungie_api/constants.ts b/src/lib/bungie_api/constants.ts index d5ebda0..e577816 100644 --- a/src/lib/bungie_api/constants.ts +++ b/src/lib/bungie_api/constants.ts @@ -452,309 +452,7 @@ export enum SOCKET_HASH { UNLOCKED_ARTIFICE_ARMOR = 720825311, } -export enum PLUG_SET { - LEG_PLUGS = 541478408, - CLASS_ITEM_PLUGS = 963686427, - HELMET_PLUGS = 2037229815, - CHEST_PLUGS = 2321486318, - ARM_PLUGS = 3899745242, -} - -export module SUBCLASS_PLUG_SETS { - export module SUPERS { - export enum TITAN { - ARC = 1129, - SOLAR = 1100, - VOID = 1087, - } - - export enum HUNTER { - PRISMATIC = 1358, - ARC = 1124, - SOLAR = 1095, - VOID = 1082, - } - - export enum WARLOCK { - PRISMATIC = 1368, - SOLAR = 1104, - VOID = 1091, - ARC = 1133, - STASIS = 1368, - STRAND = 1196, - } - } - - export module MELEE_ABILITIES { - export enum TITAN { - ARC = 1130, - SOLAR = 1101, - VOID = 1088, - } - - export enum HUNTER { - PRISMATIC = 1359, - ARC = 1125, - SOLAR = 1096, - VOID = 1083, - } - - export enum WARLOCK { - PRISMATIC = 1369, - ARC = 1134, - SOLAR = 1105, - VOID = 1092, - STASIS = 956, - STRAND = 1197, - } - } - - export module ASPECTS { - export enum TITAN { - SOLAR = 4030440911, - ARC = 3609966783, - VOID = 1369926501, - } - - export enum HUNTER { - ARC = 3432159481, - PRISMATIC = 2685327650, - VOID = 949441155, - SOLAR = 634290851, - } - - export enum WARLOCK { - SOLAR = 3562933678, - ARC = 3085216490, - PRISMATIC = 2676106717, - STASIS = 2491007355, - STRAND = 2260242405, - VOID = 2203811618, - } - } - - export enum GRENADES { - PRISMATIC_WARLOCK = 1370, - PRISMATIC_HUNTER = 1360, - STRAND = 1189, - ARC = 1126, - SOLAR = 1097, - VOID = 1084, - STASIS = 950, - } - - export enum FRAGMENTS { - PRISMATIC = 3916244727, - STASIS = 2878515719, - ARC = 2179662812, - SOLAR = 1319395210, - STRAND = 837761865, - VOID = 225543744, - } -} - export module PLUG_CATEGORY_HASH { - export module SUPERS { - export enum TITAN { - TITAN_ARC_SUPERS = 1861253111, - TITAN_STASIS_SUPERS = 635737914, - TITAN_PRISMATIC_SUPERS = 902963970, - TITAN_SOLAR_SUPERS = 2850085618, - TITAN_STRAND_SUPERS = 1080622901, - TITAN_VOID_SUPERS = 3468785159, - } - - export enum HUNTER { - HUNTER_SOLAR_SUPERS = 3151809860, - HUNTER_PRISMATIC_SUPERS = 180411040, - HUNTER_STRAND_SUPERS = 144959979, - HUNTER_STASIS_SUPERS = 818442312, - HUNTER_VOID_SUPERS = 2613010961, - HUNTER_ARC_SUPERS = 4145425829, - } - - export enum WARLOCK { - WARLOCK_ARC_SUPERS = 2285394316, - WARLOCK_VOID_SUPERS = 4141244538, - WARLOCK_PRISMATIC_SUPERS = 1684765285, - WARLOCK_STRAND_SUPERS = 1774026300, - WARLOCK_SOLAR_SUPERS = 2997411645, - WARLOCK_STASIS_SUPERS = 3379648287, - } - } - - export module CLASS_ABILITIES { - export enum ARC { - WARLOCK_ARC_CLASS = 1308084083, - HUNTER_ARC_CLASS = 3956119552, - TITAN_ARC_CLASS = 1281712906, - } - - export enum SOLAR { - WARLOCK_SOLAR_CLASS = 1662395848, - HUNTER_SOLAR_CLASS = 3538316507, - TITAN_SOLAR_CLASS = 1197336009, - } - - export enum VOID { - WARLOCK_VOID_CLASS = 3202031457, - HUNTER_VOID_CLASS = 3673640204, - TITAN_VOID_CLASS = 3366817658, - } - - export enum STASIS { - WARLOCK_STASIS_CLASS = 1960796738, - HUNTER_STASIS_CLASS = 641408223, - TITAN_STASIS_CLASS = 826897697, - } - - export enum STRAND { - WARLOCK_STRAND_CLASS = 2200902275, - HUNTER_STRAND_CLASS = 2552562702, - TITAN_STRAND_CLASS = 2480042224, - } - - export enum PRISMATIC { - WARLOCK_PRISMATIC_CLASS = 3339135424, - HUNTER_PRISMATIC_CLASS = 3324969927, - TITAN_PRISMATIC_CLASS = 3820930681, - } - } - - export module MELEE_ABILITIES { - export enum ARC { - TITAN_ARC_MELEE = 1458470025, - HUNTER_ARC_MELEE = 2434874031, - WARLOCK_ARC_MELEE = 1387605624, - } - - export enum SOLAR { - TITAN_SOLAR_MELEE = 605941486, - HUNTER_SOLAR_MELEE = 4225254304, - WARLOCK_SOLAR_MELEE = 2822977079, - } - - export enum VOID { - TITAN_VOID_MELEE = 4008726361, - HUNTER_VOID_MELEE = 1288993259, - WARLOCK_VOID_MELEE = 2900030790, - } - - export enum STASIS { - TITAN_STASIS_MELEE = 3693308166, - HUNTER_STASIS_MELEE = 3530064820, - WARLOCK_STASIS_MELEE = 4031311265, - } - - export enum STRAND { - TITAN_STRAND_MELEE = 3826855743, - HUNTER_STRAND_MELEE = 3873313773, - WARLOCK_STRAND_MELEE = 3904090216, - } - - export enum PRISMATIC { - TITAN_PRISMATIC_MELEE = 1422809918, - HUNTER_PRISMATIC_MELEE = 511532732, - WARLOCK_PRISMATIC_MELEE = 204703343, - } - } - - export module MOVEMENT_ABILITIES { - export enum ARC { - HUNTER_ARC_MOVEMENT = 2101241798, - TITAN_ARC_MOVEMENT = 2415307576, - WARLOCK_ARC_MOVEMENT = 1943502171, - } - - export enum SOLAR { - HUNTER_SOLAR_MOVEMENT = 3752921107, - TITAN_SOLAR_MOVEMENT = 379285521, - WARLOCK_SOLAR_MOVEMENT = 1763298974, - } - - export enum VOID { - HUNTER_VOID_MOVEMENT = 1796328914, - TITAN_VOID_MOVEMENT = 1924069544, - WARLOCK_VOID_MOVEMENT = 3427909241, - } - - export enum STASIS { - HUNTER_STASIS_MOVEMENT = 1929408791, - TITAN_STASIS_MOVEMENT = 3711066169, - WARLOCK_STASIS_MOVEMENT = 1191502208, - } - - export enum STRAND { - HUNTER_STRAND_MOVEMENT = 1979332108, - TITAN_STRAND_MOVEMENT = 2139679542, - WARLOCK_STRAND_MOVEMENT = 3728449707, - } - - export enum PRISMATIC { - HUNTER_PRISMATIC_MOVEMENT = 1681184239, - TITAN_PRISMATIC_MOVEMENT = 3777887553, - WARLOCK_PRISMATIC_MOVEMENT = 2883193222, - } - } - - export module ASPECTS { - export enum ARC { - HUNTER_ARC_ASPECTS = 185594100, - WARLOCK_ARC_ASPECTS = 2111409167, - TITAN_ARC_ASPECTS = 3460332466, - } - - export enum SOLAR { - HUNTER_SOLAR_ASPECTS = 3052104375, - WARLOCK_SOLAR_ASPECTS = 81856188, - TITAN_SOLAR_ASPECTS = 1970675705, - } - - export enum VOID { - HUNTER_VOID_ASPECTS = 2905530840, - WARLOCK_VOID_ASPECTS = 227647633, - TITAN_VOID_ASPECTS = 3990226434, - } - - export enum STASIS { - HUNTER_STASIS_ASPECTS = 1853189378, - WARLOCK_STASIS_ASPECTS = 2997725741, - TITAN_STASIS_ASPECTS = 1491608144, - } - - export enum STRAND { - HUNTER_STRAND_ASPECTS = 3805562622, - WARLOCK_STRAND_ASPECTS = 2557935615, - TITAN_STRAND_ASPECTS = 323641540, - } - - export enum PRISMATIC { - HUNTER_PRISMATIC_ASPECTS = 1164816619, - WARLOCK_PRISMATIC_ASPECTS = 769886388, - TITAN_PRISMATIC_ASPECTS = 912150793, - } - } - - export enum GRENADES { - TITAN_PRISMATIC_GRENADES = 3205146347, - HUNTER_PRISMATIC_GRENADES = 2789335173, - WARLOCK_PRISMATIC_GRENADES = 3287837048, - SHARED_ARC_GRENADES = 404070091, - SHARED_STASIS_GRENADES = 900498880, - SHARED_VOID_GRENADES = 3089520417, - SHARED_SOLAR_GRENADES = 3369359206, - SHARED_STRAND_GRENADES = 2831653331, - } - - export enum FRAGMENTS { - SHARED_PRISMATIC_FRAGMENTS = 2696330562, - SHARED_SOLAR_FRAGMENTS = 3119191718, - SHARED_STASIS_FRAGMENTS = 83940941, - SHARED_ARC_FRAGMENTS = 2430016289, - SHARED_VOID_FRAGMENTS = 39076551, - SHARED_STRAND_FRAGMENTS = 685964393, - } - export enum ARMOR_MODS { ARTIFICE_ARMOR_MODS = 3773173029, STAT_ARMOR_MODS = 2487827355, diff --git a/src/lib/bungie_api/manifest.ts b/src/lib/bungie_api/manifest.ts index 58542d7..74819ce 100644 --- a/src/lib/bungie_api/manifest.ts +++ b/src/lib/bungie_api/manifest.ts @@ -21,10 +21,13 @@ export async function updateManifest() { if (!currentVersion || currentVersion !== response.data.Response.version) { await db.manifestArmorDef.clear(); await db.manifestArmorModDef.clear(); + await db.manifestArmorStatModDef.clear(); await db.manifestEmblemDef.clear(); await db.manifestExoticArmorCollection.clear(); await db.manifestSubclass.clear(); await db.manifestSubclassModDef.clear(); + await db.manifestSubclassFragmentsDef.clear(); + await db.manifestSubclassAspectsDef.clear(); localStorage.setItem('manifestVersion', response.data.Response.version); const itemInventoryComponent = @@ -80,7 +83,9 @@ export async function updateManifest() { if ( current.itemSubType !== MANIFEST_TYPES.ORNAMENTS && current.itemCategoryHashes.includes(ITEM_CATEGORY_HASHES.ARMOR_MODS) && + current.displayProperties.name && current.displayProperties.name !== 'Locked Armor Mod' && + !current.displayProperties.description.includes('deprecated') && !current.itemTypeDisplayName.includes('Legacy') && !current.itemTypeDisplayName.includes('Deprecated') && !current.itemTypeDisplayName.includes('Artifact Mod') && @@ -98,7 +103,7 @@ export async function updateManifest() { icon: urlPrefix + current.displayProperties.icon, energyCost: current.plug.energyCost ? current.plug.energyCost.energyCost : 0, category: current.plug.plugCategoryHash, - isOwned: false, + isOwned: true, collectibleHash: -1, perkName: '', perkDescription: '', @@ -141,7 +146,7 @@ export async function updateManifest() { icon: urlPrefix + current.displayProperties.icon, energyCost: current.plug.energyCost ? current.plug.energyCost.energyCost : 0, category: current.plug.plugCategoryHash, - isOwned: false, + isOwned: true, collectibleHash: -1, perkName: '', perkDescription: '', @@ -155,7 +160,7 @@ export async function updateManifest() { name: current.displayProperties.name, icon: urlPrefix + current.displayProperties.icon, category: current.plug.plugCategoryHash, - isOwned: false, + isOwned: true, perkName: '', perkDescription: '', perkIcon: '', @@ -167,7 +172,7 @@ export async function updateManifest() { name: current.displayProperties.name, icon: urlPrefix + current.displayProperties.icon, category: current.plug.plugCategoryHash, - isOwned: false, + isOwned: true, perkName: '', perkDescription: '', perkIcon: '', @@ -208,7 +213,7 @@ export async function updateManifest() { name: current.displayProperties.name, icon: urlPrefix + current.displayProperties.icon, category: current.plug.plugCategoryHash, - isOwned: false, + isOwned: true, perkName: '', perkDescription: '', perkIcon: '', @@ -251,6 +256,11 @@ export async function updateManifest() { .where('itemHash') .equals(current.itemHash) .modify({ collectibleHash: current.hash }); + + await db.manifestArmorStatModDef + .where('itemHash') + .equals(current.itemHash) + .modify({ collectibleHash: current.hash }); } } }