From 4c43b2130321948d46d6e59d15068c57b5a07778 Mon Sep 17 00:00:00 2001 From: Kobert-P Date: Thu, 7 Jun 2018 20:31:22 +0200 Subject: Help.json now contains a brief description that is output for global !help --- DiscoBot/Auxiliary/CommandInfo.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'DiscoBot/Auxiliary') 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() -- cgit v1.2.3-70-g09d2 From 19fd05a2990ec309a3869d61a6bcf48aba4793dd Mon Sep 17 00:00:00 2001 From: Kobert-P Date: Sun, 10 Jun 2018 01:17:57 +0200 Subject: AddSpaces extension --- DiscoBot/Auxiliary/Extensions.cs | 17 +++++++++++++++++ DiscoBot/Commands/Help.cs | 5 +++-- DiscoBot/Commands/List.cs | 8 +++++++- DiscoBot/DiscoBot.csproj | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 DiscoBot/Auxiliary/Extensions.cs (limited to 'DiscoBot/Auxiliary') diff --git a/DiscoBot/Auxiliary/Extensions.cs b/DiscoBot/Auxiliary/Extensions.cs new file mode 100644 index 0000000..2176129 --- /dev/null +++ b/DiscoBot/Auxiliary/Extensions.cs @@ -0,0 +1,17 @@ +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; + } + } +} diff --git a/DiscoBot/Commands/Help.cs b/DiscoBot/Commands/Help.cs index 7d35875..c6de4a9 100644 --- a/DiscoBot/Commands/Help.cs +++ b/DiscoBot/Commands/Help.cs @@ -63,11 +63,12 @@ namespace DiscoBot.Commands foreach (var com in Commands) { - res += "!" + com.Name + ": " + com.Brief; + int first_column_width = 8; + res += ("!" + com.Name + ": ").AddSpaces(first_column_width) + com.Brief; if (com.Description.Length > 1) { - res += "\n\t(\"!man " + com.Name + "\" gibt genauere Informationen)"; + res += "\n" + "".AddSpaces(first_column_width) + "(\"!man " + com.Name + "\" gibt genauere Informationen)"; } res += "\n\n"; diff --git a/DiscoBot/Commands/List.cs b/DiscoBot/Commands/List.cs index c688daa..5b7b8b4 100644 --- a/DiscoBot/Commands/List.cs +++ b/DiscoBot/Commands/List.cs @@ -22,6 +22,7 @@ var character = ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username]))); + int first_column_width = 18; switch (prop.ToLower()) { @@ -55,10 +56,15 @@ case "t": case "ta": case "talent": + res.Add(character.Name + ":"); + res.AddRange( + character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe)); + break; case "zauber": + case "z": res.Add(character.Name + ":"); 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": 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 @@ + -- cgit v1.2.3-70-g09d2 From ff80592d541c79653ef0a7c04e0938d7249069ef Mon Sep 17 00:00:00 2001 From: Kobert-P Date: Mon, 11 Jun 2018 16:49:40 +0200 Subject: Neu: !list held + !list waffe Verbesserung --- DiscoBot/Auxiliary/Extensions.cs | 15 ++++++++ DiscoBot/Commands/List.cs | 76 ++++++++++++++++++++++++++++++++++------ 2 files changed, 81 insertions(+), 10 deletions(-) (limited to 'DiscoBot/Auxiliary') diff --git a/DiscoBot/Auxiliary/Extensions.cs b/DiscoBot/Auxiliary/Extensions.cs index 2176129..a1d58fa 100644 --- a/DiscoBot/Auxiliary/Extensions.cs +++ b/DiscoBot/Auxiliary/Extensions.cs @@ -13,5 +13,20 @@ } 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/List.cs b/DiscoBot/Commands/List.cs index 5b7b8b4..be7441b 100644 --- a/DiscoBot/Commands/List.cs +++ b/DiscoBot/Commands/List.cs @@ -24,8 +24,50 @@ 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)); @@ -37,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)); @@ -56,13 +98,13 @@ case "t": case "ta": case "talent": - res.Add(character.Name + ":"); + 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": case "z": - res.Add(character.Name + ":"); + res.Add(character.Name + ":\n"); res.AddRange( character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe)); break; @@ -70,11 +112,12 @@ 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; @@ -87,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()))); @@ -103,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)); + } } } } -- cgit v1.2.3-70-g09d2