Rework high flea listing price adjuster to be configurable, more item types can be added (!111)

Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/111
This commit is contained in:
chomp 2023-08-06 11:36:07 +00:00
parent a962823192
commit 6a864bffa9
4 changed files with 70 additions and 55 deletions

View File

@ -1,7 +1,7 @@
{ {
"runIntervalSeconds": 45, "runIntervalSeconds": 45,
"sell": { "sell": {
"simulatedSellHours": 12, "simulatedSellHours": 12,
"fees": true, "fees": true,
"chance": { "chance": {
"base": 50, "base": 50,
@ -31,29 +31,29 @@
"ragfair": false "ragfair": false
}, },
"dynamic": { "dynamic": {
"purchasesAreFoundInRaid": false, "purchasesAreFoundInRaid": false,
"useTraderPriceForOffersIfHigher": true, "useTraderPriceForOffersIfHigher": true,
"barter": { "barter": {
"enable": true, "enable": true,
"chancePercent": 20, "chancePercent": 20,
"itemCountMin": 1, "itemCountMin": 1,
"itemCountMax": 3, "itemCountMax": 3,
"priceRangeVariancePercent": 15, "priceRangeVariancePercent": 15,
"minRoubleCostToBecomeBarter": 20000, "minRoubleCostToBecomeBarter": 20000,
"itemTypeBlacklist": [ "itemTypeBlacklist": [
"55802f4a4bdc2ddb688b4569", "55802f4a4bdc2ddb688b4569",
"55802f3e4bdc2de7118b4584", "55802f3e4bdc2de7118b4584",
"543be5cb4bdc2deb348b4568", "543be5cb4bdc2deb348b4568",
"55818ac54bdc2d5b648b456e", "55818ac54bdc2d5b648b456e",
"5a74651486f7744e73386dd1" "5a74651486f7744e73386dd1"
] ]
}, },
"offerAdjustment":{ "offerAdjustment": {
"adjustPriceWhenBelowHandbookPrice": false, "adjustPriceWhenBelowHandbookPrice": false,
"maxPriceDifferenceBelowHandbookPercent": 64, "maxPriceDifferenceBelowHandbookPercent": 64,
"handbookPriceMultipier": 1.1, "handbookPriceMultipier": 1.1,
"priceThreshholdRub": 20000 "priceThreshholdRub": 20000
}, },
"expiredOfferThreshold": 1500, "expiredOfferThreshold": 1500,
"offerItemCount": { "offerItemCount": {
"min": 7, "min": 7,
@ -67,7 +67,7 @@
"min": 0.95, "min": 0.95,
"max": 1.05 "max": 1.05
}, },
"showDefaultPresetsOnly": true, "showDefaultPresetsOnly": true,
"endTimeSeconds": { "endTimeSeconds": {
"min": 360, "min": 360,
"max": 3600 "max": 3600
@ -128,7 +128,7 @@
"min": 0.1, "min": 0.1,
"max": 0.95 "max": 0.95
}, },
"_currencies": "what percentage of the offers are in each currency", "_currencies": "what percentage of the offers are in each currency",
"currencies": { "currencies": {
"5449016a4bdc2d6f028b456f": 78, "5449016a4bdc2d6f028b456f": 78,
"5696686a4bdc2da3298b456a": 14, "5696686a4bdc2da3298b456a": 14,
@ -141,20 +141,28 @@
"5448e53e4bdc2d60728b4567", "5448e53e4bdc2d60728b4567",
"5448bf274bdc2dfc2f8b456a", "5448bf274bdc2dfc2f8b456a",
"543be5e94bdc2df1348b4568", "543be5e94bdc2df1348b4568",
"5448f39d4bdc2d0a728b4568" "5448f39d4bdc2d0a728b4568",
"62e910aaf957f2915e0a5e36"
], ],
"removeSeasonalItemsWhenNotInEvent": true, "removeSeasonalItemsWhenNotInEvent": true,
"blacklist": { "blacklist": {
"damagedAmmoPacks": true, "damagedAmmoPacks": true,
"custom": [], "custom": [],
"enableBsgList": true, "enableBsgList": false,
"enableQuestList": true, "enableQuestList": true,
"traderItems": false "traderItems": false
}, },
"unreasonableModPrices": { "unreasonableModPrices": {
"enabled": true, "5448fe124bdc2da5018b4567": {
"handbookPriceOverMultiplier": 9, "enabled": true,
"newPriceHandbookMultiplier": 9 "handbookPriceOverMultiplier": 9,
} "newPriceHandbookMultiplier": 9
},
"57864a66245977548f04a81f": {
"enabled": true,
"handbookPriceOverMultiplier": 11,
"newPriceHandbookMultiplier": 11
}
}
} }
} }

View File

@ -3917,7 +3917,7 @@
"count": 1, "count": 1,
"endProduct": "62e910aaf957f2915e0a5e36", "endProduct": "62e910aaf957f2915e0a5e36",
"isEncoded": true, "isEncoded": true,
"locked": true, "locked": false,
"needFuelForAllProductionTime": true, "needFuelForAllProductionTime": true,
"productionLimitCount": 0, "productionLimitCount": 0,
"productionTime": 43200, "productionTime": 43200,
@ -3938,10 +3938,6 @@
"requiredLevel": 2, "requiredLevel": 2,
"type": "Area" "type": "Area"
}, },
{
"questId": "625d700cc48e6c62a440fab5",
"type": "QuestComplete"
},
{ {
"templateId": "590c2d8786f774245b1f03f3", "templateId": "590c2d8786f774245b1f03f3",
"type": "Tool" "type": "Tool"

View File

@ -85,15 +85,8 @@ export interface Dynamic
removeSeasonalItemsWhenNotInEvent: boolean removeSeasonalItemsWhenNotInEvent: boolean
/** Flea blacklist settings */ /** Flea blacklist settings */
blacklist: Blacklist blacklist: Blacklist
/** Should prices over the multiplier be adjusted */ /** Dict of price limits keyed by item type */
unreasonableModPrices: IUnreasonableModPrices unreasonableModPrices: Record<string, IUnreasonableModPrices>
}
export interface IUnreasonableModPrices
{
enabled: boolean
handbookPriceOverMultiplier: number
newPriceHandbookMultiplier: number
} }
export interface Barter export interface Barter
@ -146,3 +139,10 @@ export interface Blacklist
traderItems: boolean traderItems: boolean
} }
export interface IUnreasonableModPrices
{
enabled: boolean
handbookPriceOverMultiplier: number
newPriceHandbookMultiplier: number
}

View File

@ -11,7 +11,6 @@ import {
} from "../models/eft/common/tables/IRepeatableQuests"; } from "../models/eft/common/tables/IRepeatableQuests";
import { StageBonus } from "../models/eft/hideout/IHideoutArea"; import { StageBonus } from "../models/eft/hideout/IHideoutArea";
import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile";
import { BaseClasses } from "../models/enums/BaseClasses";
import { ConfigTypes } from "../models/enums/ConfigTypes"; import { ConfigTypes } from "../models/enums/ConfigTypes";
import { HideoutAreas } from "../models/enums/HideoutAreas"; import { HideoutAreas } from "../models/enums/HideoutAreas";
import { QuestStatus } from "../models/enums/QuestStatus"; import { QuestStatus } from "../models/enums/QuestStatus";
@ -102,7 +101,7 @@ export class ProfileFixerService
this.updateProfilePocketsToNewId(pmcProfile); this.updateProfilePocketsToNewId(pmcProfile);
this.updateProfileQuestDataValues(pmcProfile); this.updateProfileQuestDataValues(pmcProfile);
if (this.ragfairConfig.dynamic.unreasonableModPrices.enabled) if (Object.keys(this.ragfairConfig.dynamic.unreasonableModPrices).length > 0)
{ {
this.adjustUnreasonableModFleaPrices(); this.adjustUnreasonableModFleaPrices();
} }
@ -113,17 +112,29 @@ export class ProfileFixerService
const db = this.databaseServer.getTables(); const db = this.databaseServer.getTables();
const fleaPrices = db.templates.prices; const fleaPrices = db.templates.prices;
const handbookPrices = db.templates.handbook.Items; const handbookPrices = db.templates.handbook.Items;
for (const itemTpl in fleaPrices)
for (const itemTypeKey in this.ragfairConfig.dynamic.unreasonableModPrices)
{ {
if (this.itemHelper.isOfBaseclass(itemTpl, BaseClasses.MOD)) const details = this.ragfairConfig.dynamic.unreasonableModPrices[itemTypeKey];
if (!details?.enabled)
{ {
continue;
}
for (const itemTpl in fleaPrices)
{
if (!this.itemHelper.isOfBaseclass(itemTpl, itemTypeKey))
{
continue;
}
const itemHandbookPrice = handbookPrices.find(x => x.Id === itemTpl); const itemHandbookPrice = handbookPrices.find(x => x.Id === itemTpl);
if (!itemHandbookPrice) if (!itemHandbookPrice)
{ {
continue; continue;
} }
if (fleaPrices[itemTpl] > (itemHandbookPrice.Price * this.ragfairConfig.dynamic.unreasonableModPrices.handbookPriceOverMultiplier)) if (fleaPrices[itemTpl] > (itemHandbookPrice.Price * details.handbookPriceOverMultiplier))
{ {
if (fleaPrices[itemTpl] <= 1) if (fleaPrices[itemTpl] <= 1)
{ {
@ -131,7 +142,7 @@ export class ProfileFixerService
} }
// Price is over limit, adjust // Price is over limit, adjust
fleaPrices[itemTpl] = itemHandbookPrice.Price * this.ragfairConfig.dynamic.unreasonableModPrices.newPriceHandbookMultiplier; fleaPrices[itemTpl] = itemHandbookPrice.Price * details.newPriceHandbookMultiplier;
} }
} }
} }