diff options
author | TrueDoctor <d-kobert@web.de> | 2018-06-22 15:56:04 +0200 |
---|---|---|
committer | TrueDoctor <d-kobert@web.de> | 2018-06-22 15:56:04 +0200 |
commit | b9abcb7ed618f08d7b2614843ab6c4feea5ff573 (patch) | |
tree | 93d3f83e5b85502dd3311b73dc6140b40e7b1e25 /DiscoBot/DSA_Game | |
parent | a6aaf717690551e72e2bcaa418f61f51b91ab630 (diff) |
Character stats do now get updated, when a session is loaded or saved
Diffstat (limited to 'DiscoBot/DSA_Game')
-rw-r--r-- | DiscoBot/DSA_Game/Characters/SaveChar.cs | 14 | ||||
-rw-r--r-- | DiscoBot/DSA_Game/Dsa.cs | 31 |
2 files changed, 38 insertions, 7 deletions
diff --git a/DiscoBot/DSA_Game/Characters/SaveChar.cs b/DiscoBot/DSA_Game/Characters/SaveChar.cs index 89ca98a..4c9a940 100644 --- a/DiscoBot/DSA_Game/Characters/SaveChar.cs +++ b/DiscoBot/DSA_Game/Characters/SaveChar.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; namespace DiscoBot.DSA_Game.Characters { + using Discord; + public class SaveChar { public string Name { get; set; } @@ -27,4 +29,16 @@ namespace DiscoBot.DSA_Game.Characters }; } } + + + public static class ICharExtension + { + public static void Update(this ICharacter c, SaveChar s) + { + c.Astralpunkte_Aktuell = s.Astralpunkte_Aktuell; + c.Ausdauer_Aktuell = s.Ausdauer_Aktuell; + c.Lebenspunkte_Aktuell = s.Lebenspunkte_Aktuell; + c.Name = s.Name; + } + } } diff --git a/DiscoBot/DSA_Game/Dsa.cs b/DiscoBot/DSA_Game/Dsa.cs index f1ed069..09e874d 100644 --- a/DiscoBot/DSA_Game/Dsa.cs +++ b/DiscoBot/DSA_Game/Dsa.cs @@ -14,6 +14,8 @@ public static class Dsa { + private static Session s_session; + public static ICommandContext GeneralContext { get; set; } public static AudioService Service { get; set; } @@ -22,11 +24,27 @@ public static List<Talent> Talente { get; set; } = new List<Talent>(); - public static Session Session { get; set; } = new Session(); + public static Session Session + { + get + { + s_session.Chars = Chars.Select(x => SaveChar.FromICharacter(x)).ToList(); + return s_session; + } + + set + { + s_session = value; + foreach (var x in value.Chars) + { + Chars.Find(c => c.Name.Equals(x.Name)).Update(x); + } + } + } public static void Startup() { - + /*Session = new Session();*/ // relation.Add("Papo", "Pump aus der Gosse"); foreach (var filename in Directory.GetFiles("helden", "*.xml")) { @@ -39,12 +57,11 @@ Properties.Serialize(); Talente = Talente.OrderBy(x => x.Name).ToList(); - Session = new Session - { - Chars = Chars.Select(x => SaveChar.FromICharacter(x)).ToList(), - GeneralContext = GeneralContext - }; + { + Chars = Chars.Select(x => SaveChar.FromICharacter(x)).ToList(), + GeneralContext = GeneralContext + }; Session.Save(); } } |