示例#1
0
 public void CheckFadai()
 {
     fadai++;
     if (fadai >= GlobalParams.Fadai)
     {
         SendText("#test 发呆了~,开始启动发呆处理程序~");
         if (FadaiHandler != null)
         {
             SendText("fd");
             FadaiHandler();
         }
         fadai = 0;
     }
     if (GlobalVariable.Ticks % 200 == 0 && GlobalVariable.Ticks > 500)
     {
         _alias.SaveAlias();
         CustomVariable.SaveVariable();
         TestMessage(".......................................");
     }
     if (GlobalParams.Timer != 0)
     {
         if (GlobalVariable.Ticks % GlobalParams.Timer == 0)
         {
             SendText("timer");
         }
     }
 }
示例#2
0
 private void Init()
 {
     CustomVariable.InitVariable();
     _comm = MudCommunication.GetInstance();
     this._comm.serverMessage += new MudCommunication.serverMessageEventHandler(serverConnection_serverMessage);
     this._comm.disconnected  += new MudCommunication.disconnectionEventHandler(serverConnection_disconnected);
     this._comm.telnetMessage += new MudCommunication.serverTelnetEventHandler(serverConnection_telnetMessage);
     this._comm.FadaiHandler  += new MudCommunication.FadaiEventHandler(DealFadai);
 }
示例#3
0
        private void AddCustomVariable(string cmd)
        {
            GroupCollection groups = Regex.Match(cmd, @"#set\s(?<name>@[a-z,A-z,0-9]+)=?(?<value>.+)?", RegexOptions.Compiled).Groups;
            string          value  = groups["value"].Value;

            if (value.StartsWith("@"))
            {
                value = CustomVariable.GetVariable(value);
            }
            CustomVariable.AddVariable(groups["name"].Value, value);
        }
示例#4
0
 private string ProcessCustomVariable(string cmd)
 {
     if (cmd.Contains('@'))
     {
         MatchCollection matches = Regex.Matches(cmd, @"@[a-z,A-z,0-9]+", RegexOptions.Compiled);
         foreach (Match match in matches)
         {
             string name = match.Value;
             cmd = cmd.Replace(name, CustomVariable.GetVariable(name));
         }
     }
     return(cmd);
 }
示例#5
0
 private void ProcessCalcuate(string cmd)
 {
     try
     {
         GroupCollection groups = Regex.Match(cmd, @"#calc\s(?<name>@[a-z,A-z,0-9]+)=(?<value>.+)?", RegexOptions.Compiled).Groups;
         string          value  = groups["value"].Value;
         value = Regex.Replace(value, @"@[a-z,A-z,0-9]+", new MatchEvaluator(new Func <Match, string>(m =>
         {
             return(CustomVariable.GetVariable(m.Value));
         })), RegexOptions.Compiled);
         double result = Util.ParseArithmeticalExpression(value);
         CustomVariable.AddVariable(groups["name"].Value, result.ToString());
     }
     catch (Exception e)
     {
         SendText("#test Error:" + e.Message);
     }
 }
示例#6
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     AliasProcessor.GetInstance().SaveAlias();
     CustomVariable.SaveVariable();
 }