Improved readability of GetRelativePmcBotLevelRange

This commit is contained in:
Chomp
2025-07-24 18:16:13 +01:00
parent a886575cff
commit 1f6231ce6b
2 changed files with 9 additions and 13 deletions
@@ -81,6 +81,7 @@ public class BotLevelGenerator(
)
{
var levelOverride = botGenerationDetails.LocationSpecificPmcLevelOverride;
var playerLevel = botGenerationDetails.PlayerLevel ?? 1;
// Create a min limit PMCs level cannot fall below
var minPossibleLevel = levelOverride is not null
@@ -95,19 +96,14 @@ public class BotLevelGenerator(
? Math.Min(levelOverride.Max, maxAvailableLevel) // Is PMC and have a level override
: Math.Min(levelDetails.Max, maxAvailableLevel); // Not pmc with override or non-pmc
// Get min level relative to player if value exists
var minLevel = botGenerationDetails.PlayerLevel.HasValue
? botGenerationDetails.PlayerLevel.Value
- botGenerationDetails.BotRelativeLevelDeltaMin.Value
: 1 - botGenerationDetails.BotRelativeLevelDeltaMin.Value;
// Get min level relative to player level
// May be negative, is clamped to 1 below
var minLevel = playerLevel - botGenerationDetails.BotRelativeLevelDeltaMin;
// Get max level relative to player if value exists
var maxLevel = botGenerationDetails.PlayerLevel.HasValue
? botGenerationDetails.PlayerLevel.Value
+ botGenerationDetails.BotRelativeLevelDeltaMax.Value
: 1 + botGenerationDetails.BotRelativeLevelDeltaMin.Value;
// Get max level relative to player level
var maxLevel = playerLevel + botGenerationDetails.BotRelativeLevelDeltaMax;
// Bound the level to the min/max possible
// Clamp the level to the min/max possible
maxLevel = Math.Clamp(maxLevel, minPossibleLevel, maxPossibleLevel);
minLevel = Math.Clamp(minLevel, minPossibleLevel, maxPossibleLevel);
@@ -45,13 +45,13 @@ public record BotGenerationDetails
/// Delta of highest level of bot e.g. 50 means 50 levels above player
/// </summary>
[JsonPropertyName("botRelativeLevelDeltaMax")]
public int? BotRelativeLevelDeltaMax { get; set; }
public int BotRelativeLevelDeltaMax { get; set; }
/// <summary>
/// Delta of lowest level of bot e.g. 50 means 50 levels below player
/// </summary>
[JsonPropertyName("botRelativeLevelDeltaMin")]
public int? BotRelativeLevelDeltaMin { get; set; }
public int BotRelativeLevelDeltaMin { get; set; }
/// <summary>
/// How many to create and store