d13e86ba46
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>
61 lines
1.6 KiB
TypeScript
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;
|
|
}
|
|
}
|