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 { IGetItemPricesResponse } from "@spt/models/eft/game/IGetItemPricesResponse";
|
||||||
import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
|
import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
|
||||||
import { IHideoutProductionData } 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 { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase";
|
||||||
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
||||||
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
||||||
@ -122,14 +121,6 @@ export class DataCallbacks {
|
|||||||
return this.httpResponse.getBody(this.databaseService.getHideout().production);
|
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
|
* 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) {
|
if (!recipe) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
this.localisationService.getText("hideout-unable_to_find_scav_case_recipie_in_database", body.recipeId),
|
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"
|
// - 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"
|
// - scav case recipe: Production time value is stored in attribute "ProductionTime" with capital "P"
|
||||||
const adjustedCraftTime =
|
const adjustedCraftTime =
|
||||||
recipe.ProductionTime -
|
recipe.productionTime -
|
||||||
this.hideoutHelper.getSkillProductionTimeReduction(
|
this.hideoutHelper.getSkillProductionTimeReduction(
|
||||||
pmcData,
|
pmcData,
|
||||||
recipe.ProductionTime,
|
recipe.productionTime,
|
||||||
SkillTypes.CRAFTING,
|
SkillTypes.CRAFTING,
|
||||||
this.databaseService.getGlobals().config.SkillsSettings.Crafting.CraftTimeReductionPerLevel,
|
this.databaseService.getGlobals().config.SkillsSettings.Crafting.CraftTimeReductionPerLevel,
|
||||||
);
|
);
|
||||||
@ -799,7 +799,7 @@ export class HideoutController {
|
|||||||
return output;
|
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) {
|
if (scavCase) {
|
||||||
this.handleScavCase(sessionID, pmcData, request, output);
|
this.handleScavCase(sessionID, pmcData, request, output);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
|
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 { BaseClasses } from "@spt/models/enums/BaseClasses";
|
||||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||||
import { Money } from "@spt/models/enums/Money";
|
import { Money } from "@spt/models/enums/Money";
|
||||||
@ -54,7 +54,9 @@ export class ScavCaseRewardGenerator {
|
|||||||
this.cacheDbItems();
|
this.cacheDbItems();
|
||||||
|
|
||||||
// Get scavcase details from hideout/scavcase.json
|
// 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);
|
const rewardItemCounts = this.getScavCaseRewardCountsAndPrices(scavCaseDetails);
|
||||||
|
|
||||||
// Get items that fit the price criteria as set by the scavCase config
|
// 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
|
* 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
|
* @returns ScavCaseRewardCountsAndPrices object
|
||||||
*/
|
*/
|
||||||
protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IHideoutScavCase): IScavCaseRewardCountsAndPrices {
|
protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IScavRecipe): IScavCaseRewardCountsAndPrices {
|
||||||
const rewardTypes = Object.keys(scavCaseDetails.EndProducts) as Array<keyof IScavCaseRewardCountsAndPrices>; // Default is ["Common", "Rare", "Superrare"];
|
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
|
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
|
// Create reward min/max counts for each type
|
||||||
for (const rewardType of rewardTypes) {
|
for (const rewardType of rewardTypes) {
|
||||||
result[rewardType] = {
|
result[rewardType] = {
|
||||||
minCount: scavCaseDetails.EndProducts[rewardType].min,
|
minCount: scavCaseDetails.endProducts[rewardType].min,
|
||||||
maxCount: scavCaseDetails.EndProducts[rewardType].max,
|
maxCount: scavCaseDetails.endProducts[rewardType].max,
|
||||||
minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType.toLowerCase()].min,
|
minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType.toLowerCase()].min,
|
||||||
maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType.toLowerCase()].max,
|
maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType.toLowerCase()].max,
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { inherits } from "util";
|
|
||||||
import { MinMax } from "@spt/models/common/MinMax";
|
import { MinMax } from "@spt/models/common/MinMax";
|
||||||
|
|
||||||
export interface IHideoutProductionData {
|
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 { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
|
||||||
import { IHideoutProductionData } 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 { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase";
|
||||||
import { IQteData } from "@spt/models/eft/hideout/IQteData";
|
import { IQteData } from "@spt/models/eft/hideout/IQteData";
|
||||||
|
|
||||||
export interface IHideout {
|
export interface IHideout {
|
||||||
areas: IHideoutArea[];
|
areas: IHideoutArea[];
|
||||||
production: IHideoutProductionData;
|
production: IHideoutProductionData;
|
||||||
scavcase: IHideoutScavCase[];
|
|
||||||
settings: IHideoutSettingsBase;
|
settings: IHideoutSettingsBase;
|
||||||
qte: IQteData[];
|
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 { IHandbookBase } from "@spt/models/eft/common/tables/IHandbookBase";
|
||||||
import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
|
import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
|
||||||
import { IHideoutProductionData } 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 { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase";
|
||||||
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
||||||
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
||||||
@ -109,17 +108,6 @@ export class DataStaticRouter extends StaticRouter {
|
|||||||
return this.dataCallbacks.getHideoutAreas(url, info, sessionID);
|
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(
|
new RouteAction(
|
||||||
"/client/languages",
|
"/client/languages",
|
||||||
async (
|
async (
|
||||||
|
@ -509,10 +509,10 @@ export class CircleOfCultistService {
|
|||||||
const hasScavCaseAreaUnlocked = pmcData.Hideout.Areas[HideoutAreas.SCAV_CASE]?.level > 0;
|
const hasScavCaseAreaUnlocked = pmcData.Hideout.Areas[HideoutAreas.SCAV_CASE]?.level > 0;
|
||||||
if (hasScavCaseAreaUnlocked) {
|
if (hasScavCaseAreaUnlocked) {
|
||||||
// Gather up items used to start scav case crafts
|
// Gather up items used to start scav case crafts
|
||||||
const scavCaseCrafts = hideoutDbData.scavcase;
|
const scavCaseCrafts = hideoutDbData.production.scavRecipes;
|
||||||
for (const craft of scavCaseCrafts) {
|
for (const craft of scavCaseCrafts) {
|
||||||
// Find the item requirements from each craft
|
// Find the item requirements from each craft
|
||||||
const itemRequirements = this.getItemRequirements(craft.Requirements);
|
const itemRequirements = this.getItemRequirements(craft.requirements);
|
||||||
for (const requirement of itemRequirements) {
|
for (const requirement of itemRequirements) {
|
||||||
if (itemRewardBlacklist.includes(requirement.templateId)) {
|
if (itemRewardBlacklist.includes(requirement.templateId)) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user