Server/project/src/helpers/QuestConditionHelper.ts
Alex 173a726f33 Removed all null references in favor of undefined (!354)
Co-authored-by: clodan <clodan@clodan.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/354
Co-authored-by: Alex <clodan@noreply.dev.sp-tarkov.com>
Co-committed-by: Alex <clodan@noreply.dev.sp-tarkov.com>
2024-05-27 20:06:07 +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[],
): IQuestCondition[]
{
return this.filterConditions(q, "Quest", furtherFilter);
}
public getLevelConditions(
q: IQuestCondition[],
furtherFilter?: (a: IQuestCondition) => IQuestCondition[],
): IQuestCondition[]
{
return this.filterConditions(q, "Level", furtherFilter);
}
public getLoyaltyConditions(
q: IQuestCondition[],
furtherFilter?: (a: IQuestCondition) => IQuestCondition[],
): IQuestCondition[]
{
return this.filterConditions(q, "TraderLoyalty", furtherFilter);
}
public getStandingConditions(
q: IQuestCondition[],
furtherFilter?: (a: IQuestCondition) => IQuestCondition[],
): IQuestCondition[]
{
return this.filterConditions(q, "TraderStanding", furtherFilter);
}
protected filterConditions(
q: IQuestCondition[],
questType: string,
furtherFilter?: (a: IQuestCondition) => IQuestCondition[],
): IQuestCondition[]
{
const filteredQuests = q.filter((c) =>
{
if (c.conditionType === questType)
{
if (furtherFilter)
{
return furtherFilter(c);
}
return true;
}
return false;
});
return filteredQuests;
}
}