Ejemplo n.º 1
0
        public void table_print(string format, List <String> list, int columns)
        {
            //string format = "{2,-37} - {1,-37} - {0,-37}";
            //string format2 = "{1,-37} - {0,-37} - {0,-37}";
            //string format2 = "{2,-40} - {1,-40} - {0,-40}";



            int lasti = 0;

            for (int i = 0; i < list.Count; i++)
            {
                if (i % columns == 0 && i > 0)
                {
                    lasti = i;
                    SimcraftImpl.Write(format, list[i - 2], list[i - 1], list[i]);
                }
                if (i == list.Count - 1 && i != lasti)
                {
                    SimcraftImpl.Write(format + " nvm duplicates", list.Count > 2 ? list[i - 2] : "", list.Count > 2 ? list[i - 1] : "", list[i]);
                    //SimcraftImpl.Write(format, lasti < i - 2 ? list[i - 2] : "",
                    //    lasti < i - 1 ? list[i - 1] : "", lasti < i ? list[i] : "");
                }
            }
            SimcraftImpl.Write("-------------------------------------------------------------------------");
        }
Ejemplo n.º 2
0
        public static Assembly CompileCode(string code)
        {
            Microsoft.CSharp.CSharpCodeProvider provider = new CSharpCodeProvider();
#pragma warning disable 618
            ICodeCompiler compiler = provider.CreateCompiler();
#pragma warning restore 618
            CompilerParameters compilerparams = new CompilerParameters();
            compilerparams.GenerateExecutable = false;
            compilerparams.GenerateInMemory   = false;



            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                try
                {
                    string location = assembly.Location;
                    if (!String.IsNullOrEmpty(location))
                    {
                        compilerparams.ReferencedAssemblies.Add(location);
                    }
                }
                catch (NotSupportedException)
                {
                    // this happens for dynamic assemblies, so just ignore it.
                }
            }


            CompilerResults results =
                compiler.CompileAssemblyFromSource(compilerparams, code);
            if (results.Errors.HasErrors)
            {
                StringBuilder errors = new StringBuilder("Compiler Errors :\r\n");
                foreach (CompilerError error in results.Errors)
                {
                    SimcraftImpl.Write(String.Format("Line {0},{1}\t: {2} - line {3}\n", error.Line, error.Column, error.ErrorText, error), default(Color), LogLevel.Normal);
                    //Console.WriteLine(fullExpression.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)[error.Line-1]);
                    //errors.AppendFormat("Line {0},{1}\t: {2} - line {3}\n",
                    //error.Line, error.Column, error.ErrorText, error, fullExpression.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)[error.Line]);
                }
                throw new Exception(errors.ToString());
            }
            else
            {
                AppDomain.CurrentDomain.Load(results.CompiledAssembly.GetName());
                return(results.CompiledAssembly);
            }
        }
Ejemplo n.º 3
0
        public bool ParseAction()
        {
            String indent = "";

            ParseExpression();
            FixTokens();

            var __code = "";

            String prefix = indent;

            if (swing.IsMatch(_condition_string))
            {
                Comments.Add("Dont use swing timers man ...");
                prefix += "//";
            }

            if (_condition_string.Contains("aura."))
            {
                Comments.Add("Aura Conditions nono!");
                prefix += "//";
            }

            Understood = true;

            switch (this.type)
            {
            case ActionType.start_pyro_chain:
                __code = comments(indent) + "" + prefix + as_start_pyro_chain_t();
                break;

            case ActionType.stop_pyro_chain:
                __code = comments(indent) + "" + prefix + as_stop_pyro_chain_t();
                break;

            case ActionType.wait:
                __code = comments(indent) + "" + prefix + as_wait_t();
                break;

            case ActionType.run_action_list:
            case ActionType.call_action_list:
                __code = comments(indent) + "" + prefix + run_action_list_t(this);
                break;

            case ActionType.potion:
                __code = comments(indent) + "" + prefix + as_potion_t();
                break;

            case ActionType.use_item:
                __code = comments(indent) + "" + prefix + as_use_item_t();
                break;

            case ActionType.none:
                __code = comments(indent) + "" + prefix + as_action_t();

                if (!SimcNames.spells.ContainsKey(action))
                {
                    SimcraftImpl.Write("Invalid Spell: " + action + ", skipping.");
                    __code = "//" + _fullExpression;
                }

                /*if (!SimcraftImpl.DBHasClassSpell(action))
                 * {
                 *  if (!SimcraftImpl.DBHasSpell(action))
                 *  {
                 *      SimcraftImpl.Write("Invalid Spell: " + action + ", skipping.");
                 *      __code = "//" + _fullExpression;
                 *  }
                 * }*/
                break;

            case ActionType.mana_potion:
            case ActionType.apply_poison:
            case ActionType.cancel_buff:
            case ActionType.cancel_metamorphosis:
            case ActionType.choose_target:
            case ActionType.flask:
            case ActionType.food:
            case ActionType.pool_resource:
            case ActionType.snapshot_stats:
            case ActionType.stance:
            case ActionType.summon_pet:
            case ActionType.wait_until_ready:
                break;
            }


            foreach (Match m in filter_trinket.Matches(_condition_string))
            {
                __code = __code.Replace(m.Groups[1].ToString(), ResolveTrinketExpression(m.Groups[1].ToString(), myList.Items)[0]) + Environment.NewLine;
            }

            csCode = __code;



            return(Understood);
        }
Ejemplo n.º 4
0
        public static ActionOption new_option(String text)
        {
            text = text.Trim();
            if (text.StartsWith("if="))
            {
                return(option(ActionOptionType.If, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("interrupt_if="))
            {
                return(option(ActionOptionType.InterruptIf, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("early_chain_if="))
            {
                return(option(ActionOptionType.EarlyChainIf, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("interrupt="))
            {
                return(option(ActionOptionType.Interrupt, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("chain="))
            {
                return(option(ActionOptionType.Chain, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("cycle_targets="))
            {
                return(option(ActionOptionType.CycleTargets, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("cycle_players="))
            {
                return(option(ActionOptionType.CyclePlayers, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("max_cycle_targets="))
            {
                return(option(ActionOptionType.MaxCycleTargets, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("moving="))
            {
                return(option(ActionOptionType.Moving, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("sync="))
            {
                return(option(ActionOptionType.Sync, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("wait_on_ready="))
            {
                return(option(ActionOptionType.WaitOnReady, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("target="))
            {
                return(option(ActionOptionType.Target, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("label="))
            {
                return(option(ActionOptionType.Label, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("precombat="))
            {
                return(option(ActionOptionType.Precombat, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("line_cd="))
            {
                return(option(ActionOptionType.LineCd, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("action_skill="))
            {
                return(option(ActionOptionType.ActionSkill, text.Substring(text.IndexOf("=") + 1)));
            }

            if (text.StartsWith("slot="))
            {
                return(option(ActionOptionType.Slot, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("five_stacks="))
            {
                return(option(ActionOptionType.FiveStacks, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("damage="))
            {
                return(option(ActionOptionType.Damage, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("type="))
            {
                return(option(ActionOptionType.Type, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("name="))
            {
                return(option(ActionOptionType.Name, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("choose="))
            {
                return(option(ActionOptionType.Choose, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("sec="))
            {
                return(option(ActionOptionType.Seconds, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("ammo_type="))
            {
                return(option(ActionOptionType.AmmoType, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("lethal="))
            {
                return(option(ActionOptionType.LethalPoison, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("for_next="))
            {
                return(option(ActionOptionType.ForNext, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("max_energy="))
            {
                return(option(ActionOptionType.MaxEnergy, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.StartsWith("extra_amount="))
            {
                return(option(ActionOptionType.ExtraAmmount, text.Substring(text.IndexOf("=") + 1)));
            }
            if (text.Length > 1)
            {
                SimcraftImpl.Write("I dont recognize the option " + text);
            }



            return(new ActionOption());
        }
Ejemplo n.º 5
0
        public void PrintResolutionTable()
        {
            PrintCode();

            List <String> c     = new List <string>();
            int           lasti = 0;

            string format  = "{2,-37} - {1,-37} - {0,-37}";
            string format2 = "{2,-40} - {1,-40} - {0,-40}";

            SimcraftImpl.Write("-------------------------------------------------------------------------");
            foreach (var t in buffs)
            {
                try
                {
                    var _t =
                        SimcNames.buffs[t].FirstOrDefault(
                            ret => ret.V1 == WoWSpec.None || ret.V1 == StyxWoW.Me.Specialization);
                    if (_t == default(SimcNames.SpecPair))
                    {
                        SimcraftImpl.Write("Couldnt find buff: " + t);
                    }
                    else
                    {
                        SimcraftImpl.Write("Buff: " + t + " id: " + _t.V2);
                    }
                }
                catch (Exception e)
                {
                    SimcraftImpl.Write("Couldnt find Buff: " + t);
                }
            }
            SimcraftImpl.Write("-------------------------------------------------------------------------");
            c.Clear();
            foreach (var t in debuffs)
            {
                try
                {
                    var _t =
                        SimcNames.debuffs[t].FirstOrDefault(
                            ret => ret.V1 == WoWSpec.None || ret.V1 == StyxWoW.Me.Specialization);
                    if (_t == default(SimcNames.SpecPair))
                    {
                        SimcraftImpl.Write("Couldnt find debuff: " + t);
                    }
                    else
                    {
                        SimcraftImpl.Write("Debuff: " + t + " id: " + _t.V2);
                    }
                }
                catch (Exception e)
                {
                    SimcraftImpl.Write("Couldnt find Debuff: " + t);
                }
            }
            SimcraftImpl.Write("-------------------------------------------------------------------------");
            c.Clear();
            foreach (var t in talents)
            {
                try
                {
                    var _t = SimcraftImpl.DBGetClassSpell(t);
                    SimcraftImpl.Write("Talent: " + t +
                                       (StyxWoW.Me.GetLearnedTalents().Count(a => a.Name == _t.name) > 0
                                      ? " - Enabled"
                                      : " - Disabled") + " id: " + _t.id);
                }
                catch (Exception e)
                {
                    SimcraftImpl.Write("Couldnt find Talent: " + t);
                }
            }
            SimcraftImpl.Write("-------------------------------------------------------------------------");
            //table_print(format2, c, 3);
            c.Clear();
            foreach (var t in spells)
            {
                try
                {
                    var _t =
                        SimcNames.spells[t].FirstOrDefault(
                            ret => ret.V1 == WoWSpec.None || ret.V1 == StyxWoW.Me.Specialization);
                    if (_t == default(SimcNames.SpecPair))
                    {
                        SimcraftImpl.Write("Couldnt find spell: " + t);
                    }
                    else
                    {
                        //SimcraftImpl.Write("t2: " + _t.V2);
                        var sp = SimcraftImpl.dbc.Spells[_t.V2];

                        var spdb = SimcraftImpl.inst.spell;
                        sp.token = t;
                        var ct = spdb[sp];

                        /*var ex = spdb[sp].execute_time;
                         * var clt = spdb[sp].channel_time;
                         * var dur = spdb[sp].duration;
                         * var rec = spdb[sp].recharge_time;
                         * var ran =  spdb[sp].range;
                         *
                         * SimcraftImpl.Write("Spell: {0} id: {1} execute_time: " +
                         *            "{2} cast_time: {3} channel_time: " +
                         *            "{4} duration: {5} recharge_time: " +
                         *            "{6} range: {7}", t, sp.id, ex, ct, clt, dur, rec, ran);*/
                    }
                }
                catch (Exception e)
                {
                    SimcraftImpl.Write(e.ToString());
                    SimcraftImpl.Write("Couldnt find SpellEx: " + t);
                }
            }
            SimcraftImpl.Write("-------------------------------------------------------------------------");

            c.Clear();
        }