summaryrefslogtreecommitdiff
path: root/DSACore/Commands/CommandHandler.cs
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/Commands/CommandHandler.cs
parentb411aa2128c2724bec0ecedb8cb4e1ffa59f3b53 (diff)
ported most code to WebApiProject
everything except the user identification and file locations should be somewhat functional
Diffstat (limited to 'DSACore/Commands/CommandHandler.cs')
-rw-r--r--DSACore/Commands/CommandHandler.cs121
1 files changed, 121 insertions, 0 deletions
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}";
+ }
+ }
+}