separate InfestedFoundry client & database structs

This commit is contained in:
Sainan 2025-01-20 08:20:06 +01:00
parent 103104cdbc
commit 04955c094e
5 changed files with 19 additions and 11 deletions

View File

@ -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;

View File

@ -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<IInventoryClient>().InfestedFoundry;
} else
switch (operation.UpgradeRequirement) {
case "/Lotus/Types/Items/MiscItems/OrokinReactor":

View File

@ -23,7 +23,7 @@ import {
ISeasonChallenge,
IPlayerSkills,
ISettings,
IInfestedFoundry,
IInfestedFoundryDatabase,
IHelminthResource,
IConsumedSuit,
IQuestProgress,
@ -492,7 +492,7 @@ const helminthResourceSchema = new Schema<IHelminthResource>(
{ _id: false }
);
const infestedFoundrySchema = new Schema<IInfestedFoundry>(
const infestedFoundrySchema = new Schema<IInfestedFoundryDatabase>(
{
Name: String,
Resources: { type: [helminthResourceSchema], default: undefined },

View File

@ -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<IInfestedFoundryClient, "LastConsumedSuit" | "AbilityOverrideUnlockCooldown"> {
LastConsumedSuit?: IEquipmentDatabase;
AbilityOverrideUnlockCooldown?: Date;
}

View File

@ -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 {