diff options
author | Dennis Kobert <d-kobert@web.de> | 2017-11-03 20:07:03 +0100 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2017-11-03 20:07:03 +0100 |
commit | e49ac2778bb6d38517f14447c0675df354552528 (patch) | |
tree | b549066769229d8c7b189efad8ac5bc2dda08015 /DiscoBot/Char.cs | |
parent | 2fe5af08ab78e01ddda7fe31ab08526eb9a11f14 (diff) | |
parent | d59a67e552628b464f079bccae20349d649bdd61 (diff) |
test
Diffstat (limited to 'DiscoBot/Char.cs')
-rw-r--r-- | DiscoBot/Char.cs | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/DiscoBot/Char.cs b/DiscoBot/Char.cs new file mode 100644 index 0000000..28ed7b9 --- /dev/null +++ b/DiscoBot/Char.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml; + +namespace DiscoBot +{ + public class Char + { + + string name; + public Dictionary<string, int> eigenschaften = new Dictionary<string, int>(); + public List<Talent> talente = new List<Talent>(); + public List<Kampf> kampftalente = new List<Kampf>(); + + public Dictionary<string, string> Proptable = new Dictionary<string, string>(); + + + public Char(String path = "Felis.xml") + { + + Load(path); + } + + private void Load(string path) + { + XmlTextReader reader = new XmlTextReader(path); + while (reader.Read()) + { + if (reader.NodeType == XmlNodeType.Element) + switch (reader.Name) + { + case "held": + name = reader.GetAttribute("name"); + break; + case "eigenschaft": + eigenschaften.Add(reader.GetAttribute("name"), Convert.ToInt32(reader.GetAttribute("value")) + Convert.ToInt32(reader.GetAttribute("mod"))); + break; + case "talentliste": + reader.Read(); + while (reader.Name.Equals("talent")) + { + 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(); + int at = Convert.ToInt32(reader.GetAttribute("value")); + reader.Read(); + int pa = Convert.ToInt32(reader.GetAttribute("value")); + kampftalente.Add(new Kampf(atname, at, pa)); + break; + } + + + + } + Proptable.Add("MU", "Mut"); + Proptable.Add("KL", "Klugheit"); + Proptable.Add("IN", "Intuition"); + Proptable.Add("CH", "Charisma"); + Proptable.Add("FF", "Fingerfertigkeit"); + Proptable.Add("GE", "Gewandtheit"); + Proptable.Add("KO", "Konstitution"); + Proptable.Add("KK", "Körperkraft"); + + } + public string TestTalent(string talent) + { + var output = new StringBuilder(); + var ttalent = talente.Find(v => v.name.Equals(talent)); + 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+" "); + } + output.Append("tap: "+ tap); + return output.ToString(); + } + + } + public class Talent + { + 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() + { + var temp = probe.Split('/'); + foreach (string s in temp) + s.Replace("/", ""); + return temp; + } + + } + public class Kampf + { + string name; + private 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 + { + static System.Random rnd = new System.Random(); + public static int Rolld20() + { + return rnd.Next(1,21) ; + } + } +} |