Refactored scavcase reward code to use correct data and interfaces
This commit is contained in:
parent
9cf7a611bf
commit
0c5ecefc41
@ -8,7 +8,6 @@ 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 { 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";
|
||||
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
||||
@ -122,14 +121,6 @@ export class DataCallbacks {
|
||||
return this.httpResponse.getBody(this.databaseService.getHideout().production);
|
||||
}
|
||||
|
||||
public getHideoutScavcase(
|
||||
url: string,
|
||||
info: IEmptyRequestData,
|
||||
sessionID: string,
|
||||
): IGetBodyResponseData<IHideoutScavCase[]> {
|
||||
return this.httpResponse.getBody(this.databaseService.getHideout().scavcase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle client/languages
|
||||
*/
|
||||
|
@ -692,7 +692,7 @@ export class HideoutController {
|
||||
}
|
||||
}
|
||||
|
||||
const recipe = this.databaseService.getHideout().scavcase.find((r) => r._id === body.recipeId);
|
||||
const recipe = this.databaseService.getHideout().production.scavRecipes.find((r) => r._id === body.recipeId);
|
||||
if (!recipe) {
|
||||
this.logger.error(
|
||||
this.localisationService.getText("hideout-unable_to_find_scav_case_recipie_in_database", body.recipeId),
|
||||
@ -705,10 +705,10 @@ export class HideoutController {
|
||||
// - normal recipe: Production time value is stored in attribute "productionTime" with small "p"
|
||||
// - scav case recipe: Production time value is stored in attribute "ProductionTime" with capital "P"
|
||||
const adjustedCraftTime =
|
||||
recipe.ProductionTime -
|
||||
recipe.productionTime -
|
||||
this.hideoutHelper.getSkillProductionTimeReduction(
|
||||
pmcData,
|
||||
recipe.ProductionTime,
|
||||
recipe.productionTime,
|
||||
SkillTypes.CRAFTING,
|
||||
this.databaseService.getGlobals().config.SkillsSettings.Crafting.CraftTimeReductionPerLevel,
|
||||
);
|
||||
@ -799,7 +799,7 @@ export class HideoutController {
|
||||
return output;
|
||||
}
|
||||
|
||||
const scavCase = hideoutDb.scavcase.find((r) => r._id === request.recipeId);
|
||||
const scavCase = hideoutDb.production.scavRecipes.find((r) => r._id === request.recipeId);
|
||||
if (scavCase) {
|
||||
this.handleScavCase(sessionID, pmcData, request, output);
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
|
||||
import { IHideoutScavCase } from "@spt/models/eft/hideout/IHideoutScavCase";
|
||||
import { IScavRecipe } from "@spt/models/eft/hideout/IHideoutProduction";
|
||||
import { BaseClasses } from "@spt/models/enums/BaseClasses";
|
||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||
import { Money } from "@spt/models/enums/Money";
|
||||
@ -54,7 +54,9 @@ export class ScavCaseRewardGenerator {
|
||||
this.cacheDbItems();
|
||||
|
||||
// Get scavcase details from hideout/scavcase.json
|
||||
const scavCaseDetails = this.databaseService.getHideout().scavcase.find((r) => r._id === recipeId);
|
||||
const scavCaseDetails = this.databaseService
|
||||
.getHideout()
|
||||
.production.scavRecipes.find((r) => r._id === recipeId);
|
||||
const rewardItemCounts = this.getScavCaseRewardCountsAndPrices(scavCaseDetails);
|
||||
|
||||
// Get items that fit the price criteria as set by the scavCase config
|
||||
@ -347,18 +349,18 @@ export class ScavCaseRewardGenerator {
|
||||
|
||||
/**
|
||||
* Gathers the reward min and max count params for each reward quality level from config and scavcase.json into a single object
|
||||
* @param scavCaseDetails scavcase.json values
|
||||
* @param scavCaseDetails production.json/scavRecipes object
|
||||
* @returns ScavCaseRewardCountsAndPrices object
|
||||
*/
|
||||
protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IHideoutScavCase): IScavCaseRewardCountsAndPrices {
|
||||
const rewardTypes = Object.keys(scavCaseDetails.EndProducts) as Array<keyof IScavCaseRewardCountsAndPrices>; // Default is ["Common", "Rare", "Superrare"];
|
||||
protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IScavRecipe): IScavCaseRewardCountsAndPrices {
|
||||
const rewardTypes = Object.keys(scavCaseDetails.endProducts) as Array<keyof IScavCaseRewardCountsAndPrices>; // Default is ["Common", "Rare", "Superrare"];
|
||||
const result: Partial<IScavCaseRewardCountsAndPrices> = {}; // Make partial object as we're going to add all the data immediately after
|
||||
|
||||
// Create reward min/max counts for each type
|
||||
for (const rewardType of rewardTypes) {
|
||||
result[rewardType] = {
|
||||
minCount: scavCaseDetails.EndProducts[rewardType].min,
|
||||
maxCount: scavCaseDetails.EndProducts[rewardType].max,
|
||||
minCount: scavCaseDetails.endProducts[rewardType].min,
|
||||
maxCount: scavCaseDetails.endProducts[rewardType].max,
|
||||
minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType.toLowerCase()].min,
|
||||
maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType.toLowerCase()].max,
|
||||
};
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { inherits } from "util";
|
||||
import { MinMax } from "@spt/models/common/MinMax";
|
||||
|
||||
export interface IHideoutProductionData {
|
||||
|
@ -1,20 +0,0 @@
|
||||
import { MinMax } from "@spt/models/common/MinMax";
|
||||
|
||||
export interface IHideoutScavCase {
|
||||
_id: string;
|
||||
ProductionTime: number;
|
||||
Requirements: IRequirement[];
|
||||
EndProducts: IEndProducts;
|
||||
}
|
||||
export interface IRequirement {
|
||||
templateId: string;
|
||||
count: number;
|
||||
isFunctional: boolean;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface IEndProducts {
|
||||
Common: MinMax;
|
||||
Rare: MinMax;
|
||||
Superrare: MinMax;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
||||
import { IGlobals } from "@spt/models/eft/common/IGlobals";
|
||||
import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
|
||||
import { IHideoutProduction } 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";
|
||||
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
||||
|
||||
export interface IDataCallbacks {
|
||||
getSettings(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<ISettingsBase>;
|
||||
getGlobals(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IGlobals>;
|
||||
getTemplateItems(url: string, info: IEmptyRequestData, sessionID: string): string;
|
||||
getTemplateHandbook(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<any>;
|
||||
getTemplateSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<any>;
|
||||
getTemplateCharacter(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<string[]>;
|
||||
getHideoutSettings(
|
||||
url: string,
|
||||
info: IEmptyRequestData,
|
||||
sessionID: string,
|
||||
): IGetBodyResponseData<IHideoutSettingsBase>;
|
||||
getHideoutAreas(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IHideoutArea[]>;
|
||||
gethideoutProduction(
|
||||
url: string,
|
||||
info: IEmptyRequestData,
|
||||
sessionID: string,
|
||||
): IGetBodyResponseData<IHideoutProduction[]>;
|
||||
getHideoutScavcase(
|
||||
url: string,
|
||||
info: IEmptyRequestData,
|
||||
sessionID: string,
|
||||
): IGetBodyResponseData<IHideoutScavCase[]>;
|
||||
getLocalesLanguages(
|
||||
url: string,
|
||||
info: IEmptyRequestData,
|
||||
sessionID: string,
|
||||
): IGetBodyResponseData<Record<string, string>>;
|
||||
getLocalesMenu(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<any>;
|
||||
getLocalesGlobal(url: string, info: IEmptyRequestData, sessionID: string): string;
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
|
||||
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: IHideoutProductionData;
|
||||
scavcase: IHideoutScavCase[];
|
||||
settings: IHideoutSettingsBase;
|
||||
qte: IQteData[];
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import { ICustomizationItem } from "@spt/models/eft/common/tables/ICustomization
|
||||
import { IHandbookBase } from "@spt/models/eft/common/tables/IHandbookBase";
|
||||
import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
|
||||
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";
|
||||
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
||||
@ -109,17 +108,6 @@ export class DataStaticRouter extends StaticRouter {
|
||||
return this.dataCallbacks.getHideoutAreas(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/client/hideout/production/scavcase/recipes",
|
||||
async (
|
||||
url: string,
|
||||
info: any,
|
||||
sessionID: string,
|
||||
output: string,
|
||||
): Promise<IGetBodyResponseData<IHideoutScavCase[]>> => {
|
||||
return this.dataCallbacks.getHideoutScavcase(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/client/languages",
|
||||
async (
|
||||
|
@ -509,10 +509,10 @@ export class CircleOfCultistService {
|
||||
const hasScavCaseAreaUnlocked = pmcData.Hideout.Areas[HideoutAreas.SCAV_CASE]?.level > 0;
|
||||
if (hasScavCaseAreaUnlocked) {
|
||||
// Gather up items used to start scav case crafts
|
||||
const scavCaseCrafts = hideoutDbData.scavcase;
|
||||
const scavCaseCrafts = hideoutDbData.production.scavRecipes;
|
||||
for (const craft of scavCaseCrafts) {
|
||||
// Find the item requirements from each craft
|
||||
const itemRequirements = this.getItemRequirements(craft.Requirements);
|
||||
const itemRequirements = this.getItemRequirements(craft.requirements);
|
||||
for (const requirement of itemRequirements) {
|
||||
if (itemRewardBlacklist.includes(requirement.templateId)) {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user