Filter out seasonal items from scavcase rewards when not inside seasonal event

This commit is contained in:
Dev 2024-03-07 18:15:42 +00:00
parent f439f5888b
commit b79fc89d11

View File

@ -19,6 +19,7 @@ import { ConfigServer } from "@spt-aki/servers/ConfigServer";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { ItemFilterService } from "@spt-aki/services/ItemFilterService"; import { ItemFilterService } from "@spt-aki/services/ItemFilterService";
import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService";
import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService";
import { HashUtil } from "@spt-aki/utils/HashUtil"; import { HashUtil } from "@spt-aki/utils/HashUtil";
import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { JsonUtil } from "@spt-aki/utils/JsonUtil";
import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil";
@ -42,6 +43,7 @@ export class ScavCaseRewardGenerator
@inject("PresetHelper") protected presetHelper: PresetHelper, @inject("PresetHelper") protected presetHelper: PresetHelper,
@inject("DatabaseServer") protected databaseServer: DatabaseServer, @inject("DatabaseServer") protected databaseServer: DatabaseServer,
@inject("RagfairPriceService") protected ragfairPriceService: RagfairPriceService, @inject("RagfairPriceService") protected ragfairPriceService: RagfairPriceService,
@inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService,
@inject("ItemFilterService") protected itemFilterService: ItemFilterService, @inject("ItemFilterService") protected itemFilterService: ItemFilterService,
@inject("ConfigServer") protected configServer: ConfigServer, @inject("ConfigServer") protected configServer: ConfigServer,
) )
@ -96,6 +98,9 @@ export class ScavCaseRewardGenerator
{ {
if (!this.dbItemsCache) if (!this.dbItemsCache)
{ {
// Get an array of seasonal items that should not be shown right now as seasonal event is not active
const seasonalItems = this.seasonalEventService.getInactiveSeasonalEventItems();
this.dbItemsCache = Object.values(this.databaseServer.getTables().templates.items).filter((item) => this.dbItemsCache = Object.values(this.databaseServer.getTables().templates.items).filter((item) =>
{ {
// Base "Item" item has no parent, ignore it // Base "Item" item has no parent, ignore it
@ -135,6 +140,11 @@ export class ScavCaseRewardGenerator
return false; return false;
} }
if (seasonalItems.includes(item._id))
{
return false;
}
return true; return true;
}); });
} }