2023-03-03 16:23:46 +01:00
|
|
|
import { injectable } from "tsyringe";
|
2023-10-19 19:21:17 +02:00
|
|
|
|
2024-01-05 20:52:21 +01:00
|
|
|
import { IQuestCondition } from "@spt-aki/models/eft/common/tables/IQuest";
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class QuestConditionHelper
|
|
|
|
{
|
2023-11-16 02:35:05 +01:00
|
|
|
public getQuestConditions(
|
2024-01-05 20:52:21 +01:00
|
|
|
q: IQuestCondition[],
|
|
|
|
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
|
|
|
|
): IQuestCondition[]
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.filterConditions(q, "Quest", furtherFilter);
|
|
|
|
}
|
|
|
|
|
2023-11-16 02:35:05 +01:00
|
|
|
public getLevelConditions(
|
2024-01-05 20:52:21 +01:00
|
|
|
q: IQuestCondition[],
|
|
|
|
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
|
|
|
|
): IQuestCondition[]
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.filterConditions(q, "Level", furtherFilter);
|
|
|
|
}
|
|
|
|
|
2023-11-16 02:35:05 +01:00
|
|
|
public getLoyaltyConditions(
|
2024-01-05 20:52:21 +01:00
|
|
|
q: IQuestCondition[],
|
|
|
|
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
|
|
|
|
): IQuestCondition[]
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.filterConditions(q, "TraderLoyalty", furtherFilter);
|
|
|
|
}
|
|
|
|
|
2023-11-16 02:35:05 +01:00
|
|
|
public getStandingConditions(
|
2024-01-05 20:52:21 +01:00
|
|
|
q: IQuestCondition[],
|
|
|
|
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
|
|
|
|
): IQuestCondition[]
|
2023-10-10 13:03:20 +02:00
|
|
|
{
|
|
|
|
return this.filterConditions(q, "TraderStanding", furtherFilter);
|
|
|
|
}
|
|
|
|
|
2023-11-16 02:35:05 +01:00
|
|
|
protected filterConditions(
|
2024-01-05 20:52:21 +01:00
|
|
|
q: IQuestCondition[],
|
2023-11-16 02:35:05 +01:00
|
|
|
questType: string,
|
2024-01-05 20:52:21 +01:00
|
|
|
furtherFilter: (a: IQuestCondition) => IQuestCondition[] = null,
|
|
|
|
): IQuestCondition[]
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
2023-11-16 02:35:05 +01:00
|
|
|
const filteredQuests = q.filter((c) =>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
2023-12-27 18:15:38 +01:00
|
|
|
if (c.conditionType === questType)
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
if (furtherFilter)
|
|
|
|
{
|
|
|
|
return furtherFilter(c);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
return filteredQuests;
|
|
|
|
}
|
2023-11-16 02:35:05 +01:00
|
|
|
}
|