From 471c606e12b23cd21fb1b7eb9500a1ea23bc2374 Mon Sep 17 00:00:00 2001 From: Dev Date: Wed, 21 Aug 2024 14:43:19 +0100 Subject: [PATCH] Updated production recipe interface to match live --- project/src/callbacks/DataCallbacks.ts | 6 ++--- project/src/controllers/GameController.ts | 8 ++++-- project/src/controllers/HideoutController.ts | 6 ++--- project/src/helpers/HideoutHelper.ts | 17 ++++++++----- project/src/helpers/QuestHelper.ts | 4 +-- .../models/eft/hideout/IHideoutProduction.ts | 25 +++++++++++++++++++ project/src/models/spt/hideout/IHideout.ts | 4 +-- .../src/routers/static/DataStaticRouter.ts | 6 ++--- 8 files changed, 55 insertions(+), 21 deletions(-) diff --git a/project/src/callbacks/DataCallbacks.ts b/project/src/callbacks/DataCallbacks.ts index 5a9f55be..160ef80e 100644 --- a/project/src/callbacks/DataCallbacks.ts +++ b/project/src/callbacks/DataCallbacks.ts @@ -7,7 +7,7 @@ import { ICustomizationItem } from "@spt/models/eft/common/tables/ICustomization import { IHandbookBase } from "@spt/models/eft/common/tables/IHandbookBase"; import { IGetItemPricesResponse } from "@spt/models/eft/game/IGetItemPricesResponse"; import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea"; -import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction"; +import { IHideoutProductionData } from "@spt/models/eft/hideout/IHideoutProduction"; import { IHideoutScavCase } from "@spt/models/eft/hideout/IHideoutScavCase"; import { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase"; import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData"; @@ -115,11 +115,11 @@ export class DataCallbacks { return this.httpResponse.getBody(this.databaseService.getHideout().areas); } - public gethideoutProduction( + public getHideoutProduction( url: string, info: IEmptyRequestData, sessionID: string, - ): IGetBodyResponseData { + ): IGetBodyResponseData { return this.httpResponse.getBody(this.databaseService.getHideout().production); } diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index f4c504fa..d4e7af6f 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -232,7 +232,7 @@ export class GameController { return; } - for (const craft of this.databaseService.getHideout().production) { + for (const craft of this.databaseService.getHideout().production.recipes) { // Only adjust crafts ABOVE the override craft.productionTime = Math.min(craft.productionTime, overrideSeconds); } @@ -517,7 +517,11 @@ export class GameController { protected setAllDbItemsAsSellableOnFlea(): void { const dbItems = Object.values(this.databaseService.getItems()); for (const item of dbItems) { - if (item._type === "Item" && !item._props?.CanSellOnRagfair && !this.ragfairConfig.dynamic.blacklist.custom.includes(item._id)) { + if ( + item._type === "Item" && + !item._props?.CanSellOnRagfair && + !this.ragfairConfig.dynamic.blacklist.custom.includes(item._id) + ) { item._props.CanSellOnRagfair = true; } } diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index 4fd046ec..51a7d4bb 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -567,11 +567,11 @@ export class HideoutController { // Find the recipe of the production const recipe = this.databaseService .getHideout() - .production.find((production) => production._id === body.recipeId); + .production.recipes.find((production) => production._id === body.recipeId); // Find the actual amount of items we need to remove because body can send weird data const recipeRequirementsClone = this.cloner.clone( - recipe.requirements.filter((i) => i.type === "Item" || i.type === "Tool"), + recipe.requirements.filter((r) => r.type === "Item" || r.type === "Tool"), ); const output = this.eventOutputHolder.getOutput(sessionID); @@ -733,7 +733,7 @@ export class HideoutController { return output; } - const recipe = hideoutDb.production.find((r) => r._id === request.recipeId); + const recipe = hideoutDb.production.recipes.find((r) => r._id === request.recipeId); if (recipe) { this.handleRecipe(sessionID, recipe, pmcData, request, output); diff --git a/project/src/helpers/HideoutHelper.ts b/project/src/helpers/HideoutHelper.ts index b241c071..3f11e40c 100644 --- a/project/src/helpers/HideoutHelper.ts +++ b/project/src/helpers/HideoutHelper.ts @@ -70,7 +70,7 @@ export class HideoutHelper { ): IItemEventRouterResponse { const recipe = this.databaseService .getHideout() - .production.find((production) => production._id === body.recipeId); + .production.recipes.find((production) => production._id === body.recipeId); if (!recipe) { this.logger.error(this.localisationService.getText("hideout-missing_recipe_in_db", body.recipeId)); @@ -290,7 +290,7 @@ export class HideoutHelper { } // Other recipes not covered by above - const recipe = recipes.find((r) => r._id === prodId); + const recipe = recipes.recipes.find((r) => r._id === prodId); if (!recipe) { this.logger.error(this.localisationService.getText("hideout-missing_recipe_for_area", prodId)); @@ -564,7 +564,9 @@ export class HideoutHelper { ): number { const globalSkillsDb = this.databaseService.getGlobals().config.SkillsSettings; - const recipe = this.databaseService.getHideout().production.find((production) => production._id === recipeId); + const recipe = this.databaseService + .getHideout() + .production.recipes.find((production) => production._id === recipeId); if (!recipe) { this.logger.error(this.localisationService.getText("hideout-missing_recipe_in_db", recipeId)); @@ -756,7 +758,10 @@ export class HideoutHelper { * @returns seconds to produce item */ protected getTotalProductionTimeSeconds(prodId: string): number { - return this.databaseService.getHideout().production.find((prod) => prod._id === prodId)?.productionTime ?? 0; + return ( + this.databaseService.getHideout().production.recipes.find((prod) => prod._id === prodId)?.productionTime ?? + 0 + ); } /** @@ -835,7 +840,7 @@ export class HideoutHelper { const btcProd = pmcData.Hideout.Production[HideoutHelper.bitcoinFarm]; const bitcoinProdData = this.databaseService .getHideout() - .production.find((production) => production._id === HideoutHelper.bitcoinProductionId); + .production.recipes.find((production) => production._id === HideoutHelper.bitcoinProductionId); const coinSlotCount = this.getBTCSlots(pmcData); // Full on bitcoins, halt progress @@ -963,7 +968,7 @@ export class HideoutHelper { protected getBTCSlots(pmcData: IPmcData): number { const bitcoinProductions = this.databaseService .getHideout() - .production.find((production) => production._id === HideoutHelper.bitcoinFarm); + .production.recipes.find((production) => production._id === HideoutHelper.bitcoinFarm); const productionSlots = bitcoinProductions?.productionLimitCount || 3; // Default to 3 if none found const hasManagementSkillSlots = this.profileHelper.hasEliteSkillLevel(SkillTypes.HIDEOUT_MANAGEMENT, pmcData); const managementSlotsCount = this.getEliteSkillAdditionalBitcoinSlotCount() || 2; diff --git a/project/src/helpers/QuestHelper.ts b/project/src/helpers/QuestHelper.ts index 04f9f3f6..cce2c005 100644 --- a/project/src/helpers/QuestHelper.ts +++ b/project/src/helpers/QuestHelper.ts @@ -966,7 +966,7 @@ export class QuestHelper { ): void { // Get hideout crafts and find those that match by areatype/required level/end product tpl - hope for just one match const hideoutProductions = this.databaseService.getHideout().production; - const matchingProductions = hideoutProductions.filter( + const matchingProductions = hideoutProductions.recipes.filter( (prod) => prod.areaType === Number.parseInt(craftUnlockReward.traderId) && prod.requirements.some((requirement) => requirement.questId === questDetails._id) && @@ -1121,7 +1121,7 @@ export class QuestHelper { public getMailItemRedeemTimeHoursForProfile(pmcData: IPmcData): number { const value = this.questConfig.mailRedeemTimeHours[pmcData.Info.GameVersion]; if (!value) { - return this.questConfig.mailRedeemTimeHours["default"]; + return this.questConfig.mailRedeemTimeHours.default; } return value; diff --git a/project/src/models/eft/hideout/IHideoutProduction.ts b/project/src/models/eft/hideout/IHideoutProduction.ts index 150e7daf..5daa3a5d 100644 --- a/project/src/models/eft/hideout/IHideoutProduction.ts +++ b/project/src/models/eft/hideout/IHideoutProduction.ts @@ -1,3 +1,11 @@ +import { MinMax } from "@spt/models/common/MinMax"; + +export interface IHideoutProductionData { + recipes: IHideoutProduction[]; + scavRecipes: IScavRecipe[]; + cultistRecipes: ICultistRecipe[]; +} + export interface IHideoutProduction { _id: string; areaType: number; @@ -24,3 +32,20 @@ export interface Requirement { resource?: number; questId?: string; } + +export type IScavRecipe = { + _id: string; + requirements: Requirement[]; + productionTime: number; + endProducts: IEndProducts; +}; + +export interface IEndProducts { + Common: MinMax; + Rare: MinMax; + Superrare: MinMax; +} + +export type ICultistRecipe = { + _id: string; +}; diff --git a/project/src/models/spt/hideout/IHideout.ts b/project/src/models/spt/hideout/IHideout.ts index 94e3df22..d37eecda 100644 --- a/project/src/models/spt/hideout/IHideout.ts +++ b/project/src/models/spt/hideout/IHideout.ts @@ -1,12 +1,12 @@ import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea"; -import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction"; +import { IHideoutProductionData } from "@spt/models/eft/hideout/IHideoutProduction"; import { IHideoutScavCase } from "@spt/models/eft/hideout/IHideoutScavCase"; import { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase"; import { IQteData } from "@spt/models/eft/hideout/IQteData"; export interface IHideout { areas: IHideoutArea[]; - production: IHideoutProduction[]; + production: IHideoutProductionData; scavcase: IHideoutScavCase[]; settings: IHideoutSettingsBase; qte: IQteData[]; diff --git a/project/src/routers/static/DataStaticRouter.ts b/project/src/routers/static/DataStaticRouter.ts index 8b3eece2..4abecd7e 100644 --- a/project/src/routers/static/DataStaticRouter.ts +++ b/project/src/routers/static/DataStaticRouter.ts @@ -4,7 +4,7 @@ import { IGlobals } from "@spt/models/eft/common/IGlobals"; import { ICustomizationItem } from "@spt/models/eft/common/tables/ICustomizationItem"; import { IHandbookBase } from "@spt/models/eft/common/tables/IHandbookBase"; import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea"; -import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction"; +import { IHideoutProductionData } from "@spt/models/eft/hideout/IHideoutProduction"; import { IHideoutScavCase } from "@spt/models/eft/hideout/IHideoutScavCase"; import { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase"; import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData"; @@ -83,8 +83,8 @@ export class DataStaticRouter extends StaticRouter { info: any, sessionID: string, output: string, - ): Promise> => { - return this.dataCallbacks.gethideoutProduction(url, info, sessionID); + ): Promise> => { + return this.dataCallbacks.getHideoutProduction(url, info, sessionID); }, ), new RouteAction(