Implement most of the callbacks, few other changes too

This commit is contained in:
CWX
2025-01-11 17:14:56 +00:00
parent ba78a15613
commit 8f22759ec5
44 changed files with 1601 additions and 494 deletions
+31 -5
View File
@@ -1,20 +1,46 @@
using Core.Models.Eft.Profile;
using Core.Annotations;
using Core.Models.Eft.Profile;
using Core.Services;
namespace Core.Controllers;
[Injectable]
public class AchievementController
{
public AchievementController()
protected Core.Models.Utils.ILogger _logger;
protected DatabaseService _databaseService;
public AchievementController
(
Core.Models.Utils.ILogger logger,
DatabaseService databaseService
)
{
_logger = logger;
_databaseService = databaseService;
}
public GetAchievementsResponse GetAchievements(string sessionID)
{
throw new NotImplementedException();
return new()
{
Achievements = _databaseService.GetAchievements()
};
}
public CompletedAchievementsResponse GetAchievementStatics(string sessionID)
{
throw new NotImplementedException();
var achievements = _databaseService.GetAchievements();
var stats = new Dictionary<string, int>();
foreach (var achievement in achievements)
{
stats.Add(achievement.Id, 0);
}
return new()
{
Elements = stats
};
}
}
}
+99 -12
View File
@@ -1,44 +1,131 @@
using Core.Models.Common;
using Core.Context;
using Core.Generators;
using Core.Helpers;
using Core.Models.Common;
using Core.Models.Eft.Bot;
using Core.Models.Eft.Common;
using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.Match;
using Core.Models.Enums;
using Core.Models.Spt.Bots;
using Core.Models.Spt.Config;
using Core.Servers;
using Core.Services;
using Core.Utils;
using Core.Utils.Cloners;
using Condition = Core.Models.Spt.Config.Condition;
using ILogger = Core.Models.Utils.ILogger;
namespace Core.Controllers;
public class BotController
{
private BotConfig _botConfig;
private PmcConfig _pmcConfig;
protected ILogger _logger;
public BotController()
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 ProfileHelper _profileHelper;
protected ConfigServer _configServer;
protected ApplicationContext _applicationContext;
protected RandomUtil _randomUtil;
protected ICloner _cloner;
protected BotConfig _botConfig;
protected PmcConfig _pmcConfig;
public BotController
(
ILogger logger,
DatabaseService databaseService,
BotGenerator botGenerator,
BotHelper botHelper,
BotDifficultyHelper botDifficultyHelper,
WeightedRandomHelper weightedRandomHelper,
BotGenerationCacheService botGenerationCacheService,
MatchBotDeatilsCacheService matchBotDeatilsCacheService,
LocalisationService localisationService,
SeasonalEventService seasonalEventService,
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;
_profileHelper = profileHelper;
_configServer = configServer;
_applicationContext = applicationContext;
_randomUtil = randomUtil;
_cloner = cloner;
_botConfig = _configServer.GetConfig<BotConfig>(ConfigTypes.BOT);
_pmcConfig = _configServer.GetConfig<PmcConfig>(ConfigTypes.PMC);
}
public int GetBotPresetGenerationLimit(string type)
{
throw new NotImplementedException();
var typeInLower = type.ToLower();
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;
}
public Dictionary<string, object> GetBotCoreDifficulty()
{
throw new NotImplementedException();
return _databaseService.GetBots().Core;
}
public object GetBotDifficulty(string type, string difficulty) // TODO: return type was: IBotCore | IDifficultyCategories
public DifficultyCategories GetBotDifficulty(string type, string diffLevel, GetRaidConfigurationRequestData raidConfig, bool ignoreRaidSettings = false)
{
throw new NotImplementedException();
var difficulty = diffLevel.ToLower();
if (!(raidConfig != null || ignoreRaidSettings)) // TODD: this might be wrong logic
_logger.Error(_localisationService.GetText("bot-missing_application_context", "RAID_CONFIGURATION"));
// Check value chosen in pre-raid difficulty dropdown
// If value is not 'asonline', change requested difficulty to be what was chosen in dropdown
var botDifficultyDropDownValue = raidConfig?.WavesSettings?.BotDifficulty?.ToString().ToLower() ?? "asonline";
if (botDifficultyDropDownValue != "asonline")
difficulty = _botDifficultyHelper.ConvertBotDifficultyDropdownToBotDifficulty(botDifficultyDropDownValue);
var botDb = _databaseService.GetBots();
return _botDifficultyHelper.GetBotDifficultySettings(type, difficulty, botDb);
}
public Dictionary<string, object> GetAllBotDifficulties()
{
throw new NotImplementedException();
var result = new Dictionary<string, object>();
var botTypesDb = _databaseService.GetBots().Types;
// TODO: Come back to this, brainfuck
return result;
}
public async Task<List<BotBase>> Generate(GenerateBotsRequestData info, bool playerscav)
public List<BotBase> Generate(string sessionId, GenerateBotsRequestData info)
{
throw new NotImplementedException();
}
@@ -90,7 +177,7 @@ public class BotController
throw new NotImplementedException();
}
public int GetBotCap()
public int GetBotCap(string location)
{
throw new NotImplementedException();
}
@@ -99,4 +186,4 @@ public class BotController
{
throw new NotImplementedException();
}
}
}
+14 -3
View File
@@ -1,4 +1,5 @@
using Core.Models.Eft.Dialog;
using Core.Models.Eft.HttpResponse;
using Core.Models.Eft.Profile;
using Core.Models.Enums;
@@ -85,7 +86,7 @@ public class DialogueController
/// <param name="sessionId">Session id</param>
/// <returns>GetMailDialogViewResponseData object</returns>
public GetMailDialogViewResponseData GenerateDialogueView(
GetMailDialogViewResponseData request,
GetMailDialogViewRequestData request,
string sessionId)
{
throw new NotImplementedException();
@@ -174,7 +175,7 @@ public class DialogueController
/// <param name="dialogueIds">Dialog ids to set as read</param>
/// <param name="sessionId">Player profile id</param>
public void SetRead(
HashSet<string> dialogueIds,
List<string> dialogueIds,
string sessionId)
{
throw new NotImplementedException();
@@ -250,4 +251,14 @@ public class DialogueController
{
throw new NotImplementedException();
}
}
public FriendRequestSendResponse SendFriendRequest(string sessionId, FriendRequestData request)
{
throw new NotImplementedException();
}
public void DeleteFriend(string sessionID, DeleteFriendRequest request)
{
throw new NotImplementedException();
}
}
+9 -4
View File
@@ -48,7 +48,7 @@ public class GameController
/// <param name="sessionId"></param>
/// <param name="requestData"></param>
/// <returns></returns>
public object GetGameMode( // TODO: Returns `any` in node server
public GameModeResponse GetGameMode(
string sessionId,
GameModeRequestData requestData)
{
@@ -70,12 +70,12 @@ public class GameController
/// </summary>
/// <param name="sessionId"></param>
/// <returns></returns>
/*
public CurrentGroupResponse GetCurrentGroup(string sessionId)
{
throw new NotImplementedException();
}
*/
/// <summary>
/// Handle client/checkVersion
@@ -182,4 +182,9 @@ public class GameController
{
throw new NotImplementedException();
}
}
public void Load()
{
throw new NotImplementedException();
}
}
+40 -3
View File
@@ -1,9 +1,46 @@
using Core.Context;
using Core.Helpers;
using Core.Models.Eft.InRaid;
using Core.Models.Enums;
using Core.Models.Spt.Config;
using Core.Servers;
using Core.Services;
using ILogger = Core.Models.Utils.ILogger;
namespace Core.Controllers;
public class InRaidController
{
protected ILogger _logger;
protected SaveServer _saveServer;
protected ProfileHelper _profileHelper;
protected LocalisationService _localisationService;
protected ApplicationContext _applicationContext;
protected ConfigServer _configServer;
protected InRaidConfig _inRaidConfig;
protected BotConfig _botConfig;
public InRaidController
(
ILogger logger,
SaveServer saveServer,
ProfileHelper profileHelper,
LocalisationService localisationService,
ApplicationContext applicationContext,
ConfigServer configServer
)
{
_logger = logger;
_saveServer = saveServer;
_profileHelper = profileHelper;
_localisationService = localisationService;
_applicationContext = applicationContext;
_configServer = configServer;
_inRaidConfig = configServer.GetConfig<InRaidConfig>(ConfigTypes.IN_RAID);
_botConfig = configServer.GetConfig<BotConfig>(ConfigTypes.BOT);
}
/// <summary>
/// Save locationId to active profiles in-raid object AND app context
/// </summary>
@@ -33,9 +70,9 @@ public class InRaidController
/// <summary>
/// Get the inraid config from configs/inraid.json
/// </summary>
public void GetInRaidConfig()
public InRaidConfig GetInRaidConfig()
{
throw new NotImplementedException();
return _inRaidConfig;
}
/// <summary>
@@ -63,4 +100,4 @@ public class InRaidController
{
throw new NotImplementedException();
}
}
}
+1 -1
View File
@@ -93,4 +93,4 @@ public class MatchController
{
throw new NotImplementedException();
}
}
}
+30 -1
View File
@@ -1,6 +1,35 @@
using Core.Models.Eft.Common;
using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.ItemEvent;
using Core.Models.Eft.Quests;
namespace Core.Controllers;
public class QuestController
{
// TODO
}
public ItemEventRouterResponse CompleteQuest(PmcData pmcData, CompleteQuestRequestData info, string sessionId)
{
throw new NotImplementedException();
}
public ItemEventRouterResponse AcceptRepeatableQuest(PmcData pmcData, AcceptQuestRequestData info, string sessionId)
{
throw new NotImplementedException();
}
public ItemEventRouterResponse AcceptQuest(PmcData pmcData, AcceptQuestRequestData info, string sessionId)
{
throw new NotImplementedException();
}
public ItemEventRouterResponse HandoverQuest(PmcData pmcData, HandoverQuestRequestData info, string sessionId)
{
throw new NotImplementedException();
}
public List<Quest> GetClientQuest(string sessionId)
{
throw new NotImplementedException();
}
}
+39 -1
View File
@@ -1,6 +1,44 @@
using Core.Models.Eft.Common;
using Core.Models.Eft.ItemEvent;
using Core.Models.Eft.Ragfair;
namespace Core.Controllers;
public class RagfairController
{
// TODO
}
public GetOffersResult GetOffers(string sessionId, SearchRequestData info)
{
throw new NotImplementedException();
}
public GetItemPriceResult GetItemMinAvgMaxFleaPriceValues(GetMarketPriceRequestData info)
{
throw new NotImplementedException();
}
public ItemEventRouterResponse AddPlayerOffer(PmcData pmcData, AddOfferRequestData info, string sessionId)
{
throw new NotImplementedException();
}
public ItemEventRouterResponse RemoveOffer(PmcData pmcData, RemoveOfferRequestData info, string sessionId)
{
throw new NotImplementedException();
}
public ItemEventRouterResponse ExtendOffer(PmcData pmcData, ExtendOfferRequestData info, string sessionId)
{
throw new NotImplementedException();
}
public Dictionary<string, double> GetAllFleaPrices()
{
throw new NotImplementedException();
}
public RagfairOffer GetOfferById(string sessionId, GetRagfairOfferByIdRequest info)
{
throw new NotImplementedException();
}
}
+15 -1
View File
@@ -1,6 +1,20 @@
using Core.Models.Eft.Common;
using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.ItemEvent;
using Core.Models.Eft.Quests;
namespace Core.Controllers;
public class RepeatableQuestController
{
// TODO
}
public ItemEventRouterResponse ChangeRepeatableQuest(PmcData pmcData, RepeatableQuestChangeRequest info, string sessionId)
{
throw new NotImplementedException();
}
public List<PmcDataRepeatableQuest> GetClientRepeatableQuests(string sessionId)
{
throw new NotImplementedException();
}
}
+2 -2
View File
@@ -79,8 +79,8 @@ public class TraderController
/// Handle client/items/prices/TRADERID
/// </summary>
/// <returns></returns>
public GetItemPricesResponse GetItemPrices()
public GetItemPricesResponse GetItemPrices(string sessionId, string traderId)
{
throw new NotImplementedException();
}
}
}