Updated production recipe interface to match live

This commit is contained in:
Dev 2024-08-21 14:43:19 +01:00
parent b209c0728c
commit 471c606e12
8 changed files with 55 additions and 21 deletions

View File

@ -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<IHideoutProduction[]> {
): IGetBodyResponseData<IHideoutProductionData> {
return this.httpResponse.getBody(this.databaseService.getHideout().production);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<IGetBodyResponseData<IHideoutProduction[]>> => {
return this.dataCallbacks.gethideoutProduction(url, info, sessionID);
): Promise<IGetBodyResponseData<IHideoutProductionData>> => {
return this.dataCallbacks.getHideoutProduction(url, info, sessionID);
},
),
new RouteAction(