From c7da90d2abb295b3b3cb77c9198c5ed6e08a4eb2 Mon Sep 17 00:00:00 2001 From: Bia10 Date: Sat, 30 Sep 2023 06:50:33 +0200 Subject: [PATCH 1/2] add option to output to chat --- .../Commands/Admin/DebugCommand.cs | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs b/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs index 634fb36ae..4ac925b0f 100644 --- a/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs +++ b/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs @@ -1,14 +1,22 @@ using Edelstein.Common.Gameplay.Game.Objects.User.Messages; using Edelstein.Protocol.Gameplay.Game.Objects.User; +using PowerArgs; namespace Edelstein.Plugin.Rue.Commands.Admin; -public class DebugCommand : AbstractCommand +public class DebugCommandArgs : CommandArgs +{ + [ArgPosition(0)] + [ArgDescription("Output to chat window?")] + public bool ToChat { get; set; } = false; +} + +public class DebugCommand : AbstractCommand { public override string Name => "Debug"; public override string Description => "Testing command for debugging purposes"; - public override async Task Execute(IFieldUser user, string[] args) + protected override async Task Execute(IFieldUser user, DebugCommandArgs args) { await user.Message(new IncEXPMessage(1000, true)); await user.Message(new IncMoneyMessage(1000)); @@ -22,7 +30,7 @@ public override async Task Execute(IFieldUser user, string[] args) [3] = "ExtendedSP Records", [4] = "Quest Records", [5] = "QuestEx Records", - [6] = "QuestCompletes Records", + [6] = "QuestCompleted Records", }), -1); if (answer == -1) return; @@ -30,7 +38,15 @@ public override async Task Execute(IFieldUser user, string[] args) switch (answer) { case 0: - await user.Prompt(s => s.Say(user.Stats.ToString() ?? string.Empty), default); + var userStats = user.Stats.ToString() ?? string.Empty; + + if (args.ToChat) + { + await user.Message(userStats); + break; + } + + await user.Prompt(s => s.Say(userStats), default); break; case 1: await DisplayRecordsToUser( @@ -39,21 +55,24 @@ await DisplayRecordsToUser( user.Character.TemporaryStats.Records.ToDictionary( kvp => kvp.Key.ToString(), kvp => kvp.Value.ToString() ?? string.Empty), - kvp => $"Type: {kvp.Key} Record: {kvp.Value}"); + kvp => $"Type: {kvp.Key} Record: {kvp.Value}", + args.ToChat); break; case 2: await DisplayRecordsToUser( user, "Skill", user.Stats.SkillLevels.Records, - kvp => $"Id: {kvp.Key} Level: {kvp.Value}"); + kvp => $"Id: {kvp.Key} Level: {kvp.Value}", + args.ToChat); break; case 3: await DisplayRecordsToUser( user, "ExtendSP", user.Character.ExtendSP.Records, - kvp => $"Id: {kvp.Key} Level: {kvp.Value}"); + kvp => $"Id: {kvp.Key} Level: {kvp.Value}", + args.ToChat); break; case 4: await DisplayRecordsToUser( @@ -62,7 +81,8 @@ await DisplayRecordsToUser( user.Character.QuestRecords.Records.ToDictionary( kvp => kvp.Key.ToString(), kvp => kvp.Value.ToString() ?? string.Empty), - kvp => $"Id: {kvp.Key} Value: {kvp.Value}"); + kvp => $"Id: {kvp.Key} Value: {kvp.Value}", + args.ToChat); break; case 5: await DisplayRecordsToUser( @@ -71,16 +91,18 @@ await DisplayRecordsToUser( user.Character.QuestRecordsEx.Records.ToDictionary( kvp => kvp.Key.ToString(), kvp => kvp.Value.ToString() ?? string.Empty), - kvp => $"Id: {kvp.Key} Value: {kvp.Value}"); + kvp => $"Id: {kvp.Key} Value: {kvp.Value}", + args.ToChat); break; case 6: await DisplayRecordsToUser( user, - "QuestCompletes", + "QuestCompleted", user.Character.QuestCompletes.Records.ToDictionary( kvp => kvp.Key.ToString(), kvp => kvp.Value.ToString() ?? string.Empty), - kvp => $"Id: {kvp.Key} Value: {kvp.Value}"); + kvp => $"Id: {kvp.Key} Value: {kvp.Value}", + args.ToChat); break; } } @@ -89,7 +111,8 @@ private static async Task DisplayRecordsToUser( IFieldUser user, string header, IDictionary record, - Func, string> formatting) + Func, string> formatting, + bool outputToChat = false) { var recordText = $"{header} records for player #e#b#h #:\\n"; @@ -99,6 +122,9 @@ private static async Task DisplayRecordsToUser( recordText += $"[{i}] {formatting(kvp)}\\n"; } - await user.Prompt(s => s.Say(recordText), default); + if (outputToChat) + await user.Message(recordText); + else if (!outputToChat) + await user.Prompt(s => s.Say(recordText), default); } } From 3f97f9b5e917e3d1cfbe8ce197a8b66c1c93fb71 Mon Sep 17 00:00:00 2001 From: Bia10 Date: Sat, 30 Sep 2023 07:59:32 +0200 Subject: [PATCH 2/2] adjust formatting --- .../Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs b/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs index 4ac925b0f..a742604d2 100644 --- a/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs +++ b/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs @@ -114,12 +114,14 @@ private static async Task DisplayRecordsToUser( Func, string> formatting, bool outputToChat = false) { - var recordText = $"{header} records for player #e#b#h #:\\n"; + var characterName = outputToChat ? user.Character.Name : "#e#b#h #"; + var newline = outputToChat ? string.Empty : "\\n"; + var recordText = $"{header} records for player {characterName}: {newline}"; for (var i = 0; i < record.Count; i++) { KeyValuePair kvp = record.ElementAt(i); - recordText += $"[{i}] {formatting(kvp)}\\n"; + recordText += $"[{i}] {formatting(kvp)} {newline}"; } if (outputToChat)