diff --git a/src/controllers/api/missionInventoryUpdateController.ts b/src/controllers/api/missionInventoryUpdateController.ts index 52e68106..377072a6 100644 --- a/src/controllers/api/missionInventoryUpdateController.ts +++ b/src/controllers/api/missionInventoryUpdateController.ts @@ -11,7 +11,7 @@ import fs from 'fs'; - [x] Melee - [x] RawUpgrades - [x] MiscItems -- [ ] RegularCredits +- [x] RegularCredits - [ ] RandomUpgradesIdentified - [ ] MissionFailed - [ ] MissionStatus @@ -23,7 +23,7 @@ import fs from 'fs'; - [ ] LastRegionPlayed - [ ] GameModeId - [ ] hosts -- [ ] ChallengeProgress +- [+] ChallengeProgress - [ ] SeasonChallengeHistory - [ ] PS - [ ] ActiveDojoColorResearch diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index c9f2520b..5becaf85 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -5,8 +5,7 @@ import { Types } from "mongoose"; import { ISuitDatabase, ISuitResponse } from "@/src/types/inventoryTypes/SuitTypes"; import { SlotType } from "@/src/types/purchaseTypes"; import { IWeaponDatabase, IWeaponResponse } from "@/src/types/inventoryTypes/weaponTypes"; -import { FlavourItem, RawUpgrade, MiscItem, IInventoryDatabase } from "@/src/types/inventoryTypes/inventoryTypes"; -import { items } from "@/static/data/items"; +import { FlavourItem, RawUpgrade, MiscItem } from "@/src/types/inventoryTypes/inventoryTypes"; const createInventory = async (accountOwnerId: Types.ObjectId) => { try { @@ -107,12 +106,12 @@ export const addCustomization = async (customizatonName: string, accountId: stri return changedInventory.FlavourItems[flavourItemIndex].toJSON(); //mongoose bug forces as FlavourItem }; -export const missionInventoryUpdate = async (data: any, accountId: string): Promise => { - const { RawUpgrades, MiscItems, Suits, Pistols, LongGuns, Melee } = data; +export const missionInventoryUpdate = async (data: any, accountId: string): Promise => { // TODO - add data type + const { RawUpgrades, MiscItems, Suits, Pistols, LongGuns, Melee, RegularCredits } = data; const inventory = await getInventory(accountId); const addGearExpByCategory = (gearArray: (ISuitDatabase|IWeaponDatabase)[], category: 'Pistols'|'LongGuns'|'Melee'|'Suits') => { - gearArray.forEach(({ ItemId, XP }: any) => { + gearArray?.forEach(({ ItemId, XP }: any) => { const itemIndex = inventory[category].findIndex(i => i._id?.equals(ItemId.$oid)); if (itemIndex !== -1) { inventory[category][itemIndex].XP += XP; @@ -134,7 +133,8 @@ export const missionInventoryUpdate = async (data: any, accountId: string): Prom } }); }; - + + inventory.RegularCredits += RegularCredits||0; addGearExpByCategory(Pistols, 'Pistols'); addGearExpByCategory(LongGuns, 'LongGuns'); addGearExpByCategory(Melee, 'Melee');