From af74efccf8d21e6151022b71f3cacd3fa83024ee Mon Sep 17 00:00:00 2001 From: uzvkl Date: Tue, 11 Jun 2019 23:33:41 +0200 Subject: Seperate the Core from dsa gamelogic --- .eslintrc | 13 - .firebaserc | 5 - DSACore/Controllers/CommandsController.cs | 56 ++++ DSACore/Controllers/LobbyController.cs | 32 +++ DSACore/Controllers/TokensController.cs | 25 ++ DSACore/Controllers/ValuesController.cs | 45 ++++ DSACore/DSACore.csproj | 28 ++ DSACore/Hubs/Login.cs | 205 +++++++++++++++ DSACore/Models/Network/Group.cs | 43 +++ DSACore/Models/Network/Token.cs | 21 ++ DSACore/Models/Network/User.cs | 9 + DSACore/Program.cs | 24 ++ .../Properties/DSALib-Auxiliary-CommandInfo.json | 101 +++++++ .../DSALib-DSA_Game-Characters-Character.json | 290 +++++++++++++++++++++ .../PublishProfiles/FolderProfile.pubxml | 23 ++ .../PublishProfiles/FolderProfile1.pubxml | 23 ++ DSACore/Properties/launchSettings.json | 30 +++ DSACore/Startup.cs | 47 ++++ DSACore/appsettings.Development.json | 9 + DSACore/appsettings.json | 10 + DiscordBot/Auxiliary/CommandExtension.cs | 98 ------- DiscordBot/Auxiliary/Dice.cs | 31 --- DiscordBot/Auxiliary/Permissions.cs | 32 --- DiscordBot/Auxiliary/RandomMisc.cs | 36 --- DiscordBot/Auxiliary/SpellCorrect.cs | 105 -------- DiscordBot/CommandHandler.cs | 112 -------- DiscordBot/Commands/CommandHelper.cs | 119 --------- DiscordBot/Commands/FileHandler.cs | 24 -- DiscordBot/Commands/MiscCommands.cs | 190 -------------- DiscordBot/DiscordBot.csproj | 12 - DiscordBot/Program.cs | 58 ----- DiscordBot/Rework/Permissions.cs | 38 --- database.rules.json | 7 - dsa/DSACore/Controllers/CommandsController.cs | 56 ---- dsa/DSACore/Controllers/LobbyController.cs | 32 --- dsa/DSACore/Controllers/TokensController.cs | 25 -- dsa/DSACore/Controllers/ValuesController.cs | 45 ---- dsa/DSACore/DSACore.csproj | 28 -- dsa/DSACore/Hubs/Login.cs | 205 --------------- dsa/DSACore/Models/Network/Group.cs | 43 --- dsa/DSACore/Models/Network/Token.cs | 21 -- dsa/DSACore/Models/Network/User.cs | 9 - dsa/DSACore/Program.cs | 24 -- .../Properties/DSALib-Auxiliary-CommandInfo.json | 101 ------- .../DSALib-DSA_Game-Characters-Character.json | 290 --------------------- .../PublishProfiles/FolderProfile.pubxml | 23 -- .../PublishProfiles/FolderProfile1.pubxml | 23 -- dsa/DSACore/Properties/launchSettings.json | 30 --- .../PropertiesDSALib-Auxiliary-CommandInfo.json | 101 ------- ...ertiesDSALib-DSA_Game-Characters-Character.json | 290 --------------------- .../PropertiesNewtonsoft-Json-Linq-JProperty.json | 30 --- dsa/DSACore/Startup.cs | 47 ---- dsa/DSACore/Token | 1 - dsa/DSACore/appsettings.Development.json | 9 - dsa/DSACore/appsettings.json | 10 - dsa/DiscoBot.sln | 43 +++ firebase.json | 20 -- firestore.indexes.json | 3 - firestore.rules | 7 - storage.rules | 7 - 60 files changed, 1064 insertions(+), 2360 deletions(-) delete mode 100644 .eslintrc delete mode 100644 .firebaserc create mode 100644 DSACore/Controllers/CommandsController.cs create mode 100644 DSACore/Controllers/LobbyController.cs create mode 100644 DSACore/Controllers/TokensController.cs create mode 100644 DSACore/Controllers/ValuesController.cs create mode 100644 DSACore/DSACore.csproj create mode 100644 DSACore/Hubs/Login.cs create mode 100644 DSACore/Models/Network/Group.cs create mode 100644 DSACore/Models/Network/Token.cs create mode 100644 DSACore/Models/Network/User.cs create mode 100644 DSACore/Program.cs create mode 100644 DSACore/Properties/DSALib-Auxiliary-CommandInfo.json create mode 100644 DSACore/Properties/DSALib-DSA_Game-Characters-Character.json create mode 100644 DSACore/Properties/PublishProfiles/FolderProfile.pubxml create mode 100644 DSACore/Properties/PublishProfiles/FolderProfile1.pubxml create mode 100644 DSACore/Properties/launchSettings.json create mode 100644 DSACore/Startup.cs create mode 100644 DSACore/appsettings.Development.json create mode 100644 DSACore/appsettings.json delete mode 100644 DiscordBot/Auxiliary/CommandExtension.cs delete mode 100644 DiscordBot/Auxiliary/Dice.cs delete mode 100644 DiscordBot/Auxiliary/Permissions.cs delete mode 100644 DiscordBot/Auxiliary/RandomMisc.cs delete mode 100644 DiscordBot/Auxiliary/SpellCorrect.cs delete mode 100644 DiscordBot/CommandHandler.cs delete mode 100644 DiscordBot/Commands/CommandHelper.cs delete mode 100644 DiscordBot/Commands/FileHandler.cs delete mode 100644 DiscordBot/Commands/MiscCommands.cs delete mode 100644 DiscordBot/DiscordBot.csproj delete mode 100644 DiscordBot/Program.cs delete mode 100644 DiscordBot/Rework/Permissions.cs delete mode 100644 database.rules.json delete mode 100644 dsa/DSACore/Controllers/CommandsController.cs delete mode 100644 dsa/DSACore/Controllers/LobbyController.cs delete mode 100644 dsa/DSACore/Controllers/TokensController.cs delete mode 100644 dsa/DSACore/Controllers/ValuesController.cs delete mode 100644 dsa/DSACore/DSACore.csproj delete mode 100644 dsa/DSACore/Hubs/Login.cs delete mode 100644 dsa/DSACore/Models/Network/Group.cs delete mode 100644 dsa/DSACore/Models/Network/Token.cs delete mode 100644 dsa/DSACore/Models/Network/User.cs delete mode 100644 dsa/DSACore/Program.cs delete mode 100644 dsa/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json delete mode 100644 dsa/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json delete mode 100644 dsa/DSACore/Properties/PublishProfiles/FolderProfile.pubxml delete mode 100644 dsa/DSACore/Properties/PublishProfiles/FolderProfile1.pubxml delete mode 100644 dsa/DSACore/Properties/launchSettings.json delete mode 100644 dsa/DSACore/PropertiesDSALib-Auxiliary-CommandInfo.json delete mode 100644 dsa/DSACore/PropertiesDSALib-DSA_Game-Characters-Character.json delete mode 100644 dsa/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json delete mode 100644 dsa/DSACore/Startup.cs delete mode 100644 dsa/DSACore/Token delete mode 100644 dsa/DSACore/appsettings.Development.json delete mode 100644 dsa/DSACore/appsettings.json create mode 100644 dsa/DiscoBot.sln delete mode 100644 firebase.json delete mode 100644 firestore.indexes.json delete mode 100644 firestore.rules delete mode 100644 storage.rules diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index bdf49cf..0000000 --- a/.eslintrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": "google", - "parserOptions": { - "ecmaVersion": 2017, - "sourceType": "module" - }, - "rules": { - "no-unused-vars": "off", - "no-extend-native": "off", - "arrow-parens": "off" - } -} diff --git a/.firebaserc b/.firebaserc deleted file mode 100644 index 13ab980..0000000 --- a/.firebaserc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "projects": { - "default": "heldenonline-4d828" - } -} diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs new file mode 100644 index 0000000..b6e0be2 --- /dev/null +++ b/DSACore/Controllers/CommandsController.cs @@ -0,0 +1,56 @@ +using System; +using DSACore.Models.Network; +using DSALib.Commands; +using DSALib.Models.Network; +using Microsoft.AspNetCore.Mvc; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace DSACore.Controllers +{ + [Route("dsa/[controller]")] + public class CommandsController : Controller + { + // GET: api/ + [HttpGet] + public string Get() + { + return "Usage: post the command to execute"; + } + + // GET api//5 + /*[HttpGet("{id}")] + public string Get(int id) + { + return "value"; + }*/ + + // POST api//Felis + [HttpPost] + public string Post([FromBody] Command cmd) + { + try + { + return CommandHandler.ExecuteCommand(cmd).message; + } + catch (Exception e) + { + return $"Ein Fehler ist aufgetreten: \n {e.Message}"; + } + } + +/* + + // PUT api//5 + [HttpPut("{id}")] + public void Put(int id, [FromBody]string value) + { + } + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + }*/ + } +} \ No newline at end of file diff --git a/DSACore/Controllers/LobbyController.cs b/DSACore/Controllers/LobbyController.cs new file mode 100644 index 0000000..7890b4f --- /dev/null +++ b/DSACore/Controllers/LobbyController.cs @@ -0,0 +1,32 @@ +using System; +using DSACore.Models.Network; +using DSALib.Commands; +using DSALib.Models.Network; +using Microsoft.AspNetCore.Mvc; + +namespace DSACore.Controllers +{ + public class ScribbleController : Controller + { + [Route("[controller]")] + // GET: api/ + [HttpGet] + public string Get() + { + return "Usage: get /tokens/{Token}"; + } + + [HttpPost] + public string Post([FromBody] Command cmd) + { + try + { + return CommandHandler.ExecuteCommand(cmd).message; + } + catch (Exception e) + { + return $"Ein Fehler ist aufgetreten: \n {e.Message}"; + } + } + } +} \ No newline at end of file diff --git a/DSACore/Controllers/TokensController.cs b/DSACore/Controllers/TokensController.cs new file mode 100644 index 0000000..a85cabe --- /dev/null +++ b/DSACore/Controllers/TokensController.cs @@ -0,0 +1,25 @@ +using DSACore.Hubs; +using Microsoft.AspNetCore.Mvc; + +namespace DSACore.Controllers +{ + [Route("lobby/[controller]")] + [ApiController] + public class TokensController : Controller + { + // GET + [HttpGet("{token}")] + public ActionResult Get(string token) + { + if (!int.TryParse(token, out var intToken)) + return BadRequest("The token has to be a 32 bit unsigned integer"); + + if (intToken == 42) return Ok("Scribble"); + + if (!Users.Tokens.Exists(x => x.GetHashCode() == intToken)) return NotFound(); + + var group = Users.Tokens.Find(x => x.GetHashCode() == intToken); + return Ok(group.Group); + } + } +} \ No newline at end of file diff --git a/DSACore/Controllers/ValuesController.cs b/DSACore/Controllers/ValuesController.cs new file mode 100644 index 0000000..eb08898 --- /dev/null +++ b/DSACore/Controllers/ValuesController.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace DSACore.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + // GET api/values + [HttpGet] + public ActionResult> Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api/values/5 + [HttpGet("{id}")] + public ActionResult Get(int id) + { + return "value"; + } + + // POST api/values + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT api/values/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE api/values/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/DSACore/DSACore.csproj b/DSACore/DSACore.csproj new file mode 100644 index 0000000..b350c64 --- /dev/null +++ b/DSACore/DSACore.csproj @@ -0,0 +1,28 @@ + + + + netcoreapp2.2 + DSACore.Program + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DSACore/Hubs/Login.cs b/DSACore/Hubs/Login.cs new file mode 100644 index 0000000..f08c24a --- /dev/null +++ b/DSACore/Hubs/Login.cs @@ -0,0 +1,205 @@ +using System; +using System.Collections.Generic; +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.FireBase; +using DSALib.Models.Network; +using Microsoft.AspNetCore.SignalR; +using Group = DSACore.Models.Network.Group; + +namespace DSACore.Hubs +{ + public class Users : Hub + { + //private static Dictionary UserGroup = new Dictionary(); + + private const string ReceiveMethod = "ReceiveMessage"; //receiveMethod; + + 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(); + } + + private static List DsaGroups { get; } + public static List Tokens { get; } = new List(); + + + public async Task SendMessage(string user, string message) + { + try + { + var group = getGroup(Context.ConnectionId).Name; + } + catch (InvalidOperationException) + { + await Clients.Caller.SendCoreAsync(ReceiveMethod, + new object[] { "Nutzer ist in keiner Gruppe. Erst joinen!" }); + } + + if (message[0] == '/') + { + var args = message.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList(); + + var Timon = args.Any(x => x == "hallo"); + + var ident = args.First().Replace("/", ""); + if (args.Count > 0) args.RemoveAt(0); + + var ret = CommandHandler.ExecuteCommand(new Command + { + CharId = 0, + CmdIdentifier = ident, + CmdTexts = args, + Name = user + }); + + switch (ret.ResponseType) + { + case ResponseType.Caller: + case ResponseType.Error: + await Clients.Caller.SendAsync(ReceiveMethod, ret.message); + break; + case ResponseType.Broadcast: + await SendToGroup(ret.message); + break; + } + } + else + { + await SendToGroup(message); + } + } + + private Task SendToGroup(string message) + { + try + { + var group = getGroup(Context.ConnectionId).Name; + return Clients.Group(group).SendCoreAsync(ReceiveMethod, + new object[] {getUser(Context.ConnectionId).Name, message}); + } + catch (InvalidOperationException) + { + return Clients.Caller.SendCoreAsync(ReceiveMethod, + new object[] {"Nutzer ist in keiner Gruppe. Erst joinen!"}); + } + } + + private Group getGroup(string id) + { + return DsaGroups.First(x => x.Users.Exists(y => y.ConnectionId.Equals(id))); + } + + private User getUser(string id) + { + return DsaGroups.First(x => x.Users.Exists(y => y.ConnectionId.Equals(id))).Users + .First(z => z.ConnectionId.Equals(id)); + } + + public async Task GetGroups() { + var test = await Database.GetGroups(); + 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); + + await Clients.Caller.SendCoreAsync("ListGroups", new object[] {DsaGroups.Select(x => x.SendGroup())}); + //throw new NotImplementedException("add database call to get groups"); + } + + public async Task AddGroup(string group, string password) + { + DsaGroups.Add(new Group(group, password)); + var Dgroup = new DSALib.Models.Database.Groups.Group {Name = group, Id = DsaGroups.Count - 1}; + //Database.AddGroup(Dgroup); + await Clients.Caller.SendCoreAsync(ReceiveMethod, new[] {$"group {group} sucessfully added"}); + //throw new NotImplementedException("add database call to add groups"); + } + + public async Task UploadChar(string xml) + { + var group = getGroup(Context.ConnectionId); + + await Database.AddChar(new Character(new MemoryStream(Encoding.UTF8.GetBytes(xml))), group.Name); + //throw new NotImplementedException("add database call to add groups"); + } + + public async Task Login(string group, string user, string hash) + { + //string password = System.Text.Encoding.UTF8.GetString(hash); + if (hash == DsaGroups.First(x => x.Name == group).Password) + { + var gGroup = DsaGroups.First(x => x.Name.Equals(group)); + if (!gGroup.Users.Exists(x => x.Name.Equals(user))) + { + await Groups.RemoveFromGroupAsync(Context.ConnectionId, "login"); + await Groups.AddToGroupAsync(Context.ConnectionId, group); + gGroup.Users.Add(new User {ConnectionId = Context.ConnectionId, Name = user}); + await SendToGroup("Ein neuer Nutzer hat die Gruppe betreten"); + await Clients.Caller.SendAsync("LoginResponse", 0); + await Clients.Caller.SendAsync("PlayerStatusChanged", new[] {user, "online"}); + + Tokens.Add(new Token(group)); + await Clients.Caller.SendAsync("Token", Tokens.Last().GetHashCode()); + purgeTokens(); + } + else + { + await Clients.Caller.SendAsync("LoginResponse", 1); + } + } + else + { + await Clients.Caller.SendAsync("LoginResponse", 2); + //await Clients.Caller.SendAsync(receiveMethod, "Falsches Passwort!"); + } + } + + private void purgeTokens() + { + Tokens.RemoveAll(x => !x.IsValid()); + } + + public override Task OnDisconnectedAsync(Exception exception) + { + Disconnect().Wait(); + return base.OnDisconnectedAsync(exception); + } + + public override Task OnConnectedAsync() + { + Groups.AddToGroupAsync(Context.ConnectionId, "login").Wait(); + Groups.AddToGroupAsync(Context.ConnectionId, "online").Wait(); + return base.OnConnectedAsync(); + } + + public async Task Disconnect() + { + await Groups.RemoveFromGroupAsync(Context.ConnectionId, "online"); + if (DsaGroups.Exists(x => x.Users.Exists(y => y.ConnectionId == Context.ConnectionId))) + try + { + var group = getGroup(Context.ConnectionId); + + + var user = getUser(Context.ConnectionId); + + await Clients.Caller.SendAsync("PlayerStatusChanged", new[] {user.Name, "offline"}); + //await SendToGroup(user.Name + " disconnected from the Server"); + group.Users.Remove(user); + await Groups.RemoveFromGroupAsync(Context.ConnectionId, group.Name); + } + catch (Exception e) + { + Console.WriteLine(e); + //throw; + } + } + } +} \ No newline at end of file diff --git a/DSACore/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs new file mode 100644 index 0000000..efe12ee --- /dev/null +++ b/DSACore/Models/Network/Group.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace DSACore.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 Users { get; set; } = new List(); + + 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/DSACore/Models/Network/Token.cs b/DSACore/Models/Network/Token.cs new file mode 100644 index 0000000..451cafc --- /dev/null +++ b/DSACore/Models/Network/Token.cs @@ -0,0 +1,21 @@ +using System; + +namespace DSACore.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/DSACore/Models/Network/User.cs b/DSACore/Models/Network/User.cs new file mode 100644 index 0000000..8b8008c --- /dev/null +++ b/DSACore/Models/Network/User.cs @@ -0,0 +1,9 @@ +namespace DSACore.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/DSACore/Program.cs b/DSACore/Program.cs new file mode 100644 index 0000000..8af0a74 --- /dev/null +++ b/DSACore/Program.cs @@ -0,0 +1,24 @@ +using DSALib.DSA_Game; +using DSALib.FireBase; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; + +namespace DSACore +{ + public class Program + { + public static void Main(string[] args) + { + Database.GetGroup(0).Wait(); + Dsa.Startup(); + CreateWebHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) + { + return WebHost.CreateDefaultBuilder(args) + .UseStartup() + .UseUrls("http://0.0.0.0:5000"); + } + } +} \ No newline at end of file diff --git a/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json b/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json new file mode 100644 index 0000000..b9941f2 --- /dev/null +++ b/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json @@ -0,0 +1,101 @@ +[ + { + "Name": "ich bin", + "Scope": "All", + "Brief": "Setzt den gespielten Charakter fest", + "Description": [ + "Mit \"!Ich bin\" kann der gespielte Charakter definiert, bzw. gewechselt werden.\n", + " Die Charaktere müssen als *.xml Dateien hinterlegt sein.\n\n", + " !ich Zeigt an welcher Charakter zur Zeit gespielt wird\n", + " !ich bin Zalibius Wechsel zum Helden Zalibius\n", + " !ich Rhoktar Orkische Variante von !ich bin.\n", + " Wechselt zu Rhoktar.\n\n", + " !list chars Zeigt die Liste verfügbarer Charaktere.\n", + " \n" + ] + }, + { + "Name": "List", + "Scope": "All", + "Brief": "Anzeige vonSpielrelevanten Listen", + "Description": [ + "Mit \"!list\" lassen sich spielrelevante Listen ausgeben. Die Angezeigte Liste wird nach einiger Zeit wieder gelöscht.\n", + "\n", + " !list chars Liste aller verfügbaren Helden (eingelesen per *.xml)\n", + " und NSCs.\n", + " (Mit \"!ich bin\" kann der Held ausgewählt werden.)\n", + " !list commands Liste aller verwendbaren Bot-Kommandos.\n", + " !list sounds Liste der Soundeffekte." + ] + }, + { + "Name": "Held", + "Scope": "All", + "Brief": "Anzeige von Heldenwerten", + "Description": [ + "Mit \"!Held\" lassen sich Heldenwerte ausgeben. Mehrere Werte können gleichzeitig angefordert werde. \"!Held LE Waffen\" liefert so z.B. Informationen zur Lebensenergie und den Kampfwerten.\n Bis auf wenige Ausnahmen wird die Angezeigte Liste nach einiger Zeit wieder gelöscht.\n", + "\n", + " !Held Zeigt den Heldenbrief an.\n", + " (Diese Liste wird nicht automatisch gelöscht)\n", + " !Held Eigenschaften Zeigt die Eigenschaften MU/KL/CH/IN/KK/GE/FF/KO.\n", + " !Held e Kurzform von \"!Held Eigenschaften\".\n", + " !Held LE Zeigt LE an.\n", + " !Held AE Zeigt AE an.\n", + " !Held stats Zeigt Eigenschaften und zusätzlich SO/LE/AE.\n", + " !Held Kampfwerte Zeigt AT/PA für aktivierte Waffentalente.\n", + " !Held Waffe/!list w Kurzformen von \"!Held Kampfwerte\".\n", + " !Held Vorteile Zeigt Vor- und Nachteile an.\n", + " !Held v Kurzform von \"!Held Vorteile\".\n", + " !Held Talente Zeigt die Liste aller aktivierten Talente, deren TaW,\n", + " sowie die Probe.\n", + " !Held t Kurzform von \"!Held Talente\".\n", + " !Held Zauber Zeigt die Liste aller aktivierten Zauber, deren ZaW,\n", + " sowie die Probe.\n", + " !Held z Kurzform von \"!Held Zauber\".\n" + ] + }, + { + "Name": "LE", + "Scope": "All", + "Brief": "Ändert dein Leben - im wahrsten Sinne des Wortes", + "Description": [ + "Mit !LE zeigt man die Lebensenergie an, ändert sie, oder setzt sie auf einen neuen Wert\n\n", + " !LE Zeigt Lebensenergie an\n", + " !LE 30 Setzt LE auf 30\n", + " !LE +5 Erhöht LE um 5 (bis zum Maximum)\n", + " !LE ++5 Erhöht LE um 5 (ignoriert Maximum)\n", + " !LE -5 Verringert LE um 5\n \n" + ] + }, + { + "Name": "AE", + "Scope": "All", + "Brief": "Ändert Astralenergie", + "Description": [ + "Mit !AE (oder !Asp) zeigt man die Astralenergie an, ändert sie, oder setzt sie auf einen neuen Wert\n\n", + " !AE Zeigt Astralenergie an\n", + " !AE 30 Setzt Asp auf 30\n", + " !AE +5 Erhöht Asp um 5 (bis zum Maximum)\n", + " !AE ++5 Erhöht Asp um 5 (ignoriert Maximum)\n", + " !AE -5 Verringert Asp um 5 (Minimum 0)\n" + ] + }, + { + "Name": "Gm", + "Scope": "Meister", + "Brief": "Kontrolliere andere Charaktere", + "Description": [ + "Mit !GM fürhrt man commands als eine andere Person aus.", + " !GM [charaktername] [command] [commandattribut] [mofifier]", + " Unterstützte [commands]'s:", + " !GM [name] LE", + " !GM [name] AE", + " !GM [name] Talent", + " !GM [name] Fernkampf", + " !GM [name] Eigenschaft", + " !GM [name] Zauber", + " !GM [name] Angriff", + " !GM [name] Parade" + ] + } +] \ No newline at end of file diff --git a/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json b/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json new file mode 100644 index 0000000..fd387f5 --- /dev/null +++ b/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json @@ -0,0 +1,290 @@ +[ + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 30, + "Lebenspunkte_Aktuell": 30, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 20, + "Astralpunkte_Aktuell": 20, + "Name": "Felis Exodus Schattenwald" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 29, + "Lebenspunkte_Aktuell": 29, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 0, + "Astralpunkte_Aktuell": 0, + "Name": "Gardist" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 31, + "Lebenspunkte_Aktuell": 31, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 0, + "Astralpunkte_Aktuell": 0, + "Name": "Hartmut Reiher" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 21, + "Lebenspunkte_Aktuell": 21, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 35, + "Astralpunkte_Aktuell": 35, + "Name": "Helga vom Drachenei, Tausendsasserin" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 25, + "Lebenspunkte_Aktuell": 25, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 0, + "Astralpunkte_Aktuell": 0, + "Name": "Krenko" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 39, + "Lebenspunkte_Aktuell": 39, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 0, + "Astralpunkte_Aktuell": 0, + "Name": "Ledur Torfinson" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 26, + "Lebenspunkte_Aktuell": 26, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 13, + "Astralpunkte_Aktuell": 13, + "Name": "Morla" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 28, + "Lebenspunkte_Aktuell": 28, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 40, + "Astralpunkte_Aktuell": 40, + "Name": "Numeri Illuminus" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 39, + "Lebenspunkte_Aktuell": 39, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 16, + "Astralpunkte_Aktuell": 16, + "Name": "Potus" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 18, + "Lebenspunkte_Aktuell": 18, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 13, + "Astralpunkte_Aktuell": 13, + "Name": "Pump aus der Gosse" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 34, + "Lebenspunkte_Aktuell": 34, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 17, + "Astralpunkte_Aktuell": 17, + "Name": "Rhoktar4" + }, + { + "Eigenschaften": {}, + "Talente": [], + "Zauber": [], + "Kampftalente": [], + "Vorteile": [], + "PropTable": { + "MU": "Mut", + "KL": "Klugheit", + "IN": "Intuition", + "CH": "Charisma", + "FF": "Fingerfertigkeit", + "GE": "Gewandtheit", + "KO": "Konstitution", + "KK": "Körperkraft" + }, + "Lebenspunkte_Basis": 28, + "Lebenspunkte_Aktuell": 28, + "Ausdauer_Basis": 0, + "Ausdauer_Aktuell": 0, + "Astralpunkte_Basis": 43, + "Astralpunkte_Aktuell": 43, + "Name": "Volant" + } +] \ No newline at end of file diff --git a/DSACore/Properties/PublishProfiles/FolderProfile.pubxml b/DSACore/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..2fd07c5 --- /dev/null +++ b/DSACore/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,23 @@ + + + + + FileSystem + FileSystem + Release + Any CPU + + True + False + netcoreapp2.1 + 35a5e2cc-0fd4-4bc0-acbf-38599caed1c4 + false + <_IsPortable>true + bin\Release\netcoreapp2.1\publish\ + False + win-x64 + + \ No newline at end of file diff --git a/DSACore/Properties/PublishProfiles/FolderProfile1.pubxml b/DSACore/Properties/PublishProfiles/FolderProfile1.pubxml new file mode 100644 index 0000000..e03b55a --- /dev/null +++ b/DSACore/Properties/PublishProfiles/FolderProfile1.pubxml @@ -0,0 +1,23 @@ + + + + + FileSystem + FileSystem + Release + Any CPU + + True + False + netcoreapp2.1 + linux-x64 + 35a5e2cc-0fd4-4bc0-acbf-38599caed1c4 + false + <_IsPortable>true + bin\Release\netcoreapp2.1\publish\ + False + + \ No newline at end of file diff --git a/DSACore/Properties/launchSettings.json b/DSACore/Properties/launchSettings.json new file mode 100644 index 0000000..2da5fec --- /dev/null +++ b/DSACore/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:2170", + "sslPort": 44365 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/commands", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "DSACore": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/commands", + "applicationUrl": "https://0.0.0.0:5001;http://0.0.0.0:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/DSACore/Startup.cs b/DSACore/Startup.cs new file mode 100644 index 0000000..ef22802 --- /dev/null +++ b/DSACore/Startup.cs @@ -0,0 +1,47 @@ +using DSACore.Hubs; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace DSACore +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + + services.AddSignalR(); + } + + // 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()) + app.UseDeveloperExceptionPage(); + else + app.UseHsts(); + + app.UseCors("CorsPolicy"); + + app.UseSignalR(routes => { routes.MapHub("/login"); }); + + app.UseWebSockets(); + + //app.UseCors("AllowSpecificOrigin"); + app.UseHttpsRedirection(); + app.UseMvc(); + } + } +} \ No newline at end of file diff --git a/DSACore/appsettings.Development.json b/DSACore/appsettings.Development.json new file mode 100644 index 0000000..e203e94 --- /dev/null +++ b/DSACore/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/DSACore/appsettings.json b/DSACore/appsettings.json new file mode 100644 index 0000000..dee968c --- /dev/null +++ b/DSACore/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Microsoft.AspNetCore.SignalR": "Debug", + "Microsoft.AspNetCore.Http.Connections": "Debug", + "Default": "Debug" + } + }, + "AllowedHosts": "*" +} diff --git a/DiscordBot/Auxiliary/CommandExtension.cs b/DiscordBot/Auxiliary/CommandExtension.cs deleted file mode 100644 index 690f352..0000000 --- a/DiscordBot/Auxiliary/CommandExtension.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Discord; -using Discord.Commands; - -namespace DiscordBot.Auxiliary -{ - public static class CommandExtension - { - private static WebClient _client; - - public static async Task ReplyTimedAsync(this ModuleBase m, string message, TimeSpan time) - { - var token = message.GetHashCode(); - var send = m.Context.Channel.SendMessageAsync($"#{token}\n```xl\n{message}```"); - - var barInvoker = new BackgroundWorker(); - barInvoker.DoWork += delegate - { - Thread.Sleep(time); - Delete(token, m); - }; - - await send; - barInvoker.RunWorkerAsync(); - } - - private static void Delete(int token, ModuleBase m) - { - var messagesAsync = m.Context.Channel.GetMessagesAsync(); - Task.WaitAll(messagesAsync.ToArray()); - var list = messagesAsync.ToEnumerable().ToList(); - var messages = new List(); - foreach (var task in list) messages.AddRange(task.ToList()); - - var test = messages.Where(x => x.Content.StartsWith($"#{token}\n") && x.Author.IsBot).Select(c => c); - Task.WaitAll(test.Select(message => (message as IUserMessage)?.DeleteAsync()).ToArray()); - } - - public static async Task ReplyAsync(this ModuleBase m, IEnumerable message, bool directMessage = false) - { - var sb = new StringBuilder(); - foreach (var re in message) - { - if (sb.Length + re.Length > 1798) - { - if (directMessage) - await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```"); - else - await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```"); - - sb.Clear(); - } - - sb.AppendLine(re); - } - - if (directMessage) - await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```"); - else - await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```"); - } - - public static async Task ReplyAsync(this ModuleBase m, IEnumerable message, TimeSpan time) - { - var sb = new StringBuilder(); - foreach (var re in message) - { - if (sb.Length + re.Length > 1798) - { - await m.ReplyTimedAsync(sb.ToString(), time); - - - sb.Clear(); - } - - sb.AppendLine(re); - } - - await m.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90)); - } - - public static async Task SendWebFile(this IMessageChannel channel, - string url = "https://i.imgur.com/0iHEycJ.png") - { - if (_client == null) _client = new WebClient(); - - var stream = _client.OpenRead(url); - await channel.SendFileAsync(stream, url.Split('/').Last()); - } - } -} \ No newline at end of file diff --git a/DiscordBot/Auxiliary/Dice.cs b/DiscordBot/Auxiliary/Dice.cs deleted file mode 100644 index c44e87e..0000000 --- a/DiscordBot/Auxiliary/Dice.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace DiscordBot.Auxiliary -{ - public static class Dice // roll it! - { - private static readonly Random Rnd = new Random(); - - public static int Roll(int d = 20) - { - return Rnd.Next(d) + 1; - } - - - public static int Roll(int count, int d) - { - if (d <= 0) return 0; - - var sum = 0; - for (var i = 0; i < Math.Abs(count); i++) - { - var roll = Roll(d); - sum += roll; - } - - sum *= Math.Abs(count) / count; - - return sum; - } - } -} \ No newline at end of file diff --git a/DiscordBot/Auxiliary/Permissions.cs b/DiscordBot/Auxiliary/Permissions.cs deleted file mode 100644 index c2cb058..0000000 --- a/DiscordBot/Auxiliary/Permissions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Discord.Commands; -using Discord.WebSocket; - -namespace DiscordBot.Auxiliary -{ - public static class Permissions - { - public static bool Check(ICommandContext c, string role) - { - return ((SocketGuildUser) c.User).Roles.ToList().Exists(v => v.Name.Equals(role)); - } - - public static bool Check(ICommandContext c, IEnumerable roles) - { - return roles.Any(role => ((SocketGuildUser) c.User).Roles.ToList().Exists(v => v.Name.Equals(role))); - } - - public static bool Test(ICommandContext c, string role) - { - if (Check(c, role)) return true; - c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait(); - return false; - } - - public static void Test(ICommandContext c, string[] roles) - { - if (!Check(c, roles)) c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait(); - } - } -} \ No newline at end of file diff --git a/DiscordBot/Auxiliary/RandomMisc.cs b/DiscordBot/Auxiliary/RandomMisc.cs deleted file mode 100644 index f7c5186..0000000 --- a/DiscordBot/Auxiliary/RandomMisc.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Linq; -using System.Text; - -namespace DiscordBot.Auxiliary -{ - public static class RandomMisc - { - public static string Roll(string input) - { - var output = new StringBuilder(); - var strings = input.Split('w', 'd').ToList(); - var count = Convert.ToInt32(strings[0]); - strings = strings[1].Split(' ').ToList(); - var d = Convert.ToInt32(strings[0]); - - if (strings.Count > 0) - { - } - - var sum = 0; - for (var i = 0; i < count; i++) - { - var roll = Dice.Roll(d); - sum += roll; - output.Append("[" + roll + "] "); - } - - if (strings.Count <= 1) return output.ToString(); - sum += Convert.ToInt32(strings[1]); - output.Append("sum: " + sum); - - return output.ToString(); - } - } -} \ No newline at end of file diff --git a/DiscordBot/Auxiliary/SpellCorrect.cs b/DiscordBot/Auxiliary/SpellCorrect.cs deleted file mode 100644 index a2ba91a..0000000 --- a/DiscordBot/Auxiliary/SpellCorrect.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Diagnostics; - -namespace DiscordBot.Auxiliary -{ - public class SpellCorrect : StringComparer - { - public const int ErrorThreshold = 94100; - - public override int Compare(string x, string y) - { - return CompareEasy(x, y); - } - - public static int CompareEasy(string x, string y) - { - if (string.IsNullOrEmpty(x)) throw new ArgumentException("message", nameof(x)); - - if (string.IsNullOrEmpty(y)) throw new ArgumentException("message", nameof(y)); - - if (x.Equals(y)) return 0; - - x = x.ToLower(); - y = y.ToLower(); - if (x.Equals(y)) return 1; - - var subs = y.Split(' ', '/'); - var score = subs.Length; - foreach (var s in subs) - if (s.Equals(x)) - score--; - - if (score < subs.Length) return score + 1; - - return 100000 - (int) (CompareExact(x, y) * 1000.0); - /*if (y.Contains(x)) - return 6;*/ - } - - public override bool Equals(string x, string y) - { - Debug.Assert(x != null, nameof(x) + " != null"); - return x.Equals(y); - } - - public override int GetHashCode(string obj) - { - throw new NotImplementedException(); - } - - public static double CompareExact(string s, string q) - { - s = s.ToLower(); - q = q.ToLower(); - - int i, j; - const double match = 3.0; - const double gap = -2.0; - const double mismatch = -2.0; - - double decay; - - var matrix = new double[s.Length + 1, q.Length + 1]; - var max = 0.0; - matrix[0, 0] = 0.0; - - for (i = 1; i < s.Length; i++) - // matrix[i, 0] = 0.0; - matrix[i, 0] = i * gap; - - for (i = 1; i < q.Length; i++) matrix[0, i] = 0.0; - - - for (i = 1; i <= s.Length; i++) - for (j = 1; j <= q.Length; j++) - { - decay = j / (double) (s.Length * 1000); - var add = s[i - 1] == q[j - 1] ? match - decay : mismatch; - var score = matrix[i - 1, j - 1] + add; - - if (score < matrix[i - 1, j] + gap) score = matrix[i - 1, j] + gap; - - if (score < matrix[i, j - 1] + gap) score = matrix[i, j - 1] + gap; - - if (i > 1 && j > 1) - if (s[i - 1] == q[j - 2] && s[i - 2] == q[j - 1]) - { - add = 3 / 2.0 * match - decay; - if (score < matrix[i - 2, j - 2] + add) score = matrix[i - 2, j - 2] + add; - } - - // if (score < 0) - // { - // score = 0; - // } - - if (max < score && i == s.Length) max = score; - - matrix[i, j] = score; - } - - return max; - } - } -} \ No newline at end of file diff --git a/DiscordBot/CommandHandler.cs b/DiscordBot/CommandHandler.cs deleted file mode 100644 index b41756f..0000000 --- a/DiscordBot/CommandHandler.cs +++ /dev/null @@ -1,112 +0,0 @@ -#region - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Reflection; -using System.Threading.Tasks; -using Discord.Commands; -using Discord.WebSocket; - -#endregion - -namespace DiscordBot -{ - public class CommandHandler - { - private static readonly HttpClient _HttpClient = new HttpClient(); - private readonly DiscordSocketClient _client; - private readonly CommandService _commands; - - public CommandHandler(DiscordSocketClient client, CommandService commands) { - _commands = commands; - _client = client; - } - - public Task InstallCommandsAsync() { - // Hook the MessageReceived event into our command handler - _client.MessageReceived += HandleCommandAsync; - - // Here we discover all of the command modules in the entry - // assembly and load them. Starting from Discord.NET 2.0, a - // service provider is required to be passed into the - // module registration method to inject the - // required dependencies. - // - // If you do not use Dependency Injection, pass null. - // See Dependency Injection guide for more information. - return _commands.AddModulesAsync(Assembly.GetEntryAssembly(), - null); - } - - - private static async Task SendCommand(string name, string command, string url) { - command = command.Remove(0, 1); - var args = command.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); - - string cmdContent = string.Empty; - if (args.Length > 1) { - cmdContent = "\"" + args.Skip(1).Aggregate((s, n) => s + "\", \"" + n) + "\""; - } - - var values = new Dictionary { - {"Name", name}, - {"CmdIdentifier", args.First()}, - {"CmdTexts", "[" + cmdContent + "]"} - }; - - var content = new FormUrlEncodedContent(values); - - var response = await _HttpClient.PostAsync(url, content); - - return await response.Content.ReadAsStringAsync(); - } - - private async Task HandleCommandAsync(SocketMessage messageParam) { - // Don't process the command if it was a system message - var message = messageParam as SocketUserMessage; - if (message == null) { - return; - } - - // Create a number to track where the prefix ends and the command begins - var argPos = 0; - - // Determine if the message is a command based on the prefix and make sure no bots trigger commands - if (!(message.HasCharPrefix('!', ref argPos) || - message.HasMentionPrefix(_client.CurrentUser, ref argPos)) || - message.Author.IsBot) { - return; - } - - // Create a WebSocket-based command context based on the message - var context = new SocketCommandContext(_client, message); - - // Execute the command with the command context we just - // created, along with the service provider for precondition checks. - - // Keep in mind that result does not indicate a return value - // rather an object stating if the command executed successfully. - var result = await _commands.ExecuteAsync( - context, - argPos, - null); - - // Optionally, we may inform the user if the command fails - // to be executed; however, this may not always be desired, - // as it may clog up the request queue should a user spam a - // command. - - if (result.Error == CommandError.UnknownCommand) { - string response = await SendCommand(message.Author.Username, message.Content, - "https://kobert.dev/api/dsa/commands"); - //var response = "invalid"; - await context.Channel.SendMessageAsync(response); - } - else if (!result.IsSuccess) { - await context.Channel.SendMessageAsync(result.ErrorReason); - } - } - } -} \ No newline at end of file diff --git a/DiscordBot/Commands/CommandHelper.cs b/DiscordBot/Commands/CommandHelper.cs deleted file mode 100644 index 162c65d..0000000 --- a/DiscordBot/Commands/CommandHelper.cs +++ /dev/null @@ -1,119 +0,0 @@ -namespace DiscoBot.Auxiliary -{ - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.IO; - using System.Linq; - using System.Net; - using System.Text; - using System.Threading; - using System.Threading.Tasks; - - using Discord; - using Discord.Commands; - - public static class CommandHelper - { - private static WebClient client; - - public static async Task ReplyTimedAsync(this ModuleBase m, string message, TimeSpan time) - { - var token = message.GetHashCode(); - var send = m.Context.Channel.SendMessageAsync($"#{token}\n```xl\n{message}```", false); - - var barInvoker = new BackgroundWorker(); - barInvoker.DoWork += delegate - { - Thread.Sleep(time); - Delete(token, m); - }; - - await send; - barInvoker.RunWorkerAsync(); - } - - private static void Delete(int token, ModuleBase m) - { - var messagesAsync = m.Context.Channel.GetMessagesAsync(); - Task.WaitAll(messagesAsync.ToArray()); - var list = messagesAsync.ToEnumerable().ToList(); - var messages = new List(); - foreach (var task in list) - { - messages.AddRange(task.ToList()); - } - - var test = messages.Where(x => x.Content.StartsWith($"#{token}\n") && x.Author.IsBot).Select(c=>c ); - var waiters = new List(); - foreach (var message in test) - { - waiters.Add((message as IUserMessage).DeleteAsync()); - } - Task.WaitAll(waiters.ToArray()); - } - - public static async Task ReplyAsync(this ModuleBase m, IEnumerable message, bool directMessage = false) - { - var sb = new StringBuilder(); - foreach (string re in message) - { - if (sb.Length + re.Length > 1798) - { - if (directMessage) - { - await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```"); - } - else - { - await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```"); - } - - sb.Clear(); - } - - sb.AppendLine(re); - } - - if (directMessage) - { - await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```"); - } - else - { - await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```"); - } - } - - public static async Task ReplyAsync(this ModuleBase m, IEnumerable message, TimeSpan time) - { - var sb = new StringBuilder(); - foreach (string re in message) - { - if (sb.Length + re.Length > 1798) - { - - await m.ReplyTimedAsync(sb.ToString(), time); - - - sb.Clear(); - } - - sb.AppendLine(re); - } - - await m.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90)); - } - - public static async Task SendWebFile(this IMessageChannel channel, string url = "https://i.imgur.com/0iHEycJ.png") - { - if (client == null) - { - client = new WebClient(); - } - - Stream stream = client.OpenRead(url); - await channel.SendFileAsync(stream, url.Split('/').Last()); - } - } -} diff --git a/DiscordBot/Commands/FileHandler.cs b/DiscordBot/Commands/FileHandler.cs deleted file mode 100644 index e3cd82d..0000000 --- a/DiscordBot/Commands/FileHandler.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Linq; -using Discord.Commands; - -namespace DiscordBot.Commands -{ - public class FileHandler : ModuleBase - { - //[Command("send"), Summary("fügt Helden hinzu")] - public void AddChar() - { - var msg = Context.Message; - if (msg.Attachments == null) throw new ArgumentException("Es wurde keine Datei angehängt"); - - var attachments = msg.Attachments.ToList(); - - if (!attachments.Any(x => x.Filename.EndsWith(".xml"))) - throw new ArgumentException("Es wurde kein xml Held mitgeschickt"); - - foreach (var attachment in attachments.Where(x => x.Filename.EndsWith(".xml"))) - throw new NotImplementedException("send File to Server"); - } - } -} \ No newline at end of file diff --git a/DiscordBot/Commands/MiscCommands.cs b/DiscordBot/Commands/MiscCommands.cs deleted file mode 100644 index 5707de7..0000000 --- a/DiscordBot/Commands/MiscCommands.cs +++ /dev/null @@ -1,190 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using DiscoBot.Auxiliary; -using Discord; -using Discord.Commands; -using DiscordBot.Auxiliary; - -namespace DiscordBot.Commands -{ - public class MiscCommands : ModuleBase - { - [Command("r")] - [Summary("Würfelt ")] - [Alias("R", "Roll", "roll", "Würfle")] - public Task RollAsync([Remainder] [Summary("Weapon")] string roll) - { - //return this.ReplyAsync("```xl\n" + new Auxiliary.Calculator.StringSolver(roll).Solve() + "\n```"); - return ReplyAsync("```xl\n" + RandomMisc.Roll(roll) + "\n```"); - } - - - [Command("say")] - [Summary("Echos a message.")] - [Alias("s")] - public Task SayAsync([Remainder] [Summary("The text to echo")] - string echo) - { - return ReplyAsync(echo); - } - - [Command("liebe")] - [Summary("Echos a message.")] - [Alias("Liebe", "<3", "love")] - public async Task LoveAsync() - { - var rand = new Random(); - var user = Context.Channel.GetUsersAsync().ToList().Result.ToList().First() - .Where(x => x.Status != UserStatus.Offline).OrderBy(x => rand.Next()).First(); - await ReplyAsync( - ":heart: :heart: :heart: Verteilt die Liebe! :heart: :heart: :heart: \n Besondere Liebe geht an " + - user.Username); - //await this.ReplyAsync("!liebe"); - } - - [Command("maul")] - [Summary("Echos a message.")] - public Task MaulAsync() - { - return ReplyAsync( - "Maul...? Du meintest doch sicher Maulwürfe oder? \n:heart: :heart: :heart: \nGanz viel Liebe für Maulwürfe !\n:heart: :heart: :heart:"); - } - - - [Command("match")] - [Summary("Tinder.")] - [Alias("mach", "pass", "passt")] - public Task TinderAsync(string s1, string s2) - { - var rand = new Random((s1 + s2).GetHashCode()); - - var wert = Math.Log10(Math.Floor(1000.0 * (SpellCorrect.CompareExact(s1, s2) + rand.NextDouble() * 10.0)) / - 1000.0); - wert = wert * 100.0 < 100.0 ? wert * 100.0 : 100.0 - wert; - wert = wert < 0 ? -wert : wert; - return ReplyAsync($"Ihr passt zu {Math.Floor(100.0 * wert) / 100.0}% zusammen"); - } - - [Command("reddit")] - [Summary("Reddit.")] - public Task RedditAsync() - { - return ReplyAsync( - "Ein Archiv der Vergangenen Aktionen findet man hier: https://www.reddit.com/r/ReconquistaInternet/"); - } - - [Command("compare")] - [Summary("Echos a message.")] - public async Task KickAsync() - { - //await this.Context.Guild.DownloadUsersAsync(); - var users = Context.Guild.GetUsersAsync(); - var test = File.ReadAllLines("RG.txt"); - await users; - var us = users.Result.Select(x => x.Username); - - var lines = test.Where(x => !x.Equals(string.Empty)).ToList(); - - - var sc = new SpellCorrect(); - - var res = new List(); - - foreach (var line in lines) - { - var best = us.OrderBy(user => sc.Compare(user, line)).First(); - - double fit = sc.Compare(best, line); - - if (!(fit < SpellCorrect.ErrorThreshold - 20000)) continue; - res.Add(fit.Equals(0) ? $"@\t{best} !!! => {line}" : $"-\t{best} hat Ähnlichkeit mit: {line}"); - } - - var sb = new StringBuilder(); - foreach (var re in res) - { - if (sb.Length + re.Length > 1798) - { - await CommandHelper.ReplyTimedAsync(this, sb.ToString(), TimeSpan.FromSeconds(90)); - sb.Clear(); - } - - sb.AppendLine(re); - } - - if (Permissions.Check(Context, new[] {"Admin", "Mod"})) - await CommandHelper.ReplyTimedAsync(this, sb.ToString(), TimeSpan.FromSeconds(90)); - - //await this.ReplyAsync($"{count} Duplikate gefunden"); - } - - - [Command("clear")] - [Summary("Cleans up messages.")] - public void DeleteAsync(int count) - { - var messagesAsync = Context.Channel.GetMessagesAsync(count); - if (messagesAsync != null) - { - Task.WaitAll(messagesAsync.ToArray()); - var list = messagesAsync.ToEnumerable().ToList(); - var messages = new List(); - foreach (var task in list) messages.AddRange(task.ToList()); - - if (Permissions.Check(Context, new[] {"Admin", "Mod", "Meister"})) - { - var waiters = new List(); - foreach (var message in messages) waiters.Add(((IUserMessage) message).DeleteAsync()); - - Task.WaitAll(waiters.ToArray()); - } - } - } - - [Command("check")] - [Summary("Echos a message.")] - [Alias("Check")] - public async Task CheckAsync(string quarry) - { - var perm = new List {"Admin", "Mod", "Privatpolizei"}; - - Permissions.Test(Context, perm.ToArray()); - - var test = File.ReadAllLines("RG.txt"); - - var lines = test.Where(x => !x.Equals(string.Empty)).ToList(); - - - var sc = new SpellCorrect(); - var count = lines.OrderBy(line => sc.Compare(quarry, line)).First(); - - var fit = sc.Compare(count, quarry); - - string antwort; - - antwort = fit < SpellCorrect.ErrorThreshold - 20000 - ? $"```xl\nAuf anderem Server Match gefunden: {count}" - : $"```xl\nAuf anderem Server Kein Match gefunden: {quarry}"; - - - var users = Context.Guild.GetUsersAsync(); - await users; - var us = users.Result.Select(x => x.Username); - - sc = new SpellCorrect(); - count = us.OrderBy(line => sc.Compare(quarry, line)).First(); - - fit = sc.Compare(count, quarry); - - antwort = fit < SpellCorrect.ErrorThreshold - 20000 - ? $"{antwort}\nAuf unserem Server Match gefunden: {count}\n```" - : $"{antwort}\nAuf unserem Server Kein Match gefunden: {quarry} \n```"; - - await ReplyAsync(antwort); - } - } -} \ No newline at end of file diff --git a/DiscordBot/DiscordBot.csproj b/DiscordBot/DiscordBot.csproj deleted file mode 100644 index 620a3a6..0000000 --- a/DiscordBot/DiscordBot.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - netcoreapp2.2 - - - - - - - diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs deleted file mode 100644 index 60febcd..0000000 --- a/DiscordBot/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using Discord; -using Discord.Commands; -using Discord.WebSocket; - -namespace DiscordBot -{ - class Program - { - public static void Main(string[] args) - => new Program().MainAsync().GetAwaiter().GetResult(); - - private DiscordSocketClient _client; - private CommandHandler cHandler; - - public async Task MainAsync() - { - _client = new DiscordSocketClient(); - - _client.Log += Log; - - - cHandler = new CommandHandler(_client, new CommandService()); - // Remember to keep token private or to read it from an - // external source! In this case, we are reading the token - // from an environment variable. If you do not know how to set-up - // environment variables, you may find more information on the - // Internet or by using other methods such as reading from - // a configuration. - await cHandler.InstallCommandsAsync(); - - try - { - await _client.LoginAsync(TokenType.Bot, - Environment.GetEnvironmentVariable("DiscordToken")); - } - catch - { - await _client.LoginAsync(TokenType.Bot, File.ReadAllText("Token")); - } - - await _client.StartAsync(); - - // Block this task until the program is closed. - await Task.Delay(-1); - } - - private Task Log(LogMessage msg) - { - Console.WriteLine(msg.ToString()); - return Task.CompletedTask; - } - } -} diff --git a/DiscordBot/Rework/Permissions.cs b/DiscordBot/Rework/Permissions.cs deleted file mode 100644 index 119e628..0000000 --- a/DiscordBot/Rework/Permissions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Linq; -using Discord.Commands; -using Discord.WebSocket; - -namespace DiscordBot.Rework -{ - public static class Permissions - { - public static bool Check(ICommandContext c, string role) - { - return ((SocketGuildUser)c.User).Roles.ToList().Exists(v => v.Name.Equals(role)); - } - - public static bool Check(ICommandContext c, string[] roles) - { - return roles.Any(role => ((SocketGuildUser)c.User).Roles.ToList().Exists(v => v.Name.Equals(role))); - } - - public static bool Test(ICommandContext c, string role) - { - if (!Check(c, role)) - { - c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait(); - return false; - } - - return true; - } - - public static void Test(ICommandContext c, string[] roles) - { - if (!Check(c, roles)) - { - c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait(); - } - } - } -} diff --git a/database.rules.json b/database.rules.json deleted file mode 100644 index f54493d..0000000 --- a/database.rules.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */ - "rules": { - ".read": false, - ".write": false - } -} \ No newline at end of file diff --git a/dsa/DSACore/Controllers/CommandsController.cs b/dsa/DSACore/Controllers/CommandsController.cs deleted file mode 100644 index b6e0be2..0000000 --- a/dsa/DSACore/Controllers/CommandsController.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using DSACore.Models.Network; -using DSALib.Commands; -using DSALib.Models.Network; -using Microsoft.AspNetCore.Mvc; - -// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 - -namespace DSACore.Controllers -{ - [Route("dsa/[controller]")] - public class CommandsController : Controller - { - // GET: api/ - [HttpGet] - public string Get() - { - return "Usage: post the command to execute"; - } - - // GET api//5 - /*[HttpGet("{id}")] - public string Get(int id) - { - return "value"; - }*/ - - // POST api//Felis - [HttpPost] - public string Post([FromBody] Command cmd) - { - try - { - return CommandHandler.ExecuteCommand(cmd).message; - } - catch (Exception e) - { - return $"Ein Fehler ist aufgetreten: \n {e.Message}"; - } - } - -/* - - // PUT api//5 - [HttpPut("{id}")] - public void Put(int id, [FromBody]string value) - { - } - - // DELETE api//5 - [HttpDelete("{id}")] - public void Delete(int id) - { - }*/ - } -} \ No newline at end of file diff --git a/dsa/DSACore/Controllers/LobbyController.cs b/dsa/DSACore/Controllers/LobbyController.cs deleted file mode 100644 index 7890b4f..0000000 --- a/dsa/DSACore/Controllers/LobbyController.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using DSACore.Models.Network; -using DSALib.Commands; -using DSALib.Models.Network; -using Microsoft.AspNetCore.Mvc; - -namespace DSACore.Controllers -{ - public class ScribbleController : Controller - { - [Route("[controller]")] - // GET: api/ - [HttpGet] - public string Get() - { - return "Usage: get /tokens/{Token}"; - } - - [HttpPost] - public string Post([FromBody] Command cmd) - { - try - { - return CommandHandler.ExecuteCommand(cmd).message; - } - catch (Exception e) - { - return $"Ein Fehler ist aufgetreten: \n {e.Message}"; - } - } - } -} \ No newline at end of file diff --git a/dsa/DSACore/Controllers/TokensController.cs b/dsa/DSACore/Controllers/TokensController.cs deleted file mode 100644 index a85cabe..0000000 --- a/dsa/DSACore/Controllers/TokensController.cs +++ /dev/null @@ -1,25 +0,0 @@ -using DSACore.Hubs; -using Microsoft.AspNetCore.Mvc; - -namespace DSACore.Controllers -{ - [Route("lobby/[controller]")] - [ApiController] - public class TokensController : Controller - { - // GET - [HttpGet("{token}")] - public ActionResult Get(string token) - { - if (!int.TryParse(token, out var intToken)) - return BadRequest("The token has to be a 32 bit unsigned integer"); - - if (intToken == 42) return Ok("Scribble"); - - if (!Users.Tokens.Exists(x => x.GetHashCode() == intToken)) return NotFound(); - - var group = Users.Tokens.Find(x => x.GetHashCode() == intToken); - return Ok(group.Group); - } - } -} \ No newline at end of file diff --git a/dsa/DSACore/Controllers/ValuesController.cs b/dsa/DSACore/Controllers/ValuesController.cs deleted file mode 100644 index eb08898..0000000 --- a/dsa/DSACore/Controllers/ValuesController.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; - -namespace DSACore.Controllers -{ - [Route("api/[controller]")] - [ApiController] - public class ValuesController : ControllerBase - { - // GET api/values - [HttpGet] - public ActionResult> Get() - { - return new string[] { "value1", "value2" }; - } - - // GET api/values/5 - [HttpGet("{id}")] - public ActionResult Get(int id) - { - return "value"; - } - - // POST api/values - [HttpPost] - public void Post([FromBody] string value) - { - } - - // PUT api/values/5 - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) - { - } - - // DELETE api/values/5 - [HttpDelete("{id}")] - public void Delete(int id) - { - } - } -} diff --git a/dsa/DSACore/DSACore.csproj b/dsa/DSACore/DSACore.csproj deleted file mode 100644 index f7def31..0000000 --- a/dsa/DSACore/DSACore.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - netcoreapp2.2 - DSACore.Program - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dsa/DSACore/Hubs/Login.cs b/dsa/DSACore/Hubs/Login.cs deleted file mode 100644 index f08c24a..0000000 --- a/dsa/DSACore/Hubs/Login.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System; -using System.Collections.Generic; -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.FireBase; -using DSALib.Models.Network; -using Microsoft.AspNetCore.SignalR; -using Group = DSACore.Models.Network.Group; - -namespace DSACore.Hubs -{ - public class Users : Hub - { - //private static Dictionary UserGroup = new Dictionary(); - - private const string ReceiveMethod = "ReceiveMessage"; //receiveMethod; - - 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(); - } - - private static List DsaGroups { get; } - public static List Tokens { get; } = new List(); - - - public async Task SendMessage(string user, string message) - { - try - { - var group = getGroup(Context.ConnectionId).Name; - } - catch (InvalidOperationException) - { - await Clients.Caller.SendCoreAsync(ReceiveMethod, - new object[] { "Nutzer ist in keiner Gruppe. Erst joinen!" }); - } - - if (message[0] == '/') - { - var args = message.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList(); - - var Timon = args.Any(x => x == "hallo"); - - var ident = args.First().Replace("/", ""); - if (args.Count > 0) args.RemoveAt(0); - - var ret = CommandHandler.ExecuteCommand(new Command - { - CharId = 0, - CmdIdentifier = ident, - CmdTexts = args, - Name = user - }); - - switch (ret.ResponseType) - { - case ResponseType.Caller: - case ResponseType.Error: - await Clients.Caller.SendAsync(ReceiveMethod, ret.message); - break; - case ResponseType.Broadcast: - await SendToGroup(ret.message); - break; - } - } - else - { - await SendToGroup(message); - } - } - - private Task SendToGroup(string message) - { - try - { - var group = getGroup(Context.ConnectionId).Name; - return Clients.Group(group).SendCoreAsync(ReceiveMethod, - new object[] {getUser(Context.ConnectionId).Name, message}); - } - catch (InvalidOperationException) - { - return Clients.Caller.SendCoreAsync(ReceiveMethod, - new object[] {"Nutzer ist in keiner Gruppe. Erst joinen!"}); - } - } - - private Group getGroup(string id) - { - return DsaGroups.First(x => x.Users.Exists(y => y.ConnectionId.Equals(id))); - } - - private User getUser(string id) - { - return DsaGroups.First(x => x.Users.Exists(y => y.ConnectionId.Equals(id))).Users - .First(z => z.ConnectionId.Equals(id)); - } - - public async Task GetGroups() { - var test = await Database.GetGroups(); - 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); - - await Clients.Caller.SendCoreAsync("ListGroups", new object[] {DsaGroups.Select(x => x.SendGroup())}); - //throw new NotImplementedException("add database call to get groups"); - } - - public async Task AddGroup(string group, string password) - { - DsaGroups.Add(new Group(group, password)); - var Dgroup = new DSALib.Models.Database.Groups.Group {Name = group, Id = DsaGroups.Count - 1}; - //Database.AddGroup(Dgroup); - await Clients.Caller.SendCoreAsync(ReceiveMethod, new[] {$"group {group} sucessfully added"}); - //throw new NotImplementedException("add database call to add groups"); - } - - public async Task UploadChar(string xml) - { - var group = getGroup(Context.ConnectionId); - - await Database.AddChar(new Character(new MemoryStream(Encoding.UTF8.GetBytes(xml))), group.Name); - //throw new NotImplementedException("add database call to add groups"); - } - - public async Task Login(string group, string user, string hash) - { - //string password = System.Text.Encoding.UTF8.GetString(hash); - if (hash == DsaGroups.First(x => x.Name == group).Password) - { - var gGroup = DsaGroups.First(x => x.Name.Equals(group)); - if (!gGroup.Users.Exists(x => x.Name.Equals(user))) - { - await Groups.RemoveFromGroupAsync(Context.ConnectionId, "login"); - await Groups.AddToGroupAsync(Context.ConnectionId, group); - gGroup.Users.Add(new User {ConnectionId = Context.ConnectionId, Name = user}); - await SendToGroup("Ein neuer Nutzer hat die Gruppe betreten"); - await Clients.Caller.SendAsync("LoginResponse", 0); - await Clients.Caller.SendAsync("PlayerStatusChanged", new[] {user, "online"}); - - Tokens.Add(new Token(group)); - await Clients.Caller.SendAsync("Token", Tokens.Last().GetHashCode()); - purgeTokens(); - } - else - { - await Clients.Caller.SendAsync("LoginResponse", 1); - } - } - else - { - await Clients.Caller.SendAsync("LoginResponse", 2); - //await Clients.Caller.SendAsync(receiveMethod, "Falsches Passwort!"); - } - } - - private void purgeTokens() - { - Tokens.RemoveAll(x => !x.IsValid()); - } - - public override Task OnDisconnectedAsync(Exception exception) - { - Disconnect().Wait(); - return base.OnDisconnectedAsync(exception); - } - - public override Task OnConnectedAsync() - { - Groups.AddToGroupAsync(Context.ConnectionId, "login").Wait(); - Groups.AddToGroupAsync(Context.ConnectionId, "online").Wait(); - return base.OnConnectedAsync(); - } - - public async Task Disconnect() - { - await Groups.RemoveFromGroupAsync(Context.ConnectionId, "online"); - if (DsaGroups.Exists(x => x.Users.Exists(y => y.ConnectionId == Context.ConnectionId))) - try - { - var group = getGroup(Context.ConnectionId); - - - var user = getUser(Context.ConnectionId); - - await Clients.Caller.SendAsync("PlayerStatusChanged", new[] {user.Name, "offline"}); - //await SendToGroup(user.Name + " disconnected from the Server"); - group.Users.Remove(user); - await Groups.RemoveFromGroupAsync(Context.ConnectionId, group.Name); - } - catch (Exception e) - { - Console.WriteLine(e); - //throw; - } - } - } -} \ No newline at end of file diff --git a/dsa/DSACore/Models/Network/Group.cs b/dsa/DSACore/Models/Network/Group.cs deleted file mode 100644 index efe12ee..0000000 --- a/dsa/DSACore/Models/Network/Group.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace DSACore.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 Users { get; set; } = new List(); - - 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/dsa/DSACore/Models/Network/Token.cs b/dsa/DSACore/Models/Network/Token.cs deleted file mode 100644 index 451cafc..0000000 --- a/dsa/DSACore/Models/Network/Token.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace DSACore.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/dsa/DSACore/Models/Network/User.cs b/dsa/DSACore/Models/Network/User.cs deleted file mode 100644 index 8b8008c..0000000 --- a/dsa/DSACore/Models/Network/User.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace DSACore.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/dsa/DSACore/Program.cs b/dsa/DSACore/Program.cs deleted file mode 100644 index 8af0a74..0000000 --- a/dsa/DSACore/Program.cs +++ /dev/null @@ -1,24 +0,0 @@ -using DSALib.DSA_Game; -using DSALib.FireBase; -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; - -namespace DSACore -{ - public class Program - { - public static void Main(string[] args) - { - Database.GetGroup(0).Wait(); - Dsa.Startup(); - CreateWebHostBuilder(args).Build().Run(); - } - - public static IWebHostBuilder CreateWebHostBuilder(string[] args) - { - return WebHost.CreateDefaultBuilder(args) - .UseStartup() - .UseUrls("http://0.0.0.0:5000"); - } - } -} \ No newline at end of file diff --git a/dsa/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json b/dsa/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json deleted file mode 100644 index b9941f2..0000000 --- a/dsa/DSACore/Properties/DSALib-Auxiliary-CommandInfo.json +++ /dev/null @@ -1,101 +0,0 @@ -[ - { - "Name": "ich bin", - "Scope": "All", - "Brief": "Setzt den gespielten Charakter fest", - "Description": [ - "Mit \"!Ich bin\" kann der gespielte Charakter definiert, bzw. gewechselt werden.\n", - " Die Charaktere müssen als *.xml Dateien hinterlegt sein.\n\n", - " !ich Zeigt an welcher Charakter zur Zeit gespielt wird\n", - " !ich bin Zalibius Wechsel zum Helden Zalibius\n", - " !ich Rhoktar Orkische Variante von !ich bin.\n", - " Wechselt zu Rhoktar.\n\n", - " !list chars Zeigt die Liste verfügbarer Charaktere.\n", - " \n" - ] - }, - { - "Name": "List", - "Scope": "All", - "Brief": "Anzeige vonSpielrelevanten Listen", - "Description": [ - "Mit \"!list\" lassen sich spielrelevante Listen ausgeben. Die Angezeigte Liste wird nach einiger Zeit wieder gelöscht.\n", - "\n", - " !list chars Liste aller verfügbaren Helden (eingelesen per *.xml)\n", - " und NSCs.\n", - " (Mit \"!ich bin\" kann der Held ausgewählt werden.)\n", - " !list commands Liste aller verwendbaren Bot-Kommandos.\n", - " !list sounds Liste der Soundeffekte." - ] - }, - { - "Name": "Held", - "Scope": "All", - "Brief": "Anzeige von Heldenwerten", - "Description": [ - "Mit \"!Held\" lassen sich Heldenwerte ausgeben. Mehrere Werte können gleichzeitig angefordert werde. \"!Held LE Waffen\" liefert so z.B. Informationen zur Lebensenergie und den Kampfwerten.\n Bis auf wenige Ausnahmen wird die Angezeigte Liste nach einiger Zeit wieder gelöscht.\n", - "\n", - " !Held Zeigt den Heldenbrief an.\n", - " (Diese Liste wird nicht automatisch gelöscht)\n", - " !Held Eigenschaften Zeigt die Eigenschaften MU/KL/CH/IN/KK/GE/FF/KO.\n", - " !Held e Kurzform von \"!Held Eigenschaften\".\n", - " !Held LE Zeigt LE an.\n", - " !Held AE Zeigt AE an.\n", - " !Held stats Zeigt Eigenschaften und zusätzlich SO/LE/AE.\n", - " !Held Kampfwerte Zeigt AT/PA für aktivierte Waffentalente.\n", - " !Held Waffe/!list w Kurzformen von \"!Held Kampfwerte\".\n", - " !Held Vorteile Zeigt Vor- und Nachteile an.\n", - " !Held v Kurzform von \"!Held Vorteile\".\n", - " !Held Talente Zeigt die Liste aller aktivierten Talente, deren TaW,\n", - " sowie die Probe.\n", - " !Held t Kurzform von \"!Held Talente\".\n", - " !Held Zauber Zeigt die Liste aller aktivierten Zauber, deren ZaW,\n", - " sowie die Probe.\n", - " !Held z Kurzform von \"!Held Zauber\".\n" - ] - }, - { - "Name": "LE", - "Scope": "All", - "Brief": "Ändert dein Leben - im wahrsten Sinne des Wortes", - "Description": [ - "Mit !LE zeigt man die Lebensenergie an, ändert sie, oder setzt sie auf einen neuen Wert\n\n", - " !LE Zeigt Lebensenergie an\n", - " !LE 30 Setzt LE auf 30\n", - " !LE +5 Erhöht LE um 5 (bis zum Maximum)\n", - " !LE ++5 Erhöht LE um 5 (ignoriert Maximum)\n", - " !LE -5 Verringert LE um 5\n \n" - ] - }, - { - "Name": "AE", - "Scope": "All", - "Brief": "Ändert Astralenergie", - "Description": [ - "Mit !AE (oder !Asp) zeigt man die Astralenergie an, ändert sie, oder setzt sie auf einen neuen Wert\n\n", - " !AE Zeigt Astralenergie an\n", - " !AE 30 Setzt Asp auf 30\n", - " !AE +5 Erhöht Asp um 5 (bis zum Maximum)\n", - " !AE ++5 Erhöht Asp um 5 (ignoriert Maximum)\n", - " !AE -5 Verringert Asp um 5 (Minimum 0)\n" - ] - }, - { - "Name": "Gm", - "Scope": "Meister", - "Brief": "Kontrolliere andere Charaktere", - "Description": [ - "Mit !GM fürhrt man commands als eine andere Person aus.", - " !GM [charaktername] [command] [commandattribut] [mofifier]", - " Unterstützte [commands]'s:", - " !GM [name] LE", - " !GM [name] AE", - " !GM [name] Talent", - " !GM [name] Fernkampf", - " !GM [name] Eigenschaft", - " !GM [name] Zauber", - " !GM [name] Angriff", - " !GM [name] Parade" - ] - } -] \ No newline at end of file diff --git a/dsa/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json b/dsa/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json deleted file mode 100644 index fd387f5..0000000 --- a/dsa/DSACore/Properties/DSALib-DSA_Game-Characters-Character.json +++ /dev/null @@ -1,290 +0,0 @@ -[ - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 30, - "Lebenspunkte_Aktuell": 30, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 20, - "Astralpunkte_Aktuell": 20, - "Name": "Felis Exodus Schattenwald" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 29, - "Lebenspunkte_Aktuell": 29, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 0, - "Astralpunkte_Aktuell": 0, - "Name": "Gardist" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 31, - "Lebenspunkte_Aktuell": 31, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 0, - "Astralpunkte_Aktuell": 0, - "Name": "Hartmut Reiher" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 21, - "Lebenspunkte_Aktuell": 21, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 35, - "Astralpunkte_Aktuell": 35, - "Name": "Helga vom Drachenei, Tausendsasserin" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 25, - "Lebenspunkte_Aktuell": 25, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 0, - "Astralpunkte_Aktuell": 0, - "Name": "Krenko" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 39, - "Lebenspunkte_Aktuell": 39, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 0, - "Astralpunkte_Aktuell": 0, - "Name": "Ledur Torfinson" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 26, - "Lebenspunkte_Aktuell": 26, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 13, - "Astralpunkte_Aktuell": 13, - "Name": "Morla" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 28, - "Lebenspunkte_Aktuell": 28, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 40, - "Astralpunkte_Aktuell": 40, - "Name": "Numeri Illuminus" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 39, - "Lebenspunkte_Aktuell": 39, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 16, - "Astralpunkte_Aktuell": 16, - "Name": "Potus" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 18, - "Lebenspunkte_Aktuell": 18, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 13, - "Astralpunkte_Aktuell": 13, - "Name": "Pump aus der Gosse" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 34, - "Lebenspunkte_Aktuell": 34, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 17, - "Astralpunkte_Aktuell": 17, - "Name": "Rhoktar4" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 28, - "Lebenspunkte_Aktuell": 28, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 43, - "Astralpunkte_Aktuell": 43, - "Name": "Volant" - } -] \ No newline at end of file diff --git a/dsa/DSACore/Properties/PublishProfiles/FolderProfile.pubxml b/dsa/DSACore/Properties/PublishProfiles/FolderProfile.pubxml deleted file mode 100644 index 2fd07c5..0000000 --- a/dsa/DSACore/Properties/PublishProfiles/FolderProfile.pubxml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - FileSystem - FileSystem - Release - Any CPU - - True - False - netcoreapp2.1 - 35a5e2cc-0fd4-4bc0-acbf-38599caed1c4 - false - <_IsPortable>true - bin\Release\netcoreapp2.1\publish\ - False - win-x64 - - \ No newline at end of file diff --git a/dsa/DSACore/Properties/PublishProfiles/FolderProfile1.pubxml b/dsa/DSACore/Properties/PublishProfiles/FolderProfile1.pubxml deleted file mode 100644 index e03b55a..0000000 --- a/dsa/DSACore/Properties/PublishProfiles/FolderProfile1.pubxml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - FileSystem - FileSystem - Release - Any CPU - - True - False - netcoreapp2.1 - linux-x64 - 35a5e2cc-0fd4-4bc0-acbf-38599caed1c4 - false - <_IsPortable>true - bin\Release\netcoreapp2.1\publish\ - False - - \ No newline at end of file diff --git a/dsa/DSACore/Properties/launchSettings.json b/dsa/DSACore/Properties/launchSettings.json deleted file mode 100644 index 2da5fec..0000000 --- a/dsa/DSACore/Properties/launchSettings.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:2170", - "sslPort": 44365 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "api/commands", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "DSACore": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "api/commands", - "applicationUrl": "https://0.0.0.0:5001;http://0.0.0.0:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} \ No newline at end of file diff --git a/dsa/DSACore/PropertiesDSALib-Auxiliary-CommandInfo.json b/dsa/DSACore/PropertiesDSALib-Auxiliary-CommandInfo.json deleted file mode 100644 index b9941f2..0000000 --- a/dsa/DSACore/PropertiesDSALib-Auxiliary-CommandInfo.json +++ /dev/null @@ -1,101 +0,0 @@ -[ - { - "Name": "ich bin", - "Scope": "All", - "Brief": "Setzt den gespielten Charakter fest", - "Description": [ - "Mit \"!Ich bin\" kann der gespielte Charakter definiert, bzw. gewechselt werden.\n", - " Die Charaktere müssen als *.xml Dateien hinterlegt sein.\n\n", - " !ich Zeigt an welcher Charakter zur Zeit gespielt wird\n", - " !ich bin Zalibius Wechsel zum Helden Zalibius\n", - " !ich Rhoktar Orkische Variante von !ich bin.\n", - " Wechselt zu Rhoktar.\n\n", - " !list chars Zeigt die Liste verfügbarer Charaktere.\n", - " \n" - ] - }, - { - "Name": "List", - "Scope": "All", - "Brief": "Anzeige vonSpielrelevanten Listen", - "Description": [ - "Mit \"!list\" lassen sich spielrelevante Listen ausgeben. Die Angezeigte Liste wird nach einiger Zeit wieder gelöscht.\n", - "\n", - " !list chars Liste aller verfügbaren Helden (eingelesen per *.xml)\n", - " und NSCs.\n", - " (Mit \"!ich bin\" kann der Held ausgewählt werden.)\n", - " !list commands Liste aller verwendbaren Bot-Kommandos.\n", - " !list sounds Liste der Soundeffekte." - ] - }, - { - "Name": "Held", - "Scope": "All", - "Brief": "Anzeige von Heldenwerten", - "Description": [ - "Mit \"!Held\" lassen sich Heldenwerte ausgeben. Mehrere Werte können gleichzeitig angefordert werde. \"!Held LE Waffen\" liefert so z.B. Informationen zur Lebensenergie und den Kampfwerten.\n Bis auf wenige Ausnahmen wird die Angezeigte Liste nach einiger Zeit wieder gelöscht.\n", - "\n", - " !Held Zeigt den Heldenbrief an.\n", - " (Diese Liste wird nicht automatisch gelöscht)\n", - " !Held Eigenschaften Zeigt die Eigenschaften MU/KL/CH/IN/KK/GE/FF/KO.\n", - " !Held e Kurzform von \"!Held Eigenschaften\".\n", - " !Held LE Zeigt LE an.\n", - " !Held AE Zeigt AE an.\n", - " !Held stats Zeigt Eigenschaften und zusätzlich SO/LE/AE.\n", - " !Held Kampfwerte Zeigt AT/PA für aktivierte Waffentalente.\n", - " !Held Waffe/!list w Kurzformen von \"!Held Kampfwerte\".\n", - " !Held Vorteile Zeigt Vor- und Nachteile an.\n", - " !Held v Kurzform von \"!Held Vorteile\".\n", - " !Held Talente Zeigt die Liste aller aktivierten Talente, deren TaW,\n", - " sowie die Probe.\n", - " !Held t Kurzform von \"!Held Talente\".\n", - " !Held Zauber Zeigt die Liste aller aktivierten Zauber, deren ZaW,\n", - " sowie die Probe.\n", - " !Held z Kurzform von \"!Held Zauber\".\n" - ] - }, - { - "Name": "LE", - "Scope": "All", - "Brief": "Ändert dein Leben - im wahrsten Sinne des Wortes", - "Description": [ - "Mit !LE zeigt man die Lebensenergie an, ändert sie, oder setzt sie auf einen neuen Wert\n\n", - " !LE Zeigt Lebensenergie an\n", - " !LE 30 Setzt LE auf 30\n", - " !LE +5 Erhöht LE um 5 (bis zum Maximum)\n", - " !LE ++5 Erhöht LE um 5 (ignoriert Maximum)\n", - " !LE -5 Verringert LE um 5\n \n" - ] - }, - { - "Name": "AE", - "Scope": "All", - "Brief": "Ändert Astralenergie", - "Description": [ - "Mit !AE (oder !Asp) zeigt man die Astralenergie an, ändert sie, oder setzt sie auf einen neuen Wert\n\n", - " !AE Zeigt Astralenergie an\n", - " !AE 30 Setzt Asp auf 30\n", - " !AE +5 Erhöht Asp um 5 (bis zum Maximum)\n", - " !AE ++5 Erhöht Asp um 5 (ignoriert Maximum)\n", - " !AE -5 Verringert Asp um 5 (Minimum 0)\n" - ] - }, - { - "Name": "Gm", - "Scope": "Meister", - "Brief": "Kontrolliere andere Charaktere", - "Description": [ - "Mit !GM fürhrt man commands als eine andere Person aus.", - " !GM [charaktername] [command] [commandattribut] [mofifier]", - " Unterstützte [commands]'s:", - " !GM [name] LE", - " !GM [name] AE", - " !GM [name] Talent", - " !GM [name] Fernkampf", - " !GM [name] Eigenschaft", - " !GM [name] Zauber", - " !GM [name] Angriff", - " !GM [name] Parade" - ] - } -] \ No newline at end of file diff --git a/dsa/DSACore/PropertiesDSALib-DSA_Game-Characters-Character.json b/dsa/DSACore/PropertiesDSALib-DSA_Game-Characters-Character.json deleted file mode 100644 index fd387f5..0000000 --- a/dsa/DSACore/PropertiesDSALib-DSA_Game-Characters-Character.json +++ /dev/null @@ -1,290 +0,0 @@ -[ - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 30, - "Lebenspunkte_Aktuell": 30, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 20, - "Astralpunkte_Aktuell": 20, - "Name": "Felis Exodus Schattenwald" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 29, - "Lebenspunkte_Aktuell": 29, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 0, - "Astralpunkte_Aktuell": 0, - "Name": "Gardist" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 31, - "Lebenspunkte_Aktuell": 31, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 0, - "Astralpunkte_Aktuell": 0, - "Name": "Hartmut Reiher" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 21, - "Lebenspunkte_Aktuell": 21, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 35, - "Astralpunkte_Aktuell": 35, - "Name": "Helga vom Drachenei, Tausendsasserin" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 25, - "Lebenspunkte_Aktuell": 25, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 0, - "Astralpunkte_Aktuell": 0, - "Name": "Krenko" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 39, - "Lebenspunkte_Aktuell": 39, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 0, - "Astralpunkte_Aktuell": 0, - "Name": "Ledur Torfinson" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 26, - "Lebenspunkte_Aktuell": 26, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 13, - "Astralpunkte_Aktuell": 13, - "Name": "Morla" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 28, - "Lebenspunkte_Aktuell": 28, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 40, - "Astralpunkte_Aktuell": 40, - "Name": "Numeri Illuminus" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 39, - "Lebenspunkte_Aktuell": 39, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 16, - "Astralpunkte_Aktuell": 16, - "Name": "Potus" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 18, - "Lebenspunkte_Aktuell": 18, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 13, - "Astralpunkte_Aktuell": 13, - "Name": "Pump aus der Gosse" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 34, - "Lebenspunkte_Aktuell": 34, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 17, - "Astralpunkte_Aktuell": 17, - "Name": "Rhoktar4" - }, - { - "Eigenschaften": {}, - "Talente": [], - "Zauber": [], - "Kampftalente": [], - "Vorteile": [], - "PropTable": { - "MU": "Mut", - "KL": "Klugheit", - "IN": "Intuition", - "CH": "Charisma", - "FF": "Fingerfertigkeit", - "GE": "Gewandtheit", - "KO": "Konstitution", - "KK": "Körperkraft" - }, - "Lebenspunkte_Basis": 28, - "Lebenspunkte_Aktuell": 28, - "Ausdauer_Basis": 0, - "Ausdauer_Aktuell": 0, - "Astralpunkte_Basis": 43, - "Astralpunkte_Aktuell": 43, - "Name": "Volant" - } -] \ No newline at end of file diff --git a/dsa/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json b/dsa/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json deleted file mode 100644 index 0ed0f48..0000000 --- a/dsa/DSACore/PropertiesNewtonsoft-Json-Linq-JProperty.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:2170", - "sslPort": 44365 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "api/commands", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "DSACore": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "api/commands", - "applicationUrl": "https://0.0.0.0:5001;http://0.0.0.0:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} \ No newline at end of file diff --git a/dsa/DSACore/Startup.cs b/dsa/DSACore/Startup.cs deleted file mode 100644 index ef22802..0000000 --- a/dsa/DSACore/Startup.cs +++ /dev/null @@ -1,47 +0,0 @@ -using DSACore.Hubs; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; - -namespace DSACore -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - - services.AddSignalR(); - } - - // 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()) - app.UseDeveloperExceptionPage(); - else - app.UseHsts(); - - app.UseCors("CorsPolicy"); - - app.UseSignalR(routes => { routes.MapHub("/login"); }); - - app.UseWebSockets(); - - //app.UseCors("AllowSpecificOrigin"); - app.UseHttpsRedirection(); - app.UseMvc(); - } - } -} \ No newline at end of file diff --git a/dsa/DSACore/Token b/dsa/DSACore/Token deleted file mode 100644 index eb02248..0000000 --- a/dsa/DSACore/Token +++ /dev/null @@ -1 +0,0 @@ -fBhKAyCEJlqqU1l6gS1LNWwEZByQ23oAWbvtXXB5 \ No newline at end of file diff --git a/dsa/DSACore/appsettings.Development.json b/dsa/DSACore/appsettings.Development.json deleted file mode 100644 index e203e94..0000000 --- a/dsa/DSACore/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - } -} diff --git a/dsa/DSACore/appsettings.json b/dsa/DSACore/appsettings.json deleted file mode 100644 index dee968c..0000000 --- a/dsa/DSACore/appsettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Microsoft.AspNetCore.SignalR": "Debug", - "Microsoft.AspNetCore.Http.Connections": "Debug", - "Default": "Debug" - } - }, - "AllowedHosts": "*" -} diff --git a/dsa/DiscoBot.sln b/dsa/DiscoBot.sln new file mode 100644 index 0000000..a6b258a --- /dev/null +++ b/dsa/DiscoBot.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.452 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DSACore", "..\DSACore\DSACore.csproj", "{35A5E2CC-0FD4-4BC0-ACBF-38599CAED1C4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FireBase", "FireBase\FireBase.csproj", "{87CC30E6-CBEA-4282-A3CC-FD5119A1993B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DSALib", "DSALib\DSALib.csproj", "{C5D9AFDF-70E2-4A47-96FF-1EC47C1DE38D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnitTest", "NUnitTestProject1\NUnitTest.csproj", "{CF821E64-B50E-420F-98A2-07315B362ED0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {35A5E2CC-0FD4-4BC0-ACBF-38599CAED1C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35A5E2CC-0FD4-4BC0-ACBF-38599CAED1C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35A5E2CC-0FD4-4BC0-ACBF-38599CAED1C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35A5E2CC-0FD4-4BC0-ACBF-38599CAED1C4}.Release|Any CPU.Build.0 = Release|Any CPU + {87CC30E6-CBEA-4282-A3CC-FD5119A1993B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87CC30E6-CBEA-4282-A3CC-FD5119A1993B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87CC30E6-CBEA-4282-A3CC-FD5119A1993B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87CC30E6-CBEA-4282-A3CC-FD5119A1993B}.Release|Any CPU.Build.0 = Release|Any CPU + {C5D9AFDF-70E2-4A47-96FF-1EC47C1DE38D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5D9AFDF-70E2-4A47-96FF-1EC47C1DE38D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5D9AFDF-70E2-4A47-96FF-1EC47C1DE38D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5D9AFDF-70E2-4A47-96FF-1EC47C1DE38D}.Release|Any CPU.Build.0 = Release|Any CPU + {CF821E64-B50E-420F-98A2-07315B362ED0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF821E64-B50E-420F-98A2-07315B362ED0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF821E64-B50E-420F-98A2-07315B362ED0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF821E64-B50E-420F-98A2-07315B362ED0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CADA01A3-B80B-4979-8397-7CB5B825CE34} + EndGlobalSection +EndGlobal diff --git a/firebase.json b/firebase.json deleted file mode 100644 index bc9ddf4..0000000 --- a/firebase.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "database": { - "rules": "database.rules.json" - }, - "firestore": { - "rules": "firestore.rules", - "indexes": "firestore.indexes.json" - }, - "hosting": { - "public": "Webinterface/NodeJSServer/dist", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ] - }, - "storage": { - "rules": "storage.rules" - } -} diff --git a/firestore.indexes.json b/firestore.indexes.json deleted file mode 100644 index b19e92b..0000000 --- a/firestore.indexes.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "indexes": [] -} \ No newline at end of file diff --git a/firestore.rules b/firestore.rules deleted file mode 100644 index b76ec00..0000000 --- a/firestore.rules +++ /dev/null @@ -1,7 +0,0 @@ -service cloud.firestore { - match /databases/{database}/documents { - match /{document=**} { - allow read, write; - } - } -} \ No newline at end of file diff --git a/storage.rules b/storage.rules deleted file mode 100644 index d494542..0000000 --- a/storage.rules +++ /dev/null @@ -1,7 +0,0 @@ -service firebase.storage { - match /b/{bucket}/o { - match /{allPaths=**} { - allow read, write: if request.auth!=null; - } - } -} -- cgit v1.2.3-54-g00ecf