Esempio n. 1
0
        public string Interpret(string input, IExpressionVisitor visitor = null)
        {
            if (input.Length > 0)
            {
                input = new string(input.ToCharArray().TakeWhile(c => c != '\0').ToArray());
                input = char.ToUpper(input[0]) + input.Substring(1, input.Length - 1);
            }

            if (!Punctuations.Any(c => input.EndsWith(c.ToString())))
            {
                input += ".";
            }

            return(Expression.Interpret(input, visitor));
        }
Esempio n. 2
0
 public string Interpret(string input, IExpressionVisitor visitor = null)
 {
     if (input.StartsWith("/"))
     {
         return(CommandExpression.Interpret(input, visitor));
     }
     else if (input.StartsWith("!"))
     {
         return(ColorExpression.Interpret(input, visitor));
     }
     else
     {
         return(TextExpression.Interpret(input, visitor));
     }
 }
Esempio n. 3
0
 public void LogChatMessage(byte playerId, string message)
 {
     if (ValidateChatInput(message))
     {
         IExpressionVisitor visitor = GetVisitor(message);
         message = TextInterpreter.Interpret(message, visitor);
         Debug.WriteLine(message);
         if (!string.IsNullOrEmpty(message))
         {
             string playerName = ServerConnection.ConstructName(playerId);
             if (ServerConnection.Instance.IdMatches(playerId))
             {
                 Output.AppendText("[me] ", InfoColor, NormalFont);
             }
             Output.AppendText($"{playerName}", NormalColor, BoldFont);
             Output.AppendText($": {message.TrimEnd('\0')}\r\n", NormalColor, NormalFont);
             Debug.WriteLine(message);
         }
     }
 }