0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 02:50:44 -05:00

Refactor getNumberOfItemsNeededToFillGap

This commit is contained in:
Dev 2023-04-24 13:34:40 +01:00
parent b563dd3f78
commit 463e33d1b7

View File

@ -268,17 +268,21 @@ export class FenceService
protected getCountOfItemsToGenerate(existingItemCountToReplace: number): number protected getCountOfItemsToGenerate(existingItemCountToReplace: number): number
{ {
const desiredTotalCount = this.traderConfig.fence.assortSize; const desiredTotalCount = this.traderConfig.fence.assortSize;
const actualTotalCount = this.fenceAssort.items.filter(x => x.slotId === "hideout").length; const actualTotalCount = this.fenceAssort.items.reduce((count, item) =>
if (actualTotalCount < desiredTotalCount)
{ {
return (desiredTotalCount - actualTotalCount) + existingItemCountToReplace; return item.slotId === "hideout"
} ? count + 1
: count;
}, 0);
return existingItemCountToReplace; return actualTotalCount < desiredTotalCount
? (desiredTotalCount - actualTotalCount) + existingItemCountToReplace
: existingItemCountToReplace;
} }
/** /**
* Choose an item (not mod) at random and remove from assorts * Choose an item (not mod) at random and remove from assorts
* @param assort Items to remove from
*/ */
protected removeRandomItemFromAssorts(assort: ITraderAssort): void protected removeRandomItemFromAssorts(assort: ITraderAssort): void
{ {