summaryrefslogtreecommitdiff
path: root/DiscoBot
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot')
-rw-r--r--DiscoBot/Char.cs88
-rw-r--r--DiscoBot/Commands.cs47
-rw-r--r--DiscoBot/DiscoBot.csproj1
-rw-r--r--DiscoBot/Misc.cs84
4 files changed, 154 insertions, 66 deletions
diff --git a/DiscoBot/Char.cs b/DiscoBot/Char.cs
index 1c838f6..352274f 100644
--- a/DiscoBot/Char.cs
+++ b/DiscoBot/Char.cs
@@ -46,6 +46,14 @@ namespace DiscoBot
reader.Read();
}
break;
+ case "zauberliste":
+ reader.Read();
+ while (reader.Name.Equals("zauber"))
+ {
+ talente.Add(new Talent(reader.GetAttribute("name"), reader.GetAttribute("probe").Remove(0, 2).Trim(')'), Convert.ToInt32(reader.GetAttribute("value"))));
+ reader.Read();
+ }
+ break;
case "kampfwerte":
string atname = reader.GetAttribute("name");
reader.Read();
@@ -72,73 +80,59 @@ namespace DiscoBot
public string TestTalent(string talent) //Talentprobe
{
var output = new StringBuilder();
- var ttalent = talente.Find(v => v.name.Equals(talent)); //find the talent
+ var ttalentlist = talente.Select(v => v.CheckName(talent)).ToList(); //find the talent
+ int error = ttalentlist.Min();
+ var ttalent = talente[ttalentlist.IndexOf(error)];
var props = ttalent.Test(); //get the required properties
int tap = ttalent.value; //get tap
+ output.AppendFormat("{0} {1} taw:{2} error: \n", ttalent.name,ttalent.probe,ttalent.value,error);
for (int i = 0; i <= 2; i++) //foreach property, dice and tap
{
- int temp = dice.Rolld20();
+ int temp = dice.Roll();
int eigenschaft = eigenschaften[Proptable[props[i]]];
if (eigenschaft < temp)
tap -= temp - eigenschaft;
output.Append(temp + " "); //add to string
}
- output.Append("tap: " + tap);
+ output.AppendFormat("tap: {0}",tap);
+ if (error == 100)
+ return talent + " nicht gefunden!";
return output.ToString(); //return output
}
public string Angriff(string talent) //prety self explanetory
{
- var attack = kampftalente.Find(x => x.name.Equals(talent));
- int tap = attack.at/*+eigenschaften["at"]*/;
- int temp = dice.Rolld20();
- tap -= temp;
- return temp + " " + tap;
+ var output = new StringBuilder();
+ var attack = kampftalente.Find(x => x.name.ToLower().Equals(talent.ToLower()));
+ int tap = attack.at;
+ output.AppendFormat("{0}-Angriff taw:{1} \n", attack.name, tap);
+ int temp = dice.Roll();
+ output.Append(temp );
+ return output.ToString();
}
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;
+ var output = new StringBuilder();
+ var attack = kampftalente.Find(x => x.name.ToLower().Equals(talent.ToLower()));
+ int tap = attack.pa;
+ output.AppendFormat("{0}-Parade taw:{1} \n", attack.name, tap);
+ int temp = dice.Roll();
+ output.Append(temp);
+ return output.ToString();
}
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 //talent objekt
- {
- public string name, probe;
- public int value;
- public Talent(string name, string probe, int value) { this.name = name; this.probe = probe; this.value = value; }
- public string[] Test() //turn XX/XX/XX into string[]{XX,XX,XX}
- {
- var temp = probe.Split('/');
- foreach (string s in temp)
- s.Replace("/", "");
- return temp;
+ var output = new StringBuilder();
+ int fk = eigenschaften["fk"];
+ var attack = talente.Find(v => v.name.ToLower().Equals(talent.ToLower()));
+ int tap = attack.value ;
+ output.AppendFormat("{0} taw:{1} erschwernis:{2} \n", attack.name, tap,erschwernis);
+ tap -= erschwernis;
+ int temp = dice.Roll();
+ tap -= temp>fk?temp-fk:0;
+ output.Append(temp + " tap:" + tap);
+ return output.ToString();
}
}
- public class Kampf
- {
- 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() { }
- }
- public static class dice//roll it!
- {
- static System.Random rnd = new System.Random();
- public static int Rolld20()
- {
- return rnd.Next(1, 21);
- }
- }
+
}
diff --git a/DiscoBot/Commands.cs b/DiscoBot/Commands.cs
index 604c83a..f812dfc 100644
--- a/DiscoBot/Commands.cs
+++ b/DiscoBot/Commands.cs
@@ -18,6 +18,7 @@ namespace DiscoBot
{
relation.Add("The Doctor", "Felis Exodus Schattenwald");//Relation
relation.Add("Tardis", "Numeri Illuminus");
+ relation.Add("DSA Bot", "Numeri Illuminus");
chars.Add(new Char(@"helden\Felis.xml")); //Savefile
chars.Add(new Char(@"helden\Numeri.xml"));
@@ -25,25 +26,34 @@ namespace DiscoBot
}
public class Info : ModuleBase
{
- // ~say hello -> hello
[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);
}
}
+ public class Roll : ModuleBase
+ {
+ [Command("r"), Summary("Würfelt ")]
+ [Alias("R", "Roll", "roll", "Würfle")]
+ public async Task Say([Remainder, Summary("Weapon")] string roll)
+ {
+
+ await ReplyAsync("```xl\n**" + Misc.Roll(roll) + "**\n```");
+
+ }
+ }
+
public class TestTalent : ModuleBase
{
- // ~say hello -> hello
- [Command("t"), Summary("tests a talent.")]
- public async Task Say([Remainder, Summary("The text to echo")] string talent)
+ [Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
+ [Alias("T", "Talent", "talent","zauber","z", "versuche")]
+ public async Task Say([Remainder, Summary("Talent oder Zaubername")] string talent)
{
- // ReplyAsync is a method on ModuleBase
await ReplyAsync("```xl\n" + DSA.chars.Find(x=>x.name.Equals(DSA.relation[Context.User.Username])).TestTalent(talent) + "\n```");
@@ -51,24 +61,22 @@ namespace DiscoBot
}
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)
+ [Command("a"), Summary("Würfelt ein Angriff")]
+ [Alias("A", "Angriff", "angriff", "attackiere_mit","attacke","Attacke")]
+ public async Task Say([Remainder, Summary("Weapon")] string weapon)
{
- // 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```");
+ await ReplyAsync("```xl\n" + DSA.chars.Find(x => x.name.Equals(DSA.relation[Context.User.Username])).Angriff(weapon) + "\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)
+ [Command("p"), Summary("Würfelt eine Parade Probe")]
+ [Alias("P", "Parade", "parade","pariere_mit")]
+ public async Task Say([Remainder, Summary("Parade Weapon")] 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```");
}
@@ -76,12 +84,13 @@ namespace DiscoBot
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)
+ [Command("f"), Summary("Führt eine Fernkampfprobe aus")]
+ [Alias("F", "fernkampf", "Fernkampf", "schieße", "schieße_mit")]
+ public async Task Say([Summary("Fernkampfwaffe")] string talent,int erschwernis=0)
{
// 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```");
+ await ReplyAsync("```xl\n" + DSA.chars.Find(x => x.name.Equals(DSA.relation[Context.User.Username])).Fernkampf(talent,erschwernis) + "\n```");
}
}
diff --git a/DiscoBot/DiscoBot.csproj b/DiscoBot/DiscoBot.csproj
index 9920f40..d4f3290 100644
--- a/DiscoBot/DiscoBot.csproj
+++ b/DiscoBot/DiscoBot.csproj
@@ -132,6 +132,7 @@
<ItemGroup>
<Compile Include="Char.cs" />
<Compile Include="Commands.cs" />
+ <Compile Include="Misc.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
diff --git a/DiscoBot/Misc.cs b/DiscoBot/Misc.cs
new file mode 100644
index 0000000..c310148
--- /dev/null
+++ b/DiscoBot/Misc.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DiscoBot
+{
+ public static class Misc
+ {
+ public static string Roll(string input)
+ {
+ int count = 1, d,mod=0;
+ var Output = new StringBuilder();
+ List<string> strings = input.Split('d').ToList();
+ count = Convert.ToInt32(strings[0]);
+ strings = strings[1].Split(' ').ToList();
+ d = Convert.ToInt32(strings[0]);
+
+ if (strings.Count > 0)
+ mod = Convert.ToInt32(strings.Last());
+ int sum = 0;
+ for (int i = 0; i < count; i++)
+ {
+ var roll = dice.Roll(d);
+ sum += roll;
+ Output.Append(roll + " ");
+ }
+ if (count > 1)
+ Output.Append("sum: " + (sum));
+
+ return Output.ToString();
+ }
+ }
+ public static class dice//roll it!
+ {
+ static System.Random rnd = new System.Random();
+ public static int Roll(int d=20)
+ {
+ return rnd.Next(1, d+1);
+ }
+ }
+ public class Talent //talent objekt
+ {
+ public string name, probe;
+ public int value;
+ public Talent(string name, string probe, int value) { this.name = name; this.probe = probe; this.value = value; }
+ public string[] Test() //turn XX/XX/XX into string[]{XX,XX,XX}
+ {
+ var temp = probe.Split('/');
+ foreach (string s in temp)
+ s.Replace("/", "");
+ return temp;
+ }
+
+ public int CheckName(string quary)
+ {
+ if (quary.Equals(name))
+ return 0;
+ if (String.Compare(name, quary, StringComparison.InvariantCultureIgnoreCase) == 0)
+ return 1;
+ var subs = name.Split(' ','/');
+ int score = subs.Count();
+ foreach (String s in subs)
+ if (String.Compare(name, quary, StringComparison.InvariantCultureIgnoreCase) == 0)
+ score--;
+ if (score != subs.Count())
+ return score+1;
+ if (name.ToLowerInvariant().Contains(quary.ToLower()))
+ return 3;
+
+ return 100;
+ }
+
+ }
+ public class Kampf
+ {
+ 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() { }
+ }
+
+}