From 93a227416557d20fe0d704f7b332f112040f4f50 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 25 Jan 2025 23:04:55 +0000 Subject: [PATCH] Fixed botgen failing when no raid settings are found --- Libraries/Core/Controllers/BotController.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Libraries/Core/Controllers/BotController.cs b/Libraries/Core/Controllers/BotController.cs index 8753a0c1..220fb5a7 100644 --- a/Libraries/Core/Controllers/BotController.cs +++ b/Libraries/Core/Controllers/BotController.cs @@ -227,12 +227,6 @@ public class BotController( var requestedBot = request.Conditions?.FirstOrDefault(); var raidSettings = GetMostRecentRaidSettings(); - - if (raidSettings is null) - { - _logger.Error($"Unable to get raid settings for session {sessionId}"); - return []; - } // Create generation request for when cache is empty var condition = new GenerateCondition @@ -264,7 +258,7 @@ public class BotController( // Does non pmc bot have a chance of being converted into a pmc var convertIntoPmcChanceMinMax = GetPmcConversionMinMaxForLocation( requestedBot?.Role, - raidSettings.Location + raidSettings?.Location ); if (convertIntoPmcChanceMinMax is not null && !botGenerationDetails.IsPmc.GetValueOrDefault(false)) { @@ -354,10 +348,9 @@ public class BotController( private MinMax? GetPmcConversionMinMaxForLocation(string? requestedBotRole, string? location) { - var mapSpecificConversionValues = _pmcConfig.ConvertIntoPmcChance!.GetValueOrDefault(location?.ToLower(), null); - return mapSpecificConversionValues is null - ? _pmcConfig.ConvertIntoPmcChance.GetValueOrDefault("default")?.GetValueOrDefault(requestedBotRole) - : mapSpecificConversionValues.GetByJsonProp(requestedBotRole?.ToLower()); + return _pmcConfig.ConvertIntoPmcChance!.TryGetValue(location?.ToLower() ?? "", out var mapSpecificConversionValues) + ? mapSpecificConversionValues.GetByJsonProp(requestedBotRole?.ToLower()) + : _pmcConfig.ConvertIntoPmcChance.GetValueOrDefault("default")?.GetValueOrDefault(requestedBotRole); } private GetRaidConfigurationRequestData? GetMostRecentRaidSettings()