diff options
Diffstat (limited to 'DSALib/Characters')
-rw-r--r-- | DSALib/Characters/Critter.cs | 74 |
1 files changed, 62 insertions, 12 deletions
diff --git a/DSALib/Characters/Critter.cs b/DSALib/Characters/Critter.cs index 5090b6b..c6776ed 100644 --- a/DSALib/Characters/Critter.cs +++ b/DSALib/Characters/Critter.cs @@ -1,26 +1,64 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DSALib.Characters { + using System.IO; + using DiscoBot.DSA_Game.Characters; + using Newtonsoft.Json; + public class Critter : Being, ICombatant { - private int rs, mr, ko, pa, gs, gw; - + public int Rs { get; set; } + + public int Mr { get; set; } + + public int Ko { get; set; } + + public int Pa { get; set; } + + public int Gs { get; set; } + + public int Gw { get; set; } + + public string Ini { get; set; } + + public string Comment { get; set; } + + public List<CritterAttack> CritterAttacks { get; set; } - public Critter(int gw, int gs, int rs, int mr, int ko, int pa) + private CritterAttack lastAttack; + + public Critter(int gw, int gs, int rs, int mr, int ko, int pa, string ini, List<CritterAttack> critterAttacks) + { + this.Gw = gw; + this.Gs = gs; + this.Rs = rs; + this.Mr = mr; + this.Ko = ko; + this.Pa = pa; + this.Ini = ini; + this.CritterAttacks = critterAttacks; + this.lastAttack = this.CritterAttacks[new Random().Next(critterAttacks.Count)]; + } + + public Critter() + { + } + + public static Critter Load(string path) { - this.gw = gw; - this.gs = gs; - this.rs = rs; - this.mr = mr; - this.ko = ko; - this.pa = pa; + try + { + return JsonConvert.DeserializeObject<Critter>(File.ReadAllText(path)); // Deserialize Data and create Session Object + } + catch (Exception e) + { + Console.WriteLine($"Laden von Save-File {path} fehlgeschlagen." + e); + return null; + } } public string Angriff(string talent, int erschwernis = 0) @@ -32,5 +70,17 @@ namespace DSALib.Characters { throw new NotImplementedException(); } + + public void Save(string path = @"..\..\Critters\") + { + try + { + File.WriteAllText(path + this.Name + ".json", JsonConvert.SerializeObject(this, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct + } + catch (Exception e) + { + Console.WriteLine($"Speichern von Save-File {path} fehlgeschlagen." + e); + } + } } } |