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/Commands/LookCommand.cs | 57 ----------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 Scripts/Commands/LookCommand.cs (limited to 'Scripts/Commands/LookCommand.cs') diff --git a/Scripts/Commands/LookCommand.cs b/Scripts/Commands/LookCommand.cs deleted file mode 100644 index 08783a9..0000000 --- a/Scripts/Commands/LookCommand.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Linq; - -namespace Texty.Scripts.Commands -{ - public enum LookModifier - { - At, - Around - } - - public class LookCommand : Command - { - public LookCommand() - { - } - - public LookCommand(string[] arguments) : base(CommandType.Look, arguments) - { - (Modifier, arguments) = TryParseModifier(arguments); - Target = string.Join(" ", arguments); - } - - public string Target { get; } - public LookModifier? Modifier { get; } - - /// - /// Access this LookCommand's modifier as a string. - /// - /// - /// This function is provided as a means for testing the modifier parsing from GDScript. - /// - private string ModifierAsString => Modifier?.ToString(); - - public override string ToString() - { - return $"look {ModifierAsString?.ToLower()} {string.Join(" ", Target)}"; - } - - /// - /// Try to parse this LookCommand's modifier from the given arguments. - /// - /// The arguments given to this look commands - /// A pair consisting of the parse modifier and the remaining arguments - private static (LookModifier?, string[]) TryParseModifier(string[] arguments) - { - if (arguments.Length == 0) - return (null, arguments); - - return arguments[0].ToLower() switch - { - "at" => (LookModifier.At, arguments.Skip(1).ToArray()), - "around" => (LookModifier.Around, new string[] { }), - _ => (null, arguments) - }; - } - } -} \ No newline at end of file -- cgit v1.2.3