From 778960415464079277b31365f0465159585be018 Mon Sep 17 00:00:00 2001 From: Sophia Pearson Date: Fri, 27 May 2022 18:04:46 +0200 Subject: game: parse submitted commands --- Scripts/Game.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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(nameof(CommandParser)); LayoutContainer = GetNode(nameof(LayoutContainer)); OutputContainer = LayoutContainer.GetNode(nameof(OutputContainer)); } @@ -22,7 +24,9 @@ namespace Texty.Scripts { var newRow = OutputRowScene.Instance(); 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); } -- cgit v1.2.3