summaryrefslogtreecommitdiff
path: root/DSACore/FireBase/Database.cs
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-05-19 17:00:02 +0200
committerDennis Kobert <d-kobert@web.de>2019-05-19 17:00:02 +0200
commitc4d046858e0822b7c2c540ac2368b2c0e88e7a26 (patch)
tree8ff5cfd8646908784a45762a6148ebc150810160 /DSACore/FireBase/Database.cs
parentf89f308c525e9deebc6d2cf6416e27dfe1a299dc (diff)
general refectoring
added 42 as dummy Token
Diffstat (limited to 'DSACore/FireBase/Database.cs')
-rw-r--r--DSACore/FireBase/Database.cs55
1 files changed, 27 insertions, 28 deletions
diff --git a/DSACore/FireBase/Database.cs b/DSACore/FireBase/Database.cs
index abe2b92..8946cf0 100644
--- a/DSACore/FireBase/Database.cs
+++ b/DSACore/FireBase/Database.cs
@@ -1,14 +1,13 @@
-using DSACore.DSA_Game.Characters;
-using DSACore.Models.Database;
-using Firebase.Database;
-using Firebase.Database.Query;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using DSACore.DSA_Game;
+using DSACore.DSA_Game.Characters;
using DSACore.Models.Database.DSA;
-using DSACore.Models.Database.Groups;
-
+using DSACore.Models.Network;
+using Firebase.Database;
+using Firebase.Database.Query;
namespace DSACore.FireBase
{
@@ -16,9 +15,19 @@ namespace DSACore.FireBase
{
public static FirebaseClient firebase;
+ public static Dictionary<string, DatabaseChar> Chars = new Dictionary<string, DatabaseChar>();
+
+ public static Dictionary<string, MeleeWeapon> MeleeList = new Dictionary<string, MeleeWeapon>();
+
+ public static Dictionary<string, RangedWeapon> RangedWeapons = new Dictionary<string, RangedWeapon>();
+
+ public static Dictionary<string, Talent> Talents = new Dictionary<string, Talent>();
+
+ public static Dictionary<string, GeneralSpell> Spells = new Dictionary<string, GeneralSpell>();
+
static Database()
{
- var auth = File.ReadAllText(DSA_Game.Dsa.rootPath + "Token");
+ var auth = File.ReadAllText(Dsa.rootPath + "Token");
; // your app secret
firebase = new FirebaseClient(
"https://heldenonline-4d828.firebaseio.com/",
@@ -49,17 +58,7 @@ namespace DSACore.FireBase
foreach (var firebaseObject in temp) list.Add(firebaseObject.Key, firebaseObject.Object);
}
- public static Dictionary<string, DatabaseChar> Chars = new Dictionary<string, DatabaseChar>();
-
- public static Dictionary<string, MeleeWeapon> MeleeList = new Dictionary<string, MeleeWeapon>();
-
- public static Dictionary<string, RangedWeapon> RangedWeapons = new Dictionary<string, RangedWeapon>();
-
- public static Dictionary<string, Talent> Talents = new Dictionary<string, Talent>();
-
- public static Dictionary<string, GeneralSpell> Spells = new Dictionary<string, GeneralSpell>();
-
- public static async Task<int> AddChar(Character file, Models.Network.Group group)
+ public static async Task<int> AddChar(Character file, Group group)
{
DatabaseChar.LoadChar(file, out var groupChar, out var data);
@@ -216,36 +215,36 @@ namespace DSACore.FireBase
.OnceSingleAsync<Weapon>();
}
- public static async Task<List<Models.Network.Group>> GetGroups()
+ public static async Task<List<Group>> GetGroups()
{
var groups = await firebase
.Child("Groups")
.OrderByKey()
- .OnceAsync<Group>();
- var ret = new List<Models.Network.Group>();
+ .OnceAsync<Models.Database.Groups.Group>();
+ var ret = new List<Group>();
foreach (var firebaseObject in groups)
- ret.Add(new Models.Network.Group(firebaseObject.Object.Name, firebaseObject.Object.Password));
+ ret.Add(new Group(firebaseObject.Object.Name, firebaseObject.Object.Password));
return ret;
}
- public static async Task<Group> GetGroup(int id)
+ public static async Task<Models.Database.Groups.Group> GetGroup(int id)
{
var group = await firebase
.Child("Groups")
.Child("Group" + id)
- .OnceSingleAsync<Group>();
+ .OnceSingleAsync<Models.Database.Groups.Group>();
return group;
}
- public static async Task AddGroup(Group group)
+ public static async Task AddGroup(Models.Database.Groups.Group group)
{
var lastChar = await firebase
.Child("Groups")
.OrderByKey()
.LimitToLast(1)
- .OnceAsync<Group>();
+ .OnceAsync<Models.Database.Groups.Group>();
var id = group.Id = lastChar.First().Object.Id + 1;
await firebase
@@ -254,7 +253,7 @@ namespace DSACore.FireBase
.PutAsync(group);
}
- public static async void SetGroup(Group group)
+ public static async void SetGroup(Models.Database.Groups.Group group)
{
await firebase
.Child("Groups")