[Enhancement] Ability to prevent duplicate fence offers by parentId (!245)

In relation to this QoL issue: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/547

This PR allows us to prevent fence selling duplicate items by parentId.

It adds a new property to `trader.json` `fence.preventDuplicateOffersOfCategory` its an array that takes parentIds. The scope of this PR only extends to ammo and ammo boxes. It can be expanded upon in the future with no code changes should the need arise.

The reason for this change is because currently fence can have duplicate stacks of identical ammo with different prices, which makes no sense. If you have any questions feel free to ping me on discord.

Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/245
Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com>
Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
This commit is contained in:
Cj 2024-03-05 08:49:10 +00:00 committed by chomp
parent e3f341416d
commit 0740a84f6f
3 changed files with 18 additions and 0 deletions

View File

@ -123,6 +123,10 @@
"5671435f4bdc2d96058b4569": 0,
"543be5cb4bdc2deb348b4568": 3
},
"preventDuplicateOffersOfCategory": [
"543be5cb4bdc2deb348b4568",
"5485a8684bdc2da71d8b4567"
],
"weaponDurabilityPercentMinMax": {
"current": {
"min": 40,

View File

@ -36,6 +36,8 @@ export interface FenceConfig
/** Key: item tpl */
itemStackSizeOverrideMinMax: Record<string, MinMax>;
itemTypeLimits: Record<string, number>;
/** Prevent duplicate offers of items of specific categories by parentId*/
preventDuplicateOffersOfCategory: string[];
regenerateAssortsOnRefresh: boolean;
/** Max rouble price before item is not listed on flea */
itemCategoryRoublePriceLimit: Record<string, number>;

View File

@ -613,6 +613,18 @@ export class FenceService
// rootItemBeingAdded.upd.BuyRestrictionCurrent = 0;
// rootItemBeingAdded.upd.UnlimitedCount = false;
// Skip items already in the assort if it exists in the prevent duplicate list
if (
assorts.items.some((item) => item._tpl === rootItemBeingAdded._tpl)
&& this.traderConfig.fence.preventDuplicateOffersOfCategory.includes(
this.itemHelper.getItem(rootItemBeingAdded._tpl)[1]._parent,
)
)
{
i--;
continue;
}
// Only randomise single items
const isSingleStack = rootItemBeingAdded.upd.StackObjectsCount === 1;
if (isSingleStack)