From 5861eccde04faa9c1584c6705a69040182296f93 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Tue, 22 Aug 2017 23:20:23 +0200 Subject: added support for more charackters automated char selection attack parade ranged combat --- DiscoBot/Char.cs | 42 ++++++++++++++++++++++++++++++--------- DiscoBot/Commands.cs | 55 +++++++++++++++++++++++++++++++++++++++++++++++----- DiscoBot/Program.cs | 4 ++-- 3 files changed, 85 insertions(+), 16 deletions(-) (limited to 'DiscoBot') diff --git a/DiscoBot/Char.cs b/DiscoBot/Char.cs index 28ed7b9..d64f434 100644 --- a/DiscoBot/Char.cs +++ b/DiscoBot/Char.cs @@ -10,7 +10,7 @@ namespace DiscoBot public class Char { - string name; + public string name; public Dictionary eigenschaften = new Dictionary(); public List talente = new List(); public List kampftalente = new List(); @@ -18,7 +18,7 @@ namespace DiscoBot public Dictionary Proptable = new Dictionary(); - public Char(String path = "Felis.xml") + public Char(String path ) { Load(path); @@ -73,19 +73,43 @@ namespace DiscoBot { var output = new StringBuilder(); var ttalent = talente.Find(v => v.name.Equals(talent)); - var props =ttalent.Test(); + var props = ttalent.Test(); int tap = ttalent.value; for (int i = 0; i <= 2; i++) { int temp = dice.Rolld20(); int eigenschaft = eigenschaften[Proptable[props[i]]]; if (eigenschaft < temp) - tap -= temp - eigenschaft ; - output.Append(temp+" "); + tap -= temp - eigenschaft; + output.Append(temp + " "); } - output.Append("tap: "+ tap); + output.Append("tap: " + tap); return output.ToString(); } + public string Angriff(string talent) + { + var attack = kampftalente.Find(x => x.name.Equals(talent)); + int tap = attack.at/*+eigenschaften["at"]*/; + int temp = dice.Rolld20(); + tap -= temp; + return temp + " " + tap; + } + public string Parade(string talent) + { + var attack = kampftalente.Find(x => x.name.Equals(talent)); + int tap = attack.pa /*+ eigenschaften["pa"]*/; + int temp = dice.Rolld20(); + tap -= temp; + return temp + " " + tap; + } + public string Fernkampf(string talent,int erschwernis=0) + { + var attack = talente.Find(v => v.name.Equals(talent)); + int tap = attack.value + eigenschaften["fk"]-erschwernis; + int temp = dice.Rolld20(); + tap -= -temp; + return temp + " " + tap; + } } public class Talent @@ -104,8 +128,8 @@ namespace DiscoBot } public class Kampf { - string name; - private int at, pa; + public string name; + public int at, pa; public Kampf(string name, int at, int pa) { this.name = name; this.at = at; this.pa = pa; } void Test() { } } @@ -114,7 +138,7 @@ namespace DiscoBot static System.Random rnd = new System.Random(); public static int Rolld20() { - return rnd.Next(1,21) ; + return rnd.Next(1, 21); } } } diff --git a/DiscoBot/Commands.cs b/DiscoBot/Commands.cs index 6984761..8e85daf 100644 --- a/DiscoBot/Commands.cs +++ b/DiscoBot/Commands.cs @@ -10,8 +10,18 @@ using Discord.WebSocket; namespace DiscoBot { - class Commands + public static class DSA { + public static Dictionary relation = new Dictionary(); + public static List chars = new List(); + public static void Startup() + { + relation.Add("The Doctor", "Felis Exodus Schattenwald"); + relation.Add("Tardis", "Numeri Illuminus"); + chars.Add(new Char(@"helden\Felis.xml")); + chars.Add(new Char(@"helden\Numeri.xml")); + + } } public class Info : ModuleBase { @@ -19,7 +29,7 @@ namespace DiscoBot [Command("say"), Summary("Echos a message.")] public async Task Say([Remainder, Summary("The text to echo")] string echo) { - + var a = Context.User.Username; // ReplyAsync is a method on ModuleBase await ReplyAsync(echo); @@ -27,16 +37,51 @@ namespace DiscoBot } } - public class Abfrage : ModuleBase + public class TestTalent : ModuleBase { - Char test = new Char(); // ~say hello -> hello [Command("t"), Summary("tests a talent.")] public async Task Say([Remainder, Summary("The text to echo")] string talent) { // ReplyAsync is a method on ModuleBase - await ReplyAsync("```xl\n" + test.TestTalent(talent) + "\n```"); + await ReplyAsync("```xl\n" + DSA.chars.Find(x=>x.name.Equals(DSA.relation[Context.User.Username])).TestTalent(talent) + "\n```"); + + } + } + public class Angriff : ModuleBase + { + // ~say hello -> hello + [Command("a"), Summary("tests a attack.")] + public async Task Say([Remainder, Summary("The text to echo")] string talent) + { + // ReplyAsync is a method on ModuleBase + + await ReplyAsync("```xl\n" + DSA.chars.Find(x => x.name.Equals(DSA.relation[Context.User.Username])).Angriff(talent) + "\n```"); + + } + } + public class Parade : ModuleBase + { + // ~say hello -> hello + [Command("p"), Summary("tests a parade.")] + public async Task Say([Remainder, Summary("The text to echo")] string talent) + { + // ReplyAsync is a method on ModuleBase + + await ReplyAsync("```xl\n" + DSA.chars.Find(x => x.name.Equals(DSA.relation[Context.User.Username])).Parade(talent) + "\n```"); + + } + } + public class Fernkampf : ModuleBase + { + // ~say hello -> hello + [Command("f"), Summary("tests a shot.")] + public async Task Say([Remainder, Summary("The text to echo")] string talent) + { + // ReplyAsync is a method on ModuleBase + + await ReplyAsync("```xl\n" + DSA.chars.Find(x => x.name.Equals(DSA.relation[Context.User.Username])).Fernkampf(talent) + "\n```"); } } diff --git a/DiscoBot/Program.cs b/DiscoBot/Program.cs index 962e416..1e97fc2 100644 --- a/DiscoBot/Program.cs +++ b/DiscoBot/Program.cs @@ -17,14 +17,14 @@ namespace DiscoBot private CommandService commands; private DiscordSocketClient client; private IServiceProvider services; - - public Char a = new Char(); + static void Main(string[] args) => new Program().Start().GetAwaiter().GetResult(); public async Task Start() { + DSA.Startup(); client = new DiscordSocketClient(); commands = new CommandService(); -- cgit v1.2.3-54-g00ecf