diff --git a/src/app/Edelstein.Application.Server/Bootstraps/StartPluginBootstrap.cs b/src/app/Edelstein.Application.Server/Bootstraps/StartPluginBootstrap.cs index 136712d57..4e286a859 100644 --- a/src/app/Edelstein.Application.Server/Bootstraps/StartPluginBootstrap.cs +++ b/src/app/Edelstein.Application.Server/Bootstraps/StartPluginBootstrap.cs @@ -13,9 +13,9 @@ public class StartPluginBootstrap : IBootstrap private readonly IPluginManager _manager; public StartPluginBootstrap( - ILogger> logger, - ILoggerFactory loggerFactory, - TContext context, + ILogger> logger, + ILoggerFactory loggerFactory, + TContext context, IPluginManager manager ) { @@ -24,26 +24,27 @@ IPluginManager manager _context = context; _manager = manager; } + public int Priority => BootstrapPriority.Start; public async Task Start() { var plugins = await _manager.RetrieveAll(); var hosted = plugins - .Select(p => + .Select(p => Tuple.Create(p, new PluginHost(_loggerFactory.CreateLogger(p.GetType())))) .ToImmutableList(); foreach (var host in hosted) { await host.Item1.OnInit(host.Item2, _context); - _logger.LogDebug("{Context} plugin {ID} initialised", typeof(TContext).Name, host.Item1.ID); + _logger.LogInformation("{Context} plugin {ID} initialised", typeof(TContext).Name, host.Item1.ID); } - + foreach (var host in hosted) { await host.Item1.OnStart(host.Item2, _context); - _logger.LogDebug("{Context} plugin {ID} started", typeof(TContext).Name, host.Item1.ID); + _logger.LogInformation("{Context} plugin {ID} started", typeof(TContext).Name, host.Item1.ID); } } @@ -54,7 +55,7 @@ public async Task Stop() foreach (var plugin in plugins) { await plugin.OnStop(); - _logger.LogDebug("{Context} plugin {ID} stopped", typeof(TContext).Name, plugin.ID); + _logger.LogInformation("{Context} plugin {ID} stopped", typeof(TContext).Name, plugin.ID); } } } diff --git a/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs b/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs index 7c4a9f949..634fb36ae 100644 --- a/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs +++ b/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/DebugCommand.cs @@ -7,11 +7,98 @@ 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) { await user.Message(new IncEXPMessage(1000, true)); await user.Message(new IncMoneyMessage(1000)); - await user.Prompt(s => s.Say(user.Stats.ToString()!), default); + + var answer = await user.Prompt(target => target.AskMenu( + "What would you like to debug?", new Dictionary + { + [0] = "Stats", + [1] = "Temporary Stats Records", + [2] = "Skill Records", + [3] = "ExtendedSP Records", + [4] = "Quest Records", + [5] = "QuestEx Records", + [6] = "QuestCompletes Records", + }), -1); + + if (answer == -1) return; + + switch (answer) + { + case 0: + await user.Prompt(s => s.Say(user.Stats.ToString() ?? string.Empty), default); + break; + case 1: + await DisplayRecordsToUser( + user, + "Temporary stats", + user.Character.TemporaryStats.Records.ToDictionary( + kvp => kvp.Key.ToString(), + kvp => kvp.Value.ToString() ?? string.Empty), + kvp => $"Type: {kvp.Key} Record: {kvp.Value}"); + break; + case 2: + await DisplayRecordsToUser( + user, + "Skill", + user.Stats.SkillLevels.Records, + kvp => $"Id: {kvp.Key} Level: {kvp.Value}"); + break; + case 3: + await DisplayRecordsToUser( + user, + "ExtendSP", + user.Character.ExtendSP.Records, + kvp => $"Id: {kvp.Key} Level: {kvp.Value}"); + break; + case 4: + await DisplayRecordsToUser( + user, + "Quest", + user.Character.QuestRecords.Records.ToDictionary( + kvp => kvp.Key.ToString(), + kvp => kvp.Value.ToString() ?? string.Empty), + kvp => $"Id: {kvp.Key} Value: {kvp.Value}"); + break; + case 5: + await DisplayRecordsToUser( + user, + "QuestEx", + user.Character.QuestRecordsEx.Records.ToDictionary( + kvp => kvp.Key.ToString(), + kvp => kvp.Value.ToString() ?? string.Empty), + kvp => $"Id: {kvp.Key} Value: {kvp.Value}"); + break; + case 6: + await DisplayRecordsToUser( + user, + "QuestCompletes", + user.Character.QuestCompletes.Records.ToDictionary( + kvp => kvp.Key.ToString(), + kvp => kvp.Value.ToString() ?? string.Empty), + kvp => $"Id: {kvp.Key} Value: {kvp.Value}"); + break; + } + } + + private static async Task DisplayRecordsToUser( + IFieldUser user, + string header, + IDictionary record, + Func, string> formatting) + { + var recordText = $"{header} records for player #e#b#h #:\\n"; + + for (var i = 0; i < record.Count; i++) + { + KeyValuePair kvp = record.ElementAt(i); + recordText += $"[{i}] {formatting(kvp)}\\n"; + } + + await user.Prompt(s => s.Say(recordText), default); } } diff --git a/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/EquipCommand.cs b/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/EquipCommand.cs index 6ca82936e..d0583b7a3 100644 --- a/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/EquipCommand.cs +++ b/src/plugin/Edelstein.Plugin.Rue/Commands/Admin/EquipCommand.cs @@ -8,7 +8,7 @@ public class EquipCommand : AbstractCommand { public override string Name => "Equip"; public override string Description => "Modifies equipment stats"; - + public override async Task Execute(IFieldUser user, string[] args) { var equipped = user.Character.Inventories[ItemInventoryType.Equip]?.Items.ToList() ?? new List>(); @@ -21,9 +21,10 @@ public override async Task Execute(IFieldUser user, string[] args) )), -1); if (slot == -1) return; + var item = user.Character.Inventories[ItemInventoryType.Equip]?.Items[(short)slot]; if (item is not IItemSlotEquip equip) return; - + var sel = await user.Prompt(target => target.AskMenu("Which equipment stat?", new Dictionary { [0] = "Grade", @@ -41,7 +42,7 @@ public override async Task Execute(IFieldUser user, string[] args) equip.Grade = (byte)await user.Prompt(target => target.AskNumber("What value?"), 0); break; case 4: - equip.Grade = (byte)-await user.Prompt(target => target.AskNumber("What value?"), 0); + equip.Grade = (byte) -await user.Prompt(target => target.AskNumber("What value?"), 0); break; case 1: equip.Option1 = (short)await user.Prompt(target => target.AskNumber("What value?"), 0);