From 2f3abbb6f1141f15ef77ac27e431bc66bb0c7899 Mon Sep 17 00:00:00 2001 From: Sophia Pearson Date: Sun, 4 Sep 2022 15:43:12 +0200 Subject: game: adapt scripts to new design --- Scripts/Game/CommandParser.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Scripts/Game/CommandParser.cs (limited to 'Scripts/Game/CommandParser.cs') diff --git a/Scripts/Game/CommandParser.cs b/Scripts/Game/CommandParser.cs new file mode 100644 index 0000000..5f8249a --- /dev/null +++ b/Scripts/Game/CommandParser.cs @@ -0,0 +1,23 @@ +using System.Linq; +using Godot; +using Texty.Scripts.Commands; + +namespace Texty.Scripts.Game +{ + public class CommandParser : Node + { + public override void _Ready() + { + } + + public Command TryParse(string text) + { + var components = text.Split(' '); + return components[0].ToLower() switch + { + "look" => new LookCommand(components.Skip(1).ToArray()), + _ => null + }; + } + } +} \ No newline at end of file -- cgit v1.2.3