summaryrefslogtreecommitdiff
path: root/DSACore
diff options
context:
space:
mode:
Diffstat (limited to 'DSACore')
-rw-r--r--DSACore/Hubs/ChatHub.cs33
-rw-r--r--DSACore/Models/Database/Char.cs18
-rw-r--r--DSACore/Models/Database/Group.cs15
-rw-r--r--DSACore/Models/Database/Inventory.cs15
-rw-r--r--DSACore/Models/Database/Roll.cs12
-rw-r--r--DSACore/Models/Database/Talent.cs14
-rw-r--r--DSACore/Models/Database/Weapon.cs15
-rw-r--r--DSACore/Models/Network/Command.cs (renamed from DSACore/Models/Command.cs)2
-rw-r--r--DSACore/Models/Network/Group.cs13
-rw-r--r--DSACore/Models/Network/User.cs (renamed from DSACore/Models/User.cs)4
10 files changed, 129 insertions, 12 deletions
diff --git a/DSACore/Hubs/ChatHub.cs b/DSACore/Hubs/ChatHub.cs
index a8bf883..484a350 100644
--- a/DSACore/Hubs/ChatHub.cs
+++ b/DSACore/Hubs/ChatHub.cs
@@ -9,7 +9,9 @@ namespace DSACore.Hubs
{
public class ChatHub : Hub
{
- private static Dictionary<string, User> UserGroup;
+ //private static Dictionary<string, User> UserGroup = new Dictionary<string, User>();
+
+ private static List<Group> DSAGroups = new List<Group>();
public async Task SendMessage(string user, string message)
{
@@ -17,7 +19,7 @@ namespace DSACore.Hubs
var ident = args.First().Replace("!", "");
if(args.Count>0){args.RemoveAt(0);}
- await SendToGroup(UserGroup[Context.ConnectionId].Group, user, Commands.CommandHandler.ExecuteCommand(new Command{CharId = 0,CmdIdentifier = ident, CmdTexts = args, Name = user}));
+ 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)
@@ -25,29 +27,42 @@ namespace DSACore.Hubs
return Clients.Group(group).SendCoreAsync("ReceiveMessage", new object[] { user, message });
}
+ private Group getGroup(string id)
+ {
+ return DSAGroups.First(x => x.Users.Exists(y => y.ConnectionId.Equals(id)));
+ }
+
public async Task GetGroups()
{
- await Clients.Caller.SendCoreAsync("ListGroups", new object[] { "TheCrew", "Testdata" });
+ await Clients.Caller.SendCoreAsync("ListGroups", new object[] { Groups });
throw new NotImplementedException("add database call to get groups");
}
- public async Task Login(string group, string password)
+ 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");
+ }
+
+ public async Task Login(string group, string user, string password)
{
if (password == "valid")
{
- UserGroup.Add(Context.ConnectionId, new User{Group = group});
+ DSAGroups.First(x=>x.Name.Equals(group)).Users.Add(new User{ConnectionId = Context.ConnectionId, Name = user});
await Groups.AddToGroupAsync(Context.ConnectionId, group);
}
- await SendToGroup(group, "", "Ein neuer Nutzer hat die Gruppe betreten");
+ await SendToGroup(group, user, "Ein neuer Nutzer hat die Gruppe betreten");
}
public async Task Disconnect()
{
- var user = UserGroup[Context.ConnectionId];
- await Groups.RemoveFromGroupAsync(Context.ConnectionId, user.Group);
+ var group = getGroup(Context.ConnectionId);
+ var user = group.Users.First(x => x.ConnectionId.Equals(Context.ConnectionId));
+ group.Users.Remove(user);
+ await Groups.RemoveFromGroupAsync(Context.ConnectionId, group.Name);
- await SendToGroup(user.Group, user.Name, "Connection lost");
+ await SendToGroup(group.Name, user.Name, "Connection lost");
}
}
diff --git a/DSACore/Models/Database/Char.cs b/DSACore/Models/Database/Char.cs
new file mode 100644
index 0000000..f77c760
--- /dev/null
+++ b/DSACore/Models/Database/Char.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+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; }
+ }
+}
diff --git a/DSACore/Models/Database/Group.cs b/DSACore/Models/Database/Group.cs
new file mode 100644
index 0000000..5484b76
--- /dev/null
+++ b/DSACore/Models/Database/Group.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace DSACore.Models.Database
+{
+ public class Group
+ {
+ private string Name { get; set; }
+ private string Discord { get; set; }
+ private int Id { get; set; }
+ private List<Char> Chars { get; set; }= new List<Char>();
+ }
+}
diff --git a/DSACore/Models/Database/Inventory.cs b/DSACore/Models/Database/Inventory.cs
new file mode 100644
index 0000000..8e525c6
--- /dev/null
+++ b/DSACore/Models/Database/Inventory.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace DSACore.Models.Database
+{
+ public class Inventory
+ {
+ private int Id { get; set; }
+ private List<string> Items { get; set; } = new List<string>();
+ private List<string> Food { get; set; } = new List<string>();
+ private List<Weapon> Weapons { get; set; } = new List<Weapon>();
+ }
+}
diff --git a/DSACore/Models/Database/Roll.cs b/DSACore/Models/Database/Roll.cs
new file mode 100644
index 0000000..c931e70
--- /dev/null
+++ b/DSACore/Models/Database/Roll.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace DSACore.Models.Database
+{
+ public class Roll
+ {
+ private string[] Skills { get; set; } = new string[3];
+ }
+}
diff --git a/DSACore/Models/Database/Talent.cs b/DSACore/Models/Database/Talent.cs
new file mode 100644
index 0000000..d7bfaae
--- /dev/null
+++ b/DSACore/Models/Database/Talent.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace DSACore.Models.Database
+{
+ public class Talent
+ {
+ private string Name { get; set; }
+
+ private Roll Roll { get; set; } = new Roll();
+ }
+}
diff --git a/DSACore/Models/Database/Weapon.cs b/DSACore/Models/Database/Weapon.cs
new file mode 100644
index 0000000..b72ec20
--- /dev/null
+++ b/DSACore/Models/Database/Weapon.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace DSACore.Models.Database
+{
+ public class Weapon
+ {
+ private string Name { get; set; }
+ private string Damage { get; set; }
+ private string WeaponTalent { get; set; }
+ private string Modifier { get; set; }
+ }
+}
diff --git a/DSACore/Models/Command.cs b/DSACore/Models/Network/Command.cs
index 72c2a4c..dcfc692 100644
--- a/DSACore/Models/Command.cs
+++ b/DSACore/Models/Network/Command.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-namespace DSACore.Models
+namespace DSACore.Models.Network
{
public class Command
{
diff --git a/DSACore/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs
new file mode 100644
index 0000000..40f5aeb
--- /dev/null
+++ b/DSACore/Models/Network/Group.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace DSACore.Models.Network
+{
+ public class Group
+ {
+ public string Name { get; set; }
+ public List<User> Users { get; set; }= new List<User>();
+ }
+}
diff --git a/DSACore/Models/User.cs b/DSACore/Models/Network/User.cs
index 105e564..b207a19 100644
--- a/DSACore/Models/User.cs
+++ b/DSACore/Models/Network/User.cs
@@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-namespace DSACore.Models
+namespace DSACore.Models.Network
{
public class User
{
public string Name { get; set; }
- public string Group { get; set; }
+ public string ConnectionId { get; set; }
}
}