Exemple #1
0
        public static bool IsScale(this BotCommand command, Direction?direction = null, RailwayType?type = null)
        {
            var cmd = command.ToString();

            var result = cmd.StartsWith("Scale");

            if (direction is Direction d)
            {
                result = result && cmd.EndsWith(d.ToString());
            }

            if (type is RailwayType t)
            {
                result = result && cmd.Contains(t.ToString());
            }

            return(result);
        }
Exemple #2
0
        public static string ExtractRailwayType(this BotCommand command)
        {
            if (!command.IsScale())
            {
                return(null);
            }

            var cmd = command.ToString();

            foreach (var type in new [] { "L1", "L2", "L3", "L4" })
            {
                if (cmd.Contains(type))
                {
                    return(type);
                }
            }

            return(null);
        }
Exemple #3
0
        public static Direction?ExtractDirection(this BotCommand command)
        {
            if (!command.IsScale())
            {
                return(null);
            }

            var cmd = command.ToString();

            if (cmd.Length <= 7)
            {
                return(null);
            }

            var dir = cmd.Substring(7);

            if (Enum.TryParse(dir, out Direction direction))
            {
                return(direction);
            }

            return(null);
        }
Exemple #4
0
        public static bool IsGoto(this BotCommand command)
        {
            var cmd = command.ToString();

            return(cmd.StartsWith("Goto"));
        }
Exemple #5
0
        public static bool IsMutate(this BotCommand command)
        {
            var cmd = command.ToString();

            return(cmd.StartsWith("Mutate"));
        }
 public override string ToString()
 {
     return($"/{BotCommand.ToString().ToLower()} [{MainParamName}] - {Description}");
 }
Exemple #7
0
 public void SetCommand(BotCommand cmd)
 {
     this.cmd = cmd.ToString();
 }