summaryrefslogtreecommitdiff
path: root/DSACore
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-09-29 20:22:11 +0200
committerTrueDoctor <d-kobert@web.de>2018-09-29 20:22:11 +0200
commit33dc613fffad69c1c608e21eac6fcd3f2954ead8 (patch)
treea30876c8effdb19472873539afdbb232e8081bb8 /DSACore
parent6caf0178d0132a9e70144094957a8a6dcee666e5 (diff)
added all data classes
Diffstat (limited to 'DSACore')
-rw-r--r--DSACore/Commands/CommandHandler.cs1
-rw-r--r--DSACore/Controllers/CommandsController.cs1
-rw-r--r--DSACore/DSA_Game/Dsa.cs2
-rw-r--r--DSACore/FireBase/Database.cs2
-rw-r--r--DSACore/Hubs/ChatHub.cs23
-rw-r--r--DSACore/Models/Database/Char.cs21
-rw-r--r--DSACore/Models/Database/CharSpell.cs13
-rw-r--r--DSACore/Models/Database/Field.cs13
-rw-r--r--DSACore/Models/Database/GeneralSpell.cs12
-rw-r--r--DSACore/Models/Database/Group.cs2
-rw-r--r--DSACore/Models/Database/GroupChar.cs18
-rw-r--r--DSACore/Models/Database/WeaponTalent.cs9
-rw-r--r--DSACore/Models/Network/Group.cs1
-rw-r--r--DSACore/Program.cs6
-rw-r--r--DSACore/Properties/PublishProfiles/FolderProfile.pubxml1
-rw-r--r--DSACore/Properties/launchSettings.json2
-rw-r--r--DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json2
-rw-r--r--DSACore/Startup.cs4
18 files changed, 112 insertions, 21 deletions
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<Field> Skills { get; set; } = new List<Field>();
+
+ private List<Field> Talents { get; set; } = new List<Field>();
+
+ private List<Field> Advantages { get; set; } = new List<Field>();
+
+ private List<CharSpell> Spells { get; set; } = new List<CharSpell>();
+
+ private List<WeaponTalent> WeaponTalents { get; set; } = new List<WeaponTalent>();
+
}
}
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<Char> Chars { get; set; }= new List<Char>();
+ private List<GroupChar> Chars { get; set; }= new List<GroupChar>();
}
}
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<User> Users { get; set; } = new List<User>();
}
}
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<Startup>();
+ .UseStartup<Startup>()
+ .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</_IsPortable>
<publishUrl>bin\Release\netcoreapp2.1\publish\</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
+ <RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project> \ 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();
}