# Conflicts:
#	Core/Services/BackupService.cs
This commit is contained in:
CWX
2025-01-18 14:16:18 +00:00
5 changed files with 46 additions and 91 deletions
+11 -11
View File
@@ -1,22 +1,22 @@
using Core.Annotations;
using Core.Models.Eft.HttpResponse;
using Core.Annotations;
using Core.Models.Eft.ItemEvent;
using Core.Models.Enums;
using Core.Routers;
using Core.Utils;
namespace Core.Callbacks;
[Injectable]
public class ItemEventCallbacks(HttpResponseUtil _httpResponseUtil) // , ItemEventRouter _itemEventRouter TODO: Implement ItemEventRouter
public class ItemEventCallbacks(HttpResponseUtil _httpResponseUtil, ItemEventRouter _itemEventRouter)
{
public Task<GetBodyResponseData<ItemEventRouterResponse>> HandleEvents(string url, ItemEventRouterRequest info, string sessionID)
public async Task<string> HandleEvents(string url, ItemEventRouterRequest info, string sessionID)
{
// var eventResponse = await _itemEventRouter.HandleEvents(info, sessionID);
// var result = IsCriticalError(ItemEventRouterResponse.Warnings)
// ? _httpResponseUtil.GetBody(eventResponse, GetErrorCode(eventResponse.Warnings), eventResponse.Warnings[0].Errmsg)
// : _httpResponseUtil.GetBody(eventResponse);
// TODO: Implement ItemEventRouter
throw new NotImplementedException();
var eventResponse = await _itemEventRouter.HandleEvents(info, sessionID);
var result = IsCriticalError(eventResponse.Warnings)
? _httpResponseUtil.GetBody(eventResponse, GetErrorCode(eventResponse.Warnings), eventResponse.Warnings[0].ErrorMessage)
: _httpResponseUtil.GetBody(eventResponse);
return result;
}
/// <summary>
@@ -41,7 +41,7 @@ public class ItemEventCallbacks(HttpResponseUtil _httpResponseUtil) // , ItemEve
return false;
}
public int? GetErrorCode(List<Warning> warnings)
public int GetErrorCode(List<Warning> warnings)
{
return int.Parse((warnings[0].Code is null
? BackendErrorCodes.UNKNOWN_ERROR.ToString()
+26 -70
View File
@@ -18,82 +18,38 @@ using Core.Utils.Cloners;
namespace Core.Controllers;
[Injectable]
public class BotController
{
protected ISptLogger<BotController> _logger;
protected DatabaseService _databaseService;
protected BotGenerator _botGenerator;
protected BotHelper _botHelper;
protected BotDifficultyHelper _botDifficultyHelper;
protected WeightedRandomHelper _weightedRandomHelper;
protected BotGenerationCacheService _botGenerationCacheService;
protected MatchBotDeatilsCacheService _matchBotDeatilsCacheService;
protected LocalisationService _localisationService;
protected SeasonalEventService _seasonalEventService;
protected MatchBotDetailsCacheService _matchBotDetailsCacheService;
protected ProfileHelper _profileHelper;
protected ConfigServer _configServer;
protected ApplicationContext _applicationContext;
protected RandomUtil _randomUtil;
protected ICloner _cloner;
protected BotConfig _botConfig;
protected PmcConfig _pmcConfig;
public BotController
(
ISptLogger<BotController> logger,
DatabaseService databaseService,
BotGenerator botGenerator,
BotHelper botHelper,
BotDifficultyHelper botDifficultyHelper,
WeightedRandomHelper weightedRandomHelper,
BotGenerationCacheService botGenerationCacheService,
MatchBotDeatilsCacheService matchBotDeatilsCacheService,
LocalisationService localisationService,
SeasonalEventService seasonalEventService,
MatchBotDetailsCacheService matchBotDetailsCacheService,
ProfileHelper profileHelper,
ConfigServer configServer,
ApplicationContext applicationContext,
RandomUtil randomUtil,
ICloner cloner
public class BotController(
ISptLogger<BotController> _logger,
DatabaseService _databaseService,
BotGenerator _botGenerator,
BotHelper _botHelper,
BotDifficultyHelper _botDifficultyHelper,
WeightedRandomHelper _weightedRandomHelper,
BotGenerationCacheService _botGenerationCacheService,
MatchBotDeatilsCacheService _matchBotDeatilsCacheService,
LocalisationService _localisationService,
SeasonalEventService _seasonalEventService,
MatchBotDetailsCacheService _matchBotDetailsCacheService,
ProfileHelper _profileHelper,
ConfigServer _configServer,
ApplicationContext _applicationContext,
RandomUtil _randomUtil,
ICloner _cloner
)
{
_logger = logger;
_databaseService = databaseService;
_botGenerator = botGenerator;
_botHelper = botHelper;
_botDifficultyHelper = botDifficultyHelper;
_weightedRandomHelper = weightedRandomHelper;
_botGenerationCacheService = botGenerationCacheService;
_matchBotDeatilsCacheService = matchBotDeatilsCacheService;
_localisationService = localisationService;
_seasonalEventService = seasonalEventService;
_matchBotDetailsCacheService = matchBotDetailsCacheService;
_profileHelper = profileHelper;
_configServer = configServer;
_applicationContext = applicationContext;
_randomUtil = randomUtil;
_cloner = cloner;
_botConfig = _configServer.GetConfig<BotConfig>();
_pmcConfig = _configServer.GetConfig<PmcConfig>();
}
{
private readonly BotConfig _botConfig = _configServer.GetConfig<BotConfig>();
private readonly PmcConfig _pmcConfig = _configServer.GetConfig<PmcConfig>();
public int GetBotPresetGenerationLimit(string type)
public int? GetBotPresetGenerationLimit(string type)
{
var typeInLower = type.ToLower();
var value = (int)typeof(PresetBatch).GetProperties().First(p => p.Name.ToLower() == (typeInLower == "assaultgroup" ? "assault" : typeInLower))
var value = (int?)typeof(PresetBatch).GetProperties().First(p => p.Name.ToLower() == (typeInLower == "assaultgroup" ? "assault" : typeInLower))
.GetValue(_botConfig.PresetBatch);
if (value == null)
{
_logger.Warning(_localisationService.GetText("bot-bot_preset_count_value_missing", type));
return 30;
}
return value;
if (value != null) return value;
_logger.Warning(_localisationService.GetText("bot-bot_preset_count_value_missing", type));
return 30;
}
public Dictionary<string, object> GetBotCoreDifficulty()
@@ -22,15 +22,15 @@ public class HealthItemEventRouter : ItemEventRouterDefinition
protected override List<HandledRoute> GetHandledRoutes()
{
return new()
{
return
[
new HandledRoute("Eat", false),
new HandledRoute("Heal", false),
new HandledRoute("RestoreHealth", false)
};
];
}
public override Task<ItemEventRouterResponse>? HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output)
public override Task<ItemEventRouterResponse> HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output)
{
switch (url)
{
@@ -22,8 +22,8 @@ public class HideoutItemEventRouter : ItemEventRouterDefinition
protected override List<HandledRoute> GetHandledRoutes()
{
return new()
{
return
[
new HandledRoute(HideoutEventActions.HIDEOUT_UPGRADE, false),
new HandledRoute(HideoutEventActions.HIDEOUT_UPGRADE_COMPLETE, false),
new HandledRoute(HideoutEventActions.HIDEOUT_PUT_ITEMS_IN_AREA_SLOTS, false),
@@ -40,7 +40,7 @@ public class HideoutItemEventRouter : ItemEventRouterDefinition
new HandledRoute(HideoutEventActions.HIDEOUT_DELETE_PRODUCTION_COMMAND, false),
new HandledRoute(HideoutEventActions.HIDEOUT_CUSTOMIZATION_APPLY_COMMAND, false),
new HandledRoute(HideoutEventActions.HIDEOUT_CUSTOMIZATION_SET_MANNEQUIN_POSE, false)
};
];
}
public override Task<ItemEventRouterResponse> HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output)
+2 -3
View File
@@ -1,4 +1,4 @@
using Core.Annotations;
using Core.Annotations;
namespace Core.Services;
@@ -15,8 +15,7 @@ public class BackupService
*/
public async Task InitAsync()
{
Console.WriteLine("NEEDS IMPLEMENTING: BackupService");
return;
// TODO implement
}
/**