Update trader refresh times to use a min and max value

This commit is contained in:
Dev 2024-03-16 22:12:03 +00:00
parent be64e897b9
commit 95f5a49c5c
5 changed files with 53 additions and 15 deletions

View File

@ -3,51 +3,81 @@
{
"_name": "prapor",
"traderId": "54cb50c76803fa8b248b4571",
"seconds": 11100
"seconds": {
"min": 7000,
"max": 13500
}
},
{
"_name": "therapist",
"traderId": "54cb57776803fa99248b456e",
"seconds": 8040
"seconds": {
"min": 3000,
"max": 9500
}
},
{
"_name": "fence",
"traderId": "579dc571d53a0658a154fbec",
"seconds": 5220
"seconds": {
"min": 3000,
"max": 9000
}
},
{
"_name": "skier",
"traderId": "58330581ace78e27b8b10cee",
"seconds": 6240
"seconds": {
"min": 5000,
"max": 8500
}
},
{
"_name": "peacekeeper",
"traderId": "5935c25fb3acc3127c3d8cd9",
"seconds": 8580
"seconds": {
"min": 2000,
"max": 14000
}
},
{
"_name": "mechanic",
"traderId": "5a7c2eca46aef81a7ca2145d",
"seconds": 8160
"seconds": {
"min": 7000,
"max": 13500
}
},
{
"_name": "ragman",
"traderId": "5ac3b934156ae10c4430e83c",
"seconds": 8220
"seconds": {
"min": 6500,
"max": 15000
}
},
{
"_name": "jaeger",
"traderId": "5c0647fdd443bc2504c2d371",
"seconds": 5100
"seconds": {
"min": 2000,
"max": 5500
}
},
{
"_name": "btr",
"traderId": "656f0f98d80a697f855d34b1",
"seconds": 3600
"seconds": {
"min": 3000,
"max": 7500
}
},
{
"traderId": "ragfair",
"seconds": 3600
"seconds": {
"min": 3600,
"max": 3600
}
}
],
"updateTimeDefault": 3600,

View File

@ -275,12 +275,15 @@ export class TraderHelper
);
this.traderConfig.updateTime.push( // create temporary entry to prevent logger spam
{ traderId: traderId, seconds: this.traderConfig.updateTimeDefault },
{
traderId: traderId,
seconds: { min: this.traderConfig.updateTimeDefault, max: this.traderConfig.updateTimeDefault },
},
);
}
else
{
return traderDetails.seconds;
return this.randomUtil.getInt(traderDetails.seconds.min, traderDetails.seconds.max);
}
}

View File

@ -20,7 +20,7 @@ export interface UpdateTime
{
traderId: string;
/** Seconds between trader resets */
seconds: number;
seconds: MinMax;
}
export interface FenceConfig

View File

@ -1262,7 +1262,9 @@ export class FenceService
*/
protected getFenceRefreshTime(): number
{
return this.traderConfig.updateTime.find((x) => x.traderId === Traders.FENCE).seconds;
const fence = this.traderConfig.updateTime.find((x) => x.traderId === Traders.FENCE).seconds;
return this.randomUtil.getInt(fence.min, fence.max);
}
/**

View File

@ -7,6 +7,7 @@ import { ITraderConfig } from "@spt-aki/models/spt/config/ITraderConfig";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
import { LocalisationService } from "@spt-aki/services/LocalisationService";
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
/**
@ -20,6 +21,7 @@ export class TraderPurchasePersisterService
constructor(
@inject("WinstonLogger") protected logger: ILogger,
@inject("TimeUtil") protected timeUtil: TimeUtil,
@inject("RandomUtil") protected randomUtil: RandomUtil,
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
@inject("LocalisationService") protected localisationService: LocalisationService,
@inject("ConfigServer") protected configServer: ConfigServer,
@ -134,7 +136,8 @@ export class TraderPurchasePersisterService
}
const purchaseDetails = profile.traderPurchases[traderId][purchaseKey];
const resetTimeForItem = purchaseDetails.purchaseTimestamp + traderUpdateDetails.seconds;
const resetTimeForItem = purchaseDetails.purchaseTimestamp
+ this.randomUtil.getInt(traderUpdateDetails.seconds.min, traderUpdateDetails.seconds.max);
if (resetTimeForItem < this.timeUtil.getTimestamp())
{
// Item was purchased far enough in past a trader refresh would have occured, remove purchase record from profile