summaryrefslogtreecommitdiff
path: root/DSACore/Commands/CommandHandler.cs
blob: 4b6ca42e9f5806f5b4d2a1e139bf0d8c30fe0e4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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.CmdTexts.ToArray());
                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;
        }

        private static string CheckCommand(string name, CommandTypes command, string waffe, int erschwernis = 0)
        {
            var chr = Dsa.GetCharacter(0);

            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}";

            throw new NotImplementedException("access char by id ore name and group id");
        }
    }
}