summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSophia Pearson <codergal89@gmail.com>2022-05-27 18:04:46 +0200
committerSophia Pearson <codergal89@gmail.com>2022-05-27 18:04:46 +0200
commit778960415464079277b31365f0465159585be018 (patch)
tree4984ae9c69fd589cfe1a955a90ac9a1fb2dbad49
parent6363292d14d84ae0641b6ce1048f4ca7268ebb49 (diff)
downloadtexty-778960415464079277b31365f0465159585be018.tar.xz
texty-778960415464079277b31365f0465159585be018.zip
game: parse submitted commands
-rw-r--r--Scripts/Game.cs6
1 files changed, 5 insertions, 1 deletions
diff --git a/Scripts/Game.cs b/Scripts/Game.cs
index 645c922..07dab9a 100644
--- a/Scripts/Game.cs
+++ b/Scripts/Game.cs
@@ -5,6 +5,7 @@ namespace Texty.Scripts
{
public abstract class Game : MarginContainer
{
+ public CommandParser CommandParser;
public VBoxContainer LayoutContainer;
public OutputContainer OutputContainer;
@@ -14,6 +15,7 @@ namespace Texty.Scripts
{
Debug.Assert(OutputRowScene != null, $"The {nameof(OutputRowScene)} was not set!");
+ CommandParser = GetNode<CommandParser>(nameof(CommandParser));
LayoutContainer = GetNode<VBoxContainer>(nameof(LayoutContainer));
OutputContainer = LayoutContainer.GetNode<OutputContainer>(nameof(OutputContainer));
}
@@ -22,7 +24,9 @@ namespace Texty.Scripts
{
var newRow = OutputRowScene.Instance<OutputRow>();
newRow.InputText = text;
- newRow.OutputText = "THE OUTPUT SHOULD GO HERE!";
+
+ var command = CommandParser.TryParse(text);
+ newRow.OutputText = command == null ? "Please rephrase your command" : "THE OUTPUT SHOULD GO HERE!";
OutputContainer.Add(newRow);
}