diff options
Diffstat (limited to 'Scripts/Commands/LookCommand.cs')
| -rw-r--r-- | Scripts/Commands/LookCommand.cs | 57 |
1 files changed, 0 insertions, 57 deletions
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; } - - /// <summary> - /// Access this <c>LookCommand</c>'s modifier as a string. - /// </summary> - /// <remarks> - /// This function is provided as a means for testing the modifier parsing from GDScript. - /// </remarks> - private string ModifierAsString => Modifier?.ToString(); - - public override string ToString() - { - return $"look {ModifierAsString?.ToLower()} {string.Join(" ", Target)}"; - } - - /// <summary> - /// Try to parse this <c>LookCommand</c>'s modifier from the given arguments. - /// </summary> - /// <param name="arguments">The arguments given to this look commands</param> - /// <returns>A pair consisting of the parse modifier and the remaining arguments</returns> - 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 |
