diff --git a/Libraries/Core/Helpers/DurabilityLimitsHelper.cs b/Libraries/Core/Helpers/DurabilityLimitsHelper.cs
index 69545ac8..a5b0996b 100644
--- a/Libraries/Core/Helpers/DurabilityLimitsHelper.cs
+++ b/Libraries/Core/Helpers/DurabilityLimitsHelper.cs
@@ -25,30 +25,9 @@ public class DurabilityLimitsHelper(
/// Max durability of weapon
public double GetRandomizedMaxWeaponDurability(TemplateItem itemTemplate, string? botRole = null)
{
- if (botRole is not null)
- {
- if (_botHelper.IsBotPmc(botRole))
- {
- return GenerateMaxWeaponDurability("pmc");
- }
+ var durabilityRole = GetDurabilityRole(botRole);
- if (_botHelper.IsBotBoss(botRole))
- {
- return GenerateMaxWeaponDurability("boss");
- }
-
- if (_botHelper.IsBotFollower(botRole))
- {
- return GenerateMaxWeaponDurability("follower");
- }
- }
-
- var roleExistsInConfig = _botConfig.Durability.BotDurabilities.ContainsKey(botRole);
- if (!roleExistsInConfig)
- {
- _logger.Warning($"{botRole} doesn't exist in bot config durability values, using default fallback");
- }
- return GenerateMaxWeaponDurability(roleExistsInConfig ? botRole : "default");
+ return GenerateMaxWeaponDurability(durabilityRole);
}
///
@@ -91,30 +70,47 @@ public class DurabilityLimitsHelper(
/// Current weapon durability
public double GetRandomizedWeaponDurability(TemplateItem itemTemplate, string? botRole, double maxDurability)
{
- if (botRole is not null)
+ var durabilityRole = GetDurabilityRole(botRole);
+
+ return GenerateWeaponDurability(durabilityRole, maxDurability);
+ }
+
+ ///
+ /// Convert a botrole into a durability role used for looking up durability values with
+ ///
+ /// Role to convert
+ ///
+ private string GetDurabilityRole(string? botRole)
+ {
+ if (botRole is null)
{
- if (_botHelper.IsBotPmc(botRole))
- {
- return GenerateWeaponDurability("pmc", maxDurability);
- }
+ return "default";
+ }
- if (_botHelper.IsBotBoss(botRole))
- {
- return GenerateWeaponDurability("boss", maxDurability);
- }
+ if (_botHelper.IsBotPmc(botRole))
+ {
+ return "pmc";
+ }
- if (_botHelper.IsBotFollower(botRole))
- {
- return GenerateWeaponDurability("follower", maxDurability);
- }
+ if (_botHelper.IsBotBoss(botRole))
+ {
+ return "boss";
+ }
+
+ if (_botHelper.IsBotFollower(botRole))
+ {
+ return "follower";
}
var roleExistsInConfig = _botConfig.Durability.BotDurabilities.ContainsKey(botRole);
if (!roleExistsInConfig)
{
_logger.Warning($"{botRole} doesn't exist in bot config durability values, using default fallback");
+
+ return "default";
}
- return GenerateWeaponDurability(roleExistsInConfig ? botRole : "default", maxDurability);
+
+ return botRole;
}
///