From 7ece60ac54007572c3fccdd6338e332de41773fe Mon Sep 17 00:00:00 2001 From: Chomp Date: Wed, 6 Aug 2025 12:35:02 +0100 Subject: [PATCH] Improved logic --- .../Helpers/RewardHelper.cs | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs index d2535099..34f4d9b8 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs @@ -250,30 +250,18 @@ public class RewardHelper( /// Hideout crafts that match input parameters protected List GetMatchingProductions(HideoutAreas desiredHideoutAreaType, MongoId questId, Reward craftUnlockReward) { - var craftingRecipes = databaseService.GetHideout().Production.Recipes; - - // Some crafts have the quest id stored in their requirements, check for that first - var matchingCraft = craftingRecipes.FirstOrDefault(craft => craft.Requirements.Any(requirement => requirement.QuestId == questId)); - if (matchingCraft is not null) - { - return [matchingCraft]; - } - var rewardItemTpl = craftUnlockReward.Items.FirstOrDefault()?.Template; - if (rewardItemTpl is null) - { - return []; - } + var craftingRecipes = databaseService.GetHideout().Production.Recipes; return craftingRecipes .Where(production => - // Primary condition: A requirement explicitly references the quest ID. + // Some crafts have the questId, easy match production.Requirements.Any(req => req.QuestId == questId) || - // Fallback condition: Infer the match from reward and area details. - // This part only runs if the primary condition is false and a reward item exists. + // Couldn't get craft by questId, get the closest match based on information we know ( - production.AreaType == desiredHideoutAreaType + rewardItemTpl is not null + && production.AreaType == desiredHideoutAreaType && production.EndProduct == rewardItemTpl.Value && production.Requirements.Any(req => req.Type is "QuestComplete") && production.Requirements.Any(req => req.RequiredLevel == craftUnlockReward.LoyaltyLevel)