Updated GetAllBotDifficulties to iterate over enum instead of strings
This commit is contained in:
@@ -132,13 +132,13 @@ public class BotController(
|
||||
return result;
|
||||
}
|
||||
//Get all bot types as sting array
|
||||
var botTypes = Enum.GetValues<WildSpawnType>().Select(item => item.ToString()).ToList();
|
||||
var botTypes = Enum.GetValues<WildSpawnType>();
|
||||
foreach (var botType in botTypes)
|
||||
{
|
||||
// If bot is usec/bear, swap to different name
|
||||
var botTypeLower = _botHelper.IsBotPmc(botType)
|
||||
? _botHelper.GetPmcSideByRole(botType).ToLower()
|
||||
: botType.ToLower();
|
||||
: nameof(botType).ToLower();
|
||||
|
||||
// Get details from db
|
||||
if (!botTypesDb.TryGetValue(botTypeLower, out var botDetails))
|
||||
@@ -148,7 +148,7 @@ public class BotController(
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Unable to find bot: {botTypeLower} in db, copying '{Roles.Assault}'"
|
||||
$"Unable to find bot: {botTypeLower} in db, copying: '{Roles.Assault}'"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class BotController(
|
||||
continue;
|
||||
}
|
||||
|
||||
var botNameKey = botType.ToLower();
|
||||
var botNameKey = nameof(botType).ToLower();
|
||||
foreach (var (difficultyName, _) in botDetails.BotDifficulty)
|
||||
{
|
||||
// Bot doesn't exist in result, add
|
||||
@@ -173,7 +173,7 @@ public class BotController(
|
||||
result.TryAdd(botNameKey, new Dictionary<string, DifficultyCategories>());
|
||||
}
|
||||
|
||||
// Store all difficulty values in dict keyed by difficulty type e.g. easy/normal/impossible
|
||||
// Store all difficulty values in dict keyed by difficulty type e.g. easy/normal/hard/impossible
|
||||
result[botNameKey]
|
||||
.Add(
|
||||
difficultyName,
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Frozen;
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Constants;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Models.Spt.Config;
|
||||
using SPTarkov.Server.Core.Models.Utils;
|
||||
@@ -58,6 +59,16 @@ public class BotHelper(
|
||||
return _pmcTypeIds.Contains(botRole?.ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the passed in bot role a PMC (USEC/Bear/PMC)
|
||||
/// </summary>
|
||||
/// <param name="botRole">bot role to check</param>
|
||||
/// <returns>true if is pmc</returns>
|
||||
public bool IsBotPmc(WildSpawnType botRole)
|
||||
{
|
||||
return botRole is WildSpawnType.pmcBEAR or WildSpawnType.pmcUSEC;
|
||||
}
|
||||
|
||||
public bool IsBotBoss(string botRole)
|
||||
{
|
||||
return !IsBotFollower(botRole)
|
||||
@@ -193,6 +204,24 @@ public class BotHelper(
|
||||
return GetRandomizedPmcSide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the corresponding side when pmcBEAR or pmcUSEC is passed in
|
||||
/// </summary>
|
||||
/// <param name="botRole">role to get side for</param>
|
||||
/// <returns>side (usec/bear)</returns>
|
||||
public string GetPmcSideByRole(WildSpawnType botRole)
|
||||
{
|
||||
switch (botRole)
|
||||
{
|
||||
case WildSpawnType.pmcBEAR:
|
||||
return Sides.Bear;
|
||||
case WildSpawnType.pmcUSEC:
|
||||
return Sides.Usec;
|
||||
default:
|
||||
return GetRandomizedPmcSide();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a randomized PMC side based on bot config value 'isUsec'
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user