Implemented getAllBotDifficulties
This commit is contained in:
@@ -105,7 +105,7 @@ public class BotController
|
||||
{
|
||||
var difficulty = diffLevel.ToLower();
|
||||
|
||||
if (!(raidConfig != null || ignoreRaidSettings)) // TODD: this might be wrong logic
|
||||
if (!(raidConfig != null || ignoreRaidSettings))
|
||||
_logger.Error(_localisationService.GetText("bot-missing_application_context", "RAID_CONFIGURATION"));
|
||||
|
||||
// Check value chosen in pre-raid difficulty dropdown
|
||||
@@ -118,12 +118,46 @@ public class BotController
|
||||
return _botDifficultyHelper.GetBotDifficultySettings(type, difficulty, botDb);
|
||||
}
|
||||
|
||||
public Dictionary<string, object> GetAllBotDifficulties()
|
||||
public Dictionary<string, Dictionary<string, DifficultyCategories>> GetAllBotDifficulties()
|
||||
{
|
||||
var result = new Dictionary<string, object>();
|
||||
var result = new Dictionary<string, Dictionary<string, DifficultyCategories>>();
|
||||
|
||||
var botTypesDb = _databaseService.GetBots().Types;
|
||||
// TODO: Come back to this, brainfuck
|
||||
//Get all bot types as sting array
|
||||
var botTypes = Enum.GetValues<WildSpawnType>().Select(item => item.ToString()).ToList();
|
||||
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();
|
||||
|
||||
// Get details from db
|
||||
if (!botTypesDb.TryGetValue(botTypeLower, out var botDetails))
|
||||
{
|
||||
// No bot of this type found, skip
|
||||
continue;
|
||||
};
|
||||
|
||||
if (botDetails.BotDifficulty is null)
|
||||
{
|
||||
// Bot has no difficulty values, skip
|
||||
continue;
|
||||
}
|
||||
|
||||
var botNameKey = botType.ToLower();
|
||||
foreach (var (difficultyName, difficultyValues) in botDetails.BotDifficulty)
|
||||
{
|
||||
// Bot doesnt exist in result, add
|
||||
if (!result.ContainsKey(botNameKey))
|
||||
{
|
||||
result.TryAdd(botNameKey, new Dictionary<string, DifficultyCategories>());
|
||||
}
|
||||
|
||||
// Store all difficulty values in dict keyed by difficulty type e.g. easy/normal/impossible
|
||||
result[botNameKey].Add(difficultyName, GetBotDifficulty(botNameKey, difficultyName, null, true));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,74 @@
|
||||
using Core.Annotations;
|
||||
using Core.Helpers;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
using Core.Models.Eft.Insurance;
|
||||
using Core.Models.Spt.Config;
|
||||
using Core.Models.Utils;
|
||||
using Core.Servers;
|
||||
using Core.Services;
|
||||
|
||||
namespace Core.Controllers;
|
||||
|
||||
[Injectable]
|
||||
public class InsuranceController
|
||||
{
|
||||
// TODO
|
||||
private readonly ISptLogger<InsuranceController> _logger;
|
||||
private readonly ProfileHelper _profileHelper;
|
||||
private readonly InsuranceService _insuranceService;
|
||||
private readonly ConfigServer _configServer;
|
||||
private readonly InsuranceConfig _insuranceConfig;
|
||||
|
||||
public InsuranceController(
|
||||
ISptLogger<InsuranceController> logger,
|
||||
ProfileHelper profileHelper,
|
||||
InsuranceService insuranceService,
|
||||
ConfigServer configServer
|
||||
)
|
||||
{
|
||||
_logger = logger;
|
||||
_profileHelper = profileHelper;
|
||||
_insuranceService = insuranceService;
|
||||
_configServer = configServer;
|
||||
|
||||
_insuranceConfig = _configServer.GetConfig<InsuranceConfig>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle client/insurance/items/list/cost
|
||||
* Calculate insurance cost
|
||||
*
|
||||
* @param request request object
|
||||
* @param sessionID session id
|
||||
* @returns IGetInsuranceCostResponseData object to send to client
|
||||
*/
|
||||
public GetInsuranceCostResponseData Cost(GetInsuranceCostRequestData request, string sessionId)
|
||||
{
|
||||
var response = new GetInsuranceCostResponseData();
|
||||
var pmcData = _profileHelper.GetPmcProfile(sessionId);
|
||||
var inventoryItemsHash = new Dictionary<string, Item>();
|
||||
|
||||
foreach (var item in pmcData.Inventory.Items) {
|
||||
inventoryItemsHash[item.Id] = item;
|
||||
}
|
||||
|
||||
// Loop over each trader in request
|
||||
foreach(var trader in request.Traders)
|
||||
{
|
||||
var items = new Dictionary<string, double>();
|
||||
|
||||
foreach (var itemId in request.Items) {
|
||||
// Ensure hash has item in it
|
||||
if (!inventoryItemsHash.ContainsKey(itemId))
|
||||
{
|
||||
_logger.Debug("Item with id: ${ itemId} missing from player inventory, skipping");
|
||||
continue;
|
||||
}
|
||||
items[inventoryItemsHash[itemId].Template] = _insuranceService.GetRoublePriceToInsureItemWithTrader(pmcData, inventoryItemsHash[itemId], trader);
|
||||
}
|
||||
|
||||
response[trader] = items;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user