2023-10-11 18:43:57 +02:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2024-05-21 19:59:04 +02:00
|
|
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
|
|
|
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "@spt/models/spt/config/IQuestConfig";
|
|
|
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
|
|
|
import { ICloner } from "@spt/utils/cloners/ICloner";
|
|
|
|
import { MathUtil } from "@spt/utils/MathUtil";
|
|
|
|
import { ProbabilityObject, ProbabilityObjectArray } from "@spt/utils/RandomUtil";
|
2023-10-11 18:43:57 +02:00
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class RepeatableQuestHelper
|
|
|
|
{
|
|
|
|
protected questConfig: IQuestConfig;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
@inject("MathUtil") protected mathUtil: MathUtil,
|
2023-11-16 02:35:05 +01:00
|
|
|
@inject("ConfigServer") protected configServer: ConfigServer,
|
2024-05-28 16:04:20 +02:00
|
|
|
@inject("PrimaryCloner") protected cloner: ICloner,
|
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
|
|
|
{
|
2024-05-17 21:32:41 +02:00
|
|
|
return repeatableConfig.questConfig.Elimination.find(
|
|
|
|
(x) => pmcLevel >= x.levelRange.min && pmcLevel <= x.levelRange.max,
|
2023-11-16 02:35:05 +01:00
|
|
|
);
|
2023-10-11 18:43:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>
|
|
|
|
{
|
2024-05-13 19:58:17 +02:00
|
|
|
const configArray = this.cloner.clone(configArrayInput);
|
|
|
|
const probabilityArray = new ProbabilityObjectArray<K, V>(this.mathUtil, this.cloner);
|
2023-10-11 18:43:57 +02:00
|
|
|
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
|
|
|
}
|