missionInventoryUpdate - private functions outside
This commit is contained in:
parent
f054db1327
commit
a1c2815728
@ -5,7 +5,7 @@ import { Types } from "mongoose";
|
||||
import { ISuitResponse } from "@/src/types/inventoryTypes/SuitTypes";
|
||||
import { SlotType } from "@/src/types/purchaseTypes";
|
||||
import { IWeaponResponse } from "@/src/types/inventoryTypes/weaponTypes";
|
||||
import { FlavourItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { FlavourItem, IInventoryDatabaseDocument } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import {
|
||||
MissionInventoryUpdate,
|
||||
MissionInventoryUpdateCard,
|
||||
@ -112,16 +112,11 @@ export const addCustomization = async (customizatonName: string, accountId: stri
|
||||
return changedInventory.FlavourItems[flavourItemIndex].toJSON(); //mongoose bug forces as FlavourItem
|
||||
};
|
||||
|
||||
export const missionInventoryUpdate = async (data: MissionInventoryUpdate, accountId: string): Promise<void> => {
|
||||
const { RawUpgrades, MiscItems, Suits, Pistols, LongGuns, Melee, RegularCredits } = data;
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
// TODO - multipliers logic
|
||||
|
||||
const addGearExpByCategory = (
|
||||
const addGearExpByCategory = (
|
||||
inventory: IInventoryDatabaseDocument,
|
||||
gearArray: MissionInventoryUpdateGear[] | undefined,
|
||||
categoryName: "Pistols" | "LongGuns" | "Melee" | "Suits"
|
||||
) => {
|
||||
) => {
|
||||
const category = inventory[categoryName];
|
||||
|
||||
gearArray?.forEach(({ ItemId, XP }) => {
|
||||
@ -133,12 +128,13 @@ export const missionInventoryUpdate = async (data: MissionInventoryUpdate, accou
|
||||
inventory.markModified(`${categoryName}.${itemIndex}.XP`);
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const addItemsByCategory = (
|
||||
const addItemsByCategory = (
|
||||
inventory: IInventoryDatabaseDocument,
|
||||
itemsArray: (MissionInventoryUpdateItem | MissionInventoryUpdateCard)[] | undefined,
|
||||
categoryName: "RawUpgrades" | "MiscItems"
|
||||
) => {
|
||||
) => {
|
||||
const category = inventory[categoryName];
|
||||
|
||||
itemsArray?.forEach(({ ItemCount, ItemType }) => {
|
||||
@ -151,15 +147,21 @@ export const missionInventoryUpdate = async (data: MissionInventoryUpdate, accou
|
||||
category.push({ ItemCount, ItemType });
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const missionInventoryUpdate = async (data: MissionInventoryUpdate, accountId: string): Promise<void> => {
|
||||
const { RawUpgrades, MiscItems, Suits, Pistols, LongGuns, Melee, RegularCredits } = data;
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
// TODO - multipliers logic
|
||||
|
||||
inventory.RegularCredits += RegularCredits || 0;
|
||||
addGearExpByCategory(Pistols, "Pistols");
|
||||
addGearExpByCategory(LongGuns, "LongGuns");
|
||||
addGearExpByCategory(Melee, "Melee");
|
||||
addGearExpByCategory(Suits, "Suits");
|
||||
addItemsByCategory(RawUpgrades, "RawUpgrades"); // TODO - check mods fusion level
|
||||
addItemsByCategory(MiscItems, "MiscItems");
|
||||
addGearExpByCategory(inventory, Pistols, "Pistols");
|
||||
addGearExpByCategory(inventory, LongGuns, "LongGuns");
|
||||
addGearExpByCategory(inventory, Melee, "Melee");
|
||||
addGearExpByCategory(inventory, Suits, "Suits");
|
||||
addItemsByCategory(inventory, RawUpgrades, "RawUpgrades"); // TODO - check mods fusion level
|
||||
addItemsByCategory(inventory, MiscItems, "MiscItems");
|
||||
|
||||
// TODO - save ChallengeProgress (idk where to save)
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { Oid } from "@/src/types/commonTypes";
|
||||
import { AbilityOverride, Color, Polarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||
import { Document } from "mongoose";
|
||||
import { Document, Types } from "mongoose";
|
||||
|
||||
export interface ISuitDocument extends ISuitResponse, Document {}
|
||||
// export interface ISuitDocument extends ISuitResponse, Document {}
|
||||
export interface ISuitDocument extends Document, ISuitResponse {
|
||||
_id: Types.ObjectId;
|
||||
}
|
||||
|
||||
export interface ISuitResponse extends ISuitDatabase {
|
||||
ItemId: Oid;
|
||||
@ -20,6 +23,7 @@ export interface ISuitDatabase {
|
||||
ModSlotPurchases?: number;
|
||||
FocusLens?: string;
|
||||
UnlockLevel?: number;
|
||||
_id: Types.ObjectId;
|
||||
}
|
||||
|
||||
export interface SuitConfig {
|
||||
|
@ -929,7 +929,7 @@ export interface Progress {
|
||||
|
||||
export interface RawUpgrade {
|
||||
ItemCount: number;
|
||||
LastAdded: Oid;
|
||||
LastAdded?: Oid;
|
||||
ItemType: string;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Oid } from "@/src/types/commonTypes";
|
||||
import { Color, Polarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||
import { Types } from "mongoose";
|
||||
|
||||
export interface IWeaponResponse extends IWeaponDatabase {
|
||||
ItemId: Oid;
|
||||
@ -20,6 +21,7 @@ export interface IWeaponDatabase {
|
||||
ItemName?: string;
|
||||
ModularParts?: string[];
|
||||
UnlockLevel?: number;
|
||||
_id?: Types.ObjectId;
|
||||
}
|
||||
|
||||
export interface WeaponConfig {
|
||||
|
Loading…
x
Reference in New Issue
Block a user