Update handleScavCase() to use addItemsToStash()

This commit is contained in:
Dev 2024-02-01 12:42:02 +00:00
parent d564a7a992
commit 3bf44b7863

View File

@ -742,7 +742,8 @@ export class HideoutController
const scavCase = hideoutDb.scavcase.find((r) => r._id === request.recipeId); const scavCase = hideoutDb.scavcase.find((r) => r._id === request.recipeId);
if (scavCase) if (scavCase)
{ {
return this.handleScavCase(sessionID, pmcData, request, output); this.handleScavCase(sessionID, pmcData, request, output);
return output;
} }
this.logger.error( this.logger.error(
@ -936,6 +937,7 @@ export class HideoutController
globals.config.SkillsSettings.HideoutManagement.SkillPointsPerCraft, globals.config.SkillsSettings.HideoutManagement.SkillPointsPerCraft,
true, true,
); );
// Manager Crafting skill // Manager Crafting skill
if (craftingExpAmount > 0) if (craftingExpAmount > 0)
{ {
@ -999,14 +1001,13 @@ export class HideoutController
* @param pmcData Player profile * @param pmcData Player profile
* @param request Get rewards from scavcase craft request * @param request Get rewards from scavcase craft request
* @param output Output object to update * @param output Output object to update
* @returns IItemEventRouterResponse
*/ */
protected handleScavCase( protected handleScavCase(
sessionID: string, sessionID: string,
pmcData: IPmcData, pmcData: IPmcData,
request: IHideoutTakeProductionRequestData, request: IHideoutTakeProductionRequestData,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): void
{ {
const ongoingProductions = Object.entries(pmcData.Hideout.Production); const ongoingProductions = Object.entries(pmcData.Hideout.Production);
let prodId: string; let prodId: string;
@ -1037,20 +1038,17 @@ export class HideoutController
// Create rewards for scav case // Create rewards for scav case
const scavCaseRewards = this.scavCaseRewardGenerator.generate(request.recipeId); const scavCaseRewards = this.scavCaseRewardGenerator.generate(request.recipeId);
for (const itemWithChildren of scavCaseRewards) const addItemsRequest: IAddItemsDirectRequest = {
itemsWithModsToAdd: scavCaseRewards,
foundInRaid: true,
callback: null,
useSortingTable: false
};
this.inventoryHelper.addItemsToStash(sessionID, addItemsRequest, pmcData, output);
if (output.warnings.length > 0)
{ {
const addToStashRequest: IAddItemDirectRequest = { return;
itemWithModsToAdd: itemWithChildren,
foundInRaid: true,
callback: null,
useSortingTable: false
}
this.inventoryHelper.addItemToStash(sessionID, addToStashRequest, pmcData, output);
if (output.warnings.length > 0)
{
const errorMessage = "Unable to give scavcase reward to player";
return this.httpResponse.appendErrorToOutput(output, errorMessage);
}
} }
// Remove the old production from output object before its sent to client // Remove the old production from output object before its sent to client
@ -1061,8 +1059,6 @@ export class HideoutController
// Crafting complete, flag // Crafting complete, flag
pmcData.Hideout.Production[prodId].inProgress = false; pmcData.Hideout.Production[prodId].inProgress = false;
return output;
} }
/** /**