From 04955c094e04239bb14d398b11b84be5d6023cb7 Mon Sep 17 00:00:00 2001 From: Sainan Date: Mon, 20 Jan 2025 08:20:06 +0100 Subject: [PATCH] separate InfestedFoundry client & database structs --- src/controllers/api/infestedFoundryController.ts | 4 ++-- src/controllers/api/upgradesController.ts | 4 ++-- src/models/inventoryModels/inventoryModel.ts | 4 ++-- src/types/inventoryTypes/inventoryTypes.ts | 12 ++++++++++-- src/types/purchaseTypes.ts | 6 +++--- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/controllers/api/infestedFoundryController.ts b/src/controllers/api/infestedFoundryController.ts index f7567b01..166cafc1 100644 --- a/src/controllers/api/infestedFoundryController.ts +++ b/src/controllers/api/infestedFoundryController.ts @@ -6,7 +6,7 @@ import { IOid } from "@/src/types/commonTypes"; import { IConsumedSuit, IHelminthFoodRecord, - IInfestedFoundry, + IInfestedFoundryDatabase, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes"; @@ -356,7 +356,7 @@ interface IHelminthFeedRequest { }[]; } -export const addInfestedFoundryXP = (infestedFoundry: IInfestedFoundry, delta: number): ITypeCount[] => { +export const addInfestedFoundryXP = (infestedFoundry: IInfestedFoundryDatabase, delta: number): ITypeCount[] => { const recipeChanges: ITypeCount[] = []; infestedFoundry.XP ??= 0; const prevXP = infestedFoundry.XP; diff --git a/src/controllers/api/upgradesController.ts b/src/controllers/api/upgradesController.ts index bbfd2992..d295a462 100644 --- a/src/controllers/api/upgradesController.ts +++ b/src/controllers/api/upgradesController.ts @@ -6,7 +6,7 @@ import { EquipmentFeatures, IAbilityOverride } from "@/src/types/inventoryTypes/commonInventoryTypes"; -import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes"; +import { IInventoryClient, IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { addMiscItems, addRecipes, getInventory, updateCurrency } from "@/src/services/inventoryService"; import { getRecipeByResult } from "@/src/services/itemDataService"; @@ -62,7 +62,7 @@ export const upgradesController: RequestHandler = async (req, res) => { addRecipes(inventory, recipeChanges); inventoryChanges.Recipes = recipeChanges; - inventoryChanges.InfestedFoundry = inventory.toJSON().InfestedFoundry; + inventoryChanges.InfestedFoundry = inventory.toJSON().InfestedFoundry; } else switch (operation.UpgradeRequirement) { case "/Lotus/Types/Items/MiscItems/OrokinReactor": diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index b4b08d0b..4d21729f 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -23,7 +23,7 @@ import { ISeasonChallenge, IPlayerSkills, ISettings, - IInfestedFoundry, + IInfestedFoundryDatabase, IHelminthResource, IConsumedSuit, IQuestProgress, @@ -492,7 +492,7 @@ const helminthResourceSchema = new Schema( { _id: false } ); -const infestedFoundrySchema = new Schema( +const infestedFoundrySchema = new Schema( { Name: String, Resources: { type: [helminthResourceSchema], default: undefined }, diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index f78addad..44c41dab 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -30,6 +30,7 @@ export interface IInventoryDatabase | "CrewShipWeaponSkins" | "OperatorLoadOuts" | "AdultOperatorLoadOuts" + | "InfestedFoundry" | TEquipmentKey > { accountOwnerId: Types.ObjectId; @@ -48,6 +49,7 @@ export interface IInventoryDatabase CrewShipWeaponSkins: IUpgradeDatabase[]; OperatorLoadOuts: IOperatorConfigDatabase[]; AdultOperatorLoadOuts: IOperatorConfigDatabase[]; + InfestedFoundry?: IInfestedFoundryDatabase; Suits: IEquipmentDatabase[]; LongGuns: IEquipmentDatabase[]; @@ -305,7 +307,7 @@ export interface IInventoryClient extends IDailyAffiliations { PlayedParkourTutorial: boolean; SubscribedToEmailsPersonalized: number; MechSuits: IEquipmentDatabase[]; - InfestedFoundry?: IInfestedFoundry; + InfestedFoundry?: IInfestedFoundryClient; BlessingCooldown: IMongoDate; CrewShipHarnesses: IEquipmentDatabase[]; CrewShipRawSalvage: IConsumable[]; @@ -566,7 +568,7 @@ export interface IHelminthResource { RecentlyConvertedResources?: IHelminthFoodRecord[]; } -export interface IInfestedFoundry { +export interface IInfestedFoundryClient { Name?: string; Resources?: IHelminthResource[]; Slots?: number; @@ -575,6 +577,12 @@ export interface IInfestedFoundry { InvigorationIndex?: number; InvigorationSuitOfferings?: string[]; InvigorationsApplied?: number; + LastConsumedSuit?: IEquipmentClient; + AbilityOverrideUnlockCooldown?: IMongoDate; +} + +export interface IInfestedFoundryDatabase + extends Omit { LastConsumedSuit?: IEquipmentDatabase; AbilityOverrideUnlockCooldown?: Date; } diff --git a/src/types/purchaseTypes.ts b/src/types/purchaseTypes.ts index 2aca5212..e8f6d090 100644 --- a/src/types/purchaseTypes.ts +++ b/src/types/purchaseTypes.ts @@ -1,4 +1,4 @@ -import { IInfestedFoundry } from "./inventoryTypes/inventoryTypes"; +import { IInfestedFoundryClient } from "./inventoryTypes/inventoryTypes"; export interface IPurchaseRequest { PurchaseParams: IPurchaseParams; @@ -29,9 +29,9 @@ export interface ICurrencyChanges { export type IInventoryChanges = { [_ in SlotNames]?: IBinChanges; -} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundry } & Record< +} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundryClient } & Record< string, - IBinChanges | number | object[] | IInfestedFoundry + IBinChanges | number | object[] | IInfestedFoundryClient >; export interface IPurchaseResponse {