summaryrefslogtreecommitdiff
path: root/Scripts/CommandParser.cs
diff options
context:
space:
mode:
authorSophia Pearson <codergal89@gmail.com>2022-05-23 00:02:58 +0200
committerSophia Pearson <codergal89@gmail.com>2022-05-23 00:02:58 +0200
commit6fe4972aa48a29d0aafee0461ccd6c635ca9ee6c (patch)
tree30ff503136f1d41ccbb35d3bb9fa6ab92f1e839a /Scripts/CommandParser.cs
parentf3c50714834d2d5cb204625c63aaeffb50bef236 (diff)
downloadtexty-6fe4972aa48a29d0aafee0461ccd6c635ca9ee6c.tar.xz
texty-6fe4972aa48a29d0aafee0461ccd6c635ca9ee6c.zip
commands: add basic command parser infrastructure
Diffstat (limited to 'Scripts/CommandParser.cs')
-rw-r--r--Scripts/CommandParser.cs27
1 files changed, 18 insertions, 9 deletions
diff --git a/Scripts/CommandParser.cs b/Scripts/CommandParser.cs
index 1394a5e..97d8025 100644
--- a/Scripts/CommandParser.cs
+++ b/Scripts/CommandParser.cs
@@ -1,14 +1,23 @@
+using System.Linq;
using Godot;
+using Texty.Scripts.Commands;
namespace Texty.Scripts
{
- public class CommandParser : Node
- {
-
- public override void _Ready()
- {
- }
-
- }
-}
+ 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