From 6caf0178d0132a9e70144094957a8a6dcee666e5 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Sat, 29 Sep 2018 19:16:40 +0200 Subject: fixed Network namespace --- DSACore/Hubs/ChatHub.cs | 1 + DSACore/Models/Network/Command.cs | 4 ++-- DSACore/Models/Network/Group.cs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DSACore/Hubs/ChatHub.cs b/DSACore/Hubs/ChatHub.cs index 484a350..de8705e 100644 --- a/DSACore/Hubs/ChatHub.cs +++ b/DSACore/Hubs/ChatHub.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using DSACore.Models; +using DSACore.Models.Network; using Microsoft.AspNetCore.SignalR; namespace DSACore.Hubs diff --git a/DSACore/Models/Network/Command.cs b/DSACore/Models/Network/Command.cs index dcfc692..456a896 100644 --- a/DSACore/Models/Network/Command.cs +++ b/DSACore/Models/Network/Command.cs @@ -8,13 +8,13 @@ namespace DSACore.Models.Network public class Command { public ulong GroupId { get; set; } = 0; - public ulong CharId { get; set; } + public ulong CharId { get; set; } public string Name { get; set; } public string CmdIdentifier { get; set; } public List CmdTexts { get; set; } public string CmdText => CmdTexts.Count != 0 ? CmdTexts.First() : ""; - public int Cmdmodifier => CmdTexts.Count!=0&&int.TryParse(CmdTexts.Last(),out int mod)?mod:0; + public int Cmdmodifier => CmdTexts.Count != 0 && int.TryParse(CmdTexts.Last(), out int mod) ? mod : 0; public bool IsDm { get; set; } = false; } } diff --git a/DSACore/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs index 40f5aeb..eab02cd 100644 --- a/DSACore/Models/Network/Group.cs +++ b/DSACore/Models/Network/Group.cs @@ -8,6 +8,6 @@ namespace DSACore.Models.Network public class Group { public string Name { get; set; } - public List Users { get; set; }= new List(); + public List Users { get; set; } = new List(); } } -- cgit v1.2.3-54-g00ecf From 33dc613fffad69c1c608e21eac6fcd3f2954ead8 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Sat, 29 Sep 2018 20:22:11 +0200 Subject: added all data classes --- DSACore/Commands/CommandHandler.cs | 1 + DSACore/Controllers/CommandsController.cs | 1 + DSACore/DSA_Game/Dsa.cs | 2 +- DSACore/FireBase/Database.cs | 2 +- DSACore/Hubs/ChatHub.cs | 23 ++++++++++++++++------ DSACore/Models/Database/Char.cs | 21 ++++++++++++++------ DSACore/Models/Database/CharSpell.cs | 13 ++++++++++++ DSACore/Models/Database/Field.cs | 13 ++++++++++++ DSACore/Models/Database/GeneralSpell.cs | 12 +++++++++++ DSACore/Models/Database/Group.cs | 2 +- DSACore/Models/Database/GroupChar.cs | 18 +++++++++++++++++ DSACore/Models/Database/WeaponTalent.cs | 9 +++++++++ DSACore/Models/Network/Group.cs | 1 + DSACore/Program.cs | 6 ++++-- .../PublishProfiles/FolderProfile.pubxml | 1 + DSACore/Properties/launchSettings.json | 2 +- .../PropertiesNewtonsoft-Json-Linq-JProperty.json | 2 +- DSACore/Startup.cs | 4 ++-- 18 files changed, 112 insertions(+), 21 deletions(-) create mode 100644 DSACore/Models/Database/CharSpell.cs create mode 100644 DSACore/Models/Database/Field.cs create mode 100644 DSACore/Models/Database/GeneralSpell.cs create mode 100644 DSACore/Models/Database/GroupChar.cs create mode 100644 DSACore/Models/Database/WeaponTalent.cs diff --git a/DSACore/Commands/CommandHandler.cs b/DSACore/Commands/CommandHandler.cs index 4b6ca42..7812ec4 100644 --- a/DSACore/Commands/CommandHandler.cs +++ b/DSACore/Commands/CommandHandler.cs @@ -2,6 +2,7 @@ using DSACore.Auxiliary; using DSACore.DSA_Game; using DSACore.Models; +using DSACore.Models.Network; namespace DSACore.Commands { diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs index 7e078b2..1d40a43 100644 --- a/DSACore/Controllers/CommandsController.cs +++ b/DSACore/Controllers/CommandsController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using DSACore.Models; +using DSACore.Models.Network; using Microsoft.AspNetCore.Mvc; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 diff --git a/DSACore/DSA_Game/Dsa.cs b/DSACore/DSA_Game/Dsa.cs index 94de194..d47c5b6 100644 --- a/DSACore/DSA_Game/Dsa.cs +++ b/DSACore/DSA_Game/Dsa.cs @@ -13,7 +13,7 @@ namespace DSACore.DSA_Game public static class Dsa { - public const string rootPath = "";//"DiscoBot\\DSACore\\"; + public const string rootPath = "C:\\Users\\Dennis\\Source\\Repos\\DiscoBot\\DSACore\\";//"DiscoBot\\DSACore\\"; private static Session s_session; diff --git a/DSACore/FireBase/Database.cs b/DSACore/FireBase/Database.cs index 375f812..fd8aa4c 100644 --- a/DSACore/FireBase/Database.cs +++ b/DSACore/FireBase/Database.cs @@ -13,7 +13,7 @@ namespace DSACore.FireBase { static Database() { - var auth = File.ReadAllText("Token"); ; // your app secret + var auth = File.ReadAllText(DSACore.DSA_Game.Dsa.rootPath+"Token"); ; // your app secret var firebaseClient = new FirebaseClient( "https://heldenonline-4d828.firebaseio.com/", new FirebaseOptions diff --git a/DSACore/Hubs/ChatHub.cs b/DSACore/Hubs/ChatHub.cs index de8705e..6335183 100644 --- a/DSACore/Hubs/ChatHub.cs +++ b/DSACore/Hubs/ChatHub.cs @@ -19,8 +19,18 @@ namespace DSACore.Hubs var args = message.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList(); var ident = args.First().Replace("!", ""); if(args.Count>0){args.RemoveAt(0);} + + string group; + try + { + group = getGroup(Context.ConnectionId).Name; + await SendToGroup(group, user, Commands.CommandHandler.ExecuteCommand(new Command { CharId = 0, CmdIdentifier = ident, CmdTexts = args, Name = user })); + } + catch(InvalidOperationException e) + { + await Clients.Caller.SendCoreAsync("ReceiveMessage", new[] {"Nutzer ist in keiner Gruppe. Erst joinen!"}); + } - await SendToGroup(getGroup(Context.ConnectionId).Name, user, Commands.CommandHandler.ExecuteCommand(new Command{CharId = 0,CmdIdentifier = ident, CmdTexts = args, Name = user})); } private Task SendToGroup(string group, string user, string message) @@ -35,19 +45,20 @@ namespace DSACore.Hubs public async Task GetGroups() { - await Clients.Caller.SendCoreAsync("ListGroups", new object[] { Groups }); - throw new NotImplementedException("add database call to get groups"); + await Clients.Caller.SendCoreAsync("ListGroups", new object[] { DSAGroups }); + //throw new NotImplementedException("add database call to get groups"); } public async Task AddGroup(string group, string password) { - await Clients.Caller.SendCoreAsync("ListGroups", new object[] { Groups }); - throw new NotImplementedException("add database call to add groups"); + DSAGroups.Add(new Group{Name = group, Password = password}); + Clients.Caller.SendCoreAsync("ReceiveMessage", new[] {$"group {group} sucessfully added"}); + //throw new NotImplementedException("add database call to add groups"); } public async Task Login(string group, string user, string password) { - if (password == "valid") + if (password == DSAGroups.First(x=>x.Name == group).Password) { DSAGroups.First(x=>x.Name.Equals(group)).Users.Add(new User{ConnectionId = Context.ConnectionId, Name = user}); await Groups.AddToGroupAsync(Context.ConnectionId, group); diff --git a/DSACore/Models/Database/Char.cs b/DSACore/Models/Database/Char.cs index f77c760..04c16f0 100644 --- a/DSACore/Models/Database/Char.cs +++ b/DSACore/Models/Database/Char.cs @@ -7,12 +7,21 @@ namespace DSACore.Models.Database { public class Char { - private string Name { get; set; } private int Id { get; set; } - private int Lp { get; set; } - private int LpMax { get; set; } - private int As { get; set; } - private int AsMax { get; set; } - private Weapon Weapon { get; set; } + + private string Name { get; set; } + + private string Rasse { get; set; } + + private List Skills { get; set; } = new List(); + + private List Talents { get; set; } = new List(); + + private List Advantages { get; set; } = new List(); + + private List Spells { get; set; } = new List(); + + private List WeaponTalents { get; set; } = new List(); + } } diff --git a/DSACore/Models/Database/CharSpell.cs b/DSACore/Models/Database/CharSpell.cs new file mode 100644 index 0000000..cdb5447 --- /dev/null +++ b/DSACore/Models/Database/CharSpell.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DSACore.Models.Database +{ + public class CharSpell + { + private string representation { get; set; } + private int value { get; set; } + } +} diff --git a/DSACore/Models/Database/Field.cs b/DSACore/Models/Database/Field.cs new file mode 100644 index 0000000..fe1ea1f --- /dev/null +++ b/DSACore/Models/Database/Field.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DSACore.Models.Database +{ + public class Field + { + private string Name { get; set; } + private int value { get; set; } + } +} diff --git a/DSACore/Models/Database/GeneralSpell.cs b/DSACore/Models/Database/GeneralSpell.cs new file mode 100644 index 0000000..4f2a8cb --- /dev/null +++ b/DSACore/Models/Database/GeneralSpell.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DSACore.Models.Database +{ + public class GeneralSpell : Talent + { + private string Comlexity = "A"; + } +} diff --git a/DSACore/Models/Database/Group.cs b/DSACore/Models/Database/Group.cs index 5484b76..fb17909 100644 --- a/DSACore/Models/Database/Group.cs +++ b/DSACore/Models/Database/Group.cs @@ -10,6 +10,6 @@ namespace DSACore.Models.Database private string Name { get; set; } private string Discord { get; set; } private int Id { get; set; } - private List Chars { get; set; }= new List(); + private List Chars { get; set; }= new List(); } } diff --git a/DSACore/Models/Database/GroupChar.cs b/DSACore/Models/Database/GroupChar.cs new file mode 100644 index 0000000..66e203b --- /dev/null +++ b/DSACore/Models/Database/GroupChar.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DSACore.Models.Database +{ + public class GroupChar + { + private string Name { get; set; } + private int Id { get; set; } + private int Lp { get; set; } + private int LpMax { get; set; } + private int As { get; set; } + private int AsMax { get; set; } + private Weapon Weapon { get; set; } + } +} diff --git a/DSACore/Models/Database/WeaponTalent.cs b/DSACore/Models/Database/WeaponTalent.cs new file mode 100644 index 0000000..37d7150 --- /dev/null +++ b/DSACore/Models/Database/WeaponTalent.cs @@ -0,0 +1,9 @@ +namespace DSACore.Models.Database +{ + class WeaponTalent + { + private string Name { get; set; } + private int At { get; set; } + private int Pa { get; set; } + } +} \ No newline at end of file diff --git a/DSACore/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs index eab02cd..2b59931 100644 --- a/DSACore/Models/Network/Group.cs +++ b/DSACore/Models/Network/Group.cs @@ -8,6 +8,7 @@ namespace DSACore.Models.Network public class Group { public string Name { get; set; } + public string Password { get; set; } public List Users { get; set; } = new List(); } } diff --git a/DSACore/Program.cs b/DSACore/Program.cs index af51983..ec16fd3 100644 --- a/DSACore/Program.cs +++ b/DSACore/Program.cs @@ -19,9 +19,11 @@ namespace DSACore DSA_Game.Dsa.Startup(); CreateWebHostBuilder(args).Build().Run(); } - + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) - .UseStartup(); + .UseStartup() + .UseUrls("http://0.0.0.0:5000"); + } } diff --git a/DSACore/Properties/PublishProfiles/FolderProfile.pubxml b/DSACore/Properties/PublishProfiles/FolderProfile.pubxml index 622bb03..2fd07c5 100644 --- a/DSACore/Properties/PublishProfiles/FolderProfile.pubxml +++ b/DSACore/Properties/PublishProfiles/FolderProfile.pubxml @@ -18,5 +18,6 @@ indem Sie diese MSBuild-Datei bearbeiten. Weitere Informationen hierzu finden Si <_IsPortable>true bin\Release\netcoreapp2.1\publish\ False + win-x64 \ No newline at end of file diff --git a/DSACore/Properties/launchSettings.json b/DSACore/Properties/launchSettings.json index 50d10a9..2da5fec 100644 --- a/DSACore/Properties/launchSettings.json +++ b/DSACore/Properties/launchSettings.json @@ -21,7 +21,7 @@ "commandName": "Project", "launchBrowser": true, "launchUrl": "api/commands", - "applicationUrl": "https://192.168.2.58:5001;http://192.168.2.58:5000", + "applicationUrl": "https://0.0.0.0:5001;http://0.0.0.0:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json b/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json index 5b400e5..0ed0f48 100644 --- a/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json +++ b/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json @@ -21,7 +21,7 @@ "commandName": "Project", "launchBrowser": true, "launchUrl": "api/commands", - "applicationUrl": "https://192.168.2.58:5001;http://192.168.2.58:5000", + "applicationUrl": "https://0.0.0.0:5001;http://0.0.0.0:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/DSACore/Startup.cs b/DSACore/Startup.cs index c189436..11c5607 100644 --- a/DSACore/Startup.cs +++ b/DSACore/Startup.cs @@ -29,7 +29,7 @@ namespace DSACore services.AddCors(options => options.AddPolicy("CorsPolicy", builder => { - builder.WithOrigins("https://dsa.truekuehli.de") + builder.AllowAnyOrigin()//.WithOrigins("https://dsa.truekuehli.de", "127.0.0.1") .WithHeaders("Access-Control-Allow-Origin") .AllowAnyHeader() .AllowAnyMethod() @@ -51,7 +51,7 @@ namespace DSACore // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - if (env.IsDevelopment()) + if (env.IsDevelopment()||true) { app.UseDeveloperExceptionPage(); } -- cgit v1.2.3-54-g00ecf