Cleanup of handleScavCase()
This commit is contained in:
parent
3d01fe6211
commit
8ddad763be
@ -943,35 +943,38 @@ 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);
|
||||||
|
|
||||||
|
// Add scav case rewards to player profile
|
||||||
pmcData.Hideout.Production[prodId].Products = scavCaseRewards;
|
pmcData.Hideout.Production[prodId].Products = scavCaseRewards;
|
||||||
|
|
||||||
// Remove the old production from output object before its sent to client
|
// Remove the old production from output object before its sent to client
|
||||||
delete output.profileChanges[sessionID].production[request.recipeId];
|
delete output.profileChanges[sessionID].production[request.recipeId];
|
||||||
|
|
||||||
|
// Get array of item created + count of them after completing hideout craft
|
||||||
const itemsToAdd = pmcData.Hideout.Production[prodId].Products.map(
|
const itemsToAdd = pmcData.Hideout.Production[prodId].Products.map(
|
||||||
(x: { _tpl: string; upd?: { StackObjectsCount?: number; }; }) =>
|
(x: { _tpl: string; upd?: { StackObjectsCount?: number; }; }) =>
|
||||||
{
|
{
|
||||||
let id = x._tpl;
|
const itemTpl = this.presetHelper.hasPreset(x._tpl)
|
||||||
if (this.presetHelper.hasPreset(id))
|
? this.presetHelper.getDefaultPreset(x._tpl)._id
|
||||||
{
|
: x._tpl;
|
||||||
id = this.presetHelper.getDefaultPreset(id)._id;
|
|
||||||
}
|
// Count of items crafted
|
||||||
const numOfItems = !x.upd?.StackObjectsCount ? 1 : x.upd.StackObjectsCount;
|
const numOfItems = !x.upd?.StackObjectsCount ? 1 : x.upd.StackObjectsCount;
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
return { item_id: id, count: numOfItems };
|
return { item_id: itemTpl, count: numOfItems };
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const newReq = { items: itemsToAdd, tid: "ragfair" };
|
const newReq = { items: itemsToAdd, tid: "ragfair" };
|
||||||
|
|
||||||
const callback = () =>
|
const callback = () =>
|
||||||
{
|
{
|
||||||
// Flag as complete - will be cleaned up later by update() process
|
// Flag as complete - will be cleaned up later by hideoutController.update()
|
||||||
pmcData.Hideout.Production[prodId].sptIsComplete = true;
|
pmcData.Hideout.Production[prodId].sptIsComplete = true;
|
||||||
|
|
||||||
|
// Crafting complete, flag as such
|
||||||
pmcData.Hideout.Production[prodId].inProgress = false;
|
pmcData.Hideout.Production[prodId].inProgress = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add crafted item to player inventory
|
||||||
return this.inventoryHelper.addItem(pmcData, newReq, output, sessionID, callback, true);
|
return this.inventoryHelper.addItem(pmcData, newReq, output, sessionID, callback, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user