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