Ejemplo n.º 1
0
 public InputContext(IUser invoker, ServerConnection connection, GameServer server, InputResult input)
 {
     Invoker    = invoker;
     Connection = connection;
     Server     = server;
     Input      = input;
 }
Ejemplo n.º 2
0
        public InputResult TryParse(Input input)
        {
            var result = new InputResult();

            if (input.Reaction.Equals(Emote) && Handling.HasFlag(input.Flag))
            {
                result.IsSuccess = true;
                result.Input     = this;
            }
            else
            {
                result.IsSuccess = false;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public InputResult TryParse(Input input)
        {
            var result = new InputResult();

            result.Source = input.Text;
            string text = input.Text;

            // name parameters
            if (text.StartsWith(Name, CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase))
            {
                Logger.Debug($"Reading input: \"{text}\"");
                result.IsSuccess = true;
                result.Input     = this;

                var reader = new StringReader(text);
                reader.Skip(Name.Length);
                reader.SkipWhiteSpace();

                while (reader.CanRead())
                {
                    // TODO: Handle required arguments here.
                    string arg = reader.ReadUnquotedString();
                    reader.SkipWhiteSpace();
                    Logger.Debug($"Parsing argument: \"{arg}\"");

                    if (!string.IsNullOrWhiteSpace(arg))
                    {
                        result.Args.Add(arg);
                    }
                    else
                    {
                        result.IsSuccess = false;
                        break;
                    }
                }
            }
            else
            {
                result.IsSuccess = false;
            }

            Logger.Debug($"Parsed {Name} ({result.IsSuccess})");
            return(result);
        }