summaryrefslogtreecommitdiff
path: root/DSALib
diff options
context:
space:
mode:
authoruzvkl <dennis.kobert@student.kit.edu>2019-06-11 22:46:57 +0200
committeruzvkl <dennis.kobert@student.kit.edu>2019-06-11 22:46:57 +0200
commit2490ad5d31fe2ac778ff9303776f0e91f47a2862 (patch)
tree4b2b2b284897cd239ecbc3a2d4efa6d5d103057f /DSALib
parentc80384ca8b729677d78934476e7b193b5327ae40 (diff)
Organize groups to seperate connention management form gamelogic
Diffstat (limited to 'DSALib')
-rw-r--r--DSALib/Auxiliary/WeaponImporter.cs2
-rw-r--r--DSALib/FireBase/Database.cs46
-rw-r--r--DSALib/Models/Database/DSA/Advantage.cs2
-rw-r--r--DSALib/Models/Database/DSA/CharSpell.cs2
-rw-r--r--DSALib/Models/Database/DSA/DatabaseChar.cs6
-rw-r--r--DSALib/Models/Database/DSA/Field.cs2
-rw-r--r--DSALib/Models/Database/DSA/GeneralSpell.cs2
-rw-r--r--DSALib/Models/Database/DSA/GroupChar.cs2
-rw-r--r--DSALib/Models/Database/DSA/Inventory.cs2
-rw-r--r--DSALib/Models/Database/DSA/Talent.cs2
-rw-r--r--DSALib/Models/Database/DSA/Weapon.cs2
-rw-r--r--DSALib/Models/Database/DSA/WeaponTalent.cs2
-rw-r--r--DSALib/Models/Database/Groups/DSAGroup.cs4
-rw-r--r--DSALib/Models/Network/Group.cs43
-rw-r--r--DSALib/Models/Network/Token.cs21
-rw-r--r--DSALib/Models/Network/User.cs9
-rw-r--r--DSALib/Properties-DSACore-Auxiliary-CommandInfo.json (renamed from DSALib/PropertiesDSACore-Auxiliary-CommandInfo.json)0
-rw-r--r--DSALib/Properties-DSACore-DSA_Game-Characters-Character.json (renamed from DSALib/PropertiesDSACore-DSA_Game-Characters-Character.json)0
-rw-r--r--DSALib/PropertiesDSACore-Audio-Sound.json7
19 files changed, 37 insertions, 119 deletions
diff --git a/DSALib/Auxiliary/WeaponImporter.cs b/DSALib/Auxiliary/WeaponImporter.cs
index 12d243f..61eb33e 100644
--- a/DSALib/Auxiliary/WeaponImporter.cs
+++ b/DSALib/Auxiliary/WeaponImporter.cs
@@ -4,8 +4,8 @@ using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-using DSALib.Models.Database.DSA;
using DSALib.FireBase;
+using DSALib.Models.Database.Dsa;
namespace DSALib.Auxiliary
{
diff --git a/DSALib/FireBase/Database.cs b/DSALib/FireBase/Database.cs
index 2debd27..1edd699 100644
--- a/DSALib/FireBase/Database.cs
+++ b/DSALib/FireBase/Database.cs
@@ -1,11 +1,12 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DSALib.DSA_Game;
using DSALib.DSA_Game.Characters;
-using DSALib.Models.Database.DSA;
-using DSALib.Models.Network;
+using DSALib.Models.Database.Dsa;
using Firebase.Database;
using Firebase.Database.Query;
@@ -21,14 +22,13 @@ namespace DSALib.FireBase
public static Dictionary<string, RangedWeapon> RangedWeapons = new Dictionary<string, RangedWeapon>();
- public static Dictionary<string, DSALib.Models.Database.DSA.Talent> Talents = new Dictionary<string, DSALib.Models.Database.DSA.Talent>();
+ public static Dictionary<string, DSALib.Models.Database.Dsa.Talent> Talents = new Dictionary<string, DSALib.Models.Database.Dsa.Talent>();
public static Dictionary<string, GeneralSpell> Spells = new Dictionary<string, GeneralSpell>();
static Database()
{
- var auth = File.ReadAllText(Dsa.rootPath + "Token");
- ; // your app secret
+ var auth = File.ReadAllText(Dsa.rootPath + "Token"); // your app secret
Firebase = new FirebaseClient(
"https://heldenonline-4d828.firebaseio.com/",
new FirebaseOptions
@@ -36,16 +36,18 @@ namespace DSALib.FireBase
AuthTokenAsyncFactory = () => Task.FromResult(auth)
});
- Initialize();
+ Task.Run(Initialize);
}
- private static void Initialize()
- {
- IntializeCollection("Chars", Chars).Start();
- IntializeCollection("MeleeWeapons", MeleeList).Start();
- IntializeCollection("RangedWeapons", RangedWeapons).Start();
- IntializeCollection("Talents", Talents).Start();
- IntializeCollection("Spells", Spells).Start();
+ private static void Initialize() {
+ var waiting = new[] {
+ // ToDo IntializeCollection("Chars", Chars),
+ IntializeCollection("MeleeWeapons", MeleeList),
+ IntializeCollection("RangedWeapons", RangedWeapons),
+ IntializeCollection("Talents", Talents),
+ IntializeCollection("Spells", Spells),
+ };
+ Task.WaitAll(waiting);
}
private static async Task IntializeCollection<T>(string path, Dictionary<string, T> list)
@@ -58,7 +60,7 @@ namespace DSALib.FireBase
foreach (var firebaseObject in temp) list.Add(firebaseObject.Key, firebaseObject.Object);
}
- public static async Task<int> AddChar(Character file, Group group)
+ public static async Task<int> AddChar(Character file, string group)
{
DatabaseChar.LoadChar(file, out var groupChar, out var data);
@@ -136,7 +138,7 @@ namespace DSALib.FireBase
.PutAsync(inv);
}
- public static async Task AddTalent(DSALib.Models.Database.DSA.Talent tal)
+ public static async Task AddTalent(DSALib.Models.Database.Dsa.Talent tal)
{
await Firebase
.Child("Talents")
@@ -152,7 +154,7 @@ namespace DSALib.FireBase
.DeleteAsync();
}
- public static DSALib.Models.Database.DSA.Talent GetTalent(string talent)
+ public static DSALib.Models.Database.Dsa.Talent GetTalent(string talent)
{
/*
return await firebase
@@ -180,10 +182,6 @@ namespace DSALib.FireBase
public static GeneralSpell GetSpell(string spell)
{
- /*return await firebase
- .Child("Spells")
- .Child(spell)
- .OnceSingleAsync<GeneralSpell>();*/
return Spells[spell];
}
@@ -215,16 +213,16 @@ namespace DSALib.FireBase
.OnceSingleAsync<Weapon>();
}
- public static async Task<List<Group>> GetGroups()
+ public static async Task<List<Tuple<string, string>>> GetGroups()
{
var groups = await Firebase
.Child("Groups")
.OrderByKey()
.OnceAsync<DSALib.Models.Database.Groups.Group>();
- var ret = new List<Group>();
+ var ret = new List<Tuple<string, string>>();
foreach (var firebaseObject in groups)
- ret.Add(new Group(firebaseObject.Object.Name, firebaseObject.Object.Password));
+ ret.Add(new Tuple<string, string>(firebaseObject.Object.Name, firebaseObject.Object.Password));
return ret;
}
diff --git a/DSALib/Models/Database/DSA/Advantage.cs b/DSALib/Models/Database/DSA/Advantage.cs
index 500cf6d..2ed0bf9 100644
--- a/DSALib/Models/Database/DSA/Advantage.cs
+++ b/DSALib/Models/Database/DSA/Advantage.cs
@@ -1,6 +1,6 @@
using System;
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class Advantage
{
diff --git a/DSALib/Models/Database/DSA/CharSpell.cs b/DSALib/Models/Database/DSA/CharSpell.cs
index 77a8dc8..d08bc74 100644
--- a/DSALib/Models/Database/DSA/CharSpell.cs
+++ b/DSALib/Models/Database/DSA/CharSpell.cs
@@ -1,6 +1,6 @@
using System;
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class CharSpell
{
diff --git a/DSALib/Models/Database/DSA/DatabaseChar.cs b/DSALib/Models/Database/DSA/DatabaseChar.cs
index cfd7174..1312f95 100644
--- a/DSALib/Models/Database/DSA/DatabaseChar.cs
+++ b/DSALib/Models/Database/DSA/DatabaseChar.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using DSALib.DSA_Game.Characters;
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class DatabaseChar
{
@@ -16,7 +16,7 @@ namespace DSALib.Models.Database.DSA
{
Id = id;
Name = name ?? throw new ArgumentNullException(nameof(name));
- Rasse = rasse ?? throw new ArgumentNullException(nameof(rasse));
+ Race = rasse ?? throw new ArgumentNullException(nameof(rasse));
Skills = skills ?? throw new ArgumentNullException(nameof(skills));
Talents = talents ?? throw new ArgumentNullException(nameof(talents));
Advantages = advantages ?? throw new ArgumentNullException(nameof(advantages));
@@ -28,7 +28,7 @@ namespace DSALib.Models.Database.DSA
public string Name { get; set; }
- public string Rasse { get; set; }
+ public string Race { get; set; }
public List<Field> Skills { get; set; } = new List<Field>();
diff --git a/DSALib/Models/Database/DSA/Field.cs b/DSALib/Models/Database/DSA/Field.cs
index 1b10232..6d1b82e 100644
--- a/DSALib/Models/Database/DSA/Field.cs
+++ b/DSALib/Models/Database/DSA/Field.cs
@@ -1,6 +1,6 @@
using System;
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class Field
{
diff --git a/DSALib/Models/Database/DSA/GeneralSpell.cs b/DSALib/Models/Database/DSA/GeneralSpell.cs
index 6fe6a78..964c38e 100644
--- a/DSALib/Models/Database/DSA/GeneralSpell.cs
+++ b/DSALib/Models/Database/DSA/GeneralSpell.cs
@@ -1,4 +1,4 @@
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class GeneralSpell : Talent
{
diff --git a/DSALib/Models/Database/DSA/GroupChar.cs b/DSALib/Models/Database/DSA/GroupChar.cs
index 0c1ecf1..a0115cd 100644
--- a/DSALib/Models/Database/DSA/GroupChar.cs
+++ b/DSALib/Models/Database/DSA/GroupChar.cs
@@ -1,4 +1,4 @@
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class GroupChar
{
diff --git a/DSALib/Models/Database/DSA/Inventory.cs b/DSALib/Models/Database/DSA/Inventory.cs
index 086564c..f3f5d7a 100644
--- a/DSALib/Models/Database/DSA/Inventory.cs
+++ b/DSALib/Models/Database/DSA/Inventory.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class Inventory
{
diff --git a/DSALib/Models/Database/DSA/Talent.cs b/DSALib/Models/Database/DSA/Talent.cs
index 578d93c..214aecc 100644
--- a/DSALib/Models/Database/DSA/Talent.cs
+++ b/DSALib/Models/Database/DSA/Talent.cs
@@ -1,6 +1,6 @@
using System;
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class Talent : DSALib.Models.Database.DataObject
{
diff --git a/DSALib/Models/Database/DSA/Weapon.cs b/DSALib/Models/Database/DSA/Weapon.cs
index 8ed63d7..308c6c5 100644
--- a/DSALib/Models/Database/DSA/Weapon.cs
+++ b/DSALib/Models/Database/DSA/Weapon.cs
@@ -1,6 +1,6 @@
using System;
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class Weapon
{
diff --git a/DSALib/Models/Database/DSA/WeaponTalent.cs b/DSALib/Models/Database/DSA/WeaponTalent.cs
index f65fb3f..2ab921b 100644
--- a/DSALib/Models/Database/DSA/WeaponTalent.cs
+++ b/DSALib/Models/Database/DSA/WeaponTalent.cs
@@ -1,6 +1,6 @@
using System;
-namespace DSALib.Models.Database.DSA
+namespace DSALib.Models.Database.Dsa
{
public class WeaponTalent
{
diff --git a/DSALib/Models/Database/Groups/DSAGroup.cs b/DSALib/Models/Database/Groups/DSAGroup.cs
index 377376e..adbd0ac 100644
--- a/DSALib/Models/Database/Groups/DSAGroup.cs
+++ b/DSALib/Models/Database/Groups/DSAGroup.cs
@@ -1,9 +1,9 @@
using System.Collections.Generic;
-using DSALib.Models.Database.DSA;
+using DSALib.Models.Database.Dsa;
namespace DSALib.Models.Database.Groups
{
- public class DSAGroup : Group
+ public class DsaGroup : Group
{
public List<GroupChar> Chars { get; set; } = new List<GroupChar>();
}
diff --git a/DSALib/Models/Network/Group.cs b/DSALib/Models/Network/Group.cs
deleted file mode 100644
index 608e5ea..0000000
--- a/DSALib/Models/Network/Group.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace DSALib.Models.Network
-{
- public class Group
- {
- public Group(string name, string password)
- {
- Name = name;
- Password = password;
- }
-
- public Group(string name, int userOnline)
- {
- Name = name ?? throw new ArgumentNullException(nameof(name));
- }
-
- public string Name { get; set; }
- public string Password { get; set; }
- public List<User> Users { get; set; } = new List<User>();
-
- public int UserCount => Users.Count;
-
- public SendGroup SendGroup()
- {
- return new SendGroup(Name, UserCount);
- }
- }
-
- public class SendGroup
- {
- public SendGroup(string name, int userCount)
- {
- Name = name ?? throw new ArgumentNullException(nameof(name));
- UserCount = userCount;
- }
-
- public string Name { get; set; }
-
- public int UserCount { get; set; }
- }
-} \ No newline at end of file
diff --git a/DSALib/Models/Network/Token.cs b/DSALib/Models/Network/Token.cs
deleted file mode 100644
index 2310607..0000000
--- a/DSALib/Models/Network/Token.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-
-namespace DSALib.Models.Network
-{
- public class Token
- {
- private readonly DateTime creation = DateTime.Now;
-
- public Token(string group)
- {
- Group = group;
- }
-
- public string Group { get; set; }
-
- public bool IsValid()
- {
- return DateTime.Now - creation < TimeSpan.FromMinutes(1);
- }
- }
-} \ No newline at end of file
diff --git a/DSALib/Models/Network/User.cs b/DSALib/Models/Network/User.cs
deleted file mode 100644
index 314a0bf..0000000
--- a/DSALib/Models/Network/User.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace DSALib.Models.Network
-{
- public class User
- {
- public string Name { get; set; }
- public string ConnectionId { get; set; }
- public int Char { get; set; }
- }
-} \ No newline at end of file
diff --git a/DSALib/PropertiesDSACore-Auxiliary-CommandInfo.json b/DSALib/Properties-DSACore-Auxiliary-CommandInfo.json
index b9941f2..b9941f2 100644
--- a/DSALib/PropertiesDSACore-Auxiliary-CommandInfo.json
+++ b/DSALib/Properties-DSACore-Auxiliary-CommandInfo.json
diff --git a/DSALib/PropertiesDSACore-DSA_Game-Characters-Character.json b/DSALib/Properties-DSACore-DSA_Game-Characters-Character.json
index fd387f5..fd387f5 100644
--- a/DSALib/PropertiesDSACore-DSA_Game-Characters-Character.json
+++ b/DSALib/Properties-DSACore-DSA_Game-Characters-Character.json
diff --git a/DSALib/PropertiesDSACore-Audio-Sound.json b/DSALib/PropertiesDSACore-Audio-Sound.json
deleted file mode 100644
index 87a0e6b..0000000
--- a/DSALib/PropertiesDSACore-Audio-Sound.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "Name": "Test",
- "Url": "http",
- "Volume": 100
- }
-] \ No newline at end of file