From c4d046858e0822b7c2c540ac2368b2c0e88e7a26 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 19 May 2019 17:00:02 +0200 Subject: general refectoring added 42 as dummy Token --- DSACore/FireBase/Database.cs | 55 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'DSACore/FireBase/Database.cs') 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 Chars = new Dictionary(); + + public static Dictionary MeleeList = new Dictionary(); + + public static Dictionary RangedWeapons = new Dictionary(); + + public static Dictionary Talents = new Dictionary(); + + public static Dictionary Spells = new Dictionary(); + 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 Chars = new Dictionary(); - - public static Dictionary MeleeList = new Dictionary(); - - public static Dictionary RangedWeapons = new Dictionary(); - - public static Dictionary Talents = new Dictionary(); - - public static Dictionary Spells = new Dictionary(); - - public static async Task AddChar(Character file, Models.Network.Group group) + public static async Task AddChar(Character file, Group group) { DatabaseChar.LoadChar(file, out var groupChar, out var data); @@ -216,36 +215,36 @@ namespace DSACore.FireBase .OnceSingleAsync(); } - public static async Task> GetGroups() + public static async Task> GetGroups() { var groups = await firebase .Child("Groups") .OrderByKey() - .OnceAsync(); - var ret = new List(); + .OnceAsync(); + var ret = new List(); 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 GetGroup(int id) + public static async Task GetGroup(int id) { var group = await firebase .Child("Groups") .Child("Group" + id) - .OnceSingleAsync(); + .OnceSingleAsync(); 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(); + .OnceAsync(); 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") -- cgit v1.2.3-54-g00ecf