summaryrefslogtreecommitdiff
path: root/DSACore
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-09-26 23:49:26 +0200
committerTrueDoctor <d-kobert@web.de>2018-09-26 23:49:26 +0200
commit19bf37de7642ae8cdefd8fc6b4fadac3ac96ea9b (patch)
tree08e7a9b15d806777fa1b839e897a171823649ab1 /DSACore
parentb411aa2128c2724bec0ecedb8cb4e1ffa59f3b53 (diff)
ported most code to WebApiProject
everything except the user identification and file locations should be somewhat functional
Diffstat (limited to 'DSACore')
-rw-r--r--DSACore/Auxiliary/Calculator/Argument.cs2
-rw-r--r--DSACore/Auxiliary/Calculator/ISolvable.cs2
-rw-r--r--DSACore/Auxiliary/Calculator/Operator.cs4
-rw-r--r--DSACore/Auxiliary/Calculator/Ops.cs2
-rw-r--r--DSACore/Auxiliary/Calculator/StringSolver.cs7
-rw-r--r--DSACore/Auxiliary/TalentEnumerableExtension.cs4
-rw-r--r--DSACore/Commands/CommandHandler.cs121
-rw-r--r--DSACore/Commands/CommandTypes.cs13
-rw-r--r--DSACore/Commands/FileHandler.cs39
-rw-r--r--DSACore/Commands/Gm.cs183
-rw-r--r--DSACore/Commands/HeldList.cs170
-rw-r--r--DSACore/Commands/Help.cs76
-rw-r--r--DSACore/Commands/LebenUndAstral.cs168
-rw-r--r--DSACore/Commands/List.cs47
-rw-r--r--DSACore/Commands/MiscCommands.cs230
-rw-r--r--DSACore/Commands/NpcCommands.cs46
-rw-r--r--DSACore/Commands/ProbenTest.cs85
-rw-r--r--DSACore/DSA_Game/Characters/Character.cs2
-rw-r--r--DSACore/DSA_Game/Characters/NPC.cs9
-rw-r--r--DSACore/DSA_Game/Characters/SaveChar.cs11
-rw-r--r--DSACore/DSA_Game/Dsa.cs22
-rw-r--r--DSACore/DSA_Game/Save/Properties.cs65
-rw-r--r--DSACore/DSA_Game/Save/SaveCommand.cs4
-rw-r--r--DSACore/DSA_Game/Save/Session.cs4
-rw-r--r--DSACore/Models/Command.cs8
25 files changed, 1266 insertions, 58 deletions
diff --git a/DSACore/Auxiliary/Calculator/Argument.cs b/DSACore/Auxiliary/Calculator/Argument.cs
index 2379bfe..52f33a9 100644
--- a/DSACore/Auxiliary/Calculator/Argument.cs
+++ b/DSACore/Auxiliary/Calculator/Argument.cs
@@ -1,4 +1,4 @@
-namespace DiscoBot.Auxiliary.Calculator
+namespace DSACore.Auxiliary.Calculator
{
using System;
diff --git a/DSACore/Auxiliary/Calculator/ISolvable.cs b/DSACore/Auxiliary/Calculator/ISolvable.cs
index a869bdb..1f571d0 100644
--- a/DSACore/Auxiliary/Calculator/ISolvable.cs
+++ b/DSACore/Auxiliary/Calculator/ISolvable.cs
@@ -1,4 +1,4 @@
-namespace DiscoBot.Auxiliary.Calculator
+namespace DSACore.Auxiliary.Calculator
{
/// <summary>
/// Object has to be able to return an integer as it's value
diff --git a/DSACore/Auxiliary/Calculator/Operator.cs b/DSACore/Auxiliary/Calculator/Operator.cs
index 703f060..440e21e 100644
--- a/DSACore/Auxiliary/Calculator/Operator.cs
+++ b/DSACore/Auxiliary/Calculator/Operator.cs
@@ -1,7 +1,7 @@
using System;
-using DSACore.Auxiliary;
+using DSACorev.Auxiliary.Calculator;
-namespace DiscoBot.Auxiliary.Calculator
+namespace DSACore.Auxiliary.Calculator
{
/// <summary>
/// The Operator Class represents a binary operator with tow Arguments and an Operation type
diff --git a/DSACore/Auxiliary/Calculator/Ops.cs b/DSACore/Auxiliary/Calculator/Ops.cs
index 62c1309..702558d 100644
--- a/DSACore/Auxiliary/Calculator/Ops.cs
+++ b/DSACore/Auxiliary/Calculator/Ops.cs
@@ -1,4 +1,4 @@
-namespace DiscoBot.Auxiliary.Calculator
+namespace DSACorev.Auxiliary.Calculator
{
/// <summary>
/// The Different Operations, witch can be performed in execution-order
diff --git a/DSACore/Auxiliary/Calculator/StringSolver.cs b/DSACore/Auxiliary/Calculator/StringSolver.cs
index 30c2134..2eff5b4 100644
--- a/DSACore/Auxiliary/Calculator/StringSolver.cs
+++ b/DSACore/Auxiliary/Calculator/StringSolver.cs
@@ -1,4 +1,9 @@
-namespace DiscoBot.Auxiliary.Calculator
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using DSACorev.Auxiliary.Calculator;
+
+namespace DSACore.Auxiliary.Calculator
{
using System;
using System.Collections.Generic;
diff --git a/DSACore/Auxiliary/TalentEnumerableExtension.cs b/DSACore/Auxiliary/TalentEnumerableExtension.cs
index d8af015..a4ace2f 100644
--- a/DSACore/Auxiliary/TalentEnumerableExtension.cs
+++ b/DSACore/Auxiliary/TalentEnumerableExtension.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
+using DSACore.DSA_Game.Characters;
+using System.Collections.Generic;
using System.Linq;
using System.Text;
-using DiscoBot.DSA_Game.Characters;
using DSALib;
namespace DSACore.Auxiliary
diff --git a/DSACore/Commands/CommandHandler.cs b/DSACore/Commands/CommandHandler.cs
new file mode 100644
index 0000000..0eb59e6
--- /dev/null
+++ b/DSACore/Commands/CommandHandler.cs
@@ -0,0 +1,121 @@
+using System;
+using DSACore.Auxiliary;
+using DSACore.DSA_Game;
+using DSACore.Models;
+
+namespace DSACore.Commands
+{
+ public class CommandHandler
+ {
+ public static string ExecuteCommand(Command cmd)
+ {
+ switch (cmd.CmdIdentifier.ToLower())
+ {
+ case "addChar":
+ return FileHandler.AddChar(cmd.CharId, cmd.CmdText);
+ case "held":
+ case "wert":
+ case "werte":
+ case "char":
+ return Commands.HeldList.ListAsync(cmd.CharId, cmd.CmdText);
+ case "help":
+ case "man":
+ case "hilfe":
+ case "h":
+ return Help.ShowHelp(cmd.CmdText);
+ case "le":
+ case "leben":
+ case "lp":
+ return LE.LEAsync(cmd.CharId, cmd.CmdText);
+ case "ae":
+ case "astral":
+ case "asp":
+ return AE.AEAsync(cmd.CharId, cmd.CmdText);
+ case "list":
+ return List.ListAsync(cmd.CmdText);
+ case "r":
+ case "roll":
+ return RandomMisc.Roll(cmd.CmdText + " " + cmd.Cmdmodifier);
+ case "solve":
+ return new Auxiliary.Calculator.StringSolver(cmd.CmdText + cmd.Cmdmodifier).Solve().ToString();
+ case "npc":
+ return NpcCommands.CreateNpc(cmd.CharId, cmd.CmdTexts, cmd.Cmdmodifier);
+
+ }
+
+ return Proben(cmd.Name, cmd.CmdIdentifier, cmd.CmdText, cmd.Cmdmodifier);
+ }
+
+ private static string Proben(string name, string command, string waffe, int erschwernis = 0)
+ {
+ string res;
+ switch (command.ToLower())
+ {
+ case "f":
+ case "fern":
+ case "fernkampf":
+ res = CheckCommand(name, CommandTypes.Fernkampf, waffe, erschwernis);
+ break;
+ case "t":
+ case "ta":
+ case "talent":
+ case "talente":
+ res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis);
+ break;
+ case "e":
+ case "ei":
+ case "eigenschaft":
+ res = CheckCommand(name, CommandTypes.Eigenschaft, waffe, erschwernis);
+ break;
+ case "z":
+ case "za":
+ case "zauber":
+ case "magie":
+ case "m":
+ res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis);
+ break;
+ case "a":
+ case "at":
+ case "an":
+ case "angrif":
+ case "angriff":
+ res = CheckCommand(name, CommandTypes.Angriff, waffe, erschwernis);
+ break;
+ case "p":
+ case "pa":
+ case "parade":
+ res = CheckCommand(name, CommandTypes.Parade, waffe, erschwernis);
+ break;
+ default:
+ res = $"Kommando {command} nicht gefunden";
+ break;
+ }
+
+ return res;
+ }
+
+ public static string CheckCommand(string name, CommandTypes command, string waffe, int erschwernis = 0)
+ {
+ var chr = Dsa.GetCharacter(0);
+ throw new NotImplementedException("access char by id ore name and group id");
+
+ switch (command)
+ {
+ case CommandTypes.Talent:
+ return chr.TestTalent(waffe, erschwernis);
+ case CommandTypes.Eigenschaft:
+ return chr.TestEigenschaft(waffe, erschwernis);
+ case CommandTypes.Angriff:
+ return chr.Angriff(waffe, erschwernis);
+ case CommandTypes.Parade:
+ return chr.Parade(waffe, erschwernis);
+ case CommandTypes.Fernkampf:
+ return chr.Fernkampf(waffe, erschwernis);
+ case CommandTypes.Zauber:
+ return chr.TestZauber(waffe, erschwernis);
+ }
+
+ return $"{name} verwendet {waffe}";
+ }
+ }
+}
diff --git a/DSACore/Commands/CommandTypes.cs b/DSACore/Commands/CommandTypes.cs
new file mode 100644
index 0000000..d53328b
--- /dev/null
+++ b/DSACore/Commands/CommandTypes.cs
@@ -0,0 +1,13 @@
+namespace DSACore.Commands
+{
+ public enum CommandTypes
+ {
+ Talent,
+ Eigenschaft,
+ Angriff,
+ Parade,
+ Fernkampf,
+ KeinChar,
+ Zauber
+ }
+}
diff --git a/DSACore/Commands/FileHandler.cs b/DSACore/Commands/FileHandler.cs
new file mode 100644
index 0000000..af4698a
--- /dev/null
+++ b/DSACore/Commands/FileHandler.cs
@@ -0,0 +1,39 @@
+using DSACore.DSA_Game;
+using DSACore.DSA_Game.Characters;
+
+namespace DSACore.Commands
+{
+ using System;
+ using System.Linq;
+ using System.Net;
+
+ using DSALib;
+
+ public class FileHandler
+ {
+ public static string AddChar(ulong id, string url)
+ {
+ if (url == string.Empty)
+ {
+ throw new ArgumentException("Es wurde keine Datei angehängt");
+ }
+
+
+ if (!url.EndsWith(".xml"))
+ {
+ throw new ArgumentException("Es wurde kein xml Held mitgeschickt");
+ }
+
+ using (var client = new WebClient())
+ {
+ client.DownloadFile(url, "helden\\" + url.Split("/").Last());
+ }
+
+ Dsa.Chars.Add(new Character("helden\\" + url.Split("/").Last()));
+ (Dsa.Chars.Last() as Character)?.Talente.Select(x => new Talent(x.Name, x.Probe, 0))
+ .Where(c => !Dsa.Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Dsa.Talente.Add(v));
+
+ return $"{url.Split("/").Last()} wurde erfolgreich gespeichert";
+ }
+ }
+} \ No newline at end of file
diff --git a/DSACore/Commands/Gm.cs b/DSACore/Commands/Gm.cs
new file mode 100644
index 0000000..a320269
--- /dev/null
+++ b/DSACore/Commands/Gm.cs
@@ -0,0 +1,183 @@
+using DSACore.Auxiliary;
+using DSACore.DSA_Game;
+
+namespace DSACore.Commands
+{
+ using System.Linq;
+ using System.Threading.Tasks;
+ using DSALib.Characters;
+
+ /*public class Iam
+ {
+
+ [Command("Iam"), Summary("Wechselt den Character")]
+ [Alias("iam", "I_am", "i_am", "IchBin", "ichbin", "Ichbin", "Ich_bin", "ich_bin", "Ich", "ich", "I", "i")]
+ public Task Change_Character(params string[] givenName) // use fancy parameters
+ {
+ string res;
+ string name;
+
+ if (givenName.Length == 0 || (givenName.Length == 1 && (givenName[0].ToLower().Equals("bin") || givenName[0].ToLower().Equals("am"))))
+ {
+ res = " \nDu bist " + Dsa.Session.Relation[this.Context.User.Username] + "!\n \n";
+
+ return this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ if (givenName.Length > 1 && (givenName[0].ToLower().Equals("bin") || givenName[0].ToLower().Equals("am")) )
+ {
+ name = givenName.Skip(1).Aggregate((s, c) => s + c); // (Skip(1)) don't use the first element; Aggregate: take source s and do operation s = s+c for all elements
+ }
+ else
+ {
+ name = givenName.Aggregate((s, c) => s + c);
+ }
+
+ if (name.ToLower().Equals("man") || name.ToLower().Equals("help"))
+ {
+ return this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("ich bin") + "\n```");
+
+ }
+
+ var character = Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(name, x.Name)).First(); // usage of compareEasy
+
+ Dsa.Session.Relation[this.Context.User.Username] = character.Name;
+ res = " \nWillkommen " + character.Name + "!\n \n";
+
+
+ return this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+ }
+
+
+ public class Gm : ModuleBase
+ {
+ public static string CheckCommand(string name, CommandTypes command, string waffe, int erschwernis = 0)
+ {
+ var comp = new SpellCorrect();
+ var chr = Dsa.Chars.OrderBy(x => comp.Compare(name, x.Name)).First();
+
+ switch (command)
+ {
+ case CommandTypes.Talent:
+ return chr.TestTalent(waffe, erschwernis);
+ case CommandTypes.Eigenschaft:
+ return chr.TestEigenschaft(waffe, erschwernis);
+ case CommandTypes.Angriff:
+ return chr.Angriff(waffe, erschwernis);
+ case CommandTypes.Parade:
+ return chr.Parade(waffe, erschwernis);
+ case CommandTypes.Fernkampf:
+ return chr.Fernkampf(waffe, erschwernis);
+ case CommandTypes.Zauber:
+ return chr.TestZauber(waffe, erschwernis);
+ }
+
+ return $"{name} verwendet {waffe}";
+ }
+
+ [Command("gm"), Summary("Führt eine probe aus")]
+ [Alias("GM", "as", "As", "als")]
+ public async Task ProbeAsync([Summary("Fernkampfwaffe")] string name, string command, string cmdText = "", int modifier = 0)
+ {
+ if (!Permissions.Test(this.Context, "Meister")) return;
+
+ command = command.ToLower();
+
+ string res;
+ string temp = string.Empty;
+ ICharacter cha = Dsa.Chars.OrderBy(x =>
+ SpellCorrect.CompareEasy(name, x.Name)).First();
+ switch (command)
+ {
+ case "le":
+ case "leben":
+ case "lp":
+ LE le = new LE();
+ temp = string.Empty;
+
+ if (modifier != 0)
+ {
+ temp = modifier.ToString();
+ }
+
+ res = cha.get_LE_Text(cmdText.Trim() + temp);
+
+ break;
+ case "ae":
+ case "asp":
+ case "astral":
+ AE ae = new AE();
+ temp = string.Empty;
+
+ if (modifier != 0)
+ {
+ temp = modifier.ToString();
+ }
+
+ res = cha.get_AE_Text(cmdText.Trim() + temp);
+
+ break;
+ default:
+ res = this.Test(name, command, cmdText, modifier);
+ break;
+ }
+
+
+ if (Dsa.GeneralContext != null && Dsa.GeneralContext.Channel.Id != this.Context.Channel.Id)
+ {
+ await Dsa.GeneralContext.Channel.SendMessageAsync("```xl\n" + res + "\n```");
+ }
+
+ await this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ private string Test(string name, string command, string waffe, int erschwernis = 0)
+ {
+ string res;
+ switch (command.ToLower())
+ {
+ case "f":
+ case "fern":
+ case "fernkampf":
+ res = CheckCommand(name, CommandTypes.Fernkampf, waffe, erschwernis);
+ break;
+ case "t":
+ case "ta":
+ case "talent":
+ case "talente":
+ res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis);
+ break;
+ case "e":
+ case "ei":
+ case "eigenschaft":
+ res = CheckCommand(name, CommandTypes.Eigenschaft, waffe, erschwernis);
+ break;
+ case "z":
+ case "za":
+ case "zauber":
+ case "magie":
+ case "m":
+ res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis);
+ break;
+ case "a":
+ case "at":
+ case "an":
+ case "angrif":
+ case "angriff":
+ res = CheckCommand(name, CommandTypes.Angriff, waffe, erschwernis);
+ break;
+ case "p":
+ case "pa":
+ case "parade":
+ res = CheckCommand(name, CommandTypes.Parade, waffe, erschwernis);
+ break;
+ default:
+ res = $"Kommando {command} nicht gefunden";
+ break;
+ }
+
+ return res;
+ }
+ }*/
+}
diff --git a/DSACore/Commands/HeldList.cs b/DSACore/Commands/HeldList.cs
new file mode 100644
index 0000000..825474c
--- /dev/null
+++ b/DSACore/Commands/HeldList.cs
@@ -0,0 +1,170 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using DSACore.DSA_Game.Characters;
+using DSACore.Auxiliary;
+using DSACore.DSA_Game;
+
+namespace DSACore.Commands
+{
+ public class HeldList
+ {
+ public static string ListAsync(ulong id, params string[] prop_list)
+ {
+ var res = new List<string>();
+
+ var character = Dsa.GetCharacter(id) as Character;
+
+ int first_column_width = 18;
+
+
+ if (prop_list.Length == 0 || prop_list[0].ToLower().StartsWith("all") || prop_list[0].ToLower().StartsWith("brief") || prop_list[0].ToLower().StartsWith("zettel"))
+ {
+
+ res.Add(character.Name + ":\n");
+ //Eigenschaften
+ res.AddRange(
+ character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
+ res.Add("");
+ //LE/AE
+ res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
+ if (character.Astralpunkte_Basis > 0)
+ {
+ res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
+ }
+ res.Add("");
+ //Kampfwerte
+ res.Add("".AddSpaces(first_column_width) + " AT/PA");
+ res.AddRange(
+ character.Kampftalente.Select(s => s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" + s.Pa.ToString().AddSpacesAtHead(2)));
+ res.Add("");
+ //Fernkampf
+ res.Add("".AddSpaces(first_column_width) + " FK");
+ res.AddRange(
+ character.Talente.Where(x => x.IstFernkampftalent()).Select(s => s.Name.AddSpaces(first_column_width) + " " + (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
+ res.Add("");
+ //Vorteile
+ res.AddRange(
+ character.Vorteile
+ .Select(s => s.Name + "\t " + s.Value));
+ res.Add("");
+ //Talente
+ res.AddRange(
+ character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
+ res.Add("");
+ //evtl Zauber
+ if (character.Zauber.Count > 0)
+ {
+ res.AddRange(
+ character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
+ }
+
+ }
+ else if (prop_list[0].ToLower().StartsWith("man") || prop_list[0].ToLower().StartsWith("help") || prop_list[0].ToLower().StartsWith("hilf"))
+ {
+ return "```xl\n" + Help.Get_Specific_Help("Held") + "\n```";
+ }
+ else
+ {
+
+ res.Add(character.Name + ":\n");
+
+ foreach (string prop in prop_list)
+ {
+
+ switch (prop.ToLower())
+ {
+ case "e":
+ case "eig":
+ case "eigenschaft":
+ case "eigenschaften":
+ res.AddRange(
+ character.Eigenschaften.Take(8).Select(s => s.Key + ":\t " + s.Value));
+ break;
+ case "stat":
+ case "stats":
+ res.AddRange(
+ character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
+ res.Add("");
+ res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
+ if (character.Astralpunkte_Basis > 0)
+ {
+ res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
+ }
+ break;
+ case "le":
+ res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
+ break;
+ case "ae":
+ res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
+ break;
+ case "t":
+ case "ta":
+ case "talent":
+ case "talente":
+ res.AddRange(
+ character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
+ break;
+ case "zauber":
+ case "z":
+ res.AddRange(
+ character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
+ break;
+ case "w":
+ case "waffe":
+ case "waffen":
+ case "kampf":
+ case "kampfwert":
+ case "kampfwerte":
+ res.Add("".AddSpaces(first_column_width) + " AT/PA");
+ res.AddRange(
+ character.Kampftalente.Select(s => s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" + s.Pa.ToString().AddSpacesAtHead(2)));
+ break;
+ case "f":
+ case "fern":
+ res.Add("".AddSpaces(first_column_width) + " FK");
+ res.AddRange(
+ character.Talente.Where(x => x.IstFernkampftalent()).Select(s => s.Name.AddSpaces(first_column_width) + " " + (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
+ break;
+ case "v":
+ case "vt":
+ case "vor":
+ case "vorteil":
+ case "vorteile":
+ case "nachteil":
+ case "nachteile":
+ res.AddRange(
+ character.Vorteile
+ .Select(s => s.Name + "\t " + s.Value));
+ break;
+
+ default:
+ res.Add($"Kommando {prop} nicht gefunden");
+ break;
+ }
+
+ res.Add("");
+ }
+
+ }
+
+
+ var sb = new StringBuilder();
+ foreach (string re in res)
+ {
+ sb.AppendLine(re);
+ }
+
+ return sb.ToString();
+ /*
+ if (persist == 1)
+ {
+ await this.ReplyAsync(res, true);
+ }
+ else
+ {
+ await this.ReplyAsync(res, TimeSpan.FromSeconds(90));
+ }*/
+ }
+ }
+}
diff --git a/DSACore/Commands/Help.cs b/DSACore/Commands/Help.cs
new file mode 100644
index 0000000..1575b36
--- /dev/null
+++ b/DSACore/Commands/Help.cs
@@ -0,0 +1,76 @@
+using System.Linq;
+using System.Threading.Tasks;
+using DSACore.Auxiliary;
+
+namespace DSACore.Commands
+{
+ public class Help
+ {
+ static Help()
+ {
+ /*TextReader stream = new StreamReader(@"..\..\Help.json"); // Load command-description file
+ var reader = new JsonTextReader(stream); // create stream reader
+
+ reader.Read(); // step into structure, until the array starts
+ reader.Read();
+ reader.Read();
+
+ try
+ {
+ var test = new JsonSerializer().Deserialize<List<CommandInfo>>(reader); // Deserialize Data and create CommandInfo Struct
+
+ Commands.AddRange(test); // Add new CommandInfos to List
+ }
+ catch (Exception e)
+ {
+ // ignored
+ }*/
+ }
+
+ //public static List<CommandInfo> Commands { get; } = new List<CommandInfo>();
+
+
+ public static string Get_Specific_Help(string command)
+ {
+ // return command specific help
+ var com = DSACore.DSA_Game.Save.Properties.CommandInfos.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
+ return com.GetDescription();
+ }
+
+ public static string Get_Generic_Help()
+ {
+ string res = "";
+ foreach (var com in DSACore.DSA_Game.Save.Properties.CommandInfos)
+ {
+ int first_column_width = 8;
+ res += ("!" + com.Name + ": ").AddSpaces(first_column_width) + com.Brief;
+
+ if (com.Description.Length > 1)
+ {
+ res += "\n" + "".AddSpaces(first_column_width) + "(\"!man " + com.Name + "\" gibt genauere Informationen)";
+ }
+
+ res += "\n\n";
+ }
+ return res;
+ }
+
+ public static string ShowHelp(params string[] commandList)
+ {
+ var command = "";
+ if (commandList.Length > 0) {
+ command = commandList.Aggregate((s, c) => s + " " + c);
+ }
+
+ if (command.Equals(string.Empty)) // return generic Help
+ {
+ string res = Get_Generic_Help();
+
+ return res;
+ }
+
+
+ return Get_Specific_Help(command);
+ }
+ }
+}
diff --git a/DSACore/Commands/LebenUndAstral.cs b/DSACore/Commands/LebenUndAstral.cs
new file mode 100644
index 0000000..b5bc260
--- /dev/null
+++ b/DSACore/Commands/LebenUndAstral.cs
@@ -0,0 +1,168 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using DSACore.DSA_Game;
+using DSACore.Auxiliary;
+using DSALib.Characters;
+
+namespace DSACore.Commands
+{
+ public class LE
+ {
+ public static string LEAsync(ulong id, string modifier)
+ {
+ //This is the string that will be printed
+ string res = "";
+
+
+ //Get the actual text
+ res += Dsa.GetCharacter(id).get_LE_Text(modifier);
+
+
+ return res;
+ }
+ }
+
+ public class AE
+ {
+ public static string AEAsync(ulong id, string modifier)
+ {
+ //This is the string that will be printed
+ string res = "";
+
+
+ //Get the actual text
+ res += Dsa.GetCharacter(id).get_AE_Text(modifier);
+
+ return res;
+ }
+ }
+
+ public static class StatExtension
+ {
+ public static string get_LE_Text(this ICharacter c, string prop)
+ {
+ string res = "";
+ var comp = new SpellCorrect();
+ var character = c;
+
+ res += (character.Name + ":\n");
+
+ //If there is actual input we process it
+ if (prop.Length > 0)
+ {
+ res += "LE: ";
+ res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis + " -> ";
+
+ // Apply a change to current value
+ if (prop.StartsWith("+") || prop.StartsWith("-"))
+ {
+ //Allow overflowing the max
+ if (prop.StartsWith("++"))
+ {
+ character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop.Substring(1, prop.Length - 1));
+ }
+ else
+ {
+ int temp = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop) - character.Lebenspunkte_Basis;
+ //Stop from overflow overflow
+ if (temp > 0 && prop.StartsWith("+"))
+ {
+ character.Lebenspunkte_Aktuell = (character.Lebenspunkte_Basis > character.Lebenspunkte_Aktuell) ? character.Lebenspunkte_Basis : character.Lebenspunkte_Aktuell;
+ res += " Maximale Lebenspunkte sind erreicht ";
+ }
+ //Simply apply change
+ else
+ {
+ character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop);
+ }
+ }
+
+ res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
+ }
+ else
+ {
+ // Set to new value regardless of original
+ character.Lebenspunkte_Aktuell = Convert.ToInt32(prop);
+
+ res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
+ }
+ }
+ //If no value is passed, the curent value is displayed
+ else
+ {
+ res += ("LE: " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
+ }
+
+ return res;
+ }
+ public static string get_AE_Text(this ICharacter c, string prop)
+ {
+ string res = "";
+ var comp = new SpellCorrect();
+ var character = c;
+
+ res += (character.Name + ":\n");
+
+ //If there is actual input we process it
+ if (prop.Length > 0)
+ {
+
+ res += "AE: ";
+ res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis + " -> ";
+
+ // Apply a change to current value
+ if (prop.StartsWith("+") || prop.StartsWith("-"))
+ {
+ //Allow overflowing the max
+ if (prop.StartsWith("++"))
+ {
+ character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell + Convert.ToInt32(prop.Substring(1, prop.Length - 1));
+ }
+ else
+ {
+ int temp = character.Astralpunkte_Aktuell + Convert.ToInt32(prop) - character.Astralpunkte_Basis;
+ //Stop from overflow overflow
+ if (temp > 0 && prop.StartsWith("+"))
+ {
+ character.Astralpunkte_Aktuell = (character.Astralpunkte_Basis > character.Astralpunkte_Aktuell) ? character.Astralpunkte_Basis : character.Astralpunkte_Aktuell;
+ res += " Maximale Astralpunkte sind erreicht ";
+ }
+ //Simply apply change
+ else
+ {
+ character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell + Convert.ToInt32(prop);
+ }
+ }
+
+ if (character.Astralpunkte_Aktuell < 0)
+ {
+ res += "Nicht genügend Astralpunkte! ";
+ character.Astralpunkte_Aktuell = 0;
+ }
+
+ res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
+
+ }
+ //Set to new value regardless of original
+ else
+ {
+ character.Astralpunkte_Aktuell = Convert.ToInt32(prop);
+
+ res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
+ }
+ }
+ //If no value is passed, the curent value is displayed
+ else
+ {
+ res += ("AE: " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
+ }
+
+
+ return res;
+ }
+ }
+}
+
+
+
diff --git a/DSACore/Commands/List.cs b/DSACore/Commands/List.cs
new file mode 100644
index 0000000..1fa0dde
--- /dev/null
+++ b/DSACore/Commands/List.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using DSACore.DSA_Game;
+using DSACore.Audio;
+
+namespace DSACore.Commands
+{
+ public class List
+ {
+ public static string ListAsync(string prop)
+ {
+ var res = new List<string>();
+
+ //int persist = 0;
+
+ switch (prop.ToLower())
+ {
+ case "man":
+ case "help":
+ return Help.Get_Specific_Help("List");
+ // break;
+ case "chars":
+ res.AddRange(Dsa.Chars.Select(x => x.Name));
+ break;
+ case "commands":
+ // res.AddRange(Help.Commands.Select(x => x.Name));
+ res.Add(Help.Get_Generic_Help());
+ break;
+ case "play":
+ case "sound":
+ case "sounds":
+ res.AddRange(
+ Enum.GetNames(typeof(Sound)));
+ break;
+
+ default:
+ res.Add($"Kommando {prop} nicht gefunden");
+ break;
+ }
+
+
+ return res.ToString();
+ }
+ }
+}
diff --git a/DSACore/Commands/MiscCommands.cs b/DSACore/Commands/MiscCommands.cs
new file mode 100644
index 0000000..21646e7
--- /dev/null
+++ b/DSACore/Commands/MiscCommands.cs
@@ -0,0 +1,230 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using DSACore.DSA_Game;
+using DSACore.Auxiliary;
+using Microsoft.AspNetCore.Hosting.Internal;
+
+namespace DSACore.Commands
+{
+ public class MiscCommands
+ {
+ /*[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 this.ReplyAsync("```xl\n" + RandomMisc.Roll(roll) + "\n```");
+ }
+
+ [Command("rd"), Summary("Würfel Dennis ")]
+ public Task RollDennisAsync([Remainder, Summary("Weapon")] string roll)
+ {
+ return this.ReplyAsync("```xl\n" + new DSACore.Auxiliary.Calculator.StringSolver(roll).Solve() + "\n```");
+ }*/
+/*
+
+ [Command("general"), Summary("Set General ")]
+ public Task SetGeneralAsync([Remainder, Summary("Set General")] int i = 0)
+ {
+ Dsa.GeneralContext = this.Context;
+ return this.Context.Channel.SendMessageAsync($"```xl\n Der Dachs hat in '{this.Context.Channel.Name}' ein Zuhause gefunden. Gm Nachrichten werden nun auch in diesem Channel gepostet. \n```");
+ }
+
+ [Command("say"), Summary("Echos a message.")]
+ [Alias("s")]
+ public Task SayAsync([Remainder, Summary("The text to echo")] string echo)
+ {
+ return this.ReplyAsync(echo);
+ }
+
+ [Command("liebe"), Summary("Echos a message.")]
+ [Alias("Liebe", "<3", "love")]
+ public async Task LoveAsync()
+ {
+ Random rand = new Random();
+ var user = HostingApplication.Context.Channel.GetUsersAsync().ToList().Result.ToList().First().Where(x=>x.Status!= UserStatus.Offline).OrderBy(x => rand.Next()).First();
+ await this.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 this.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("report"), Summary("Report a Tweet")]
+ public async Task ReportAsync([Remainder, Summary("Link")] string link)
+ {
+ var content = new System.Net.Http.StringContent(link);
+
+ using (HttpClient client = new HttpClient())
+ {
+ var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);
+ }
+
+ await this.ReplyAsync($"Dein report wurde hinzugefügt");
+ }
+
+ [Command("match"), Summary("Tinder.")]
+ [Alias("mach","pass", "passt")]
+ public Task TinderAsync(string s1, string s2)
+ {
+
+ var sc = new SpellCorrect();
+ var rand = new System.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 this.ReplyAsync($"Ihr passt zu {Math.Floor(100.0 * wert )/ 100.0}% zusammen");
+
+ }
+
+ [Command("reddit"), Summary("Reddit.")]
+ public Task RedditAsync()
+ {
+ return this.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 = HostingApplication.Context.Guild.GetUsersAsync(CacheMode.AllowDownload);
+ 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<string>();
+
+ foreach (string line in lines)
+ {
+ var best = us.OrderBy(user => sc.Compare(user, line)).First();
+
+ double fit = sc.Compare(best, line);
+
+ if (fit < SpellCorrect.ErrorThreshold - 20000)
+ {
+ if (fit.Equals(0))
+ {
+ res.Add($"@\t{best} !!! => {line}");
+ }
+ else
+ {
+ res.Add($"-\t{best} hat Ähnlichkeit mit: {line}");
+ }
+ }
+ }
+
+ var sb = new StringBuilder();
+ foreach (string re in res)
+ {
+ if (sb.Length + re.Length > 1798)
+ {
+ await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
+ sb.Clear();
+ }
+
+ sb.AppendLine(re);
+ }
+
+ if(Permissions.Check(this.Context, new []{"Admin", "Mod"}))
+ await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
+
+ //await this.ReplyAsync($"{count} Duplikate gefunden");
+
+ }
+
+
+ [Command("clear"), Summary("Cleans up messages.")]
+ public async Task DeleteAsync(int count)
+ {
+ var messagesAsync = HostingApplication.Context.Channel.GetMessagesAsync(count);
+ Task.WaitAll(messagesAsync.ToArray());
+ var list = messagesAsync.ToEnumerable().ToList();
+ var messages = new List<IMessage>();
+ foreach (var task in list)
+ {
+ messages.AddRange(task.ToList());
+ }
+
+ if (Permissions.Check(HostingApplication.Context, new[] { "Admin", "Mod", "Meister" }))
+ {
+
+ var waiters = new List<Task>();
+ foreach (var message in messages)
+ {
+ waiters.Add((message as IUserMessage).DeleteAsync());
+ }
+
+ Task.WaitAll(waiters.ToArray());
+ }
+
+ }
+
+ [Command("check"), Summary("Echos a message.")]
+ [Alias("Check")]
+ public async Task CheckAsync(string quarry)
+ {
+ var perm = new List<string> { "Admin", "Mod", "Privatpolizei" };
+
+ Permissions.Test(this.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;
+
+ if (fit < SpellCorrect.ErrorThreshold - 20000)
+ {
+ Antwort= $"```xl\nAuf anderem Server Match gefunden: {count}";
+ }
+ else
+ {
+ Antwort = $"```xl\nAuf anderem Server Kein Match gefunden: {quarry}";
+ }
+
+
+ var users = HostingApplication.Context.Guild.GetUsersAsync(CacheMode.AllowDownload);
+ 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);
+
+ if (fit < SpellCorrect.ErrorThreshold - 20000)
+ {
+ Antwort = Antwort + $"\nAuf unserem Server Match gefunden: {count}\n```";
+ }
+ else
+ {
+ Antwort = Antwort + $"\nAuf unserem Server Kein Match gefunden: {quarry} \n```";
+ }
+
+ await ReplyAsync(Antwort);
+
+ }*/
+ }
+}
diff --git a/DSACore/Commands/NpcCommands.cs b/DSACore/Commands/NpcCommands.cs
new file mode 100644
index 0000000..1fe8e2e
--- /dev/null
+++ b/DSACore/Commands/NpcCommands.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using DSACore.Characters;
+using DSACore.DSA_Game;
+using DSACore.DSA_Game.Characters;
+using DSACore.Auxiliary;
+using Microsoft.AspNetCore.Mvc.Internal;
+
+namespace DSACore.Commands
+{
+ public class NpcCommands
+ {
+
+ public static string CreateNpc(ulong id, IEnumerable<string> props, int modifier)
+ {
+ if (int.TryParse(props.Last(), out int mean))
+ {
+ return Random(id, props.First(), mean, modifier);
+ }
+
+ return Copy(id, props.First(), props.Last(), modifier);
+
+ }
+
+ public static string Random(ulong id, string npcName, int mean = 9, int stDv = 1)
+ {
+ throw new NotImplementedException();
+ Dsa.Chars.Add(new Npc(npcName, mean, stDv));
+ return $"{npcName} wurde zufällig generiert";
+ }
+
+ public static string Copy(ulong id, string npcName, string source, int stDv = 1)
+ {
+ if (Dsa.Chars.Exists(x => x.Name.Equals(npcName)))
+ {
+ throw new Exception("Char gibt es schon");
+ }
+ throw new NotImplementedException();
+ var chr = Dsa.GetCharacter(id);
+ Dsa.Chars.Add(new Character(chr as Character, npcName, stDv));
+ return $"{npcName} wurde als variierte Kopie von {source} erstellt";
+ }
+ }
+} \ No newline at end of file
diff --git a/DSACore/Commands/ProbenTest.cs b/DSACore/Commands/ProbenTest.cs
new file mode 100644
index 0000000..a927cd9
--- /dev/null
+++ b/DSACore/Commands/ProbenTest.cs
@@ -0,0 +1,85 @@
+namespace DSACore.Commands
+{
+ public class ProbenTest
+ {
+ /*[Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
+ [Alias("T", "Talent", "talent", "versuche")]
+ public Task TalentAsync([Summary("Talent oder Zaubername")] string talent, int erschwernis = 0)
+ {
+ string res;
+ try
+ {
+ res = Gm.CheckCommand(
+ Dsa.Session.Relation[this.Context.User.Username],
+ CommandTypes.Talent,
+ talent,
+ erschwernis);
+ }
+ catch
+ {
+ res = Gm.CheckCommand(
+ Dsa.Session.Relation["Tardis"],
+ CommandTypes.Talent,
+ talent,
+ erschwernis);
+ }
+
+ return this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ [Command("Zauber"), Summary("Würfelt ein Zauberprobe")]
+ [Alias("Z", "zauber", "z")]
+ public Task ZauberAsync([Summary("Zaubername")] string zauber, int erschwernis = 0)
+ {
+ string res;
+ try
+ {
+ res = Gm.CheckCommand(
+ Dsa.Session.Relation[this.Context.User.Username],
+ CommandTypes.Zauber,
+ zauber,
+ erschwernis);
+ }
+ catch
+ {
+ res = Gm.CheckCommand(
+ Dsa.Session.Relation["Tardis"],
+ CommandTypes.Zauber,
+ zauber,
+ erschwernis);
+ }
+
+ return this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ [Command("e"), Summary("Würfelt eine Eigenschaftsprobe")]
+ [Alias("E", "Eigenschaft", "eigenschaft", "eigen")]
+ public Task EigenschaftAsync([Summary("Eigenschaftskürzel und Erschwernis")] string talent, int erschwernis = 0)
+ {
+ var chr = Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username]));
+ string res = chr.TestEigenschaft(talent, erschwernis);
+ return this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ [Command("a"), Summary("Würfelt ein Angriff")]
+ [Alias("A", "At", "at", "Angriff", "angriff", "attackiere_mit", "attacke", "Attacke")]
+ public Task AngriffAsync([Summary("Weapon")] string weapon, int erschwernis = 0)
+ {
+ return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Angriff(weapon, erschwernis) + "\n```");
+ }
+
+ [Command("p"), Summary("Würfelt eine Parade Probe")]
+ [Alias("P", "Parade", "parade", "pariere_mit")]
+ public Task ParadeAsync([Summary("Parade Weapon")] string talent, int erschwernis = 0)
+ {
+ return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Parade(talent, erschwernis) + "\n```");
+ }
+
+ [Command("f"), Summary("Führt eine Fernkampfprobe aus")]
+ [Alias("F", "fern", "Fern", "Schuss", "schuss", "fernkampf", "Fernkampf", "schieße", "schieße_mit")]
+ public Task FernkampfAsync([Summary("Fernkampfwaffe")] string waffe, int erschwernis = 0)
+ {
+ return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Fernkampf(waffe, erschwernis) + "\n```");
+ }*/
+ }
+}
diff --git a/DSACore/DSA_Game/Characters/Character.cs b/DSACore/DSA_Game/Characters/Character.cs
index 1236b12..8fad2ef 100644
--- a/DSACore/DSA_Game/Characters/Character.cs
+++ b/DSACore/DSA_Game/Characters/Character.cs
@@ -2,7 +2,7 @@
using DSALib;
using DSALib.Characters;
-namespace DiscoBot.DSA_Game.Characters
+namespace DSACore.DSA_Game.Characters
{
using System;
using System.Collections.Generic;
diff --git a/DSACore/DSA_Game/Characters/NPC.cs b/DSACore/DSA_Game/Characters/NPC.cs
index ec8adfc..0a660ee 100644
--- a/DSACore/DSA_Game/Characters/NPC.cs
+++ b/DSACore/DSA_Game/Characters/NPC.cs
@@ -1,12 +1,13 @@
-using DSACore.Auxiliary;
+using System;
+using DSACore.Auxiliary;
using DSALib.Characters;
-namespace DiscoBot.Characters
+namespace DSACore.Characters
{
using System;
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game.Characters;
+ using DSACore.Auxiliary;
+ using DSACore.DSA_Game.Characters;
public class Npc : Being, ICharacter
{
diff --git a/DSACore/DSA_Game/Characters/SaveChar.cs b/DSACore/DSA_Game/Characters/SaveChar.cs
index 50cb91c..87c2566 100644
--- a/DSACore/DSA_Game/Characters/SaveChar.cs
+++ b/DSACore/DSA_Game/Characters/SaveChar.cs
@@ -1,11 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using DSALib.Characters;
-
-namespace DiscoBot.DSA_Game.Characters
+using DSALib.Characters;
+
+namespace DSACore.DSA_Game.Characters
{
public class SaveChar
diff --git a/DSACore/DSA_Game/Dsa.cs b/DSACore/DSA_Game/Dsa.cs
index 8907f96..4573542 100644
--- a/DSACore/DSA_Game/Dsa.cs
+++ b/DSACore/DSA_Game/Dsa.cs
@@ -1,13 +1,15 @@
-using DSALib;
+using System;
+using DSALib;
using DSALib.Characters;
+using Microsoft.EntityFrameworkCore.Design;
-namespace DiscoBot.DSA_Game
+namespace DSACore.DSA_Game
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
- using DiscoBot.DSA_Game.Characters;
- using DiscoBot.DSA_Game.Save;
+ using DSACore.DSA_Game.Characters;
+ using DSACore.DSA_Game.Save;
public static class Dsa
{
@@ -37,7 +39,7 @@ namespace DiscoBot.DSA_Game
public static void Startup()
{
- //new DiscoBot.Auxiliary.Calculator.StringSolver("1d100 - (1d200 + 1) * -50000").Solve();
+ //new .Auxiliary.Calculator.StringSolver("1d100 - (1d200 + 1) * -50000").Solve();
/*Session = new Session();*/
// relation.Add("Papo", "Pump aus der Gosse");
foreach (var filename in Directory.GetFiles("helden", "*.xml"))
@@ -57,5 +59,15 @@ namespace DiscoBot.DSA_Game
};
Session.Save();
}
+
+ public static ICharacter GetCharacter(ulong id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public static ICharacter GetCharacter(string name, ulong groupId)
+ {
+ throw new NotImplementedException();
+ }
}
} \ No newline at end of file
diff --git a/DSACore/DSA_Game/Save/Properties.cs b/DSACore/DSA_Game/Save/Properties.cs
index a27c9d7..1c86ab9 100644
--- a/DSACore/DSA_Game/Save/Properties.cs
+++ b/DSACore/DSA_Game/Save/Properties.cs
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using DSACore.Audio;
using DSACore.Auxiliary;
+using Newtonsoft.Json;
-namespace DiscoBot.DSA_Game.Save
+namespace DSACore.DSA_Game.Save
{
using System.Collections;
using System.IO;
@@ -21,38 +23,43 @@ namespace DiscoBot.DSA_Game.Save
this.objects.Add("CommandInfos", new List<CommandInfo>());*/
}
- public static List<CommandInfo> CommandInfos { get => objects["CommandInfo"] as List<CommandInfo>; set => objects["CommandInfo"] = value; } // use Properties.Commandinfos to access the abstract Object array
+ public static List<CommandInfo> CommandInfos
+ {
+ get => objects["CommandInfo"] as List<CommandInfo>;
+ set => objects["CommandInfo"] = value;
+ } // use Properties.Commandinfos to access the abstract Object array
- public static List<Sound> Sounds { get => objects["Sound"] as List<Sound>; set => objects["Sound"] = value; }
+ public static List<Sound> Sounds
+ {
+ get => objects["Sound"] as List<Sound>;
+ set => objects["Sound"] = value;
+ }
public static void Deserialize(string path = @"..\..\Properties")
{
-
- var files = Directory.GetFiles(path, "*.json");
+ var files = Directory.GetFiles(path, "*.json");
- foreach (string file in files)
+ foreach (string file in files)
+ {
+ try
{
- try
- {
- string name = file.Split('\\').Last().Split('.')[0].Replace('-', '.');
- string data = File.ReadAllText(file);
- Type type = Type.GetType(name);
- if (data.StartsWith("["))
- {
- type = typeof(List<>).MakeGenericType(type);
- }
-
- var o = JsonConvert.DeserializeObject(data, type);
- objects.Add(name.Split('.').Last(), o);
- }
- catch (Exception e)
+ string name = file.Split('\\').Last().Split('.')[0].Replace('-', '.');
+ string data = File.ReadAllText(file);
+ Type type = Type.GetType(name);
+ if (data.StartsWith("["))
{
- // ignored
- Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen."+ e);
+ type = typeof(List<>).MakeGenericType(type);
}
+ var o = JsonConvert.DeserializeObject(data, type);
+ objects.Add(name.Split('.').Last(), o);
}
-
+ catch (Exception e)
+ {
+ // ignored
+ Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen." + e);
+ }
+ }
}
public static void Serialize(string path = @"..\..\Properties\")
@@ -61,17 +68,21 @@ namespace DiscoBot.DSA_Game.Save
{
foreach (var o in objects)
{
- string assembly = o.Value is IList list ? ((IList)list)[0]?.GetType().FullName : o.Value.GetType().FullName;
+ string assembly = o.Value is IList list
+ ? ((IList) list)[0]?.GetType().FullName
+ : o.Value.GetType().FullName;
var name = path + assembly.Replace('.', '-') + ".json";
- File.WriteAllText(name, JsonConvert.SerializeObject(o.Value, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
+ File.WriteAllText(name,
+ JsonConvert.SerializeObject(o.Value,
+ Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
}
}
catch (Exception e)
{
// ignored
- Console.WriteLine($"Speichern von Save-File fehlgeschlagen."+ e);
+ Console.WriteLine($"Speichern von Save-File fehlgeschlagen." + e);
}
}
}
-}
+} \ No newline at end of file
diff --git a/DSACore/DSA_Game/Save/SaveCommand.cs b/DSACore/DSA_Game/Save/SaveCommand.cs
index 9a2ae8e..198d707 100644
--- a/DSACore/DSA_Game/Save/SaveCommand.cs
+++ b/DSACore/DSA_Game/Save/SaveCommand.cs
@@ -2,7 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
-namespace DiscoBot.DSA_Game.Save
+namespace DSACore.DSA_Game.Save
{
using System.IO;
@@ -17,7 +17,7 @@ namespace DiscoBot.DSA_Game.Save
return;
}
- var path = DSA_Game.Save.Session.DirectoryPath + @"\" + name;
+ var path = Save.Session.DirectoryPath + @"\" + name;
var files = Directory.GetFiles(path);
var session = files.OrderByDescending(x => Convert.ToInt32(x.Split('-').Last().Split('.').First())).First();
diff --git a/DSACore/DSA_Game/Save/Session.cs b/DSACore/DSA_Game/Save/Session.cs
index d0cba21..60e900f 100644
--- a/DSACore/DSA_Game/Save/Session.cs
+++ b/DSACore/DSA_Game/Save/Session.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
-namespace DiscoBot.DSA_Game.Save
+namespace DSACore.DSA_Game.Save
{
using System.IO;
- using DiscoBot.DSA_Game.Characters;
+ using Characters;
using Newtonsoft.Json;
public class Session
diff --git a/DSACore/Models/Command.cs b/DSACore/Models/Command.cs
index 75e3bee..2630d47 100644
--- a/DSACore/Models/Command.cs
+++ b/DSACore/Models/Command.cs
@@ -7,7 +7,13 @@ namespace DSACore.Models
{
public class Command
{
+ public ulong GroupId { get; set; } = 0;
+ public ulong CharId { get; set; }
public string Name { get; set; }
- public string CmdText { get; set; }
+ public string CmdIdentifier { get; set; }
+ public List<string> CmdTexts { get; set; }
+ public string CmdText => CmdTexts.First();
+ public int Cmdmodifier { get; set; } = 0;
+ public bool IsDm { get; set; } = false;
}
}