diff options
author | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
commit | 1509b5ef3d7e9e71d9294e234ec0e39f2d831998 (patch) | |
tree | 78300ffff230958101b422a4e6026925b287822f /DSACore/DSA_Game/Characters/Character.cs | |
parent | c3bb858bb54dc8c64bbd48054c2c58dc0073f09c (diff) | |
parent | c4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff) |
Merge branch 'scribble' of https://github.com/TrueDoctor/DiscoBot into scribble
Diffstat (limited to 'DSACore/DSA_Game/Characters/Character.cs')
-rw-r--r-- | DSACore/DSA_Game/Characters/Character.cs | 188 |
1 files changed, 83 insertions, 105 deletions
diff --git a/DSACore/DSA_Game/Characters/Character.cs b/DSACore/DSA_Game/Characters/Character.cs index 247fc58..ac890cb 100644 --- a/DSACore/DSA_Game/Characters/Character.cs +++ b/DSACore/DSA_Game/Characters/Character.cs @@ -1,129 +1,117 @@ -using System.IO; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml; using DSACore.Auxiliary; using DSALib; using DSALib.Characters; namespace DSACore.DSA_Game.Characters { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Xml; - - public class Character : Being, ICharacter { public Character() { - this.PropTable.Add("MU", "Mut"); // routing - this.PropTable.Add("KL", "Klugheit"); - this.PropTable.Add("IN", "Intuition"); - this.PropTable.Add("CH", "Charisma"); - this.PropTable.Add("FF", "Fingerfertigkeit"); - this.PropTable.Add("GE", "Gewandtheit"); - this.PropTable.Add("KO", "Konstitution"); - this.PropTable.Add("KK", "Körperkraft"); - + PropTable.Add("MU", "Mut"); // routing + 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 Character(string path) : this() { - this.Load(new MemoryStream(File.ReadAllBytes(path))); // load - this.Post_process(); // calculate derived values + Load(new MemoryStream(File.ReadAllBytes(path))); // load + Post_process(); // calculate derived values } + public Character(MemoryStream stream) : this() { - this.Load(stream); // load - this.Post_process(); // calculate derived values + Load(stream); // load + Post_process(); // calculate derived values } public Character(Character c, string name, int stDv = 2) : this() { - this.Name = name; + Name = name; foreach (var i in c.Eigenschaften) - { - this.Eigenschaften.Add(i.Key, i.Value + (int)Math.Round(RandomMisc.Random(stDv))); - } + Eigenschaften.Add(i.Key, i.Value + (int) Math.Round(RandomMisc.Random(stDv))); foreach (var i in c.Vorteile) - { - this.Vorteile.Add(new Vorteil(i.Name, i.Value + (int)Math.Round(RandomMisc.Random(stDv)))); - } + Vorteile.Add(new Vorteil(i.Name, i.Value + (int) Math.Round(RandomMisc.Random(stDv)))); foreach (var i in c.Talente) - { - this.Talente.Add(new Talent(i.Name, i.Probe, i.Value + (int)Math.Round(RandomMisc.Random(stDv)))); - } + Talente.Add(new Talent(i.Name, i.Probe, i.Value + (int) Math.Round(RandomMisc.Random(stDv)))); foreach (var i in c.Zauber) - { - this.Zauber.Add(new Zauber(i.Name, i.Probe, i.Value + (int)Math.Round(RandomMisc.Random(stDv)), i.Complexity, i.Representation)); - } + Zauber.Add(new Zauber(i.Name, i.Probe, i.Value + (int) Math.Round(RandomMisc.Random(stDv)), + i.Complexity, i.Representation)); foreach (var i in c.Kampftalente) - { - this.Kampftalente.Add(new KampfTalent(i.Name, i.At + (int)Math.Round(RandomMisc.Random(stDv)), i.Pa + (int)Math.Round(RandomMisc.Random(stDv)))); - } + Kampftalente.Add(new KampfTalent(i.Name, i.At + (int) Math.Round(RandomMisc.Random(stDv)), + i.Pa + (int) Math.Round(RandomMisc.Random(stDv)))); - this.Post_process(); // calculate derived values + Post_process(); // calculate derived values } - public Dictionary<string, int> Eigenschaften { get; set; } = new Dictionary<string, int>(); // char properties + public Dictionary<string, int> Eigenschaften { get; set; } = new Dictionary<string, int>(); // char properties - public List<Talent> Talente { get; set; } = new List<Talent>(); // list of talent objects (talents) + public List<Talent> Talente { get; set; } = new List<Talent>(); // list of talent objects (talents) - public List<Zauber> Zauber { get; set; } = new List<Zauber>(); // list of spell objects + public List<Zauber> Zauber { get; set; } = new List<Zauber>(); // list of spell objects - public List<KampfTalent> Kampftalente { get; set; } = new List<KampfTalent>(); // list of combat objects + public List<KampfTalent> Kampftalente { get; set; } = new List<KampfTalent>(); // list of combat objects public List<Vorteil> Vorteile { get; set; } = new List<Vorteil>(); public Dictionary<string, string> PropTable { get; set; } = new Dictionary<string, string>(); // -> Körperkraft - public string TestTalent(string talent, int erschwernis = 0) // Talentprobe + public string TestTalent(string talent, int erschwernis = 0) // Talentprobe { - return this.Talente.ProbenTest(this, talent, erschwernis); + return Talente.ProbenTest(this, talent, erschwernis); } - public string TestZauber(string zauber, int erschwernis = 0) // Talentprobe + public string TestZauber(string zauber, int erschwernis = 0) // Talentprobe { - return this.Zauber.ProbenTest(this, zauber, erschwernis); + return Zauber.ProbenTest(this, zauber, erschwernis); } public string TestEigenschaft(string eigenschaft, int erschwernis = 0) { var output = new StringBuilder(); - var prop = this.PropTable[eigenschaft.ToUpper()]; - int tap = this.Eigenschaften[prop]; + var prop = PropTable[eigenschaft.ToUpper()]; + var tap = Eigenschaften[prop]; output.AppendFormat( "{0}-Eigenschaftsprobe ew:{1} {2} \n", prop, tap, erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis); - int roll = Dice.Roll(); + var roll = Dice.Roll(); output.Append($"Gewürfelt: {roll} übrig: {tap - roll - erschwernis}"); return output.ToString(); } - public string Angriff(string talent, int erschwernis = 0) // pretty self explanatory + public string Angriff(string talent, int erschwernis = 0) // pretty self explanatory { var output = new StringBuilder(); var sc = new SpellCorrect(); - var attack = this.Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First(); + var attack = Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First(); if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold) - { - return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen..."; - } + return $"{Name} kann nicht mit der Waffenart {talent} umgehen..."; - int tap = attack.At; + var tap = attack.At; output.AppendFormat( "{0}-Angriff taw:{1} {2} \n", attack.Name, tap, erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis); - int temp = Dice.Roll(); + var temp = Dice.Roll(); output.Append(temp - erschwernis); return output.ToString(); } @@ -132,21 +120,19 @@ namespace DSACore.DSA_Game.Characters { var output = new StringBuilder(); var sc = new SpellCorrect(); - var attack = this.Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First(); + var attack = Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First(); if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold) - { - return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen..."; - } + return $"{Name} kann nicht mit der Waffenart {talent} umgehen..."; - int tap = attack.Pa; + var tap = attack.Pa; output.AppendFormat( "{0}-Parade taw:{1} {2}\n", attack.Name, tap, erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis); - int temp = Dice.Roll(); + var temp = Dice.Roll(); output.Append(temp - erschwernis); return output.ToString(); } @@ -155,21 +141,19 @@ namespace DSACore.DSA_Game.Characters { var output = new StringBuilder(); var sc = new SpellCorrect(); - int fk = this.Eigenschaften["fk"]; - var attack = this.Talente.OrderBy(x => sc.Compare(talent, x.Name)).First(); + var fk = Eigenschaften["fk"]; + var attack = Talente.OrderBy(x => sc.Compare(talent, x.Name)).First(); if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold) - { - return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen..."; - } + return $"{Name} kann nicht mit der Waffenart {talent} umgehen..."; - int tap = attack.Value; + var tap = attack.Value; output.AppendFormat( "{0} taw:{1} {2} \n", attack.Name, tap, erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis); tap -= erschwernis; - int temp = Dice.Roll(); + var temp = Dice.Roll(); tap -= temp > fk ? temp - fk : 0; output.Append($"W20: {temp} tap: {tap}"); return output.ToString(); @@ -177,34 +161,30 @@ namespace DSACore.DSA_Game.Characters private void Post_process() { - var LE_Wert = this.Eigenschaften["Lebensenergie"]; - var AE_Wert = this.Eigenschaften.First(s => s.Key.Contains("Astralenergie")).Value; + var LE_Wert = Eigenschaften["Lebensenergie"]; + var AE_Wert = Eigenschaften.First(s => s.Key.Contains("Astralenergie")).Value; //var KL_Wert = this.Eigenschaften.First(s => s.Key.Contains("Klugheit")).Value; - var MU_Wert = this.Eigenschaften.First(s => s.Key.Contains("Mut")).Value; - var IN_Wert = this.Eigenschaften.First(s => s.Key.Contains("Intuition")).Value; - var CH_Wert = this.Eigenschaften.First(s => s.Key.Contains("Charisma")).Value; - var KK_Wert = this.Eigenschaften["Körperkraft"]; - var KO__Wert = this.Eigenschaften["Konstitution"]; - - this.Astralpunkte_Basis = 0; + var MU_Wert = Eigenschaften.First(s => s.Key.Contains("Mut")).Value; + var IN_Wert = Eigenschaften.First(s => s.Key.Contains("Intuition")).Value; + var CH_Wert = Eigenschaften.First(s => s.Key.Contains("Charisma")).Value; + var KK_Wert = Eigenschaften["Körperkraft"]; + var KO__Wert = Eigenschaften["Konstitution"]; - this.Ausdauer_Basis = 0; + Astralpunkte_Basis = 0; - this.Lebenspunkte_Basis = LE_Wert + (int)(KO__Wert + (KK_Wert / 2.0) + 0.5); + Ausdauer_Basis = 0; - if (this.Vorteile.Exists(x => x.Name.ToLower().Contains("zauberer"))) - { - this.Astralpunkte_Basis = AE_Wert + (int)((MU_Wert + IN_Wert + CH_Wert) / 2.0 + 0.5); - } + Lebenspunkte_Basis = LE_Wert + (int) (KO__Wert + KK_Wert / 2.0 + 0.5); - this.Lebenspunkte_Aktuell = this.Lebenspunkte_Basis; - this.Astralpunkte_Aktuell = this.Astralpunkte_Basis; - this.Ausdauer_Aktuell = this.Ausdauer_Basis; + if (Vorteile.Exists(x => x.Name.ToLower().Contains("zauberer"))) + Astralpunkte_Basis = AE_Wert + (int) ((MU_Wert + IN_Wert + CH_Wert) / 2.0 + 0.5); + Lebenspunkte_Aktuell = Lebenspunkte_Basis; + Astralpunkte_Aktuell = Astralpunkte_Basis; + Ausdauer_Aktuell = Ausdauer_Basis; } - private void Load(MemoryStream stream) { @@ -212,10 +192,7 @@ namespace DSACore.DSA_Game.Characters while (reader.Read()) { // read until he hits keywords - if (reader.NodeType != XmlNodeType.Element) - { - continue; - } + if (reader.NodeType != XmlNodeType.Element) continue; switch (reader.Name) { @@ -223,12 +200,13 @@ namespace DSACore.DSA_Game.Characters reader.Skip(); break; case "held": - this.Name = reader.GetAttribute("name"); // name + Name = reader.GetAttribute("name"); // name break; case "eigenschaft": - this.Eigenschaften.Add( + Eigenschaften.Add( reader.GetAttribute("name") ?? throw new InvalidOperationException(), - Convert.ToInt32(reader.GetAttribute("value")) + Convert.ToInt32(reader.GetAttribute("mod"))); + Convert.ToInt32(reader.GetAttribute("value")) + + Convert.ToInt32(reader.GetAttribute("mod"))); break; case "vt": reader.Read(); @@ -236,14 +214,14 @@ namespace DSACore.DSA_Game.Characters { try { - this.Vorteile.Add(new Vorteil( + Vorteile.Add(new Vorteil( reader.GetAttribute("name"), - // Convert.ToInt32(reader.GetAttribute("value")))); - reader.GetAttribute("value"))); + // Convert.ToInt32(reader.GetAttribute("value")))); + reader.GetAttribute("value"))); } catch { - this.Vorteile.Add(new Vorteil(reader.GetAttribute("name"))); + Vorteile.Add(new Vorteil(reader.GetAttribute("name"))); } reader.Read(); @@ -254,7 +232,7 @@ namespace DSACore.DSA_Game.Characters reader.Read(); while (reader.Name.Equals("talent")) { - this.Talente.Add( + Talente.Add( new Talent( reader.GetAttribute("name"), reader.GetAttribute("probe")?.Remove(0, 2).Trim(')'), @@ -267,7 +245,7 @@ namespace DSACore.DSA_Game.Characters reader.Read(); while (reader.Name.Equals("zauber")) { - this.Zauber.Add( + Zauber.Add( new Zauber( reader.GetAttribute("name"), reader.GetAttribute("probe")?.Remove(0, 2).Trim(')'), @@ -279,12 +257,12 @@ namespace DSACore.DSA_Game.Characters break; case "kampfwerte": - string atName = reader.GetAttribute("name"); + var atName = reader.GetAttribute("name"); reader.Read(); - int at = Convert.ToInt32(reader.GetAttribute("value")); + var at = Convert.ToInt32(reader.GetAttribute("value")); reader.Read(); - int pa = Convert.ToInt32(reader.GetAttribute("value")); - this.Kampftalente.Add(new KampfTalent(atName, at, pa)); + var pa = Convert.ToInt32(reader.GetAttribute("value")); + Kampftalente.Add(new KampfTalent(atName, at, pa)); break; } } |