diff options
-rw-r--r-- | DiscoBot/Auxiliary/CommandInfo.cs | 5 | ||||
-rw-r--r-- | DiscoBot/Auxiliary/Extensions.cs | 32 | ||||
-rw-r--r-- | DiscoBot/Commands/Gm.cs | 6 | ||||
-rw-r--r-- | DiscoBot/Commands/Help.cs | 24 | ||||
-rw-r--r-- | DiscoBot/Commands/List.cs | 82 | ||||
-rw-r--r-- | DiscoBot/DiscoBot.csproj | 1 | ||||
-rw-r--r-- | DiscoBot/Help.json | 50 |
7 files changed, 172 insertions, 28 deletions
diff --git a/DiscoBot/Auxiliary/CommandInfo.cs b/DiscoBot/Auxiliary/CommandInfo.cs index 90fbbc7..dfed417 100644 --- a/DiscoBot/Auxiliary/CommandInfo.cs +++ b/DiscoBot/Auxiliary/CommandInfo.cs @@ -8,10 +8,11 @@ namespace DiscoBot.Auxiliary { public struct CommandInfo { - public CommandInfo(string name, string[] description, string scope) + public CommandInfo(string name, string brief, string[] description, string scope) { this.Name = name; this.Scope = scope; + this.Brief = brief; this.Description = description; } @@ -19,6 +20,8 @@ namespace DiscoBot.Auxiliary public string Scope { get; } + public string Brief { get; } + public string[] Description { get; } public string GetDescription() diff --git a/DiscoBot/Auxiliary/Extensions.cs b/DiscoBot/Auxiliary/Extensions.cs new file mode 100644 index 0000000..a1d58fa --- /dev/null +++ b/DiscoBot/Auxiliary/Extensions.cs @@ -0,0 +1,32 @@ +namespace DiscoBot.Auxiliary +{ + public static class StringExtension + { + //This mehod extends string. It adds spaces until a fixed length is reached. + //If the original string is already longer, it is returner unmodified. + public static string AddSpaces(this string str, int length) + { + string temp = str; + for(int i = str.Length; i < length; i++) + { + temp += " "; + } + return temp; + } + + + + //This mehod extends string. + //It adds spaces at the HEAD of a string until a fixed length is reached. + //If the original string is already longer, it is returner unmodified. + public static string AddSpacesAtHead(this string str, int length) + { + string temp = ""; + for (int i = str.Length; i < length; i++) + { + temp += " "; + } + return temp + str; + } + } +} diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs index af152fa..212bc83 100644 --- a/DiscoBot/Commands/Gm.cs +++ b/DiscoBot/Commands/Gm.cs @@ -34,6 +34,12 @@ name = givenName.Aggregate((s, c) => s + c); } + if (name.ToLower().Equals("man") || name.ToLower().Equals("help")) + { + return this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("ich bin") + "\n```"); + + } + var character = Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(name, x.Name)).First(); // usage of compareEasy diff --git a/DiscoBot/Commands/Help.cs b/DiscoBot/Commands/Help.cs index 2bcbd03..c6de4a9 100644 --- a/DiscoBot/Commands/Help.cs +++ b/DiscoBot/Commands/Help.cs @@ -50,11 +50,31 @@ namespace DiscoBot.Commands [Command("help"), Summary("prints the help menu.")] [Alias("Help", "man", "Man")] - public async Task ShowHelpAsync(string command = "") + public async Task ShowHelpAsync(params string[] command_list) { + var command = ""; + if (command_list.Length > 0) { + command = command_list.Aggregate((s, c) => s + " " + c); + } + if (command.Equals(string.Empty)) // return generic Help { - await this.ReplyAsync("```\n[hilfreiche Erklärungen]\nAuflistung aller Commands mit !list commands\n```"); + string res = ""; + + foreach (var com in Commands) + { + int first_column_width = 8; + res += ("!" + com.Name + ": ").AddSpaces(first_column_width) + com.Brief; + + if (com.Description.Length > 1) + { + res += "\n" + "".AddSpaces(first_column_width) + "(\"!man " + com.Name + "\" gibt genauere Informationen)"; + } + + res += "\n\n"; + } + //await this.ReplyAsync("```\n[hilfreiche Erklärungen]\nAuflistung aller Commands mit !list commands\n```"); + await this.ReplyAsync("```xl\n" + res +"\n```"); return; } diff --git a/DiscoBot/Commands/List.cs b/DiscoBot/Commands/List.cs index c688daa..be7441b 100644 --- a/DiscoBot/Commands/List.cs +++ b/DiscoBot/Commands/List.cs @@ -22,9 +22,52 @@ var character = ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username]))); + int first_column_width = 18; + + int persist = 0; switch (prop.ToLower()) { + case "all": + case "held": + case "char": + case "brief": + case "zettel": + persist = 1; + + res.Add(character.Name + ":\n"); + //Eigenschaften + res.AddRange( + character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value)); + res.Add(""); + //LE/AE + res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis); + if (character.Astralpunkte_Basis > 0) + { + res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis); + } + res.Add(""); + //Kampfwerte + res.Add("".AddSpaces(first_column_width) + " AT/PA"); + res.AddRange( + character.Kampftalente.Select(s => s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" + s.Pa.ToString().AddSpacesAtHead(2))); + res.Add(""); + //Vorteile + res.AddRange( + character.Vorteile + .Select(s => s.Name + "\t " + s.Value)); + res.Add(""); + //Talente + res.AddRange( + character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe)); + res.Add(""); + //evtl Zauber + if (character.Zauber.Count > 0) + { + res.AddRange( + character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe)); + } + break; case "chars": case "Chars": res.AddRange(Dsa.Chars.Select(x => x.Name)); @@ -36,13 +79,13 @@ case "eig": case "eigenschaft": case "eigenschaften": - res.Add(character.Name + ":"); + res.Add(character.Name + ":\n"); res.AddRange( character.Eigenschaften.Take(8).Select(s => s.Key + ":\t " + s.Value)); break; case "stat": case "stats": - res.Add(character.Name + ":"); + res.Add(character.Name + ":\n"); res.AddRange( //character.Eigenschaften.Select(s => s.Key + ":\t " + s.Value)); character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value)); @@ -55,20 +98,26 @@ case "t": case "ta": case "talent": + res.Add(character.Name + ":\n"); + res.AddRange( + character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe)); + break; case "zauber": - res.Add(character.Name + ":"); + case "z": + res.Add(character.Name + ":\n"); res.AddRange( - character.Talente.Select(s => s.Name + "\t " + s.Value + "\t " + s.Probe)); + character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe)); break; case "w": case "waffe": case "waffen": res.Add(character.Name + ":"); + res.Add("".AddSpaces(first_column_width) + " AT/PA"); res.AddRange( - character.Kampftalente.Select(s => s.Name)); + character.Kampftalente.Select(s => s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" + s.Pa.ToString().AddSpacesAtHead(2))); break; case "fern": - res.Add(character.Name + ":"); + res.Add(character.Name + ":\n"); res.AddRange( character.Talente.Select(s => s.Name)); break; @@ -81,7 +130,7 @@ case "vt": case "vor": case "vorteil": - res.Add(character.Name + ":"); + res.Add(character.Name + ":\n"); res.AddRange( character.Vorteile .Select(s => s.Name + "\t " + s.Value));// (s.Value == 0 ? string.Empty : s.Value.ToString()))); @@ -97,14 +146,27 @@ { if (sb.Length + re.Length > 1798) { - await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90)); + if (persist == 1) + { + await this.ReplyAsync("```xl\n" + sb.ToString() + "\n```"); + } + else + { + await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90)); + } sb.Clear(); } sb.AppendLine(re); } - - await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90)); + if (persist == 1) + { + await this.ReplyAsync("```xl\n" + sb.ToString() + "\n```"); + } + else + { + await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90)); + } } } } diff --git a/DiscoBot/DiscoBot.csproj b/DiscoBot/DiscoBot.csproj index 58d5fbc..214c6ea 100644 --- a/DiscoBot/DiscoBot.csproj +++ b/DiscoBot/DiscoBot.csproj @@ -97,6 +97,7 @@ <Compile Include="Audio\AudioModule.cs" /> <Compile Include="Audio\AudioService.cs" /> <Compile Include="Auxiliary\CommandInfo.cs" /> + <Compile Include="Auxiliary\Extensions.cs" /> <Compile Include="Commands\Help.cs" /> <Compile Include="Auxiliary\Dice.cs" /> <Compile Include="Auxiliary\TalentEnumerableExtension.cs" /> diff --git a/DiscoBot/Help.json b/DiscoBot/Help.json index 737ddf7..90f9fc0 100644 --- a/DiscoBot/Help.json +++ b/DiscoBot/Help.json @@ -1,37 +1,57 @@ { "CommandInfos": [ { + "Name": "ich bin", + "Scope": "All", + "Brief": "Setzt den gespielten Charakter fest", + "Description": [ + "Mit \"!Ich bin\" kann der gespielte Charakter definiert, bzw. gewechselt werden.\n", + " Die Charaktere müssen als *.xml Dateien hinterlegt sein.\n\n", + " !ich Zeigt an welcher Charakter zur Zeit gespielt wird\n", + " !ich bin Zalibius Wechsel zum Helden Zalibius\n", + " !ich Rhoktar Orkische Variante von !ich bin.\n", + " Wechselt zu Rhoktar.\n\n", + " !list chars Zeigt die Liste verfügbarer Charaktere.\n", + " \n" + ] + }, + { "Name": "List", "Scope": "All", + "Brief": "Testbeschreibung", "Description": [ "Testbeschreibung" ] }, { "Name": "LE", "Scope": "All", + "Brief": "Ändert dein Leben - im wahrsten Sinne des Wortes", "Description": [ - "Use !LE to display, set, or change LE value\n\n", - " !LE Display values\n", - " !LE 30 Set LE to 30\n", - " !LE 30 Set LE to 30\n", - " !LE +5 Increment LE by 5 (up to the maximum)\n", - " !LE ++5 Increment LE by 5 (ignoring the maximum)\n", - " !LE -5 Decrease LE by 5\n \n" - ], + "Mit !LE zeigt man die Lebensenergie an, ändert sie, oder setzt sie auf einen neuen Wert\n\n", + " !LE Zeigt Lebensenergie an\n", + " !LE 30 Setzt LE auf 30\n", + " !LE +5 Erhöht LE um 5 (bis zum Maximum)\n", + " !LE ++5 Erhöht LE um 5 (ignoriert Maximum)\n", + " !LE -5 Verringert LE um 5\n \n" + ] }, { "Name": "AE", "Scope": "All", - "Description": ["Use !AE (or !Asp) to display, set, or change AE/Asp value\n\n", - " !AE Display values\n", - " !AE 30 Set Asp to 30\n", - " !AE +5 Increment Asp by 5 (up to the maximum)\n", - " !AE ++5 Increment Asp by 5 (ignoring the maximum)\n", - " !AE -5 Decrease Asp by 5 (down to 0)\n"], + "Brief": "Ändert Astralenergie", + "Description": [ + "Mit !AE (oder !Asp) zeigt man die Astralenergie an, ändert sie, oder setzt sie auf einen neuen Wert\n\n", + " !AE Zeigt Astralenergie an\n", + " !AE 30 Setzt Asp auf 30\n", + " !AE +5 Erhöht Asp um 5 (bis zum Maximum)\n", + " !AE ++5 Erhöht Asp um 5 (ignoriert Maximum)\n", + " !AE -5 Verringert Asp um 5 (Minimum 0)\n" + ] }, { "Name": "Gm", "Scope": "Meister", - "Description": ["Gm Aktionen"] + "Brief": "Testbeschreibung", + "Description": [ "Gm Aktionen" ] } ] } |