From f5744e7b330b3087e644be281ce85b8472002e62 Mon Sep 17 00:00:00 2001 From: Valens <8889280+VforValens@users.noreply.github.com> Date: Tue, 28 Jan 2025 16:34:27 -0500 Subject: [PATCH] Update ProfileSptCommand.cs Just needs some cleanup as I am not familiar with some of the errors being thrown. . Implement all non implemented functions in the class. --- .../ProfileCommand/ProfileSptCommand.cs | 147 +++++++++++++++++- 1 file changed, 145 insertions(+), 2 deletions(-) diff --git a/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.cs b/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.cs index 71d24b4e..a71618ed 100644 --- a/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.cs +++ b/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.cs @@ -1,13 +1,42 @@ -using SptCommon.Annotations; +using Core.Helpers.Dialog.Commando.SptCommands; +using SptCommon.Annotations; using Core.Models.Eft.Dialog; using Core.Models.Eft.Profile; using Core.Models.Spt.Dialog; +using Core.Models.Spt.Logging; +using Core.Servers; +using Core.Services; +using Core.Utils; -namespace Core.Helpers.Dialog.Commando.SptCommands.ProfileCommand; +namespace Core.Helpers.Dialogue.Commando.SptCommands.ProfileCommand; [Injectable] public class ProfileSptCommand : ISptCommand { + // Constructor + // ( + // SptLogger _logger, + // ItemHelper _itemHelper, + // HashUtil _hashUtil, + // PresetHelper _presetHelper, + // MailSendService _mailSendService, + // LocaleService _localeService, + // DatabaseServer dbServer, + // ProfileHelper _profileHelper + // ) + + /** + * Regex to account for all these cases: + * spt profile level 20 + * spt profile skill metabolism 10 + */ + + // TODO: Fix this shit as Valens doesn't know Regex. + // Regex commandRegex = new Regex(^spt profile (?level|skill)((?<=.*skill) (?[\w]+)){0,1} (?(?!0+)[0-9]+)$/); + // Regex examineRegex = new Regex(/^spt profile (?examine)/); + // + // protected savedCommand = SavedCommand; + public string GetCommand() { return "profile"; @@ -22,16 +51,130 @@ public class ProfileSptCommand : ISptCommand public string PerformAction(UserDialogInfo commandHandler, string sessionId, SendMessageRequest request) { + // TODO: Fix the leftover errors. + // if (ProfileSptCommand.commandRegex.test(request.text) is null && ProfileSptCommand.examineRegex.test(request.text) is null) { + // _mailSendService.SendUserMessageToPlayer( + // sessionId, + // commandHandler, + // "Invalid use of trader command. Use 'help' for more information." + // ); + // return request.DialogId; + // } + // + // var result = + // ProfileSptCommand.commandRegex.exec(request.text) ?? ProfileSptCommand.examineRegex.exec(request.text); + // + // var command = result.groups.command; + // var skill = result.groups.skill; + // var quantity = +result.groups.quantity; + // + // ProfileChangeEvent profileChangeEvent; + // switch (command) { + // case "level": + // if (quantity < 1 || quantity > _profileHelper.GetMaxLevel()) { + // _mailSendService.SendUserMessageToPlayer( + // sessionId, + // commandHandler, + // "Invalid use of profile command, the level was outside bounds: 1 to 70. Use 'help' for more information." + // ); + // return request.DialogId; + // } + // profileChangeEvent = HandleLevelCommand(quantity); + // break; + // case "skill": { + // var enumSkill = SkillTypes.find( + // (t) => t.toLocaleLowerCase() === skill.toLocaleLowerCase(), + // ); + // + // if (enumSkill == undefined) { + // _mailSendService.SendUserMessageToPlayer( + // sessionId, + // commandHandler, + // "Invalid use of profile command, the skill was not found. Use 'help' for more information." + // ); + // return request.DialogId; + // } + // + // if (quantity < 0 || quantity > 51) { + // _mailSendService.SendUserMessageToPlayer( + // sessionId, + // commandHandler, + // "Invalid use of profile command, the skill level was outside bounds: 1 to 51. Use 'help' for more information." + // ); + // return request.DialogId; + // } + // + // profileChangeEvent = HandleSkillCommand(enumSkill, quantity); + // break; + // } + // case "examine": { + // profileChangeEvent = HandleExamineCommand(); + // break; + // } + // default: + // _mailSendService.SendUserMessageToPlayer( + // sessionId, + // commandHandler, + // $"If you are reading this, this is bad. Please report this to SPT staff with a screenshot. Command ${command}." + // ); + // return request.DialogId; + // } + // + // _mailSendService.SendSystemMessageToPlayer( + // sessionId, + // "A single ruble is being attached, required by BSG logic.", + // [ + // { + // _id = _hashUtil.generate(), + // _tpl = Money.ROUBLES, + // upd = { StackObjectsCount: 1 }, + // parentId = _hashUtil.Generate(), + // slotId = "main", + // }, + // ], + // undefined, + // [profileChangeEvent] + // ); + // return request.DialogId; throw new NotImplementedException(); } protected ProfileChangeEvent HandleSkillCommand(string skill, int level) { + // TODO: Fix the leftover errors. + // ProfileChangeEvent profileChangeEvent = { + // _id = _hashUtil.Generate(), + // Type = ProfileChangeEventType.SkillPoints, + // value = level * 100, + // entity = skill, + // }; + // return profileChangeEvent; throw new NotImplementedException(); } protected ProfileChangeEvent HandleLevelCommand(int level) { + // TODO: Fix the leftover errors. + // var exp = _profileHelper.GetExperience(level); + // ProfileChangeEvent profileChangeEvent = { + // _id = _hashUtil.Generate(), + // Type = ProfileChangeEventType.ProfileLevel, + // value = exp, + // entity = undefined, + // }; + // return profileChangeEvent; + throw new NotImplementedException(); + } + + protected ProfileChangeEvent HandleExamineCommand() { + // TODO: Fix the leftover errors. + // ProfileChangeEvent profileChangeEvent = { + // id = _hashUtil.Generate(), + // Type = ProfileChangeEventType.ExamineAllItems, + // value = undefined, + // entity = undefined, + // }; + // return profileChangeEvent; throw new NotImplementedException(); } }