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