summaryrefslogtreecommitdiff
path: root/DiscoBot/Commands
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-06-11 23:38:13 +0200
committerDennis Kobert <d-kobert@web.de>2019-06-11 23:38:13 +0200
commit2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch)
treec3b34ccb2737e347a73768536895cbbaab13cc01 /DiscoBot/Commands
parentec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff)
parentaf74efccf8d21e6151022b71f3cacd3fa83024ee (diff)
Merge branch 'rework-backend'
Diffstat (limited to 'DiscoBot/Commands')
-rw-r--r--DiscoBot/Commands/CommandExtension.cs119
-rw-r--r--DiscoBot/Commands/CommandTypes.cs13
-rw-r--r--DiscoBot/Commands/FileHandler.cs45
-rw-r--r--DiscoBot/Commands/Gm.cs187
-rw-r--r--DiscoBot/Commands/HeldList.cs191
-rw-r--r--DiscoBot/Commands/Help.cs99
-rw-r--r--DiscoBot/Commands/LebenUndAstral.cs198
-rw-r--r--DiscoBot/Commands/List.cs62
-rw-r--r--DiscoBot/Commands/MiscCommands.cs247
-rw-r--r--DiscoBot/Commands/NpcCommands.cs39
-rw-r--r--DiscoBot/Commands/ProbenTest.cs91
11 files changed, 0 insertions, 1291 deletions
diff --git a/DiscoBot/Commands/CommandExtension.cs b/DiscoBot/Commands/CommandExtension.cs
deleted file mode 100644
index 098e35f..0000000
--- a/DiscoBot/Commands/CommandExtension.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-namespace DiscoBot.Auxiliary
-{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- using Discord;
- using Discord.Commands;
-
- public static class CommandExtension
- {
- private static WebClient client;
-
- public static async Task ReplyTimedAsync(this ModuleBase m, string message, TimeSpan time)
- {
- var token = message.GetHashCode();
- var send = m.Context.Channel.SendMessageAsync($"#{token}\n```xl\n{message}```", false);
-
- var barInvoker = new BackgroundWorker();
- barInvoker.DoWork += delegate
- {
- Thread.Sleep(time);
- Delete(token, m);
- };
-
- await send;
- barInvoker.RunWorkerAsync();
- }
-
- private static void Delete(int token, ModuleBase m)
- {
- var messagesAsync = m.Context.Channel.GetMessagesAsync();
- Task.WaitAll(messagesAsync.ToArray());
- var list = messagesAsync.ToEnumerable().ToList();
- var messages = new List<IMessage>();
- foreach (var task in list)
- {
- messages.AddRange(task.ToList());
- }
-
- var test = messages.Where(x => x.Content.StartsWith($"#{token}\n") && x.Author.IsBot).Select(c=>c );
- var waiters = new List<Task>();
- foreach (var message in test)
- {
- waiters.Add((message as IUserMessage).DeleteAsync());
- }
- Task.WaitAll(waiters.ToArray());
- }
-
- public static async Task ReplyAsync(this ModuleBase m, IEnumerable<string> message, bool directMessage = false)
- {
- var sb = new StringBuilder();
- foreach (string re in message)
- {
- if (sb.Length + re.Length > 1798)
- {
- if (directMessage)
- {
- await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```");
- }
- else
- {
- await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```");
- }
-
- sb.Clear();
- }
-
- sb.AppendLine(re);
- }
-
- if (directMessage)
- {
- await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```");
- }
- else
- {
- await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```");
- }
- }
-
- public static async Task ReplyAsync(this ModuleBase m, IEnumerable<string> message, TimeSpan time)
- {
- var sb = new StringBuilder();
- foreach (string re in message)
- {
- if (sb.Length + re.Length > 1798)
- {
-
- await m.ReplyTimedAsync(sb.ToString(), time);
-
-
- sb.Clear();
- }
-
- sb.AppendLine(re);
- }
-
- await m.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
- }
-
- public static async Task SendWebFile(this IMessageChannel channel, string url = "https://i.imgur.com/0iHEycJ.png")
- {
- if (client == null)
- {
- client = new WebClient();
- }
-
- Stream stream = client.OpenRead(url);
- await channel.SendFileAsync(stream, url.Split('/').Last());
- }
- }
-}
diff --git a/DiscoBot/Commands/CommandTypes.cs b/DiscoBot/Commands/CommandTypes.cs
deleted file mode 100644
index c1d0954..0000000
--- a/DiscoBot/Commands/CommandTypes.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace DiscoBot.Commands
-{
- public enum CommandTypes
- {
- Talent,
- Eigenschaft,
- Angriff,
- Parade,
- Fernkampf,
- KeinChar,
- Zauber
- }
-}
diff --git a/DiscoBot/Commands/FileHandler.cs b/DiscoBot/Commands/FileHandler.cs
deleted file mode 100644
index 0b87b15..0000000
--- a/DiscoBot/Commands/FileHandler.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Linq;
- using System.Net;
- using System.Threading.Tasks;
-
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
- using DSALib;
-
- public class FileHandler : ModuleBase
- {
- //[Command("send"), Summary("fügt Helden hinzu")]
- public async Task AddChar()
- {
- var msg = this.Context.Message;
- if (msg.Attachments == null)
- {
- throw new ArgumentException("Es wurde keine Datei angehängt");
- }
-
- var attachments = msg.Attachments.ToList();
-
- if (!attachments.Any(x => x.Filename.EndsWith(".xml")))
- {
- throw new ArgumentException("Es wurde kein xml Held mitgeschickt");
- }
-
- foreach (var attachment in attachments.Where(x => x.Filename.EndsWith(".xml")))
- {
- using (var client = new WebClient())
- {
- client.DownloadFile(attachment.Url, "helden\\" + attachment.Filename);
- }
-
- Dsa.Chars.Add(new Character("helden\\" + attachment.Filename));
- (Dsa.Chars.Last() as Character)?.Talente.Select(x => new Talent(x.Name, x.Probe, 0))
- .Where(c => !Dsa.Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Dsa.Talente.Add(v));
- }
- }
- }
-} \ No newline at end of file
diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs
deleted file mode 100644
index 483e9d2..0000000
--- a/DiscoBot/Commands/Gm.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-using DiscoBot.DSA_Game.Characters;
-
-namespace DiscoBot.Commands
-{
- using System.Linq;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
-
- using Discord.Commands;
- using DSALib.Characters;
-
- public class Iam : ModuleBase
- {
-
- //[Command("Iam"), Summary("Wechselt den Character")]
- [Alias("iam", "I_am", "i_am", "IchBin", "ichbin", "Ichbin", "Ich_bin", "ich_bin", "Ich", "ich", "I", "i")]
- public Task Change_Character(params string[] givenName) // use fancy parameters
- {
- string res;
- string name;
-
- if (givenName.Length == 0 || (givenName.Length == 1 && (givenName[0].ToLower().Equals("bin") || givenName[0].ToLower().Equals("am"))))
- {
- res = " \nDu bist " + Dsa.Session.Relation[this.Context.User.Username] + "!\n \n";
-
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- if (givenName.Length > 1 && (givenName[0].ToLower().Equals("bin") || givenName[0].ToLower().Equals("am")) )
- {
- name = givenName.Skip(1).Aggregate((s, c) => s + c); // (Skip(1)) don't use the first element; Aggregate: take source s and do operation s = s+c for all elements
- }
- else
- {
- 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
-
- Dsa.Session.Relation[this.Context.User.Username] = character.Name;
- res = " \nWillkommen " + character.Name + "!\n \n";
-
-
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
- }
-
-
- 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(name, x.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);
- case CommandTypes.Zauber:
- return chr.TestZauber(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 cmdText = "", int modifier = 0)
- {
- if (!Permissions.Test(this.Context, "Meister")) return;
-
- command = command.ToLower();
-
- string res;
- string temp = string.Empty;
- ICharacter cha = Dsa.Chars.OrderBy(x =>
- SpellCorrect.CompareEasy(name, x.Name)).First();
- switch (command)
- {
- case "le":
- case "leben":
- case "lp":
- LE le = new LE();
- temp = string.Empty;
-
- if (modifier != 0)
- {
- temp = modifier.ToString();
- }
-
- res = cha.get_LE_Text(cmdText.Trim() + temp);
-
- break;
- case "ae":
- case "asp":
- case "astral":
- AE ae = new AE();
- temp = string.Empty;
-
- if (modifier != 0)
- {
- temp = modifier.ToString();
- }
-
- res = cha.get_AE_Text(cmdText.Trim() + temp);
-
- break;
- default:
- res = this.Test(name, command, cmdText, modifier);
- break;
- }
-
-
- 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.ToLower())
- {
- 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;
- }
- }
-}
diff --git a/DiscoBot/Commands/HeldList.cs b/DiscoBot/Commands/HeldList.cs
deleted file mode 100644
index a8f26e0..0000000
--- a/DiscoBot/Commands/HeldList.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- using DiscoBot.Audio;
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
-
- public class Held : ModuleBase
- {
- //[Command("held"), Summary("gibt Heldenwerte aus")]
- [Alias("Held", "Wert", "Werte", "werte", "char", "Char")]
- public async Task ListAsync([Summary("Werte")] params string[] prop_list)
- {
- var res = new List<string>();
-
- var character = ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])));
-
- int first_column_width = 18;
-
- int persist = 0;
-
- if (prop_list.Length == 0 || prop_list[0].ToLower().StartsWith("all") || prop_list[0].ToLower().StartsWith("brief") || prop_list[0].ToLower().StartsWith("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("");
- //Fernkampf
- res.Add("".AddSpaces(first_column_width) + " FK");
- res.AddRange(
- character.Talente.Where(x => x.IstFernkampftalent()).Select(s => s.Name.AddSpaces(first_column_width) + " " + (character.Eigenschaften["fk"] + s.Value).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));
- }
-
- }
- else if (prop_list[0].ToLower().StartsWith("man") || prop_list[0].ToLower().StartsWith("help") || prop_list[0].ToLower().StartsWith("hilf"))
- {
- await this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("Held") + "\n```");
- return;
- }
- else
- {
-
- res.Add(character.Name + ":\n");
-
- foreach (string prop in prop_list)
- {
-
- switch (prop.ToLower())
- {
- case "e":
- case "eig":
- case "eigenschaft":
- case "eigenschaften":
- res.AddRange(
- character.Eigenschaften.Take(8).Select(s => s.Key + ":\t " + s.Value));
- break;
- case "stat":
- case "stats":
- res.AddRange(
- character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
- res.Add("");
- 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);
- }
- break;
- case "le":
- res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
- break;
- case "ae":
- res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
- break;
- case "t":
- case "ta":
- case "talent":
- case "talente":
- 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.AddRange(
- 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":
- case "kampf":
- case "kampfwert":
- case "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)));
- break;
- case "f":
- case "fern":
- res.Add("".AddSpaces(first_column_width) + " FK");
- res.AddRange(
- character.Talente.Where(x => x.IstFernkampftalent()).Select(s => s.Name.AddSpaces(first_column_width) + " " + (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
- break;
- case "v":
- case "vt":
- case "vor":
- case "vorteil":
- case "vorteile":
- case "nachteil":
- case "nachteile":
- res.AddRange(
- character.Vorteile
- .Select(s => s.Name + "\t " + s.Value));
- break;
-
- default:
- res.Add($"Kommando {prop} nicht gefunden");
- break;
- }
-
- res.Add("");
- }
-
- }
-
-
- //var sb = new StringBuilder();
- //foreach (string re in res)
- //{
- // if (sb.Length + re.Length > 1798)
- // {
- // 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);
- //}
- if (persist == 1)
- {
- await this.ReplyAsync(res, true);
- }
- else
- {
- await this.ReplyAsync(res, TimeSpan.FromSeconds(90));
- }
- }
- }
-}
diff --git a/DiscoBot/Commands/Help.cs b/DiscoBot/Commands/Help.cs
deleted file mode 100644
index 4c378c9..0000000
--- a/DiscoBot/Commands/Help.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System.Linq;
-
-namespace DiscoBot.Commands
-{
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Security.Cryptography;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
-
- using Discord.Commands;
-
- using Newtonsoft.Json;
-
- using CommandInfo = DiscoBot.Auxiliary.CommandInfo;
-
- public class Help : ModuleBase
- {
- static Help()
- {
- /*TextReader stream = new StreamReader(@"..\..\Help.json"); // Load command-description file
- var reader = new JsonTextReader(stream); // create stream reader
-
- reader.Read(); // step into structure, until the array starts
- reader.Read();
- reader.Read();
-
- try
- {
- var test = new JsonSerializer().Deserialize<List<CommandInfo>>(reader); // Deserialize Data and create CommandInfo Struct
-
- Commands.AddRange(test); // Add new CommandInfos to List
- }
- catch (Exception e)
- {
- // ignored
- }*/
- }
-
- //public static List<CommandInfo> Commands { get; } = new List<CommandInfo>();
-
-
- public static string Get_Specific_Help(string command)
- {
- // return command specific help
- var com = DSA_Game.Save.Properties.CommandInfos.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
- return com.GetDescription();
- }
-
- public static string Get_Generic_Help()
- {
- string res = "";
- foreach (var com in DSA_Game.Save.Properties.CommandInfos)
- {
- 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";
- }
- return res;
- }
-/*
-
- //[Command("help"), Summary("prints the help menu.")]
- [Alias("Help", "man", "Man", "Hilfe", "hilfe", "h")]
- 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
- {
- string res = Get_Generic_Help();
-
- //await this.ReplyAsync("```\n[hilfreiche Erklärungen]\nAuflistung aller Commands mit !list commands\n```");
- await this.ReplyAsync("```xl\n" + res +"\n```");
- return;
- }
-
-
-
- // return command specific help
- //var com = Commands.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
-
- //await this.ReplyAsync("```xl\n" + com.GetDescription() + "\n```");
- await this.ReplyAsync("```xl\n" + Get_Specific_Help(command) + "\n```");
- }*/
- }
-}
diff --git a/DiscoBot/Commands/LebenUndAstral.cs b/DiscoBot/Commands/LebenUndAstral.cs
deleted file mode 100644
index 2406c70..0000000
--- a/DiscoBot/Commands/LebenUndAstral.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Linq;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
- using DSALib.Characters;
-
- public class LE : ModuleBase
- {
- //[Command("LE"), Summary("Ändert aktuellen Lebenspunktestand")]
- [Alias("le", "leben", "LP", "lp", "Le", "Lp")]
-
- public async Task LEAsync([Summary("LE Modifier")] string prop = "", string s = "")
- {
- //This is the string that will be printed
- string res = "";
-
- if (prop.ToLower().Equals("help") || prop.ToLower().Equals("man"))
- {
- await this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("LE") + "\n```");
- return;
- }
-
- //In case the input is badly formated
- prop = prop.Trim() + s.Trim();
-
-
- //Get the actual text
- res += Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(Dsa.Session.Relation[this.Context.User.Username], x.Name)).First().get_LE_Text(prop);
-
-
- await this.ReplyAsync("```xl\n" + res + "\n```");
- }
- }
-
- public class AE : ModuleBase
- {
- //[Command("AE"), Summary("Ändert aktuellen Astralpunktestand")]
- [Alias("ae", "astral", "ASP", "Asp", "asp", "Astral")]
-
- public async Task AEAsync([Summary("AE Modifier")] string prop = "", string s = "")
- {
- //This is the string that will be printed
- string res = "";
-
- if (prop.ToLower().Equals("help") || prop.ToLower().Equals("man"))
- {
- await this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("AE") + "\n```");
- return;
- }
-
- //Incase the input is badly formated
- prop = prop.Trim() + s.Trim();
-
-
- //Get the actual text
- res += Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(Dsa.Session.Relation[this.Context.User.Username], x.Name)).First().get_AE_Text(prop);
-
-
-
- await this.ReplyAsync("```xl\n" + res + "\n```");
- }
- }
-
- public static class StatExtension
- {
- public static string get_LE_Text(this ICharacter c, string prop)
- {
- string res = "";
- var comp = new SpellCorrect();
- var character = c;
-
- res += (character.Name + ":\n");
-
- //If there is actual input we process it
- if (prop.Length > 0)
- {
- res += "LE: ";
- res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis + " -> ";
-
- // Apply a change to current value
- if (prop.StartsWith("+") || prop.StartsWith("-"))
- {
- //Allow overflowing the max
- if (prop.StartsWith("++"))
- {
- character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop.Substring(1, prop.Length - 1));
- }
- else
- {
- int temp = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop) - character.Lebenspunkte_Basis;
- //Stop from overflow overflow
- if (temp > 0 && prop.StartsWith("+"))
- {
- character.Lebenspunkte_Aktuell = (character.Lebenspunkte_Basis > character.Lebenspunkte_Aktuell) ? character.Lebenspunkte_Basis : character.Lebenspunkte_Aktuell;
- res += " Maximale Lebenspunkte sind erreicht ";
- }
- //Simply apply change
- else
- {
- character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop);
- }
- }
-
- res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
- }
- else
- {
- // Set to new value regardless of original
- character.Lebenspunkte_Aktuell = Convert.ToInt32(prop);
-
- res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
- }
- }
- //If no value is passed, the curent value is displayed
- else
- {
- res += ("LE: " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
- }
-
- return res;
- }
- public static string get_AE_Text(this ICharacter c, string prop)
- {
- string res = "";
- var comp = new SpellCorrect();
- var character = c;
-
- res += (character.Name + ":\n");
-
- //If there is actual input we process it
- if (prop.Length > 0)
- {
-
- res += "AE: ";
- res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis + " -> ";
-
- // Apply a change to current value
- if (prop.StartsWith("+") || prop.StartsWith("-"))
- {
- //Allow overflowing the max
- if (prop.StartsWith("++"))
- {
- character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell + Convert.ToInt32(prop.Substring(1, prop.Length - 1));
- }
- else
- {
- int temp = character.Astralpunkte_Aktuell + Convert.ToInt32(prop) - character.Astralpunkte_Basis;
- //Stop from overflow overflow
- if (temp > 0 && prop.StartsWith("+"))
- {
- character.Astralpunkte_Aktuell = (character.Astralpunkte_Basis > character.Astralpunkte_Aktuell) ? character.Astralpunkte_Basis : character.Astralpunkte_Aktuell;
- res += " Maximale Astralpunkte sind erreicht ";
- }
- //Simply apply change
- else
- {
- character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell + Convert.ToInt32(prop);
- }
- }
-
- if (character.Astralpunkte_Aktuell < 0)
- {
- res += "Nicht genügend Astralpunkte! ";
- character.Astralpunkte_Aktuell = 0;
- }
-
- res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
-
- }
- //Set to new value regardless of original
- else
- {
- character.Astralpunkte_Aktuell = Convert.ToInt32(prop);
-
- res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
- }
- }
- //If no value is passed, the curent value is displayed
- else
- {
- res += ("AE: " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
- }
-
-
- return res;
- }
- }
-}
-
-
-
diff --git a/DiscoBot/Commands/List.cs b/DiscoBot/Commands/List.cs
deleted file mode 100644
index e77362e..0000000
--- a/DiscoBot/Commands/List.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- using DiscoBot.Audio;
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
-
- public class List : ModuleBase
- {
- //[Command("list"), Summary("gibt eine Auflistung aus")]
- public async Task ListAsync([Summary("Aktion")] string prop)
- {
- var res = new List<string>();
-
- int persist = 0;
-
- switch (prop.ToLower())
- {
- case "man":
- case "help":
- await this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("List") + "\n```");
- return;
- // break;
- case "chars":
- res.AddRange(Dsa.Chars.Select(x => x.Name));
- break;
- case "commands":
- // res.AddRange(Help.Commands.Select(x => x.Name));
- res.Add(Help.Get_Generic_Help());
- break;
- case "play":
- case "sound":
- case "sounds":
- res.AddRange(
- Enum.GetNames(typeof(Sound)));
- break;
-
- default:
- res.Add($"Kommando {prop} nicht gefunden");
- break;
- }
-
-
- if (persist == 1)
- {
- await this.ReplyAsync(res);
- }
- else
- {
- await this.ReplyAsync(res, TimeSpan.FromSeconds(90));
- }
- }
- }
-}
diff --git a/DiscoBot/Commands/MiscCommands.cs b/DiscoBot/Commands/MiscCommands.cs
deleted file mode 100644
index 53bc42c..0000000
--- a/DiscoBot/Commands/MiscCommands.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Runtime.Remoting.Contexts;
-using System.Text;
-
-using DiscoBot.Auxiliary;
-
-using Discord;
-using Discord.Commands;
-using Discord.WebSocket;
-
-namespace DiscoBot.Commands
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Net.Mime;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
-
- using Discord;
- using Discord.Commands;
-
- public class MiscCommands : ModuleBase
- {
- [Command("r"), Summary("Würfelt ")]
- [Alias("R", "Roll", "roll", "Würfle")]
- public Task RollAsync([Remainder, Summary("Weapon")] string roll)
- {
- //return this.ReplyAsync("```xl\n" + new Auxiliary.Calculator.StringSolver(roll).Solve() + "\n```");
- return this.ReplyAsync("```xl\n" + RandomMisc.Roll(roll) + "\n```");
- }
-
- [Command("rd"), Summary("Würfel Dennis ")]
- public Task RollDennisAsync([Remainder, Summary("Weapon")] string roll)
- {
- return this.ReplyAsync("```xl\n" + new Auxiliary.Calculator.StringSolver(roll).Solve() + "\n```");
- }
-
- [Command("general"), Summary("Set General ")]
- public Task SetGeneralAsync([Remainder, Summary("Set General")] int i = 0)
- {
- Dsa.GeneralContext = this.Context;
- return this.Context.Channel.SendMessageAsync($"```xl\n Der Dachs hat in '{this.Context.Channel.Name}' ein Zuhause gefunden. Gm Nachrichten werden nun auch in diesem Channel gepostet. \n```");
- }
-
- [Command("say"), Summary("Echos a message.")]
- [Alias("s")]
- public Task SayAsync([Remainder, Summary("The text to echo")] string echo)
- {
- return this.ReplyAsync(echo);
- }
-
- [Command("liebe"), Summary("Echos a message.")]
- [Alias("Liebe", "<3", "love")]
- public async Task LoveAsync()
- {
- Random rand = new Random();
- var user = Context.Channel.GetUsersAsync().ToList().Result.ToList().First().Where(x=>x.Status!= UserStatus.Offline).OrderBy(x => rand.Next()).First();
- await this.ReplyAsync(":heart: :heart: :heart: Verteilt die Liebe! :heart: :heart: :heart: \n Besondere Liebe geht an " + user.Username);
- //await this.ReplyAsync("!liebe");
- }
-
- [Command("maul"), Summary("Echos a message.")]
- public Task MaulAsync()
- {
- return this.ReplyAsync("Maul...? Du meintest doch sicher Maulwürfe oder? \n:heart: :heart: :heart: \nGanz viel Liebe für Maulwürfe !\n:heart: :heart: :heart:");
-
- }
-
- [Command("report"), Summary("Report a Tweet")]
- public async Task ReportAsync([Remainder, Summary("Link")] string link)
- {
- var content = new System.Net.Http.StringContent(link);
-
- using (HttpClient client = new HttpClient())
- {
- var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);
- }
-
- await this.ReplyAsync($"Dein report wurde hinzugefügt");
- }
-
- [Command("match"), Summary("Tinder.")]
- [Alias("mach","pass", "passt")]
- public Task TinderAsync(string s1, string s2)
- {
-
- var sc = new SpellCorrect();
- var rand = new System.Random((s1+s2).GetHashCode());
-
- var wert = Math.Log10(Math.Floor(1000.0 * (SpellCorrect.CompareExact(s1, s2) + rand.NextDouble() * 10.0)) / 1000.0);
- wert = ((wert * 100.0) < 100.0 ? wert * 100.0 : 100.0 - wert);
- wert = wert < 0 ? -wert : wert;
- return this.ReplyAsync($"Ihr passt zu {Math.Floor(100.0 * wert )/ 100.0}% zusammen");
-
- }
-
- [Command("reddit"), Summary("Reddit.")]
- public Task RedditAsync()
- {
- return this.ReplyAsync($"Ein Archiv der Vergangenen Aktionen findet man hier: https://www.reddit.com/r/ReconquistaInternet/");
-
- }
-
- [Command("compare"), Summary("Echos a message.")]
- public async Task KickAsync()
- {
- //await this.Context.Guild.DownloadUsersAsync();
- var users = Context.Guild.GetUsersAsync(CacheMode.AllowDownload);
- var test = File.ReadAllLines("RG.txt");
- await users;
- var us = users.Result.Select(x => x.Username);
-
- var lines = test.Where(x => !x.Equals(string.Empty)).ToList();
-
-
- var sc = new SpellCorrect();
-
- var res = new List<string>();
-
- foreach (string line in lines)
- {
- var best = us.OrderBy(user => sc.Compare(user, line)).First();
-
- double fit = sc.Compare(best, line);
-
- if (fit < SpellCorrect.ErrorThreshold - 20000)
- {
- if (fit.Equals(0))
- {
- res.Add($"@\t{best} !!! => {line}");
- }
- else
- {
- res.Add($"-\t{best} hat Ähnlichkeit mit: {line}");
- }
- }
- }
-
- var sb = new StringBuilder();
- foreach (string re in res)
- {
- if (sb.Length + re.Length > 1798)
- {
- await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
- sb.Clear();
- }
-
- sb.AppendLine(re);
- }
-
- if(Permissions.Check(this.Context, new []{"Admin", "Mod"}))
- await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
-
- //await this.ReplyAsync($"{count} Duplikate gefunden");
-
- }
-
-
- [Command("clear"), Summary("Cleans up messages.")]
- public async Task DeleteAsync(int count)
- {
- var messagesAsync = Context.Channel.GetMessagesAsync(count);
- Task.WaitAll(messagesAsync.ToArray());
- var list = messagesAsync.ToEnumerable().ToList();
- var messages = new List<IMessage>();
- foreach (var task in list)
- {
- messages.AddRange(task.ToList());
- }
-
- if (Permissions.Check(Context, new[] { "Admin", "Mod", "Meister" }))
- {
-
- var waiters = new List<Task>();
- foreach (var message in messages)
- {
- waiters.Add((message as IUserMessage).DeleteAsync());
- }
-
- Task.WaitAll(waiters.ToArray());
- }
-
- }
-
- [Command("check"), Summary("Echos a message.")]
- [Alias("Check")]
- public async Task CheckAsync(string quarry)
- {
- var perm = new List<string> { "Admin", "Mod", "Privatpolizei" };
-
- Permissions.Test(this.Context, perm.ToArray());
-
- var test = File.ReadAllLines("RG.txt");
-
- var lines = test.Where(x => !x.Equals(string.Empty)).ToList();
-
-
- var sc = new SpellCorrect();
- var count = lines.OrderBy(line => sc.Compare(quarry, line)).First();
-
- var fit = sc.Compare(count, quarry);
-
- string Antwort;
-
- if (fit < SpellCorrect.ErrorThreshold - 20000)
- {
- Antwort= $"```xl\nAuf anderem Server Match gefunden: {count}";
- }
- else
- {
- Antwort = $"```xl\nAuf anderem Server Kein Match gefunden: {quarry}";
- }
-
-
- var users = Context.Guild.GetUsersAsync(CacheMode.AllowDownload);
- await users;
- var us = users.Result.Select(x => x.Username);
-
- sc = new SpellCorrect();
- count = us.OrderBy(line => sc.Compare(quarry, line)).First();
-
- fit = sc.Compare(count, quarry);
-
- if (fit < SpellCorrect.ErrorThreshold - 20000)
- {
- Antwort = Antwort + $"\nAuf unserem Server Match gefunden: {count}\n```";
- }
- else
- {
- Antwort = Antwort + $"\nAuf unserem Server Kein Match gefunden: {quarry} \n```";
- }
-
- await ReplyAsync(Antwort);
-
- }
- }
-}
diff --git a/DiscoBot/Commands/NpcCommands.cs b/DiscoBot/Commands/NpcCommands.cs
deleted file mode 100644
index b314494..0000000
--- a/DiscoBot/Commands/NpcCommands.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Linq;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.Characters;
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
-
- public class NpcCommands : ModuleBase
- {
- //[Command("npc"), Summary("Erstellt ein NPC")]
- [Alias("Npc", "NPc", "NPC", "nPC")]
- public Task RandomAsync([Summary("Create Random")] string npcName, int mean = 9, int stDv = 1)
- {
- Dsa.Chars.Add(new Npc(npcName, mean, stDv));
- return this.ReplyAsync($"{npcName} wurde zufällig generiert");
- }
-
- //[Command("npc"), Summary("Erstellt ein NPC")]
- [Alias("Npc", "NPc", "NPC", "nPC")]
- public Task CopyAsync([Summary("Create Copy")] string npcName, string source, int stDv = 1)
- {
- if (Dsa.Chars.Exists(x => x.Name.Equals(npcName)))
- {
- throw new Exception("Char gibt es schon");
- }
-
- var comp = new SpellCorrect();
- var chr = Dsa.Chars.OrderBy(x => comp.Compare(x.Name, source)).First();
- Dsa.Chars.Add(new Character(chr as Character, npcName, stDv));
- return this.ReplyAsync($"{npcName} wurde als variierte Kopie von {source} erstellt");
- }
- }
-} \ No newline at end of file
diff --git a/DiscoBot/Commands/ProbenTest.cs b/DiscoBot/Commands/ProbenTest.cs
deleted file mode 100644
index 77a10ad..0000000
--- a/DiscoBot/Commands/ProbenTest.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System.Threading.Tasks;
-
- using DiscoBot.DSA_Game;
-
- using Discord.Commands;
-
- public class ProbenTest : ModuleBase
- {
- //[Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
- [Alias("T", "Talent", "talent", "versuche")]
- public Task TalentAsync([Summary("Talent oder Zaubername")] string talent, int erschwernis = 0)
- {
- string res;
- try
- {
- res = Gm.CheckCommand(
- Dsa.Session.Relation[this.Context.User.Username],
- CommandTypes.Talent,
- talent,
- erschwernis);
- }
- catch
- {
- res = Gm.CheckCommand(
- Dsa.Session.Relation["Tardis"],
- CommandTypes.Talent,
- talent,
- erschwernis);
- }
-
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- //[Command("Zauber"), Summary("Würfelt ein Zauberprobe")]
- [Alias("Z", "zauber", "z")]
- public Task ZauberAsync([Summary("Zaubername")] string zauber, int erschwernis = 0)
- {
- string res;
- try
- {
- res = Gm.CheckCommand(
- Dsa.Session.Relation[this.Context.User.Username],
- CommandTypes.Zauber,
- zauber,
- erschwernis);
- }
- catch
- {
- res = Gm.CheckCommand(
- Dsa.Session.Relation["Tardis"],
- CommandTypes.Zauber,
- zauber,
- erschwernis);
- }
-
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- //[Command("e"), Summary("Würfelt eine Eigenschaftsprobe")]
- [Alias("E", "Eigenschaft", "eigenschaft", "eigen")]
- public Task EigenschaftAsync([Summary("Eigenschaftskürzel und Erschwernis")] string talent, int erschwernis = 0)
- {
- var chr = Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username]));
- string res = chr.TestEigenschaft(talent, erschwernis);
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- //[Command("a"), Summary("Würfelt ein Angriff")]
- [Alias("A", "At", "at", "Angriff", "angriff", "attackiere_mit", "attacke", "Attacke")]
- public Task AngriffAsync([Summary("Weapon")] string weapon, int erschwernis = 0)
- {
- return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Angriff(weapon, erschwernis) + "\n```");
- }
-
- //[Command("p"), Summary("Würfelt eine Parade Probe")]
- [Alias("P", "Parade", "parade", "pariere_mit")]
- public Task ParadeAsync([Summary("Parade Weapon")] string talent, int erschwernis = 0)
- {
- return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Parade(talent, erschwernis) + "\n```");
- }
-
- //[Command("f"), Summary("Führt eine Fernkampfprobe aus")]
- [Alias("F", "fern", "Fern", "Schuss", "schuss", "fernkampf", "Fernkampf", "schieße", "schieße_mit")]
- public Task FernkampfAsync([Summary("Fernkampfwaffe")] string waffe, int erschwernis = 0)
- {
- return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Fernkampf(waffe, erschwernis) + "\n```");
- }
- }
-}