2023-10-11 18:43:57 +02:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2023-10-19 19:21:17 +02:00
|
|
|
|
|
|
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
|
|
|
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "@spt-aki/models/spt/config/IQuestConfig";
|
|
|
|
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
|
|
|
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
|
|
|
import { MathUtil } from "@spt-aki/utils/MathUtil";
|
|
|
|
import { ProbabilityObject, ProbabilityObjectArray } from "@spt-aki/utils/RandomUtil";
|
2023-10-11 18:43:57 +02:00
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class RepeatableQuestHelper
|
|
|
|
{
|
|
|
|
protected questConfig: IQuestConfig;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
@inject("MathUtil") protected mathUtil: MathUtil,
|
|
|
|
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
2023-11-16 02:35:05 +01:00
|
|
|
@inject("ConfigServer") protected configServer: ConfigServer,
|
2023-10-11 18:43:57 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
this.questConfig = this.configServer.getConfig(ConfigTypes.QUEST);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the relevant elimination config based on the current players PMC level
|
|
|
|
* @param pmcLevel Level of PMC character
|
|
|
|
* @param repeatableConfig Main repeatable config
|
|
|
|
* @returns IEliminationConfig
|
|
|
|
*/
|
2023-11-16 02:35:05 +01:00
|
|
|
public getEliminationConfigByPmcLevel(
|
|
|
|
pmcLevel: number,
|
|
|
|
repeatableConfig: IRepeatableQuestConfig,
|
|
|
|
): IEliminationConfig
|
2023-10-11 18:43:57 +02:00
|
|
|
{
|
2023-11-16 02:35:05 +01:00
|
|
|
return repeatableConfig.questConfig.Elimination.find((x) =>
|
|
|
|
pmcLevel >= x.levelRange.min && pmcLevel <= x.levelRange.max
|
|
|
|
);
|
2023-10-11 18:43:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>
|
|
|
|
{
|
|
|
|
const configArray = this.jsonUtil.clone(configArrayInput);
|
|
|
|
const probabilityArray = new ProbabilityObjectArray<K, V>(this.mathUtil, this.jsonUtil);
|
|
|
|
for (const configObject of configArray)
|
|
|
|
{
|
2023-11-16 02:35:05 +01:00
|
|
|
probabilityArray.push(
|
|
|
|
new ProbabilityObject(configObject.key, configObject.relativeProbability, configObject.data),
|
|
|
|
);
|
2023-10-11 18:43:57 +02:00
|
|
|
}
|
|
|
|
return probabilityArray;
|
|
|
|
}
|
2023-11-16 02:35:05 +01:00
|
|
|
}
|