From 9bf533a1b177082cdcd50a45804580c2de370895 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 1 Jun 2023 10:46:16 +0100 Subject: [PATCH] Add additional comments and formatting fixes --- project/src/controllers/HideoutController.ts | 6 +++++- project/src/helpers/HideoutHelper.ts | 7 +++++++ project/src/services/ItemBaseClassService.ts | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index 353ef226..8e27b26b 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -369,6 +369,7 @@ export class HideoutController // Find the recipe of the production const recipe = this.databaseServer.getTables().hideout.production.find(p => p._id === body.recipeId); + // Find the actual amount of items we need to remove because body can send weird data const requirements = this.jsonUtil.clone(recipe.requirements.filter(i => i.type === "Item")); @@ -379,7 +380,10 @@ export class HideoutController const itemToCheck = pmcData.Inventory.items.find(i => i._id === itemToDelete.id); const requirement = requirements.find(requirement => requirement.templateId === itemToCheck._tpl); if (requirement.count <= 0) + { continue; + } + this.inventoryHelper.removeItemByCount(pmcData, itemToDelete.id, requirement.count, sessionID, output); requirement.count -= itemToDelete.count; } @@ -699,7 +703,7 @@ export class HideoutController } /** - * Start area production for item + * Start area production for item by adding production to profiles' Hideout.Production array * @param pmcData Player profile * @param request Start production request * @param sessionID Session id diff --git a/project/src/helpers/HideoutHelper.ts b/project/src/helpers/HideoutHelper.ts index 87bab7d7..b1fc9610 100644 --- a/project/src/helpers/HideoutHelper.ts +++ b/project/src/helpers/HideoutHelper.ts @@ -62,6 +62,13 @@ export class HideoutHelper this.hideoutConfig = this.configServer.getConfig(ConfigTypes.HIDEOUT); } + /** + * Add production to profiles' Hideout.Production array + * @param pmcData Profile to add production to + * @param body Production request + * @param sessionID Session id + * @returns client response + */ public registerProduction(pmcData: IPmcData, body: IHideoutSingleProductionStartRequestData | IHideoutContinuousProductionStartRequestData, sessionID: string): IItemEventRouterResponse { const recipe = this.databaseServer.getTables().hideout.production.find(p => p._id === body.recipeId); diff --git a/project/src/services/ItemBaseClassService.ts b/project/src/services/ItemBaseClassService.ts index 21544160..cf88b8a9 100644 --- a/project/src/services/ItemBaseClassService.ts +++ b/project/src/services/ItemBaseClassService.ts @@ -23,6 +23,7 @@ export class ItemBaseClassService /** * Create cache and store inside ItemBaseClassService + * Store a dict of an items tpl to the base classes it and its parents have */ public hydrateItemBaseClassCache(): void {