Пример #1
0
        public override ChatEvent Fire(ChatRuntime cr)
        {
            ChatEvent ce = base.Fire(cr);

            Substitutor.ReplaceVars(ref action.Text, cr.globals); // also labels
            return(ce);
        }
Пример #2
0
        //public override void HandleVars(Dictionary<string, object> globals) { } // no-op

        public override ChatEvent Fire(ChatRuntime cr)
        {
            Set clone = (Set)this.Copy();

            Substitutor.ReplaceVars(ref clone.Value, cr.globals);
            cr.Globals()[Text] = Value; // set the global var
            return(new ChatEvent(clone));
        }
Пример #3
0
        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);
        }
Пример #4
0
        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));
        }
Пример #5
0
        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);
            }
        }