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"); } } }
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); }
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); }
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); }
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); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { AliasProcessor.GetInstance().SaveAlias(); CustomVariable.SaveVariable(); }