From 0636205e05b25ff7af095c8d06ca65176c7414ba Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Thu, 3 Sep 2020 22:37:37 +0200 Subject: [PATCH] Add mock implementation for lua code --- ChaosBot/Models/CustomCommand.cs | 5 +++-- .../IProgrammingLanguageInterpreter.cs | 7 +++++++ .../LuaProgrammingLanguageInterpreter.cs | 15 +++++++++++++++ .../ProgrammingLanguageInterpreterFacade.cs | 15 +++++++++++++++ .../ProgrammingLanguageInterpreterFactory.cs | 18 ++++++++++++++++++ 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 ChaosBot/Services/ProgrammingLanguageInterpreter/IProgrammingLanguageInterpreter.cs create mode 100644 ChaosBot/Services/ProgrammingLanguageInterpreter/LuaProgrammingLanguageInterpreter.cs create mode 100644 ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFacade.cs create mode 100644 ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFactory.cs diff --git a/ChaosBot/Models/CustomCommand.cs b/ChaosBot/Models/CustomCommand.cs index d6fa2bb..3bc0e94 100644 --- a/ChaosBot/Models/CustomCommand.cs +++ b/ChaosBot/Models/CustomCommand.cs @@ -22,6 +22,7 @@ namespace ChaosBot.Models public enum CustomCommandType { - Basic + Basic = 0, + CustomLua = 1 } -} \ No newline at end of file +} diff --git a/ChaosBot/Services/ProgrammingLanguageInterpreter/IProgrammingLanguageInterpreter.cs b/ChaosBot/Services/ProgrammingLanguageInterpreter/IProgrammingLanguageInterpreter.cs new file mode 100644 index 0000000..10372de --- /dev/null +++ b/ChaosBot/Services/ProgrammingLanguageInterpreter/IProgrammingLanguageInterpreter.cs @@ -0,0 +1,7 @@ +namespace ChaosBot.Services.ProgrammingLanguageInterpreter +{ + public interface IProgrammingLanguageInterpreter + { + void Interpret(string content); + } +} diff --git a/ChaosBot/Services/ProgrammingLanguageInterpreter/LuaProgrammingLanguageInterpreter.cs b/ChaosBot/Services/ProgrammingLanguageInterpreter/LuaProgrammingLanguageInterpreter.cs new file mode 100644 index 0000000..9ea1aba --- /dev/null +++ b/ChaosBot/Services/ProgrammingLanguageInterpreter/LuaProgrammingLanguageInterpreter.cs @@ -0,0 +1,15 @@ +using System; +using NLog; + +namespace ChaosBot.Services.ProgrammingLanguageInterpreter +{ + internal class LuaProgrammingLanguageInterpreter : IProgrammingLanguageInterpreter + { + private static readonly ILogger Logger = Program.GetLogger(); + + public void Interpret(string content) + { + throw new NotImplementedException(); + } + } +} diff --git a/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFacade.cs b/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFacade.cs new file mode 100644 index 0000000..dd88949 --- /dev/null +++ b/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFacade.cs @@ -0,0 +1,15 @@ +using ChaosBot.Models; + +namespace ChaosBot.Services.ProgrammingLanguageInterpreter +{ + public static class ProgrammingLanguageInterpreterFacade + { + public static void Interpret(CustomCommand customCommand) + { + IProgrammingLanguageInterpreter interpreter = + ProgrammingLanguageInterpreterFactory.GetInterpreter(customCommand.Type); + + interpreter.Interpret(customCommand.Content); + } + } +} diff --git a/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFactory.cs b/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFactory.cs new file mode 100644 index 0000000..de2b345 --- /dev/null +++ b/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFactory.cs @@ -0,0 +1,18 @@ +using ChaosBot.Models; + +namespace ChaosBot.Services.ProgrammingLanguageInterpreter +{ + internal static class ProgrammingLanguageInterpreterFactory + { + public static IProgrammingLanguageInterpreter GetInterpreter(CustomCommandType type) + { + switch (type) + { + case CustomCommandType.CustomLua: + return new LuaProgrammingLanguageInterpreter(); + default: + return new LuaProgrammingLanguageInterpreter(); + } + } + } +}