summaryrefslogtreecommitdiff
path: root/DSACore/DSA_Game
diff options
context:
space:
mode:
Diffstat (limited to 'DSACore/DSA_Game')
-rw-r--r--DSACore/DSA_Game/Characters/Character.cs2
-rw-r--r--DSACore/DSA_Game/Characters/NPC.cs9
-rw-r--r--DSACore/DSA_Game/Characters/SaveChar.cs11
-rw-r--r--DSACore/DSA_Game/Dsa.cs22
-rw-r--r--DSACore/DSA_Game/Save/Properties.cs65
-rw-r--r--DSACore/DSA_Game/Save/SaveCommand.cs4
-rw-r--r--DSACore/DSA_Game/Save/Session.cs4
7 files changed, 68 insertions, 49 deletions
diff --git a/DSACore/DSA_Game/Characters/Character.cs b/DSACore/DSA_Game/Characters/Character.cs
index 1236b12..8fad2ef 100644
--- a/DSACore/DSA_Game/Characters/Character.cs
+++ b/DSACore/DSA_Game/Characters/Character.cs
@@ -2,7 +2,7 @@
using DSALib;
using DSALib.Characters;
-namespace DiscoBot.DSA_Game.Characters
+namespace DSACore.DSA_Game.Characters
{
using System;
using System.Collections.Generic;
diff --git a/DSACore/DSA_Game/Characters/NPC.cs b/DSACore/DSA_Game/Characters/NPC.cs
index ec8adfc..0a660ee 100644
--- a/DSACore/DSA_Game/Characters/NPC.cs
+++ b/DSACore/DSA_Game/Characters/NPC.cs
@@ -1,12 +1,13 @@
-using DSACore.Auxiliary;
+using System;
+using DSACore.Auxiliary;
using DSALib.Characters;
-namespace DiscoBot.Characters
+namespace DSACore.Characters
{
using System;
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game.Characters;
+ using DSACore.Auxiliary;
+ using DSACore.DSA_Game.Characters;
public class Npc : Being, ICharacter
{
diff --git a/DSACore/DSA_Game/Characters/SaveChar.cs b/DSACore/DSA_Game/Characters/SaveChar.cs
index 50cb91c..87c2566 100644
--- a/DSACore/DSA_Game/Characters/SaveChar.cs
+++ b/DSACore/DSA_Game/Characters/SaveChar.cs
@@ -1,11 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using DSALib.Characters;
-
-namespace DiscoBot.DSA_Game.Characters
+using DSALib.Characters;
+
+namespace DSACore.DSA_Game.Characters
{
public class SaveChar
diff --git a/DSACore/DSA_Game/Dsa.cs b/DSACore/DSA_Game/Dsa.cs
index 8907f96..4573542 100644
--- a/DSACore/DSA_Game/Dsa.cs
+++ b/DSACore/DSA_Game/Dsa.cs
@@ -1,13 +1,15 @@
-using DSALib;
+using System;
+using DSALib;
using DSALib.Characters;
+using Microsoft.EntityFrameworkCore.Design;
-namespace DiscoBot.DSA_Game
+namespace DSACore.DSA_Game
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
- using DiscoBot.DSA_Game.Characters;
- using DiscoBot.DSA_Game.Save;
+ using DSACore.DSA_Game.Characters;
+ using DSACore.DSA_Game.Save;
public static class Dsa
{
@@ -37,7 +39,7 @@ namespace DiscoBot.DSA_Game
public static void Startup()
{
- //new DiscoBot.Auxiliary.Calculator.StringSolver("1d100 - (1d200 + 1) * -50000").Solve();
+ //new .Auxiliary.Calculator.StringSolver("1d100 - (1d200 + 1) * -50000").Solve();
/*Session = new Session();*/
// relation.Add("Papo", "Pump aus der Gosse");
foreach (var filename in Directory.GetFiles("helden", "*.xml"))
@@ -57,5 +59,15 @@ namespace DiscoBot.DSA_Game
};
Session.Save();
}
+
+ public static ICharacter GetCharacter(ulong id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public static ICharacter GetCharacter(string name, ulong groupId)
+ {
+ throw new NotImplementedException();
+ }
}
} \ No newline at end of file
diff --git a/DSACore/DSA_Game/Save/Properties.cs b/DSACore/DSA_Game/Save/Properties.cs
index a27c9d7..1c86ab9 100644
--- a/DSACore/DSA_Game/Save/Properties.cs
+++ b/DSACore/DSA_Game/Save/Properties.cs
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using DSACore.Audio;
using DSACore.Auxiliary;
+using Newtonsoft.Json;
-namespace DiscoBot.DSA_Game.Save
+namespace DSACore.DSA_Game.Save
{
using System.Collections;
using System.IO;
@@ -21,38 +23,43 @@ namespace DiscoBot.DSA_Game.Save
this.objects.Add("CommandInfos", new List<CommandInfo>());*/
}
- public static List<CommandInfo> CommandInfos { get => objects["CommandInfo"] as List<CommandInfo>; set => objects["CommandInfo"] = value; } // use Properties.Commandinfos to access the abstract Object array
+ public static List<CommandInfo> CommandInfos
+ {
+ get => objects["CommandInfo"] as List<CommandInfo>;
+ set => objects["CommandInfo"] = value;
+ } // use Properties.Commandinfos to access the abstract Object array
- public static List<Sound> Sounds { get => objects["Sound"] as List<Sound>; set => objects["Sound"] = value; }
+ public static List<Sound> Sounds
+ {
+ get => objects["Sound"] as List<Sound>;
+ set => objects["Sound"] = value;
+ }
public static void Deserialize(string path = @"..\..\Properties")
{
-
- var files = Directory.GetFiles(path, "*.json");
+ var files = Directory.GetFiles(path, "*.json");
- foreach (string file in files)
+ foreach (string file in files)
+ {
+ try
{
- try
- {
- string name = file.Split('\\').Last().Split('.')[0].Replace('-', '.');
- string data = File.ReadAllText(file);
- Type type = Type.GetType(name);
- if (data.StartsWith("["))
- {
- type = typeof(List<>).MakeGenericType(type);
- }
-
- var o = JsonConvert.DeserializeObject(data, type);
- objects.Add(name.Split('.').Last(), o);
- }
- catch (Exception e)
+ string name = file.Split('\\').Last().Split('.')[0].Replace('-', '.');
+ string data = File.ReadAllText(file);
+ Type type = Type.GetType(name);
+ if (data.StartsWith("["))
{
- // ignored
- Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen."+ e);
+ type = typeof(List<>).MakeGenericType(type);
}
+ var o = JsonConvert.DeserializeObject(data, type);
+ objects.Add(name.Split('.').Last(), o);
}
-
+ catch (Exception e)
+ {
+ // ignored
+ Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen." + e);
+ }
+ }
}
public static void Serialize(string path = @"..\..\Properties\")
@@ -61,17 +68,21 @@ namespace DiscoBot.DSA_Game.Save
{
foreach (var o in objects)
{
- string assembly = o.Value is IList list ? ((IList)list)[0]?.GetType().FullName : o.Value.GetType().FullName;
+ string assembly = o.Value is IList list
+ ? ((IList) list)[0]?.GetType().FullName
+ : o.Value.GetType().FullName;
var name = path + assembly.Replace('.', '-') + ".json";
- File.WriteAllText(name, JsonConvert.SerializeObject(o.Value, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
+ File.WriteAllText(name,
+ JsonConvert.SerializeObject(o.Value,
+ Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
}
}
catch (Exception e)
{
// ignored
- Console.WriteLine($"Speichern von Save-File fehlgeschlagen."+ e);
+ Console.WriteLine($"Speichern von Save-File fehlgeschlagen." + e);
}
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/DSA_Game/Save/SaveCommand.cs b/DSACore/DSA_Game/Save/SaveCommand.cs
index 9a2ae8e..198d707 100644
--- a/DSACore/DSA_Game/Save/SaveCommand.cs
+++ b/DSACore/DSA_Game/Save/SaveCommand.cs
@@ -2,7 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
-namespace DiscoBot.DSA_Game.Save
+namespace DSACore.DSA_Game.Save
{
using System.IO;
@@ -17,7 +17,7 @@ namespace DiscoBot.DSA_Game.Save
return;
}
- var path = DSA_Game.Save.Session.DirectoryPath + @"\" + name;
+ var path = Save.Session.DirectoryPath + @"\" + name;
var files = Directory.GetFiles(path);
var session = files.OrderByDescending(x => Convert.ToInt32(x.Split('-').Last().Split('.').First())).First();
diff --git a/DSACore/DSA_Game/Save/Session.cs b/DSACore/DSA_Game/Save/Session.cs
index d0cba21..60e900f 100644
--- a/DSACore/DSA_Game/Save/Session.cs
+++ b/DSACore/DSA_Game/Save/Session.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
-namespace DiscoBot.DSA_Game.Save
+namespace DSACore.DSA_Game.Save
{
using System.IO;
- using DiscoBot.DSA_Game.Characters;
+ using Characters;
using Newtonsoft.Json;
public class Session