public override ChatEvent Fire(ChatRuntime cr) { Ask clone = (Ask)this.Copy(); Substitutor.ReplaceGroups(ref clone.Text); Substitutor.ReplaceVars(ref clone.Text, cr.globals); this.options.ForEach(o => o.Fire(cr)); // fire for child options return(new ChatEvent(clone)); }
public virtual ChatEvent Fire(ChatRuntime cr) { Command clone = this.Copy(); Substitutor.ReplaceGroups(ref clone.Text); Substitutor.ReplaceVars(ref clone.Text, cr.globals); return(new ChatEvent(clone)); // this.HandleVars(cr.globals); }
public static void MainOff(string[] args) { var globals = new Dictionary <string, object>() { { "animal", "dog" }, { "place", "Istanbul" }, { "Happy", "HappyFlip" }, { "prep", "then" }, }; // Handle subs, variable subs, and nested subs var input = @"SAY The ($animal | $Happy) (walked | (ran | (talked|fell))) and $prep (ate|slept)"; for (int i = 0; i < 15; i++) { string s = String.Copy(input); Substitutor.ReplaceGroups(ref s); Substitutor.ReplaceVars(ref s, globals); System.Console.WriteLine(i + ") " + s); } }