diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index c6c95ca1..938c0d8a 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -381,6 +381,7 @@ DuviriInfoSchema.set("toJSON", { } }); +// eslint-disable-next-line @typescript-eslint/no-unused-vars const GenericItemSchema2 = new Schema({ ItemType: String, ItemName: String, @@ -703,7 +704,7 @@ const inventorySchema = new Schema( //Melee Weapon Melee: [WeaponSchema], //Ability Weapon like Ultimate Mech\Excalibur\Ivara etc - SpecialItems: [GenericItemSchema2], + SpecialItems: [GenericItemSchema], //The Mandachord(Octavia) is a step sequencer StepSequencers: [StepSequencersSchema], @@ -1006,6 +1007,7 @@ type InventoryDocumentProps = { MiscItems: Types.DocumentArray; Boosters: Types.DocumentArray; OperatorLoadOuts: Types.DocumentArray; + SpecialItems: Types.DocumentArray; AdultOperatorLoadOuts: Types.DocumentArray; //TODO: this should still contain _id MechSuits: Types.DocumentArray; Scoops: Types.DocumentArray; diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 6727a75e..357a2120 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -24,7 +24,7 @@ import { IUpdateChallengeProgressRequest } from "../types/requestTypes"; import { logger } from "@/src/utils/logger"; -import { WeaponTypeInternal } from "@/src/services/itemDataService"; +import { WeaponTypeInternal, getExalted } from "@/src/services/itemDataService"; import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes"; export const createInventory = async ( @@ -74,6 +74,12 @@ export const addSentinel = async (sentinelName: string, accountId: string) => { }; export const addPowerSuit = async (powersuitName: string, accountId: string): Promise => { + const specialItems = getExalted(powersuitName); + if (specialItems != false) { + for await (const specialItem of specialItems) { + await addSpecialItem(specialItem, accountId); + } + } const inventory = await getInventory(accountId); const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 }); const changedInventory = await inventory.save(); @@ -81,12 +87,31 @@ export const addPowerSuit = async (powersuitName: string, accountId: string): Pr }; export const addMechSuit = async (mechsuitName: string, accountId: string) => { + const specialItems = getExalted(mechsuitName); + if (specialItems != false) { + for await (const specialItem of specialItems) { + await addSpecialItem(specialItem, accountId); + } + } const inventory = await getInventory(accountId); const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 }); const changedInventory = await inventory.save(); return changedInventory.MechSuits[suitIndex - 1].toJSON(); }; +export const addSpecialItem = async (itemName: string, accountId: string) => { + const inventory = await getInventory(accountId); + const specialItemIndex = inventory.SpecialItems.push({ + ItemType: itemName, + Configs: [], + Features: 1, + UpgradeVer: 101, + XP: 0 + }); + const changedInventory = await inventory.save(); + return changedInventory.SpecialItems[specialItemIndex - 1].toJSON(); +}; + export const updateSlots = async (accountId: string, slotName: SlotNames, slotAmount: number, extraAmount: number) => { const inventory = await getInventory(accountId); diff --git a/src/services/itemDataService.ts b/src/services/itemDataService.ts index 9714c669..0b33302c 100644 --- a/src/services/itemDataService.ts +++ b/src/services/itemDataService.ts @@ -3,6 +3,7 @@ import { logger } from "@/src/utils/logger"; import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items"; import badItems from "@/static/json/exclude-mods.json"; import dict_en from "@/node_modules/warframe-public-export-plus/dict.en.json"; +import exportSuits from "@/node_modules/warframe-public-export-plus/ExportWarframes.json"; export type MinWarframe = Omit; export type MinWeapon = Omit; @@ -109,6 +110,15 @@ export const getItemByBlueprint = (uniqueName: string): (MinItem & Buildable) | return item; }; +export const getExalted = (uniqueName: string) => { + const suit = getSuitByUniqueName(uniqueName); + if (suit?.exalted !== undefined) { + return suit.exalted; + } else { + return false; + } +}; + export const getItemCategoryByUniqueName = (uniqueName: string) => { //Lotus/Types/Items/MiscItems/PolymerBundle @@ -126,6 +136,11 @@ export const getItemCategoryByUniqueName = (uniqueName: string) => { return category; }; +export const getSuitByUniqueName = (uniqueName: string) => { + const suit = exportSuits.find(suit => suit.uniqueName === uniqueName); + return suit; +}; + export const getItemByUniqueName = (uniqueName: string) => { const item = items.find(item => item.uniqueName === uniqueName); return item; diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index decec7c1..66f863ee 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -231,7 +231,7 @@ export interface IInventoryResponse { AlignmentReplay: IAlignment; PersonalGoalProgress: IPersonalGoalProgress[]; DailyAffiliationSolaris: number; - SpecialItems: IGenericItem2[]; + SpecialItems: IGenericItem[]; ThemeStyle: string; ThemeBackground: string; ThemeSounds: string;