Updated loot generator to block seasonal items when out of season

This commit is contained in:
Chomp
2025-02-14 17:33:29 +00:00
parent 2345015bdb
commit 3b1f8c81ef
6 changed files with 56 additions and 14 deletions
+16 -8
View File
@@ -27,6 +27,7 @@ public class LootGenerator(
LocalisationService _localisationService,
WeightedRandomHelper _weightedRandomHelper,
RagfairLinkedItemService _ragfairLinkedItemService,
SeasonalEventService _seasonalEventService,
ICloner _cloner
)
{
@@ -78,7 +79,8 @@ public class LootGenerator(
options.ItemBlacklist,
options.ItemTypeWhitelist,
options.UseRewardItemBlacklist.GetValueOrDefault(false),
options.AllowBossItems.GetValueOrDefault(false)
options.AllowBossItems.GetValueOrDefault(false),
options.BlockSeasonalItemsOutOfSeason.GetValueOrDefault(false)
);
// Pool has items we could add as loot, proceed
@@ -214,10 +216,14 @@ public class LootGenerator(
/// <param name="itemTypeWhitelist">Only allow these items</param>
/// <param name="useRewardItemBlacklist">Should item.json reward item config be used</param>
/// <param name="allowBossItems">Should boss items be allowed in result</param>
/// <param name="blockSeasonalItemsOutOfSeason">Prevent seasonal items appearing outside their defined season</param>
/// <returns>results of filtering + blacklist used</returns>
protected ItemRewardPoolResults GetItemRewardPool(List<string> itemTplBlacklist, List<string> itemTypeWhitelist,
protected ItemRewardPoolResults GetItemRewardPool(
List<string> itemTplBlacklist,
List<string> itemTypeWhitelist,
bool useRewardItemBlacklist,
bool allowBossItems)
bool allowBossItems,
bool blockSeasonalItemsOutOfSeason)
{
var itemsDb = _databaseService.GetItems().Values;
var itemBlacklist = new HashSet<string>();
@@ -243,10 +249,12 @@ public class LootGenerator(
if (!allowBossItems)
{
foreach (var bossItem in _itemFilterService.GetBossItems())
{
itemBlacklist.Add(bossItem);
}
itemBlacklist.UnionWith(_itemFilterService.GetBossItems());
}
if (blockSeasonalItemsOutOfSeason)
{
itemBlacklist.UnionWith(_seasonalEventService.GetInactiveSeasonalEventItems());
}
var items = itemsDb.Where(
@@ -748,7 +756,7 @@ public class LootGenerator(
}
return _randomUtil.GetArrayValue(
GetItemRewardPool([], rewardContainerDetails.RewardTypePool, true, true)
GetItemRewardPool([], rewardContainerDetails.RewardTypePool, true, true, false)
.ItemPool.Select(
item => item.Id
)
@@ -226,4 +226,18 @@ public record AirdropLoot
get;
set;
}
[JsonPropertyName("useRewardItemBlacklist")]
public bool? UseRewardItemBlacklist
{
get;
set;
}
[JsonPropertyName("blockSeasonalItemsOutOfSeason")]
public bool? BlockSeasonalItemsOutOfSeason
{
get;
set;
}
}
@@ -132,6 +132,13 @@ public record LootRequest
get;
set;
}
[JsonPropertyName("blockSeasonalItemsOutOfSeason")]
public bool? BlockSeasonalItemsOutOfSeason
{
get;
set;
}
}
public record AirdropLootRequest : LootRequest
+3 -1
View File
@@ -192,7 +192,9 @@ public class AirdropService(
ArmorLevelWhitelist = lootSettingsByType.ArmorLevelWhitelist,
AllowBossItems = lootSettingsByType.AllowBossItems,
UseForcedLoot = lootSettingsByType.UseForcedLoot,
ForcedLoot = lootSettingsByType.ForcedLoot
ForcedLoot = lootSettingsByType.ForcedLoot,
UseRewardItemBlacklist = lootSettingsByType.UseRewardItemBlacklist,
BlockSeasonalItemsOutOfSeason = lootSettingsByType.BlockSeasonalItemsOutOfSeason
};
}
}
@@ -107,7 +107,9 @@
}
},
"armorLevelWhitelist": [0, 4, 5, 6],
"allowBossItems": false
"allowBossItems": false,
"useRewardItemBlacklist": true,
"blockSeasonalItemsOutOfSeason": true
},
"weaponArmor": {
"icon": "Weapon",
@@ -180,7 +182,9 @@
}
},
"armorLevelWhitelist": [0, 3, 4, 5, 6],
"allowBossItems": false
"allowBossItems": false,
"useRewardItemBlacklist": true,
"blockSeasonalItemsOutOfSeason": true
},
"foodMedical": {
"icon": "Medical",
@@ -261,7 +265,9 @@
}
},
"armorLevelWhitelist": [0],
"allowBossItems": false
"allowBossItems": false,
"useRewardItemBlacklist": true,
"blockSeasonalItemsOutOfSeason": true
},
"barter": {
"icon": "Supply",
@@ -343,7 +349,9 @@
}
},
"armorLevelWhitelist": [0],
"allowBossItems": false
"allowBossItems": false,
"useRewardItemBlacklist": true,
"blockSeasonalItemsOutOfSeason": true
},
"radar": {
"icon": "Supply",
@@ -369,6 +377,8 @@
"itemStackLimits": {},
"armorLevelWhitelist": [],
"allowBossItems": false,
"useRewardItemBlacklist": true,
"blockSeasonalItemsOutOfSeason": true,
"useForcedLoot": true,
"forcedLoot": {
"66d9f7256916142b3b02276e": { "min": 2, "max": 4 }
@@ -437,7 +437,8 @@
}
},
"allowBossItems": false,
"useRewardItemBlacklist": true
"useRewardItemBlacklist": true,
"blockSeasonalItemsOutOfSeason": true
},
"btrDeliveryExpireHours": 240,
"playerRepMin": -7,