From ee0202042aafc76eb4339b3a04d06d06921ccdc2 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Tue, 25 Sep 2018 21:36:25 +0200 Subject: minor error fixes and functional improvements --- DiscoBot/Audio/Soundeffects.cs | 16 +++-- DiscoBot/Audio/Voice.cs | 4 +- DiscoBot/Auxiliary/Permissions.cs | 5 +- DiscoBot/Commands/Gm.cs | 26 ++++--- DiscoBot/Commands/MiscCommands.cs | 3 +- DiscoBot/DSA_Game/Save/SaveCommand.cs | 7 +- DiscoBot/Help.json | 34 ++++++++- DiscoBot/Program.cs | 2 +- DiscoBot/Properties.json | 37 ++++++++-- .../Properties/DiscoBot-Auxiliary-CommandInfo.json | 14 +++- DiscoBot/sessions/TheCrew/TheCrew-0.json | 83 ++++++++++++++++++++++ 11 files changed, 200 insertions(+), 31 deletions(-) create mode 100644 DiscoBot/sessions/TheCrew/TheCrew-0.json (limited to 'DiscoBot') diff --git a/DiscoBot/Audio/Soundeffects.cs b/DiscoBot/Audio/Soundeffects.cs index 919e149..f3a014c 100644 --- a/DiscoBot/Audio/Soundeffects.cs +++ b/DiscoBot/Audio/Soundeffects.cs @@ -24,12 +24,17 @@ public static class SoundEffects { - public static int Volume { get; set; } = 50; + public static int MaxVolume { get; set; } = 50; public static void Play(string s) { string url = string.Empty; int volume = 255; + + var tSound = DSA_Game.Save.Properties.Sounds.OrderBy(x => SpellCorrect.CompareEasy(s, x.Name)).First(); + + url = s; + switch (s) { case "Bell": @@ -64,16 +69,15 @@ break; } - var tSound = DSA_Game.Save.Properties.Sounds.OrderBy(x => SpellCorrect.CompareEasy(s, x.Name)).First(); - - url = s; + - if (SpellCorrect.CompareEasy(s, tSound.Name) > SpellCorrect.ErrorThreshold) + if (SpellCorrect.CompareEasy(s, tSound.Name) < SpellCorrect.ErrorThreshold) { url = tSound.Url; + volume = tSound.Volume; } - volume = (int)(volume * (Volume / 100.0)); + volume = (int)(volume * (MaxVolume / 100.0)); if (url != string.Empty) diff --git a/DiscoBot/Audio/Voice.cs b/DiscoBot/Audio/Voice.cs index 24512d2..379f65b 100644 --- a/DiscoBot/Audio/Voice.cs +++ b/DiscoBot/Audio/Voice.cs @@ -78,7 +78,7 @@ { if (volume <= 100 && volume >= 0) { - SoundEffects.Volume = volume; + SoundEffects.MaxVolume = volume; } } @@ -90,6 +90,8 @@ await this.Context.Channel.SendMessageAsync("Erst Joinen!"); } + SoundEffects.Play(path); + var sounds = Enum.GetValues(typeof(Sound)); var soundList = new List(); foreach (var sound in sounds) diff --git a/DiscoBot/Auxiliary/Permissions.cs b/DiscoBot/Auxiliary/Permissions.cs index 48f8040..4d73146 100644 --- a/DiscoBot/Auxiliary/Permissions.cs +++ b/DiscoBot/Auxiliary/Permissions.cs @@ -21,12 +21,15 @@ namespace DiscoBot.Auxiliary return roles.Any(role => ((SocketGuildUser)c.User).Roles.ToList().Exists(v => v.Name.Equals(role))); } - public static void Test(ICommandContext c, string role) + public static bool Test(ICommandContext c, string role) { if (!Check(c, role)) { c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait(); + return false; } + + return true; } public static void Test(ICommandContext c, string[] roles) diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs index 1ff0286..540682c 100644 --- a/DiscoBot/Commands/Gm.cs +++ b/DiscoBot/Commands/Gm.cs @@ -1,4 +1,6 @@ -namespace DiscoBot.Commands +using DiscoBot.DSA_Game.Characters; + +namespace DiscoBot.Commands { using System.Linq; using System.Threading.Tasks; @@ -79,14 +81,16 @@ [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) + public async Task ProbeAsync([Summary("Fernkampfwaffe")] string name, string command, string cmdText = "", int modifier = 0) { - Permissions.Test(this.Context, "Meister"); + 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": @@ -95,12 +99,12 @@ LE le = new LE(); temp = string.Empty; - if (erschwernis != 0) + if (modifier != 0) { - temp = erschwernis.ToString(); + temp = modifier.ToString(); } - res = Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(Dsa.Session.Relation[this.Context.User.Username], x.Name)).First().get_LE_Text(waffe.Trim() + temp); + res = cha.get_LE_Text(cmdText.Trim() + temp); break; case "ae": @@ -109,16 +113,16 @@ AE ae = new AE(); temp = string.Empty; - if (erschwernis != 0) + if (modifier != 0) { - temp = erschwernis.ToString(); + temp = modifier.ToString(); } - res = Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(Dsa.Session.Relation[this.Context.User.Username], x.Name)).First().get_AE_Text(waffe.Trim() + temp); + res = cha.get_AE_Text(cmdText.Trim() + temp); break; default: - res = this.Test(name, command, waffe, erschwernis); + res = this.Test(name, command, cmdText, modifier); break; } @@ -134,7 +138,7 @@ private string Test(string name, string command, string waffe, int erschwernis = 0) { string res; - switch (command) + switch (command.ToLower()) { case "f": case "fern": diff --git a/DiscoBot/Commands/MiscCommands.cs b/DiscoBot/Commands/MiscCommands.cs index 715f044..bef39c6 100644 --- a/DiscoBot/Commands/MiscCommands.cs +++ b/DiscoBot/Commands/MiscCommands.cs @@ -35,6 +35,7 @@ namespace DiscoBot.Commands [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```"); } @@ -65,7 +66,7 @@ namespace DiscoBot.Commands 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"); + //await this.ReplyAsync("!liebe"); } [Command("maul"), Summary("Echos a message.")] diff --git a/DiscoBot/DSA_Game/Save/SaveCommand.cs b/DiscoBot/DSA_Game/Save/SaveCommand.cs index cd44534..1f160ec 100644 --- a/DiscoBot/DSA_Game/Save/SaveCommand.cs +++ b/DiscoBot/DSA_Game/Save/SaveCommand.cs @@ -18,6 +18,7 @@ namespace DiscoBot.DSA_Game.Save public class SaveCommand : ModuleBase { [Command("load"), Summary("Load Session")] + [Alias("session")] public async Task LoadSessionAsync([Remainder, Summary("Session Name")] string name = "") { if (name.Equals("?") || name.Equals(string.Empty)) @@ -39,7 +40,7 @@ namespace DiscoBot.DSA_Game.Save [Command("save", RunMode = RunMode.Async), Summary("Save Session")] public async Task SessionSaveAsync([Remainder, Summary("Session Name")] string name = "") { - var sendFile = this.Context.Channel.SendWebFile("https://cdn.discordapp.com/attachments/377123019673567232/465615882048110603/giphy.gif"); + //var sendFile = this.Context.Channel.SendWebFile("https://cdn.discordapp.com/attachments/377123019673567232/465615882048110603/giphy.gif"); if (name.Equals("?") || name.Equals(string.Empty)) { @@ -53,16 +54,18 @@ namespace DiscoBot.DSA_Game.Save { var files = Directory.GetFiles(path); int current = files.Max(x => Convert.ToInt32(x.Split('-').Last().Split('.').First())); + Dsa.Session.SessionName = name; Dsa.Session.Save(path + "\\" + name + $"-{++current}.json"); } else { Directory.CreateDirectory(path); + Dsa.Session.SessionName = name; Dsa.Session.Save(path + "\\" + name + $"-0.json"); } await this.ReplyAsync($"{name} wurde gespeichert"); - await sendFile; + //await sendFile; } private string[] ListSessions() diff --git a/DiscoBot/Help.json b/DiscoBot/Help.json index 1ed7feb..44ce054 100644 --- a/DiscoBot/Help.json +++ b/DiscoBot/Help.json @@ -83,8 +83,38 @@ { "Name": "Gm", "Scope": "Meister", - "Brief": "Testbeschreibung", - "Description": [ "Gm Aktionen" ] + "Brief": "Kontrolliere andere Charaktere", + "Description": [ + "Mit !GM fürhrt man commands als eine andere Person aus.", + " !GM [charaktername] [command] [commandattribut] [mofifier]", + " Unterstützte [commands]'s:", + " !GM [name] LE", + " !GM [name] AE", + " !GM [name] Talent", + " !GM [name] Fernkampf", + " !GM [name] Eigenschaft", + " !GM [name] Zauber", + " !GM [name] Angriff", + " !GM [name] Parade" + ] + }, + { + "Name": "ich bin", + "Scope": "All", + "Brief": "Kontrolliere andere Charaktere", + "Description": [ + "Mit !GM fürhrt man commands als eine andere Person aus.", + " !GM [charaktername] [command] [commandattribut] [mofifier]", + " Unterstützte [commands]'s:", + " !GM [name] LE", + " !GM [name] AE", + " !GM [name] Talent", + " !GM [name] Fernkampf", + " !GM [name] Eigenschaft", + " !GM [name] Zauber", + " !GM [name] Angriff", + " !GM [name] Parade" + ] } ] } diff --git a/DiscoBot/Program.cs b/DiscoBot/Program.cs index 89a1a42..5bc0195 100644 --- a/DiscoBot/Program.cs +++ b/DiscoBot/Program.cs @@ -75,7 +75,7 @@ namespace DiscoBot // Create a Command Context var context = new CommandContext(this.client, message); - + // Execute the command. (result does not indicate a return value, // rather an object stating if the command executed successfully) var result = await this.commands.ExecuteAsync(context, argPos, this.services); diff --git a/DiscoBot/Properties.json b/DiscoBot/Properties.json index 67765d4..8808dbf 100644 --- a/DiscoBot/Properties.json +++ b/DiscoBot/Properties.json @@ -84,10 +84,38 @@ { "Name": "Gm", "Scope": "Meister", - "Brief": "Testbeschreibung", - "Description": [ - "Gm Aktionen" - ] + "Brief": "Kontrolliere andere Charaktere", + "Description": [ + "Mit !GM fürhrt man commands als eine andere Person aus.", + " !GM [charaktername] [command] [commandattribut] [mofifier]", + " Unterstützte [commands]'s:", + " !GM [name] LE", + " !GM [name] AE", + " !GM [name] Talent", + " !GM [name] Fernkampf", + " !GM [name] Eigenschaft", + " !GM [name] Zauber", + " !GM [name] Angriff", + " !GM [name] Parade" + ] + }, + { + "Name": "ich bin", + "Scope": "All", + "Brief": "Kontrolliere andere Charaktere", + "Description": [ + "Mit !GM fürhrt man commands als eine andere Person aus.", + " !GM [charaktername] [command] [commandattribut] [mofifier]", + " Unterstützte [commands]'s:", + " !GM [name] LE", + " !GM [name] AE", + " !GM [name] Talent", + " !GM [name] Fernkampf", + " !GM [name] Eigenschaft", + " !GM [name] Zauber", + " !GM [name] Angriff", + " !GM [name] Parade" + ] } ], "Sounds": [ @@ -96,5 +124,6 @@ "Url": "http", "Volume": 100 } + ] } \ No newline at end of file diff --git a/DiscoBot/Properties/DiscoBot-Auxiliary-CommandInfo.json b/DiscoBot/Properties/DiscoBot-Auxiliary-CommandInfo.json index 7162268..b9941f2 100644 --- a/DiscoBot/Properties/DiscoBot-Auxiliary-CommandInfo.json +++ b/DiscoBot/Properties/DiscoBot-Auxiliary-CommandInfo.json @@ -83,9 +83,19 @@ { "Name": "Gm", "Scope": "Meister", - "Brief": "Testbeschreibung", + "Brief": "Kontrolliere andere Charaktere", "Description": [ - "Gm Aktionen" + "Mit !GM fürhrt man commands als eine andere Person aus.", + " !GM [charaktername] [command] [commandattribut] [mofifier]", + " Unterstützte [commands]'s:", + " !GM [name] LE", + " !GM [name] AE", + " !GM [name] Talent", + " !GM [name] Fernkampf", + " !GM [name] Eigenschaft", + " !GM [name] Zauber", + " !GM [name] Angriff", + " !GM [name] Parade" ] } ] \ No newline at end of file diff --git a/DiscoBot/sessions/TheCrew/TheCrew-0.json b/DiscoBot/sessions/TheCrew/TheCrew-0.json new file mode 100644 index 0000000..575cd54 --- /dev/null +++ b/DiscoBot/sessions/TheCrew/TheCrew-0.json @@ -0,0 +1,83 @@ +{ + "GeneralContext": null, + "Relation": { + "Nicolas": "Hartmut Reiher", + "MagicBro5": "Krenko", + "TrueKuehli": "Ledur Torfinson" + }, + "Chars": [ + { + "Name": "Felis Exodus Schattenwald", + "Lebenspunkte_Aktuell": 30, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 20 + }, + { + "Name": "Gardist", + "Lebenspunkte_Aktuell": 29, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 0 + }, + { + "Name": "Hartmut Reiher", + "Lebenspunkte_Aktuell": 29, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 0 + }, + { + "Name": "Helga vom Drachenei, Tausendsasserin", + "Lebenspunkte_Aktuell": 21, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 35 + }, + { + "Name": "Krenko", + "Lebenspunkte_Aktuell": 22, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 0 + }, + { + "Name": "Ledur Torfinson", + "Lebenspunkte_Aktuell": 39, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 0 + }, + { + "Name": "Morla", + "Lebenspunkte_Aktuell": 26, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 13 + }, + { + "Name": "Numeri Illuminus", + "Lebenspunkte_Aktuell": 28, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 40 + }, + { + "Name": "Potus", + "Lebenspunkte_Aktuell": 39, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 16 + }, + { + "Name": "Pump aus der Gosse", + "Lebenspunkte_Aktuell": 18, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 13 + }, + { + "Name": "Rhoktar4", + "Lebenspunkte_Aktuell": 34, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 17 + }, + { + "Name": "Volant", + "Lebenspunkte_Aktuell": 28, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Aktuell": 43 + } + ], + "SessionName": "TheCrew" +} \ No newline at end of file -- cgit v1.2.3-70-g09d2