diff options
author | uzvkl <dennis.kobert@student.kit.edu> | 2019-06-11 22:46:57 +0200 |
---|---|---|
committer | uzvkl <dennis.kobert@student.kit.edu> | 2019-06-11 22:46:57 +0200 |
commit | 2490ad5d31fe2ac778ff9303776f0e91f47a2862 (patch) | |
tree | 4b2b2b284897cd239ecbc3a2d4efa6d5d103057f | |
parent | c80384ca8b729677d78934476e7b193b5327ae40 (diff) |
Organize groups to seperate connention management form gamelogic
28 files changed, 68 insertions, 69 deletions
@@ -269,3 +269,6 @@ Cargo.lock # dont save that target (bad boy) /game_server/target +/DSACore/PropertiesDSALib-Auxiliary-CommandInfo.json +/DSACore/PropertiesDSALib-DSA_Game-Characters-Character.json +/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs index 2ab9c96..b6e0be2 100644 --- a/DSACore/Controllers/CommandsController.cs +++ b/DSACore/Controllers/CommandsController.cs @@ -1,4 +1,5 @@ using System; +using DSACore.Models.Network; using DSALib.Commands; using DSALib.Models.Network; using Microsoft.AspNetCore.Mvc; diff --git a/DSACore/Controllers/LobbyController.cs b/DSACore/Controllers/LobbyController.cs index c861eac..7890b4f 100644 --- a/DSACore/Controllers/LobbyController.cs +++ b/DSACore/Controllers/LobbyController.cs @@ -1,6 +1,7 @@ using System; -using DSALib.Models.Network; +using DSACore.Models.Network; using DSALib.Commands; +using DSALib.Models.Network; using Microsoft.AspNetCore.Mvc; namespace DSACore.Controllers diff --git a/DSACore/DSACore.csproj b/DSACore/DSACore.csproj index d730ea4..f7def31 100644 --- a/DSACore/DSACore.csproj +++ b/DSACore/DSACore.csproj @@ -6,7 +6,10 @@ </PropertyGroup> <ItemGroup> - <Folder Include="wwwroot\" /> + <Compile Remove="wwwroot\**" /> + <Content Remove="wwwroot\**" /> + <EmbeddedResource Remove="wwwroot\**" /> + <None Remove="wwwroot\**" /> </ItemGroup> <ItemGroup> diff --git a/DSACore/Hubs/Login.cs b/DSACore/Hubs/Login.cs index ebe0bae..f08c24a 100644 --- a/DSACore/Hubs/Login.cs +++ b/DSACore/Hubs/Login.cs @@ -4,12 +4,13 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using DSACore.Models.Network; using DSALib.Commands; using DSALib.DSA_Game.Characters; -using DSALib.Models.Network; using DSALib.FireBase; +using DSALib.Models.Network; using Microsoft.AspNetCore.SignalR; -using Group = DSALib.Models.Network.Group; +using Group = DSACore.Models.Network.Group; namespace DSACore.Hubs { @@ -19,9 +20,8 @@ namespace DSACore.Hubs private const string ReceiveMethod = "ReceiveMessage"; //receiveMethod; - static Users() - { - DsaGroups = Database.GetGroups().Result; + static Users() { + DsaGroups = Database.GetGroups().Result.Select(x=>new Group(x.Item1, x.Item2)).ToList(); DsaGroups.Add(new Group("login", "")); DsaGroups.Add(new Group("online", "")); //AddGroups(); @@ -103,11 +103,9 @@ namespace DSACore.Hubs .First(z => z.ConnectionId.Equals(id)); } - public async Task GetGroups() - { + public async Task GetGroups() { var test = await Database.GetGroups(); - - foreach (var group in test) + foreach (var group in test.Select(x => new Group(x.Item1, x.Item2)).ToList()) if (!DsaGroups.Exists(x => x.Name.Equals(group.Name))) DsaGroups.Add(group); @@ -128,7 +126,7 @@ namespace DSACore.Hubs { var group = getGroup(Context.ConnectionId); - await Database.AddChar(new Character(new MemoryStream(Encoding.UTF8.GetBytes(xml))), group); + await Database.AddChar(new Character(new MemoryStream(Encoding.UTF8.GetBytes(xml))), group.Name); //throw new NotImplementedException("add database call to add groups"); } diff --git a/DSALib/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs index 608e5ea..efe12ee 100644 --- a/DSALib/Models/Network/Group.cs +++ b/DSACore/Models/Network/Group.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace DSALib.Models.Network +namespace DSACore.Models.Network { public class Group { diff --git a/DSALib/Models/Network/Token.cs b/DSACore/Models/Network/Token.cs index 2310607..451cafc 100644 --- a/DSALib/Models/Network/Token.cs +++ b/DSACore/Models/Network/Token.cs @@ -1,6 +1,6 @@ using System; -namespace DSALib.Models.Network +namespace DSACore.Models.Network { public class Token { diff --git a/DSALib/Models/Network/User.cs b/DSACore/Models/Network/User.cs index 314a0bf..8b8008c 100644 --- a/DSALib/Models/Network/User.cs +++ b/DSACore/Models/Network/User.cs @@ -1,4 +1,4 @@ -namespace DSALib.Models.Network +namespace DSACore.Models.Network { public class User { diff --git a/DSACore/Properties/DSACore-Audio-Sound.json b/DSACore/Properties/DSACore-Audio-Sound.json deleted file mode 100644 index 87a0e6b..0000000 --- a/DSACore/Properties/DSACore-Audio-Sound.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "Name": "Test", - "Url": "http", - "Volume": 100 - } -]
\ No newline at end of file diff --git a/DSACore/Properties/DSACore-Auxiliary-CommandInfo.json b/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json index b9941f2..b9941f2 100644 --- a/DSACore/Properties/DSACore-Auxiliary-CommandInfo.json +++ b/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json diff --git a/DSACore/Properties/DSACore-DSA_Game-Characters-Character.json b/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json index fd387f5..fd387f5 100644 --- a/DSACore/Properties/DSACore-DSA_Game-Characters-Character.json +++ b/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json 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/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 diff --git a/DiscoBot.sln b/DiscoBot.sln index 72ea5dd..2016e7e 100644 --- a/DiscoBot.sln +++ b/DiscoBot.sln @@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DSALib", "DSALib\DSALib.csp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordBot", "DiscordBot\DiscordBot.csproj", "{F1418B62-F043-4761-9BDD-AE078B6A99FB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUnitTest", "NUnitTestProject1\NUnitTest.csproj", "{CF821E64-B50E-420F-98A2-07315B362ED0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnitTest", "NUnitTestProject1\NUnitTest.csproj", "{CF821E64-B50E-420F-98A2-07315B362ED0}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DSA", "DSA", "{2EAC96BE-4273-409B-AE1A-99542E8BAA02}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -43,6 +45,13 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {35A5E2CC-0FD4-4BC0-ACBF-38599CAED1C4} = {2EAC96BE-4273-409B-AE1A-99542E8BAA02} + {87CC30E6-CBEA-4282-A3CC-FD5119A1993B} = {2EAC96BE-4273-409B-AE1A-99542E8BAA02} + {C5D9AFDF-70E2-4A47-96FF-1EC47C1DE38D} = {2EAC96BE-4273-409B-AE1A-99542E8BAA02} + {F1418B62-F043-4761-9BDD-AE078B6A99FB} = {2EAC96BE-4273-409B-AE1A-99542E8BAA02} + {CF821E64-B50E-420F-98A2-07315B362ED0} = {2EAC96BE-4273-409B-AE1A-99542E8BAA02} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CADA01A3-B80B-4979-8397-7CB5B825CE34} EndGlobalSection |