Server/project/src/helpers/QuestConditionHelper.ts
Alex d13e86ba46 Rebranding to SPT (!345)
Rebranded src code and scripts to SPT

Co-authored-by: clodan <clodan@clodan.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/345
Co-authored-by: Alex <clodan@noreply.dev.sp-tarkov.com>
Co-committed-by: Alex <clodan@noreply.dev.sp-tarkov.com>
2024-05-21 17:59:04 +00:00

61 lines
1.6 KiB
TypeScript

import { injectable } from "tsyringe";
import { IQuestCondition } from "@spt/models/eft/common/tables/IQuest";
@injectable()
export class QuestConditionHelper
{
public getQuestConditions(
q: IQuestCondition[],
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
): IQuestCondition[]
{
return this.filterConditions(q, "Quest", furtherFilter);
}
public getLevelConditions(
q: IQuestCondition[],
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
): IQuestCondition[]
{
return this.filterConditions(q, "Level", furtherFilter);
}
public getLoyaltyConditions(
q: IQuestCondition[],
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
): IQuestCondition[]
{
return this.filterConditions(q, "TraderLoyalty", furtherFilter);
}
public getStandingConditions(
q: IQuestCondition[],
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
): IQuestCondition[]
{
return this.filterConditions(q, "TraderStanding", furtherFilter);
}
protected filterConditions(
q: IQuestCondition[],
questType: string,
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
): IQuestCondition[]
{
const filteredQuests = q.filter((c) =>
{
if (c.conditionType === questType)
{
if (furtherFilter)
{
return furtherFilter(c);
}
return true;
}
return false;
});
return filteredQuests;
}
}