diff options
author | Kobert-P <kassiaK@yahoo.de> | 2018-06-10 01:17:57 +0200 |
---|---|---|
committer | Kobert-P <kassiaK@yahoo.de> | 2018-06-10 01:17:57 +0200 |
commit | 19fd05a2990ec309a3869d61a6bcf48aba4793dd (patch) | |
tree | 32f1f6dc38bb70db678bf190369ae66a12d4e6d2 | |
parent | ae507064b9b0dc29d72f02b1ff3d7560bd38a89f (diff) |
AddSpaces extension
-rw-r--r-- | DiscoBot/Auxiliary/Extensions.cs | 17 | ||||
-rw-r--r-- | DiscoBot/Commands/Help.cs | 5 | ||||
-rw-r--r-- | DiscoBot/Commands/List.cs | 8 | ||||
-rw-r--r-- | DiscoBot/DiscoBot.csproj | 1 |
4 files changed, 28 insertions, 3 deletions
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 @@ <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" /> |