From d7dbf393bf5d788a7407b49e31b5782ebb0a6c18 Mon Sep 17 00:00:00 2001 From: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Date: Sat, 1 Feb 2025 15:06:11 +0100 Subject: [PATCH] rebase fix --- src/models/inventoryModels/inventoryModel.ts | 2 +- src/services/inventoryService.ts | 150 ------------------- 2 files changed, 1 insertion(+), 151 deletions(-) diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index c75b9387..52db89c0 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -60,7 +60,7 @@ import { ITraits, IKubrowPetDetailsClient, IKubrowPetEggDatabase, - IKubrowPetEggClient + IKubrowPetEggClient, ICustomMarkers, IMarkerInfo, IMarker diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 4b070fc0..30c1acd4 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1057,32 +1057,6 @@ export const updateSyndicate = ( syndicateUpdate: IMissionInventoryUpdateRequest["AffiliationChanges"] ): void => { syndicateUpdate?.forEach(affiliation => { -export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => { - const { - RawUpgrades, - MiscItems, - RegularCredits, - ChallengeProgress, - FusionPoints, - Consumables, - Recipes, - Missions, - FusionTreasures, - AffiliationChanges, - EvolutionProgress, - LastRegionPlayed, - CustomMarkers - } = data; - const inventory = await getInventory(accountId); - - // credits - inventory.RegularCredits += RegularCredits || 0; - - // endo - inventory.FusionPoints += FusionPoints || 0; - - // syndicate - AffiliationChanges?.forEach(affiliation => { const syndicate = inventory.Affiliations.find(x => x.Tag == affiliation.Tag); if (syndicate !== undefined) { syndicate.Standing += affiliation.Standing; @@ -1126,128 +1100,4 @@ export const addKeyChainItems = async ( await addItems(inventory, nonStoreItems); return inventoryChanges; - - // Gear XP - equipmentKeys.forEach(key => addGearExpByCategory(inventory, data[key], key)); - - // Incarnon Challenges - if (EvolutionProgress) { - for (const evoProgress of EvolutionProgress) { - const entry = inventory.EvolutionProgress - ? inventory.EvolutionProgress.find(entry => entry.ItemType == evoProgress.ItemType) - : undefined; - if (entry) { - entry.Progress = evoProgress.Progress; - entry.Rank = evoProgress.Rank; - } else { - inventory.EvolutionProgress ??= []; - inventory.EvolutionProgress.push(evoProgress); - } - } - } - - // LastRegionPlayed - if (LastRegionPlayed) { - inventory.LastRegionPlayed = LastRegionPlayed; - } - - if (CustomMarkers) { - CustomMarkers.forEach(markers => { - const map = inventory.CustomMarkers - ? inventory.CustomMarkers.find(entry => entry.tag == markers.tag) - : undefined; - if (map) { - map.markerInfos = markers.markerInfos; - inventory.markModified("CustomMarkers"); - } else { - inventory.CustomMarkers ??= []; - inventory.CustomMarkers.push(markers); - inventory.markModified("CustomMarkers"); - } - }); - } - - // other - addMods(inventory, RawUpgrades); - addMiscItems(inventory, MiscItems); - addConsumables(inventory, Consumables); - addRecipes(inventory, Recipes); - addChallenges(inventory, ChallengeProgress); - addFusionTreasures(inventory, FusionTreasures); - if (Missions) { - addMissionComplete(inventory, Missions); - } - - const changedInventory = await inventory.save(); - return changedInventory.toJSON(); -}; - -export const addBooster = async (ItemType: string, time: number, accountId: string): Promise => { - const currentTime = Math.floor(Date.now() / 1000) - 129600; // Value is wrong without 129600. Figure out why, please. :) - - const inventory = await getInventory(accountId); - const { Boosters } = inventory; - - const itemIndex = Boosters.findIndex(booster => booster.ItemType === ItemType); - - if (itemIndex !== -1) { - const existingBooster = Boosters[itemIndex]; - existingBooster.ExpiryDate = Math.max(existingBooster.ExpiryDate, currentTime) + time; - inventory.markModified(`Boosters.${itemIndex}.ExpiryDate`); - } else { - Boosters.push({ ItemType, ExpiryDate: currentTime + time }) - 1; - } - - await inventory.save(); -}; - -export const upgradeMod = async (artifactsData: IArtifactsRequest, accountId: string): Promise => { - const { Upgrade, LevelDiff, Cost, FusionPointCost } = artifactsData; - try { - const inventory = await getInventory(accountId); - const { Upgrades, RawUpgrades } = inventory; - const { ItemType, UpgradeFingerprint, ItemId } = Upgrade; - - const safeUpgradeFingerprint = UpgradeFingerprint || '{"lvl":0}'; - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const parsedUpgradeFingerprint = JSON.parse(safeUpgradeFingerprint); - parsedUpgradeFingerprint.lvl += LevelDiff; - const stringifiedUpgradeFingerprint = JSON.stringify(parsedUpgradeFingerprint); - - let itemIndex = Upgrades.findIndex(upgrade => upgrade._id?.equals(ItemId!.$oid)); - - if (itemIndex !== -1) { - Upgrades[itemIndex].UpgradeFingerprint = stringifiedUpgradeFingerprint; - inventory.markModified(`Upgrades.${itemIndex}.UpgradeFingerprint`); - } else { - itemIndex = - Upgrades.push({ - UpgradeFingerprint: stringifiedUpgradeFingerprint, - ItemType - }) - 1; - - const rawItemIndex = RawUpgrades.findIndex(rawUpgrade => rawUpgrade.ItemType === ItemType); - RawUpgrades[rawItemIndex].ItemCount--; - if (RawUpgrades[rawItemIndex].ItemCount > 0) { - inventory.markModified(`RawUpgrades.${rawItemIndex}.UpgradeFingerprint`); - } else { - RawUpgrades.splice(rawItemIndex, 1); - } - } - - inventory.RegularCredits -= Cost; - inventory.FusionPoints -= FusionPointCost; - - const changedInventory = await inventory.save(); - const itemId = changedInventory.toJSON().Upgrades[itemIndex]?.ItemId?.$oid; - - if (!itemId) { - throw new Error("Item Id not found in upgradeMod"); - } - - return itemId; - } catch (error) { - console.error("Error in upgradeMod:", error); - throw error; - } };