diff options
author | TrueDoctor <d-kobert@web.de> | 2018-04-09 14:13:28 +0200 |
---|---|---|
committer | TrueDoctor <d-kobert@web.de> | 2018-04-09 14:13:28 +0200 |
commit | 5cb8346a6a3ccc55295c00ac333e410629ff7c42 (patch) | |
tree | 1603fdf24f1ead61cf7dd23c09a9784cfb1c780e /DiscoBot/Commands/Gm.cs | |
parent | e49ac2778bb6d38517f14447c0675df354552528 (diff) | |
parent | 4ca7291ebee440d9f3ef2a1643d8d01b29006459 (diff) |
Merge branch 'Reset'
Diffstat (limited to 'DiscoBot/Commands/Gm.cs')
-rw-r--r-- | DiscoBot/Commands/Gm.cs | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs new file mode 100644 index 0000000..60b82fb --- /dev/null +++ b/DiscoBot/Commands/Gm.cs @@ -0,0 +1,103 @@ +namespace DiscoBot.Commands +{ + using System.Linq; + using System.Threading.Tasks; + + using DiscoBot.Auxiliary; + + using Discord.Commands; + using Discord.WebSocket; + + public class Gm : ModuleBase + { + public static string CheckCommand(string name, CommandTypes command, string waffe, int erschwernis = 0) + { + var comp = new SpellCorrect(); + var chr = Dsa.Chars.OrderBy(x => comp.Compare(x.Name, name)).First(); + switch (command) + { + case CommandTypes.Talent: + return chr.TestTalent(waffe, erschwernis); + case CommandTypes.Eigenschaft: + return chr.TestEigenschaft(waffe, erschwernis); + case CommandTypes.Angriff: + return chr.Angriff(waffe, erschwernis); + case CommandTypes.Parade: + return chr.Parade(waffe, erschwernis); + case CommandTypes.Fernkampf: + return chr.Fernkampf(waffe, erschwernis); + } + + return $"{name} verwendet {waffe}"; + } + + [Command("gm"), Summary("Führt eine probe aus")] + [Alias("GM", "as", "As", "als")] + public async Task ProbeAsync([Summary("Fernkampfwaffe")] string name, string command, string waffe, int erschwernis = 0) + { + if (!((SocketGuildUser)this.Context.User).Roles.ToList().Exists(v => v.Name.Equals("Meister"))) + { + await this.ReplyAsync("```xl\n Keine ausreichenden Berechtigunen\n```"); + return; + } + + command = command.ToLower(); + string res = this.Test(name, command, waffe, erschwernis); + + if (Dsa.GeneralContext != null && Dsa.GeneralContext.Channel.Id != this.Context.Channel.Id) + { + await Dsa.GeneralContext.Channel.SendMessageAsync("```xl\n" + res + "\n```"); + } + + await this.ReplyAsync("```xl\n" + res + "\n```"); + } + + private string Test(string name, string command, string waffe, int erschwernis = 0) + { + string res; + switch (command) + { + case "f": + case "fern": + case "fernkampf": + res = CheckCommand(name, CommandTypes.Fernkampf, waffe, erschwernis); + break; + case "t": + case "ta": + case "talent": + case "talente": + res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis); + break; + case "e": + case "ei": + case "eigenschaft": + res = CheckCommand(name, CommandTypes.Eigenschaft, waffe, erschwernis); + break; + case "z": + case "za": + case "zauber": + case "magie": + case "m": + res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis); + break; + case "a": + case "at": + case "an": + case "angrif": + case "angriff": + res = CheckCommand(name, CommandTypes.Angriff, waffe, erschwernis); + break; + case "p": + case "pa": + case "parade": + res = CheckCommand(name, CommandTypes.Parade, waffe, erschwernis); + break; + default: + res = $"Kommando {command} nicht gefunden"; + break; + } + + return res; + } + } +} |