summaryrefslogtreecommitdiff
path: root/DiscoBot/DSA_Game
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot/DSA_Game')
-rw-r--r--DiscoBot/DSA_Game/Characters/Character.cs4
-rw-r--r--DiscoBot/DSA_Game/Characters/SaveChar.cs69
-rw-r--r--DiscoBot/DSA_Game/Dsa.cs27
-rw-r--r--DiscoBot/DSA_Game/Save/Properties.cs5
-rw-r--r--DiscoBot/DSA_Game/Save/Session.cs50
5 files changed, 140 insertions, 15 deletions
diff --git a/DiscoBot/DSA_Game/Characters/Character.cs b/DiscoBot/DSA_Game/Characters/Character.cs
index c1acd39..6616a03 100644
--- a/DiscoBot/DSA_Game/Characters/Character.cs
+++ b/DiscoBot/DSA_Game/Characters/Character.cs
@@ -222,9 +222,9 @@
this.Lebenspunkte_Aktuell = this.Lebenspunkte_Basis;
this.Astralpunkte_Aktuell = this.Astralpunkte_Basis;
this.Ausdauer_Aktuell = this.Ausdauer_Basis;
-
-
+
}
+
private void Load(string path)
{
diff --git a/DiscoBot/DSA_Game/Characters/SaveChar.cs b/DiscoBot/DSA_Game/Characters/SaveChar.cs
new file mode 100644
index 0000000..94538bb
--- /dev/null
+++ b/DiscoBot/DSA_Game/Characters/SaveChar.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DiscoBot.DSA_Game.Characters
+{
+ public class SaveChar : ICharacter
+ {
+ public string Name { get; set; }
+
+ public int Lebenspunkte_Basis { get; set; }
+
+ public int Lebenspunkte_Aktuell { get; set; }
+
+ public int Ausdauer_Basis { get; set; }
+
+ public int Ausdauer_Aktuell { get; set; }
+
+ public int Astralpunkte_Basis { get; set; }
+
+ public int Astralpunkte_Aktuell { get; set; }
+
+ public static SaveChar FromICharacter(ICharacter c)
+ {
+ return new SaveChar
+ {
+ Astralpunkte_Aktuell = c.Astralpunkte_Aktuell,
+ Astralpunkte_Basis = c.Astralpunkte_Basis,
+ Ausdauer_Aktuell = c.Ausdauer_Aktuell,
+ Ausdauer_Basis = c.Ausdauer_Basis,
+ Lebenspunkte_Aktuell = c.Lebenspunkte_Aktuell,
+ Lebenspunkte_Basis = c.Lebenspunkte_Basis,
+ Name = c.Name
+ };
+ }
+
+ public string TestTalent(string talent, int erschwernis = 0)
+ {
+ throw new NotImplementedException();
+ }
+
+ public string TestEigenschaft(string eigenschaft, int erschwernis = 0)
+ {
+ throw new NotImplementedException();
+ }
+
+ public string Angriff(string talent, int erschwernis = 0)
+ {
+ throw new NotImplementedException();
+ }
+
+ public string Parade(string talent, int erschwernis = 0)
+ {
+ throw new NotImplementedException();
+ }
+
+ public string Fernkampf(string talent, int erschwernis = 0)
+ {
+ throw new NotImplementedException();
+ }
+
+ public string TestZauber(string waffe, int erschwernis)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/DiscoBot/DSA_Game/Dsa.cs b/DiscoBot/DSA_Game/Dsa.cs
index c6ea1c3..44175b6 100644
--- a/DiscoBot/DSA_Game/Dsa.cs
+++ b/DiscoBot/DSA_Game/Dsa.cs
@@ -1,11 +1,11 @@
namespace DiscoBot.DSA_Game
{
+ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using DiscoBot.Audio;
- using DiscoBot.Auxiliary;
using DiscoBot.Commands;
using DiscoBot.DSA_Game.Characters;
using DiscoBot.DSA_Game.Save;
@@ -25,7 +25,9 @@
public static List<Talent> Talente { get; set; } = new List<Talent>();
public static Properties Properties { get; set; }
-
+
+ public static Session Session { get; set; }
+
public static void Startup()
{
Relation.Add("The Doctor", "Numeri Illuminus"); // Relation
@@ -37,18 +39,18 @@
Relation.Add("Nicolas", "Hartmut Reiher");
Relation.Add("TrueKuehli", "Ledur Torfinson");
- //Relation.Add("Papo","Gwendelson");
- //Relation.Add("Papo", "Pump aus der Gosse");
+ // Relation.Add("Papo","Gwendelson");
+ // Relation.Add("Papo", "Pump aus der Gosse");
- //Nachteile für LE, AE, MR
+ // Nachteile für LE, AE, MR
// Relation.Add("Papo", "Angilbert Arres");
- //Vorteile für LE, AE, MR
+ // Vorteile für LE, AE, MR
Relation.Add("Papo", "Beef");
- //Relation.Add("Papo", "Astrallos");
+ // Relation.Add("Papo", "Astrallos");
Relation.Add("Potus", "Potus");
-
+
// relation.Add("Papo", "Pump aus der Gosse");
foreach (var filename in Directory.GetFiles("helden", "*.xml"))
{
@@ -57,10 +59,17 @@
.Where(c => !Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Talente.Add(v));
}
- Properties = Save.Properties.Deserialize();
+ Properties = Properties.Deserialize();
Properties.Serialize();
Talente = Talente.OrderBy(x => x.Name).ToList();
+
+ Session = new Session();
+ List<SaveChar> save = Chars.Select(SaveChar.FromICharacter).ToList();
+ Session.Chars = save.Select(x=>x as ICharacter).ToList();
+ Session.GeneralContext = GeneralContext;
+ Session.Relation = Relation;
+ Session.Save();
}
}
} \ No newline at end of file
diff --git a/DiscoBot/DSA_Game/Save/Properties.cs b/DiscoBot/DSA_Game/Save/Properties.cs
index 5d99a56..fe2f798 100644
--- a/DiscoBot/DSA_Game/Save/Properties.cs
+++ b/DiscoBot/DSA_Game/Save/Properties.cs
@@ -34,10 +34,7 @@ namespace DiscoBot.DSA_Game.Save
}
public void Serialize(string path = @"..\..\Properties.json")
- {/*
- var stream = new StreamWriter(path); // Load properties file
- var reader = new JsonTextWriter(stream); // create stream reader*/
-
+ {
try
{
File.WriteAllText(path, JsonConvert.SerializeObject(this, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
diff --git a/DiscoBot/DSA_Game/Save/Session.cs b/DiscoBot/DSA_Game/Save/Session.cs
new file mode 100644
index 0000000..b0a34a5
--- /dev/null
+++ b/DiscoBot/DSA_Game/Save/Session.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DiscoBot.DSA_Game.Save
+{
+ using System.IO;
+
+ using DiscoBot.DSA_Game.Characters;
+
+ using Discord.Commands;
+
+ using Newtonsoft.Json;
+
+ public class Session
+ {
+ public ICommandContext GeneralContext { get; set; }
+
+ public Dictionary<string, string> Relation { get; set; } = new Dictionary<string, string>(); // dictionary to match the char
+
+ public List<ICharacter> Chars { get; set; } = new List<ICharacter>(); // list of all characters
+
+ public static Session Load(string path = @"..\..\session.json")
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject<Session>(File.ReadAllText(path)); // Deserialize Data and create Session Object
+ }
+ catch (Exception e)
+ {
+ // ignored
+ return null;
+ }
+ }
+
+ public void Save(string path = @"..\..\session.json")
+ {
+ try
+ {
+ File.WriteAllText(path, JsonConvert.SerializeObject(this, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
+ }
+ catch (Exception e)
+ {
+ // ignored
+ }
+ }
+ }
+}