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

@ -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": {
"5448fe124bdc2da5018b4567": {
"enabled": true, "enabled": true,
"handbookPriceOverMultiplier": 9, "handbookPriceOverMultiplier": 9,
"newPriceHandbookMultiplier": 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 itemTypeKey in this.ragfairConfig.dynamic.unreasonableModPrices)
{
const details = this.ragfairConfig.dynamic.unreasonableModPrices[itemTypeKey];
if (!details?.enabled)
{
continue;
}
for (const itemTpl in fleaPrices) for (const itemTpl in fleaPrices)
{ {
if (this.itemHelper.isOfBaseclass(itemTpl, BaseClasses.MOD)) 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;
} }
} }
} }