mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 06:50:43 -05:00
Refactor getNumberOfItemsNeededToFillGap
This commit is contained in:
parent
b563dd3f78
commit
463e33d1b7
@ -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
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user