From 19bf37de7642ae8cdefd8fc6b4fadac3ac96ea9b Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Wed, 26 Sep 2018 23:49:26 +0200 Subject: ported most code to WebApiProject everything except the user identification and file locations should be somewhat functional --- DSACore/Commands/CommandHandler.cs | 121 +++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 DSACore/Commands/CommandHandler.cs (limited to 'DSACore/Commands/CommandHandler.cs') 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}"; + } + } +} -- cgit v1.2.3-54-g00ecf