Add missing validation checks to ammo cache generation for scav case

This commit is contained in:
Dev 2024-04-16 16:05:33 +01:00
parent d609d4b41a
commit f50a400cde

View File

@ -96,11 +96,12 @@ export class ScavCaseRewardGenerator
*/
protected cacheDbItems(): void
{
// TODO: pre-loop and get array of valid items, e.g. non-node/non-blacklisted, then loop over those results for below code
// Get an array of seasonal items that should not be shown right now as seasonal event is not active
const inactiveSeasonalItems = this.seasonalEventService.getInactiveSeasonalEventItems();
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) =>
{
// Base "Item" item has no parent, ignore it
@ -129,7 +130,7 @@ export class ScavCaseRewardGenerator
return false;
}
// Globally blacklisted
// Globally reward-blacklisted
if (this.itemFilterService.isItemRewardBlacklisted(item._id))
{
return false;
@ -146,7 +147,7 @@ export class ScavCaseRewardGenerator
return false;
}
if (seasonalItems.includes(item._id))
if (inactiveSeasonalItems.includes(item._id))
{
return false;
}
@ -176,6 +177,32 @@ export class ScavCaseRewardGenerator
return false;
}
// Skip item if item id is on blacklist
if (
this.scavCaseConfig.rewardItemBlacklist.includes(item._id)
|| this.itemFilterService.isItemBlacklisted(item._id)
)
{
return false;
}
// Globally reward-blacklisted
if (this.itemFilterService.isItemRewardBlacklisted(item._id))
{
return false;
}
if (!this.scavCaseConfig.allowBossItemsAsRewards && this.itemFilterService.isBossItem(item._id))
{
return false;
}
// Skip seasonal items
if (inactiveSeasonalItems.includes(item._id))
{
return false;
}
// Skip ammo that doesn't stack as high as value in config
if (item._props.StackMaxSize < this.scavCaseConfig.ammoRewards.minStackSize)
{