summaryrefslogtreecommitdiff
path: root/DiscoBot
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-06-15 21:58:34 +0200
committerTrueDoctor <d-kobert@web.de>2018-06-15 21:58:34 +0200
commitba1f440d0762ab77cd3f08734043df7db5b4329e (patch)
tree23d8c796ce19e6475ba4a0673ec24daa35384442 /DiscoBot
parent2bfbc16288454790f4c4cfa8ecace3518ee30059 (diff)
implemented session saves
Diffstat (limited to 'DiscoBot')
-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
-rw-r--r--DiscoBot/DiscoBot.csproj2
-rw-r--r--DiscoBot/Properties.json3
-rw-r--r--DiscoBot/session.json125
8 files changed, 269 insertions, 16 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
+ }
+ }
+ }
+}
diff --git a/DiscoBot/DiscoBot.csproj b/DiscoBot/DiscoBot.csproj
index 48aa374..f632c76 100644
--- a/DiscoBot/DiscoBot.csproj
+++ b/DiscoBot/DiscoBot.csproj
@@ -104,12 +104,14 @@
<Compile Include="Auxiliary\TalentEnumerableExtension.cs" />
<Compile Include="Commands\LebenUndAstral.cs" />
<Compile Include="Commands\HeldList.cs" />
+ <Compile Include="DSA_Game\Characters\SaveChar.cs" />
<Compile Include="DSA_Game\KampfTalent.cs" />
<Compile Include="Audio\Soundeffects.cs" />
<Compile Include="Auxiliary\Permissions.cs" />
<Compile Include="Commands\MiscCommands.cs" />
<Compile Include="Auxiliary\SpellCorrect.cs" />
<Compile Include="DSA_Game\Save\Properties.cs" />
+ <Compile Include="DSA_Game\Save\Session.cs" />
<Compile Include="DSA_Game\Talent.cs" />
<Compile Include="DSA_Game\Vorteil.cs" />
<Compile Include="DSA_Game\Characters\Character.cs" />
diff --git a/DiscoBot/Properties.json b/DiscoBot/Properties.json
index c1fcccf..67765d4 100644
--- a/DiscoBot/Properties.json
+++ b/DiscoBot/Properties.json
@@ -93,7 +93,8 @@
"Sounds": [
{
"Name": "Test",
- "Url": "http"
+ "Url": "http",
+ "Volume": 100
}
]
} \ No newline at end of file
diff --git a/DiscoBot/session.json b/DiscoBot/session.json
new file mode 100644
index 0000000..19251d5
--- /dev/null
+++ b/DiscoBot/session.json
@@ -0,0 +1,125 @@
+{
+ "GeneralContext": null,
+ "Relation": {
+ "The Doctor": "Numeri Illuminus",
+ "Tardis": "Helga von Drachenei, Tausendsasserin",
+ "DSA Bot": "Morla",
+ "Morla": "Morla",
+ "Rhoktar": "Rhoktar4",
+ "MagicBro5": "Krenko",
+ "Nicolas": "Hartmut Reiher",
+ "TrueKuehli": "Ledur Torfinson",
+ "Papo": "Beef",
+ "Potus": "Potus"
+ },
+ "Chars": [
+ {
+ "Name": "Felis Exodus Schattenwald",
+ "Lebenspunkte_Basis": 30,
+ "Lebenspunkte_Aktuell": 30,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 20,
+ "Astralpunkte_Aktuell": 20
+ },
+ {
+ "Name": "Gardist",
+ "Lebenspunkte_Basis": 29,
+ "Lebenspunkte_Aktuell": 29,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 0,
+ "Astralpunkte_Aktuell": 0
+ },
+ {
+ "Name": "Hartmut Reiher",
+ "Lebenspunkte_Basis": 31,
+ "Lebenspunkte_Aktuell": 31,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 0,
+ "Astralpunkte_Aktuell": 0
+ },
+ {
+ "Name": "Helga vom Drachenei, Tausendsasserin",
+ "Lebenspunkte_Basis": 21,
+ "Lebenspunkte_Aktuell": 21,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 35,
+ "Astralpunkte_Aktuell": 35
+ },
+ {
+ "Name": "Krenko",
+ "Lebenspunkte_Basis": 25,
+ "Lebenspunkte_Aktuell": 25,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 0,
+ "Astralpunkte_Aktuell": 0
+ },
+ {
+ "Name": "Ledur Torfinson",
+ "Lebenspunkte_Basis": 39,
+ "Lebenspunkte_Aktuell": 39,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 0,
+ "Astralpunkte_Aktuell": 0
+ },
+ {
+ "Name": "Morla",
+ "Lebenspunkte_Basis": 26,
+ "Lebenspunkte_Aktuell": 26,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 13,
+ "Astralpunkte_Aktuell": 13
+ },
+ {
+ "Name": "Numeri Illuminus",
+ "Lebenspunkte_Basis": 28,
+ "Lebenspunkte_Aktuell": 28,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 40,
+ "Astralpunkte_Aktuell": 40
+ },
+ {
+ "Name": "Potus",
+ "Lebenspunkte_Basis": 39,
+ "Lebenspunkte_Aktuell": 39,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 16,
+ "Astralpunkte_Aktuell": 16
+ },
+ {
+ "Name": "Pump aus der Gosse",
+ "Lebenspunkte_Basis": 18,
+ "Lebenspunkte_Aktuell": 18,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 13,
+ "Astralpunkte_Aktuell": 13
+ },
+ {
+ "Name": "Rhoktar4",
+ "Lebenspunkte_Basis": 34,
+ "Lebenspunkte_Aktuell": 34,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 17,
+ "Astralpunkte_Aktuell": 17
+ },
+ {
+ "Name": "Volant",
+ "Lebenspunkte_Basis": 28,
+ "Lebenspunkte_Aktuell": 28,
+ "Ausdauer_Basis": 0,
+ "Ausdauer_Aktuell": 0,
+ "Astralpunkte_Basis": 43,
+ "Astralpunkte_Aktuell": 43
+ }
+ ]
+} \ No newline at end of file