public ActionResult Edit(int id, WoWClass ClassInfo, HttpPostedFileBase ClassPic)
        {
            Debug.WriteLine(ClassInfo.ClassName);
            string url = "WoWClassdata/updateclass/" + id;

            Debug.WriteLine(jss.Serialize(ClassInfo));
            HttpContent content = new StringContent(jss.Serialize(ClassInfo));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            Debug.WriteLine(response.StatusCode);


            if (response.IsSuccessStatusCode)
            {
                //Only send picture data if available
                if (ClassPic != null)
                {
                    Debug.WriteLine("Calling Update Image Method");
                    url = "wowclassdata/updateclasspic/" + id;

                    MultipartFormDataContent requestcontent = new MultipartFormDataContent();
                    HttpContent imagecontent = new StreamContent(ClassPic.InputStream);
                    requestcontent.Add(imagecontent, "ClassPic", ClassPic.FileName);
                    response = client.PostAsync(url, requestcontent).Result;
                }
                return(RedirectToAction("Details", new { id = id }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Esempio n. 2
0
        public void ContextChange(object sender, LuaEventArgs args)
        {
            talent.Reset();
            glyph.Reset();
            spell.Reset();
            line_cds.Clear();
            PlayerAuras.Reset();
            PetAuras.Reset();

            _class = StyxWoW.Me.Class;
            //_spec = Me.Specialization;

            var oldctx = Context;

            Context = (StyxWoW.Me.CurrentMap.IsArena || StyxWoW.Me.CurrentMap.IsBattleground)
                ? WoWContext.PvP
                : WoWContext.PvE;
            if (Context != oldctx)
            {
                SimcraftImpl.Write("Switching to " + Context + " Mode");
            }

            ooc = DateTime.Now;
            RebuildBehaviors();
        }
Esempio n. 3
0
 public TalentTree(int specialization, List <TalentPlacement> talents, WoWClass @class, string name)
 {
     Specialization   = specialization;
     TalentPlacements = talents;
     Class            = @class;
     BuildName        = name;
 }
Esempio n. 4
0
 public static Color GetColorFromWoWClass(WoWClass wclass) {
     switch (wclass) {
         case WoWClass.None:
             return Color.White;
         case WoWClass.DeathKnight:
             return new Color(0.77f, 0.12f, 0.23f);
         case WoWClass.Druid:
             return new Color(1.00f, 0.49f, 0.04f);
         case WoWClass.Hunter:
             return new Color(0.67f, 0.83f, 0.45f);
         case WoWClass.Mage:
             return new Color(0.41f, 0.80f, 0.94f);
         case WoWClass.Paladin:
             return new Color(0.96f, 0.55f, 0.73f);
         case WoWClass.Priest:
             return Color.White;
         case WoWClass.Rogue:
             return new Color(1.00f, 0.96f, 0.41f);
         case WoWClass.Shaman:
             return new Color(0.00f, 0.44f, 0.87f);
         case WoWClass.Warlock:
             return new Color(0.58f, 0.51f, 0.79f);
         case WoWClass.Warrior:
             return new Color(0.78f, 0.61f, 0.43f);
         default:
             return Color.Black;
     }
 }
Esempio n. 5
0
 public TalentTree(int specialization, List<TalentPlacement> talents, WoWClass @class, string name)
 {
     Specialization = specialization;
     TalentPlacements = talents;
     Class = @class;
     BuildName = name;
 }
Esempio n. 6
0
        public override void Initialize()
        {
            //Caching current class here to avoid issues with loading screens where Class return None and we cant build behaviors
            _myClass = Me.Class;

            Logger.Write("Starting Singular v" + Assembly.GetExecutingAssembly().GetName().Version);
            Logger.Write("Determining talent spec.");
            try
            {
                TalentManager.Update();
            }
            catch (Exception e)
            {
                StopBot(e.ToString());
            }
            Logger.Write("Current spec is " + TalentManager.CurrentSpec.ToString().CamelToSpaced());

            if (!CreateBehaviors())
            {
                return;
            }
            Logger.Write("Behaviors created!");

            // When we actually need to use it, we will.
            EventHandlers.Init();
            MountManager.Init();
            //Logger.Write("Combat log event handler started.");
        }
    private void AdjustDPSScore()
    {
        if (ItemStats.ContainsKey("Damage Per Second"))
        {
            WoWClass myClass = ObjectManager.Me.WowClass;

            // Ranged weapons
            if (ItemEquipLoc == "INVTYPE_RANGEDRIGHT" ||
                ItemEquipLoc == "INVTYPE_RANGED" ||
                ItemEquipLoc == "INVTYPE_THROWN")
            {
                if (myClass == WoWClass.Druid ||
                    myClass == WoWClass.Rogue ||
                    myClass == WoWClass.Warrior)
                {
                    Logger.LogDebug($"Adjusting {Name} DPS ({ItemStats["Damage Per Second"]}) to {ItemStats["Damage Per Second"] / 20}");
                    ItemStats["Damage Per Second"] = ItemStats["Damage Per Second"] / 20;
                }
            }
            // Melee weapons
            else
            {
                if (myClass == WoWClass.Hunter)
                {
                    Logger.LogDebug($"Adjusting {Name} DPS ({ItemStats["Damage Per Second"]}) to {ItemStats["Damage Per Second"] / 20}");
                    ItemStats["Damage Per Second"] = ItemStats["Damage Per Second"] / 20;
                }
            }
        }
    }
        public IHttpActionResult UpdateClass(int id, [FromBody] WoWClass Class)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != Class.ClassID)
            {
                return(BadRequest());
            }

            db.Entry(Class).State = EntityState.Modified;
            //Picture update handled by UpdateClassPic
            db.Entry(Class).Property(p => p.ClassPic).IsModified     = false;
            db.Entry(Class).Property(p => p.PicExtension).IsModified = false;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClassExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 9
0
 public static List <Brain> BrainsForClass(WoWClass wowclass)
 {
     if (!Manager.IsInGame)
     {
         return(BrainPool);
     }
     return(BrainPool.Where(b => b.Class == Manager.LocalPlayer.Class).ToList());
 }
Esempio n. 10
0
        public WoWUnit(WoWObject wo, Vector3 pos,float rot, WoWClass uClass) : base(wo) {
            this.position = pos;
            this.unitClass = uClass;
            this.RUnit = new RadarUnit(new Vector2(
                -RadarObject.RadarZoom * (pos.Y - Game1.mainPlayer.Position.Y),
                -RadarObject.RadarZoom * (pos.X - Game1.mainPlayer.Position.X)), -(rot+(float)Math.PI/2), ColorHelper.GetColorFromWoWClass(uClass));

        }
Esempio n. 11
0
 public BehaviorAttribute(BehaviorType type, WoWClass @class = WoWClass.None, WoWSpec spec =(WoWSpec) int.MaxValue, WoWContext context = WoWContext.All, int priority = 0)
 {
     Type = type;
     SpecificClass = @class;
     SpecificSpec = spec;
     SpecificContext = context;
     PriorityLevel = priority;
 }
Esempio n. 12
0
 public BehaviorAttribute(BehaviorType type, WoWClass @class = WoWClass.None, WoWSpec spec = (WoWSpec)int.MaxValue, WoWContext context = WoWContext.All, int priority = 0)
 {
     Type            = type;
     SpecificClass   = @class;
     SpecificSpec    = spec;
     SpecificContext = context;
     PriorityLevel   = priority;
 }
        public IHttpActionResult UpdateClassPic(int id)
        {
            bool   haspic = false;
            string picextension;

            if (Request.Content.IsMimeMultipartContent())
            {
                Debug.WriteLine("Received multipart form data.");

                int numfiles = HttpContext.Current.Request.Files.Count;
                Debug.WriteLine("Files Received: " + numfiles);

                //check if file has been uploaded
                if (numfiles == 1 && HttpContext.Current.Request.Files[0] != null)
                {
                    var ClassPic = HttpContext.Current.Request.Files[0];
                    //checking if file is empty
                    if (ClassPic.ContentLength > 0)
                    {
                        var valtypes  = new[] { "jpeg", "jpg", "png", "gif" };
                        var extension = Path.GetExtension(ClassPic.FileName).Substring(1);
                        //Finding the extension of the file
                        if (valtypes.Contains(extension))
                        {
                            try
                            {
                                //file name is the id of the image
                                string fn = id + "." + extension;

                                //getting direct file path to ~/Content/Class/{id}.{extension}
                                string path = Path.Combine(HttpContext.Current.Server.MapPath("~/Content/myPics/"), fn);

                                //saving file
                                ClassPic.SaveAs(path);

                                //if successful, set fields
                                haspic       = true;
                                picextension = extension;

                                //Update fields in the database!
                                WoWClass SelectedClass = db.Classes.Find(id);
                                SelectedClass.ClassPic        = haspic;
                                SelectedClass.PicExtension    = extension;
                                db.Entry(SelectedClass).State = EntityState.Modified;

                                db.SaveChanges();
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine("Class picture was not saved");
                                Debug.WriteLine("Exception: " + ex);
                            }
                        }
                    }
                }
            }
            return(Ok());
        }
Esempio n. 14
0
        public static Composite GetComposite(WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount)
        {
            behaviourCount = 0;
            if (_methods.Count <= 0)
            {
                Logger.Write("Building method list");
                foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
                {
                    // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite.
                    _methods.AddRange(
                        type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where(
                            mi => !mi.IsGenericMethod && mi.GetParameters().Length == 0).Where(
                                mi => mi.ReturnType.IsAssignableFrom(typeof (Composite))));
                }
                Logger.Write("Added " + _methods.Count + " methods");
            }
            var matchedMethods = new Dictionary<BehaviorAttribute, Composite>();

            foreach (MethodInfo mi in _methods)
            {
                // If the behavior is set as ignore. Don't use it? Duh?
                if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any())
                    continue;

                // If there's no behavior attrib, then move along.
                foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false))
                {
                    var attribute = a as BehaviorAttribute;
                    if (attribute == null)
                        continue;

                    // Check if our behavior matches with what we want. If not, don't add it!
                    if (IsMatchingMethod(attribute, wowClass, spec, behavior, context))
                    {
                        Logger.Write(string.Format("Matched {0} to behavior {1} for {2} {3} with priority {4}", mi.Name,
                            behavior, wowClass.ToString().CamelToSpaced(), spec.ToString().CamelToSpaced(),
                            attribute.PriorityLevel));

                        // if it blows up here, you defined a method with the exact same attribute and priority as one already found
                        matchedMethods.Add(attribute, mi.Invoke(null, null) as Composite);
                    }
                }
            }
            // If we found no methods, rofls!
            if (matchedMethods.Count <= 0)
            {
                return null;
            }

            var result = new PrioritySelector();
            foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel))
            {
                result.AddChild(kvp.Value);
                behaviourCount++;
            }

            return result;
        }
Esempio n. 15
0
        /// <summary>
        ///     Shortcut constructor to create the wow classes.
        /// </summary>
        public FaerieFireAbility(WoWClass @class, bool enabled)
            : base(WoWSpell.FromId(SpellBook.FaerieFire), true, true)
        {
            Enabled = Enabled;
            Class = @class;

            ApplyRequiredConditions();
            ApplyDefaultSettings();
        }
Esempio n. 16
0
 public WoWPlayer(WoWObject wo, Vector3 pos, float rot, WoWClass uClass, byte moveflag) : base(wo) {
     this.Position = pos;
     this.Rotation = rot;
     this.unitClass = uClass;
     this.MovingInfo = new MovementFlags(moveflag);
     this.RPlayer = new RadarPlayer(new Vector2(
         -RadarObject.RadarZoom * (pos.Y - Game1.mainPlayer.Position.Y),
         -RadarObject.RadarZoom * (pos.X - Game1.mainPlayer.Position.X)), -(rot + (float)Math.PI / 2), ColorHelper.GetColorFromWoWClass(uClass));
 }
Esempio n. 17
0
        /// <summary>
        ///     Shortcut constructor to create the wow classes.
        /// </summary>
        public FaerieFireAbility(WoWClass @class, bool enabled)
            : base(WoWSpell.FromId(SpellBook.FaerieFire), true, true)
        {
            Enabled = Enabled;
            Class   = @class;

            ApplyRequiredConditions();
            ApplyDefaultSettings();
        }
        public IHttpActionResult AddClass([FromBody] WoWClass Class)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            db.Classes.Add(Class);
            db.SaveChanges();


            return(Ok(Class.ClassID));
        }
        public IHttpActionResult DeleteClass(int id)
        {
            WoWClass myClass = db.Classes.Find(id);

            Debug.WriteLine(myClass);
            if (myClass == null)
            {
                return(NotFound());
            }

            db.Classes.Remove(myClass);
            db.SaveChanges();

            return(Ok(myClass));
        }
        private List <AIOSpell> GetBlessingPerClass(WoWClass playerClass)
        {
            if (playerClass == WoWClass.Druid ||
                playerClass == WoWClass.Paladin)
            {
                return new List <AIOSpell>()
                       {
                           BlessingOfKings, BlessingOfWisdom, BlessingOfMight
                       }
            }
            ;

            if (playerClass == WoWClass.Hunter)
            {
                return new List <AIOSpell>()
                       {
                           BlessingOfMight, BlessingOfKings, BlessingOfWisdom
                       }
            }
            ;

            if (playerClass == WoWClass.Warrior ||
                playerClass == WoWClass.Rogue)
            {
                return new List <AIOSpell>()
                       {
                           BlessingOfMight, BlessingOfKings
                       }
            }
            ;

            if (playerClass == WoWClass.Mage ||
                playerClass == WoWClass.Priest ||
                playerClass == WoWClass.Shaman ||
                playerClass == WoWClass.Warlock)
            {
                return new List <AIOSpell>()
                       {
                           BlessingOfWisdom, BlessingOfKings, BlessingOfMight
                       }
            }
            ;

            return(null);
        }
    }
}
        // GET: Class/Edit/5
        public ActionResult Edit(int id)
        {
            string url = "WoWClassData/FindClass/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;



            if (response.IsSuccessStatusCode)
            {
                //Put data into Class
                WoWClass SelectedClass = response.Content.ReadAsAsync <WoWClass>().Result;
                return(View(SelectedClass));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        public ActionResult DeleteConfirm(int id)
        {
            string url = "WoWClassdata/FindClass/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            Debug.WriteLine(response);

            if (response.IsSuccessStatusCode)
            {
                //Put data into comp dto
                WoWClass SelectedClass = response.Content.ReadAsAsync <WoWClass>().Result;
                return(View(SelectedClass));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        // GET: Class/Details/5
        public ActionResult Details(int id)
        {
            string url = "WoWClassData/FindClass/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            //catching status code
            if (response.IsSuccessStatusCode)
            {
                //add data
                WoWClass SelectedClass = response.Content.ReadAsAsync <WoWClass>().Result;
                Debug.WriteLine(SelectedClass.ClassName);
                //  ViewModel.Class = SelectedClass;
                url      = "compdata/getclassesforcomp/" + id;
                response = client.GetAsync(url).Result;
                return(View(SelectedClass));
            }
            return(RedirectToAction("List"));
        }
Esempio n. 24
0
        internal static void Initalize()
        {
            PlayerGuid        = StyxWoW.Me.Guid;
            IsAlliance        = StyxWoW.Me.IsAlliance;
            Level             = StyxWoW.Me.Level;
            Location          = StyxWoW.Me.Location;
            Rotation          = StyxWoW.Me.Rotation;
            Class             = StyxWoW.Me.Class;
            CurrentTargetGuid = StyxWoW.Me.CurrentTargetGuid;
            Combat            = StyxWoW.Me.Combat;
            ActuallyInCombat  = StyxWoW.Me.IsActuallyInCombat;
            TraceLinePosition = StyxWoW.Me.GetTraceLinePos();
            Inventory         = new PlayerInventory();
            Professions       = new PlayerProfessions();

            MinimapZoneText = new CachedValue <string>(() => StyxWoW.Me.MinimapZoneText);
            MapId           = new CachedValue <uint>(() => StyxWoW.Me.CurrentMap.MapId);
            ParentMapId     = new CachedValue <int>(() => StyxWoW.Me.CurrentMap.ParentMapId);
            MapExpansionId  = new CachedValue <uint>(() => StyxWoW.Me.CurrentMap.ExpansionId);
            MapIsContinent  = new CachedValue <bool>(() => StyxWoW.Me.CurrentMap.IsContinent);
            ZoneId          = new CachedValue <uint>(() => StyxWoW.Me.ZoneId);
            //
            GarrisonResource            = new CachedValue <int>(() => LuaCommands.GetCurrencyCount(824));
            CurrentPendingCursorSpellId = new CachedValue <int>(_updateCurrentPendingCursorSpellId);
            LastErrorMessage            = new CachedValue <string>(GetLastErrorMessage);

            LuaEvents.OnZoneChangedNewArea += () =>
            {
                MapId.Reset();
                ParentMapId.Reset();
                MapExpansionId.Reset();
                MapIsContinent.Reset();
                MinimapZoneText.Reset();
                ZoneId.Reset();
            };

            LuaEvents.OnZoneChanged             += () => MinimapZoneText.Reset();
            LuaEvents.OnCurrencyDisplayUpdate   += () => GarrisonResource.Reset();
            LuaEvents.OnCurrentSpellCastChanged += () => CurrentPendingCursorSpellId.Reset();
            LuaEvents.OnUiErrorMessage          += () => LastErrorMessage.Reset();

            Update();
        }
Esempio n. 25
0
        public static Color GetColorFromWoWClass(WoWClass wclass)
        {
            switch (wclass)
            {
            case WoWClass.None:
                return(Color.White);

            case WoWClass.DeathKnight:
                return(new Color(0.77f, 0.12f, 0.23f));

            case WoWClass.Druid:
                return(new Color(1.00f, 0.49f, 0.04f));

            case WoWClass.Hunter:
                return(new Color(0.67f, 0.83f, 0.45f));

            case WoWClass.Mage:
                return(new Color(0.41f, 0.80f, 0.94f));

            case WoWClass.Paladin:
                return(new Color(0.96f, 0.55f, 0.73f));

            case WoWClass.Priest:
                return(Color.White);

            case WoWClass.Rogue:
                return(new Color(1.00f, 0.96f, 0.41f));

            case WoWClass.Shaman:
                return(new Color(0.00f, 0.44f, 0.87f));

            case WoWClass.Warlock:
                return(new Color(0.58f, 0.51f, 0.79f));

            case WoWClass.Warrior:
                return(new Color(0.78f, 0.61f, 0.43f));

            default:
                return(Color.Black);
            }
        }
        public IHttpActionResult FindClass(int id)
        {
            //Getting data from DB
            WoWClass Class = db.Classes.Find(id);

            //returns 404 if not found
            if (Class == null)
            {
                return(NotFound());
            }

            //DTO
            WoWClass ClassDto = new WoWClass
            {
                ClassID   = Class.ClassID,
                ClassName = Class.ClassName,
                ClassPic  = Class.ClassPic,
            };

            return(Ok(ClassDto));
        }
        public ActionResult Create(WoWClass ClassInfo)
        {
            Debug.WriteLine(ClassInfo.ClassName);
            string url = "WoWClassData/addClass";

            Debug.WriteLine(jss.Serialize(ClassInfo));
            HttpContent content = new StringContent(jss.Serialize(ClassInfo));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                int Classid = response.Content.ReadAsAsync <int>().Result;
                return(RedirectToAction("Details", new { id = Classid }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Esempio n. 28
0
        public static Color GetClassColor(WoWClass Class)
        {
            switch ((int)Class)
            {
                case 1: // warrior
                    return Warrior;

                case 2: // paladin
                    return Paladin;

                case 3: // hunter
                    return Hunter;

                case 4: // rogue
                    return Rogue;

                case 5: // priest
                    return Priest;

                case 6: // death knight
                    return DeathKnight;

                case 7: // shaman
                    return Shaman;

                case 8: // mage
                    return Mage;

                case 9: // warlock
                    return Warlock;

                case 11: // druid
                    return Druid;

                default: // other
                    return Color.Green;
            }
        }
        private static bool IsMatchingMethod(BehaviorAttribute attribute, WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context)
        {
            if (attribute.SpecificClass != wowClass && attribute.SpecificClass != WoWClass.None)
            {
                return(false);
            }
            if ((attribute.Type & behavior) == 0)
            {
                return(false);
            }
            if ((attribute.SpecificContext & context) == 0)
            {
                return(false);
            }
            if (attribute.SpecificSpec != (WoWSpec)int.MaxValue && attribute.SpecificSpec != spec)
            {
                return(false);
            }

            /* Logger.WriteDebug("IsMatchingMethod({0}, {1}, {2}, {3}) - {4}, {5}, {6}, {7}, {8}", wowClass, spec, behavior,
             * context, attribute.SpecificClass, attribute.SpecificSpec, attribute.Type, attribute.SpecificContext,
             * attribute.PriorityLevel);  */
            return(true);
        }
Esempio n. 30
0
        public static void InvokeInitializers(WoWClass wowClass, WoWSpec spec, WoWContext context, bool silent = false)
        {
            BehaviorType behavior = BehaviorType.Initialize;

            if (context == WoWContext.None)
            {
                return;
            }

            SilentBehaviorCreation = silent;

            // only load methods once
            if (_methods.Count <= 0)
            {
                // Logger.WriteDebug("Singular Behaviors: building method list");
                foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
                {
                    // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite.
                    _methods.AddRange(
                        type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where(
                            mi => !mi.IsGenericMethod && mi.GetParameters().Length == 0).Where(
                                mi => mi.ReturnType.IsAssignableFrom(typeof(Composite))));
                }
                Logger.WriteFile("Singular Behaviors: Added " + _methods.Count + " behaviors");
            }

            // find all initialization methods for this class/spec/context
            var matchedMethods = new Dictionary<BehaviorAttribute, MethodInfo>();
            foreach (MethodInfo mi in _methods)
            {
                // If the behavior is set as ignore. Don't use it? Duh?
                if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any())
                    continue;

                // If there's no behavior attrib, then move along.
                foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false))
                {
                    var attribute = a as BehaviorAttribute;
                    if (attribute == null)
                        continue;

                    // Check if our Initialization behavior matches. If not, don't add it!
                    if (IsMatchingMethod(attribute, wowClass, spec, behavior, context))
                    {
                        if (matchedMethods.ContainsKey(attribute))
                        {
                            Logger.Write(LogColor.Hilite, "PROGRAM ERROR: duplicate behaviors. Notify Singular Devs!!!");
                            Logger.WriteDiagnostic("PROGRAM ERROR: duplicate behaviors. Notify Singular Devs!!!");
                            Logger.WriteDiagnostic("Error for Attribute: class={0} spec={1} type={2} context={3} priority={4} ",
                                attribute.SpecificClass,
                                attribute.SpecificSpec,
                                attribute.Type,
                                attribute.SpecificContext,
                                attribute.PriorityLevel
                                );
                            Logger.WriteDiagnostic("    exists {0}:{1}",
                                matchedMethods[attribute].DeclaringType,
                                matchedMethods[attribute].Name
                                );
                            Logger.WriteDiagnostic("    adding {0}:{1}",
                                mi.DeclaringType,
                                mi.Name
                                );
                        }

                        matchedMethods.Add( attribute, mi);
                    }
                }
            }

            // invoke each initialization behavior in priority order
            foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel))
            {
                CurrentBehaviorType = behavior;
                CurrentBehaviorPriority = kvp.Key.PriorityLevel;
                CurrentBehaviorName = kvp.Value.Name;
                string invokeInfo = string.Format("{0} {1} {2}", kvp.Key.PriorityLevel.ToString().AlignRight(5), behavior.ToString().AlignLeft(15), kvp.Value.Name);
                if (!silent)
                    Logger.WriteFile(invokeInfo);
                kvp.Value.Invoke(null, null);
                CurrentBehaviorType = 0;
                CurrentBehaviorPriority = 0;
                CurrentBehaviorName = string.Empty;
            }

            return;
        }
Esempio n. 31
0
        public static Composite GetComposite(WoWClass wowClass, TalentSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount)
        {
            behaviourCount = 0;
            if (_methods.Count <= 0)
            {
                Logger.Write("Building method list");
                foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
                {
                    _methods.AddRange(type.GetMethods(BindingFlags.Static | BindingFlags.Public));
                }
                Logger.Write("Added " + _methods.Count + " methods");
            }
            var matchedMethods = new Dictionary <int, PrioritySelector>();

            foreach (MethodInfo mi in
                     _methods.Where(
                         mi =>
                         !mi.IsGenericMethod &&
                         mi.GetParameters().Length == 0)
                     .Where(
                         mi =>
                         mi.ReturnType == typeof(Composite) ||
                         mi.ReturnType.IsSubclassOf(typeof(Composite))))
            {
                //Logger.WriteDebug("[CompositeBuilder] Checking attributes on " + mi.Name);
                bool classMatches = false, specMatches = false, behaviorMatches = false, contextMatches = false, hasIgnore = false;
                int  thePriority      = 0;
                var  theBehaviourType = BehaviorType.All;
                var  theIgnoreType    = BehaviorType.All;
                foreach (object ca in mi.GetCustomAttributes(false))
                {
                    if (ca is ClassAttribute)
                    {
                        var attrib = ca as ClassAttribute;
                        if (attrib.SpecificClass != WoWClass.None && attrib.SpecificClass != wowClass)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my class");
                        classMatches = true;
                    }
                    else if (ca is SpecAttribute)
                    {
                        var attrib = ca as SpecAttribute;
                        if (attrib.SpecificSpec != TalentSpec.Any && attrib.SpecificSpec != spec)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my spec");
                        specMatches = true;
                    }
                    else if (ca is BehaviorAttribute)
                    {
                        var attrib = ca as BehaviorAttribute;
                        if ((attrib.Type & behavior) == 0)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my behavior");
                        theBehaviourType = attrib.Type;
                        behaviourCount++;
                        behaviorMatches = true;
                    }
                    else if (ca is ContextAttribute)
                    {
                        var attrib = ca as ContextAttribute;

                        if (SingularSettings.Instance.UseInstanceRotation)
                        {
                            if ((attrib.SpecificContext & WoWContext.Instances) == 0)
                            {
                                continue;
                            }
                        }
                        else if ((attrib.SpecificContext & context) == 0)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my context");
                        contextMatches = true;
                    }
                    else if (ca is PriorityAttribute)
                    {
                        var attrib = ca as PriorityAttribute;
                        thePriority = attrib.PriorityLevel;
                    }
                    else if (ca is IgnoreBehaviorCountAttribute)
                    {
                        var attrib = ca as IgnoreBehaviorCountAttribute;
                        hasIgnore     = true;
                        theIgnoreType = attrib.Type;
                    }
                }

                if (behaviorMatches && hasIgnore && theBehaviourType == theIgnoreType)
                {
                    behaviourCount--;
                }

                // If all our attributes match, then mark it as wanted!
                if (classMatches && specMatches && behaviorMatches && contextMatches)
                {
                    Logger.WriteDebug("{0} is a match!", mi.Name);
                    if (!hasIgnore)
                    {
                        Logger.Write(" Using {0} for {1} - {2} (Priority: {3})", mi.Name, spec.ToString().CamelToSpaced().Trim(), behavior, thePriority);
                    }
                    else
                    {
                        Logger.WriteDebug(" Using {0} for {1} - {2} (Priority: {3})", mi.Name, spec.ToString().CamelToSpaced().Trim(), behavior, thePriority);
                    }
                    Composite matched;
                    try
                    {
                        matched = (Composite)mi.Invoke(null, null);
                    }
                    catch (Exception e)
                    {
                        Logger.Write("ERROR Creating composite: {0}\n{1}", mi.Name, e.StackTrace);
                        continue;
                    }
                    if (!matchedMethods.ContainsKey(thePriority))
                    {
                        matchedMethods.Add(thePriority, new PrioritySelector(matched));
                    }
                    else
                    {
                        matchedMethods[thePriority].AddChild(matched);
                    }
                }
            }
            // If we found no methods, rofls!
            if (matchedMethods.Count <= 0)
            {
                return(null);
            }

            var result = new PrioritySelector();

            foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key))
            {
                result.AddChild(kvp.Value);
            }

            return(result);

            // Return the composite match we found. (Note: ANY composite return is fine)
            return(matchedMethods.OrderByDescending(mm => mm.Key).First().Value);
        }
Esempio n. 32
0
        private static bool IsMatchingMethod(BehaviorAttribute attribute, WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context)
        {
            if (attribute.SpecificClass != wowClass && attribute.SpecificClass != WoWClass.None)
                return false;
            if ((attribute.Type & behavior) == 0)
                return false;
            if ((attribute.SpecificContext & context) == 0)
                return false;
            if (attribute.SpecificSpec != (WoWSpec)int.MaxValue && attribute.SpecificSpec != spec)
                return false;

            Logger.WriteDebug("IsMatchingMethod({0}, {1}, {2}, {3}) - {4}, {5}, {6}, {7}, {8}", wowClass, spec, behavior,
                context, attribute.SpecificClass, attribute.SpecificSpec, attribute.Type, attribute.SpecificContext,
                attribute.PriorityLevel);
            return true;
        }
Esempio n. 33
0
        public static Composite GetComposite(WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount, bool silent = false)
        {
            if (context == WoWContext.None)
            {
                // None is an invalid context, but rather than stopping bot wait it out with donothing logic
                Logger.Write( LogColor.Hilite, "No Active Context -{0}{1} for{2} set to DoNothingBehavior temporarily", wowClass.ToString().CamelToSpaced(), behavior.ToString().CamelToSpaced(), spec.ToString().CamelToSpaced());
                behaviourCount = 1;
                return NoContextAvailable.CreateDoNothingBehavior();
            }

            SilentBehaviorCreation = silent;
            behaviourCount = 0;
            var matchedMethods = new Dictionary<BehaviorAttribute, Composite>();

            foreach (MethodInfo mi in _methods)
            {
                // If the behavior is set as ignore. Don't use it? Duh?
                if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any())
                    continue;

                // If there's no behavior attrib, then move along.
                foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false))
                {
                    var attribute = a as BehaviorAttribute;
                    if (attribute == null)
                        continue;

                    // Check if our behavior matches with what we want. If not, don't add it!
                    if (IsMatchingMethod(attribute, wowClass, spec, behavior, context))
                    {
                        if (!silent)
                            Logger.WriteFile("{0} {1} {2}", attribute.PriorityLevel.ToString().AlignRight(4), behavior.ToString().AlignLeft(15), mi.Name);

                        CurrentBehaviorType = behavior;
                        CurrentBehaviorPriority = attribute.PriorityLevel;
                        CurrentBehaviorName = mi.Name;

                        // if it blows up here, you defined a method with the exact same attribute and priority as one already found

                        // wrap in trace class
                        Composite comp = mi.Invoke(null, null) as Composite;
                        string name = behavior.ToString() + "." + mi.Name + "." + attribute.PriorityLevel.ToString();

                        if (SingularSettings.Trace)
                            comp = new CallTrace( name, comp);

                        if (matchedMethods.ContainsKey(attribute))
                        {
                            Logger.Write(LogColor.Hilite, "Internal Error:  method '{0}' has attribute that already exists", name);
                            Logger.WriteDiagnostic(" ");
                            Logger.WriteDiagnostic("Dump Methods");
                            Logger.WriteDiagnostic("===========================");
                            foreach (var v in matchedMethods)
                            {
                                Logger.WriteDiagnostic("{0} {1} {2} {3}", v.Key.SpecificClass, v.Key.SpecificSpec, v.Key.SpecificContext, v.Key.PriorityLevel);
                            }
                            Logger.WriteDiagnostic("===========================");
                            Logger.WriteDiagnostic("{0} {1} {2} {3}  == add  attempt for {4}", attribute.SpecificClass, attribute.SpecificSpec, attribute.SpecificContext, attribute.PriorityLevel, name);
                            Logger.WriteDiagnostic(" ");
                        }

                        matchedMethods.Add(attribute, comp);

                        CurrentBehaviorType = 0;
                        CurrentBehaviorPriority = 0;
                        CurrentBehaviorName = string.Empty;
                    }
                }
            }
            // If we found no methods, rofls!
            if (matchedMethods.Count <= 0)
            {
                return null;
            }

            var result = new PrioritySelector();
            foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel))
            {
                result.AddChild(kvp.Value);
                behaviourCount++;
            }

            return result;
        }
Esempio n. 34
0
 public Behavior(WoWClass cl, WoWSpec sp, WoWContext cont)
 {
     _class = cl;
     _spec = sp;
     _context = cont;
 }
Esempio n. 35
0
 public MyTargetIsPlayerClassCondition(WoWClass playerClass)
 {
     PlayerClass = playerClass;
 }
Esempio n. 36
0
 public bool Match(WoWClass cl, WoWSpec sp, WoWContext cont)
 {
     return (cl == _class &&  cont == _context);
 }
Esempio n. 37
0
        public static void Update()
        {
            // Don't bother if we're < 10
            if (StyxWoW.Me.Level < 10)
            {
                CurrentSpec = TalentSpec.Lowbie;
                return;
            }
            WoWClass myClass = StyxWoW.Me.Class;
            int      treeOne = 0, treeTwo = 0, treeThree = 0;
            bool     isExtraSpec = false;

            // Keep the frame stuck so we can do a bunch of injecting at once.
            using (new FrameLock())
            {
                Talents.Clear();
                for (int tab = 1; tab <= 3; tab++)
                {
                    var numTalents = Lua.GetReturnVal <int>("return GetNumTalents(" + tab + ")", 0);
                    for (int index = 1; index <= numTalents; index++)
                    {
                        var rank = Lua.GetReturnVal <int>(string.Format("return GetTalentInfo({0}, {1})", tab, index), 4);
                        var t    = new Talent {
                            Tab = tab - 1, Index = index - 1, Count = rank
                        };
                        Talents.Add(t);

                        // Thick Hide - Only used by tanking druids
                        if (myClass == WoWClass.Druid && tab == 2 && index == 11 && rank != 0)
                        {
                            isExtraSpec = true;
                        }

                        // Renewed Hope
                        if (myClass == WoWClass.Priest && tab == 1 && index == 8 && rank != 0)
                        {
                            isExtraSpec = true;
                        }

                        switch (tab)
                        {
                        case 1:
                            treeOne += rank;
                            break;

                        case 2:
                            treeTwo += rank;
                            break;

                        case 3:
                            treeThree += rank;
                            break;
                        }
                    }
                }

                Glyphs.Clear();

                var glyphCount = Lua.GetReturnVal <int>("return GetNumGlyphSockets()", 0);

                if (glyphCount != 0)
                {
                    for (int i = 1; i <= glyphCount; i++)
                    {
                        List <string> glyphInfo = Lua.GetReturnValues(String.Format("return GetGlyphSocketInfo({0})", i));

                        if (glyphInfo != null && glyphInfo[3] != "nil" && !string.IsNullOrEmpty(glyphInfo[3]))
                        {
                            Glyphs.Add(WoWSpell.FromId(int.Parse(glyphInfo[3])).Name.Replace("Glyph of ", ""));
                        }
                    }
                }
            }

            if (treeOne == 0 && treeTwo == 0 && treeThree == 0)
            {
                CurrentSpec = TalentSpec.Lowbie;
                return;
            }

            int max = Math.Max(Math.Max(treeOne, treeTwo), treeThree);
            // Altarboy.Logger.Log("[Talents] Best Tree: " + max);
            // Altarboy.Logger.Log("[Talents] Is Special Spec: " + isExtraSpec);
            int specMask = ((int)StyxWoW.Me.Class << 8);

            // Bear tanks, healing disc priests, etc.
            if (isExtraSpec)
            {
                specMask += TalentFlagIsextraspec;
            }

            if (max == treeOne)
            {
                CurrentSpec = (TalentSpec)(specMask + 0);
            }
            else if (max == treeTwo)
            {
                CurrentSpec = (TalentSpec)(specMask + 1);
            }
            else
            {
                CurrentSpec = (TalentSpec)(specMask + 2);
            }
        }
        public static void InvokeInitializers(WoWClass wowClass, WoWSpec spec, WoWContext context, bool silent = false)
        {
            BehaviorType behavior = BehaviorType.Initialize;

            if (context == WoWContext.None)
            {
                return;
            }

            SilentBehaviorCreation = silent;

            // only load methods once
            if (_methods.Count <= 0)
            {
                // Logger.WriteDebug("Singular Behaviors: building method list");
                foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
                {
                    // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite.
                    _methods.AddRange(
                        type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where(
                            mi => !mi.IsGenericMethod && mi.GetCustomAttributes(typeof(BehaviorAttribute)).Any()).Where(
                            mi => typeof(Composite).IsAssignableFrom(mi.ReturnType) || mi.ReturnType == typeof(Task <bool>)));
                }
                Logger.WriteFile("Singular Behaviors: Added " + _methods.Count + " behaviors");
            }

            // find all initialization methods for this class/spec/context
            var matchedMethods = new Dictionary <BehaviorAttribute, MethodInfo>();

            foreach (MethodInfo mi in _methods)
            {
                // If the behavior is set as ignore. Don't use it? Duh?
                if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any())
                {
                    continue;
                }

                // If there's no behavior attrib, then move along.
                foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false))
                {
                    var attribute = a as BehaviorAttribute;
                    if (attribute == null)
                    {
                        continue;
                    }

                    // Check if our Initialization behavior matches. If not, don't add it!
                    if (IsMatchingMethod(attribute, wowClass, spec, behavior, context))
                    {
                        if (matchedMethods.ContainsKey(attribute))
                        {
                            Logger.Write(LogColor.Hilite, "PROGRAM ERROR: duplicate behaviors. Notify Singular Devs!!!");
                            Logger.WriteDiagnostic("PROGRAM ERROR: duplicate behaviors. Notify Singular Devs!!!");
                            Logger.WriteDiagnostic("Error for Attribute: class={0} spec={1} type={2} context={3} priority={4} ",
                                                   attribute.SpecificClass,
                                                   attribute.SpecificSpec,
                                                   attribute.Type,
                                                   attribute.SpecificContext,
                                                   attribute.PriorityLevel
                                                   );
                            Logger.WriteDiagnostic("    exists {0}:{1}",
                                                   matchedMethods[attribute].DeclaringType,
                                                   matchedMethods[attribute].Name
                                                   );
                            Logger.WriteDiagnostic("    adding {0}:{1}",
                                                   mi.DeclaringType,
                                                   mi.Name
                                                   );
                        }

                        matchedMethods.Add(attribute, mi);
                    }
                }
            }

            // invoke each initialization behavior in priority order
            foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel))
            {
                CurrentBehaviorType     = behavior;
                CurrentBehaviorPriority = kvp.Key.PriorityLevel;
                CurrentBehaviorName     = kvp.Value.Name;
                string invokeInfo = string.Format("{0} {1} {2}", kvp.Key.PriorityLevel.ToString().AlignRight(5), behavior.ToString().AlignLeft(15), kvp.Value.Name);
                if (!silent)
                {
                    Logger.WriteFile(invokeInfo);
                }
                kvp.Value.Invoke(null, null);
                CurrentBehaviorType     = 0;
                CurrentBehaviorPriority = 0;
                CurrentBehaviorName     = string.Empty;
            }

            return;
        }
Esempio n. 39
0
        public static Composite GetComposite(WoWClass wowClass, TalentSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount)
        {
            behaviourCount = 0;
            if (_methods.Count <= 0)
            {
                Logger.Write("Building method list");
                foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
                {
                    _methods.AddRange(type.GetMethods(BindingFlags.Static | BindingFlags.Public));
                }
                Logger.Write("Added " + _methods.Count + " methods");
            }
            var matchedMethods = new Dictionary<int, PrioritySelector>();
            foreach (MethodInfo mi in
                _methods.Where(
                    mi =>
                    !mi.IsGenericMethod &&
                    mi.GetParameters().Length == 0)
                    .Where(
                        mi =>
                        mi.ReturnType == typeof(Composite) ||
                        mi.ReturnType.IsSubclassOf(typeof(Composite))))
            {
                //Logger.WriteDebug("[CompositeBuilder] Checking attributes on " + mi.Name);
                bool classMatches = false, specMatches = false, behaviorMatches = false, contextMatches = false, hasIgnore = false;
                int thePriority = 0;
                var theBehaviourType = BehaviorType.All;
                var theIgnoreType = BehaviorType.All;
                foreach (object ca in mi.GetCustomAttributes(false))
                {
                    if (ca is ClassAttribute)
                    {
                        var attrib = ca as ClassAttribute;
                        if (attrib.SpecificClass != WoWClass.None && attrib.SpecificClass != wowClass)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my class");
                        classMatches = true;
                    }
                    else if (ca is SpecAttribute)
                    {
                        var attrib = ca as SpecAttribute;
                        if (attrib.SpecificSpec != TalentSpec.Any && attrib.SpecificSpec != spec)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my spec");
                        specMatches = true;
                    }
                    else if (ca is BehaviorAttribute)
                    {
                        var attrib = ca as BehaviorAttribute;
                        if ((attrib.Type & behavior) == 0)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my behavior");
                        theBehaviourType = attrib.Type;
                        behaviourCount++;
                        behaviorMatches = true;
                    }
                    else if (ca is ContextAttribute)
                    {
                        var attrib = ca as ContextAttribute;

                        if (SingularSettings.Instance.UseInstanceRotation)
                        {
                            if ((attrib.SpecificContext & WoWContext.Instances) == 0)
                                continue;
                        }
                        else if ((attrib.SpecificContext & context) == 0)
                        {
                             continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my context");
                        contextMatches = true;
                    }
                    else if (ca is PriorityAttribute)
                    {
                        var attrib = ca as PriorityAttribute;
                        thePriority = attrib.PriorityLevel;
                    }
                    else if (ca is IgnoreBehaviorCountAttribute)
                    {
                        var attrib = ca as IgnoreBehaviorCountAttribute;
                        hasIgnore = true;
                        theIgnoreType = attrib.Type;
                    }
                }

                if (behaviorMatches && hasIgnore && theBehaviourType == theIgnoreType)
                {
                    behaviourCount--;
                }

                // If all our attributes match, then mark it as wanted!
                if (classMatches && specMatches && behaviorMatches && contextMatches)
                {
                    Logger.WriteDebug("{0} is a match!", mi.Name);
                    if (!hasIgnore)
                    {
                        Logger.Write(" Using {0} for {1} - {2} (Priority: {3})", mi.Name, spec.ToString().CamelToSpaced().Trim(), behavior, thePriority);
                    }
                    else
                    {
                        Logger.WriteDebug(" Using {0} for {1} - {2} (Priority: {3})", mi.Name, spec.ToString().CamelToSpaced().Trim(), behavior, thePriority);
                    }
                    Composite matched;
                    try
                    {
                        matched = (Composite) mi.Invoke(null, null);
                    }
                    catch (Exception e)
                    {
                        Logger.Write("ERROR Creating composite: {0}\n{1}", mi.Name, e.StackTrace);
                        continue;
                    }
                    if (!matchedMethods.ContainsKey(thePriority))
                    {
                        matchedMethods.Add(thePriority, new PrioritySelector(matched));
                    }
                    else
                    {
                        matchedMethods[thePriority].AddChild(matched);
                    }
                }
            }
            // If we found no methods, rofls!
            if (matchedMethods.Count <= 0)
            {
                return null;
            }

            // Return the composite match we found. (Note: ANY composite return is fine)
            return matchedMethods.OrderByDescending(mm => mm.Key).First().Value;
        }
Esempio n. 40
0
        /// <summary>
        /// populates the cboHealContext dropdown with an object list of all healing context setups
        /// that apply to current character.  will initially clear the list, then populate, and
        /// finally set the current context as selected (or first in list if not applicable)
        /// </summary>
        /// <param name="cls"></param>
        private void InitializeHealContextDropdown(WoWClass cls)
        {
            cboHealContext.Items.Clear();
            if (cls == WoWClass.Shaman)
            {
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.ShamanRestoration, SingularSettings.Instance.Shaman().Battleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.ShamanRestoration, SingularSettings.Instance.Shaman().Instance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.ShamanRestoration, SingularSettings.Instance.Shaman().Raid));
            }

            if (cls == WoWClass.Druid)
            {
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.DruidRestoration, SingularSettings.Instance.Druid().Battleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.DruidRestoration, SingularSettings.Instance.Druid().Instance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.DruidRestoration, SingularSettings.Instance.Druid().Raid));
            }

            if (cls == WoWClass.Priest)
            {
/*
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscInstance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscRaid));
 */ 
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.PriestHoly, SingularSettings.Instance.Priest().HolyBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.PriestHoly, SingularSettings.Instance.Priest().HolyInstance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.PriestHoly, SingularSettings.Instance.Priest().HolyRaid));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscInstance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscRaid));
            }

            bool needHealPage = cboHealContext.Items.Count > 0;
            cboHealContext.Enabled = needHealPage;
            if (needHealPage && !tabControl1.TabPages.Contains(tabGroupHeal))
                tabControl1.TabPages.Insert(2, tabGroupHeal);
            else if (!needHealPage && tabControl1.TabPages.Contains(tabGroupHeal))
                tabControl1.TabPages.Remove(tabGroupHeal);

            foreach (var obj in cboHealContext.Items)
            {
                HealContextItem ctx = (HealContextItem)obj;
                if (ctx.Spec == StyxWoW.Me.Specialization)
                {
                    if (ctx.Context == SingularRoutine.CurrentHealContext)
                    {
                        cboHealContext.SelectedItem = ctx;
                        break;
                    }
                    if (SingularRoutine.CurrentHealContext == HealingContext.Normal && ctx.Spec == WoWSpec.PriestHoly && ctx.Context == HealingContext.Instances)
                    {
                        cboHealContext.SelectedItem = ctx;
                        break;
                    }
                    if (SingularRoutine.CurrentHealContext == HealingContext.Normal && ctx.Spec == WoWSpec.PriestDiscipline && ctx.Context == HealingContext.Instances)
                    {
                        cboHealContext.SelectedItem = ctx;
                        break;
                    }
                }
            }

            if (cboHealContext.SelectedItem == null && cboHealContext.Items.Count > 0)
            {
                    cboHealContext.SelectedIndex = 0;
            }
        }
Esempio n. 41
0
        public static Composite GetComposite(WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount, bool silent = false)
        {
            if (context == WoWContext.None)
            {
                // None is an invalid context, but rather than stopping bot wait it out with donothing logic
                Logger.Write(Color.White, "No Active Context -{0}{1} for{2} set to DoNothingBehavior temporarily", wowClass.ToString().CamelToSpaced(), behavior.ToString().CamelToSpaced(), spec.ToString().CamelToSpaced());
                behaviourCount = 1;
                return NoContextAvailable.CreateDoNothingBehavior();
            }

            SilentBehaviorCreation = silent;
            behaviourCount = 0;
            if (_methods.Count <= 0)
            {
                // Logger.WriteDebug("Singular Behaviors: building method list");
                foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
                {
                    // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite.
                    _methods.AddRange(
                        type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where(
                            mi => !mi.IsGenericMethod && mi.GetParameters().Length == 0).Where(
                                mi => mi.ReturnType.IsAssignableFrom(typeof (Composite))));
                }
                Logger.WriteFile("Singular Behaviors: Added " + _methods.Count + " behaviors");
            }

            var matchedMethods = new Dictionary<BehaviorAttribute, Composite>();

            foreach (MethodInfo mi in _methods)
            {
                // If the behavior is set as ignore. Don't use it? Duh?
                if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any())
                    continue;

                // If there's no behavior attrib, then move along.
                foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false))
                {
                    var attribute = a as BehaviorAttribute;
                    if (attribute == null)
                        continue;

                    // Check if our behavior matches with what we want. If not, don't add it!
                    if (IsMatchingMethod(attribute, wowClass, spec, behavior, context))
                    {
                        if (!silent)
                            Logger.WriteFile("{0} {1} {2}", attribute.PriorityLevel.ToString().AlignRight(4), behavior.ToString().AlignLeft(15), mi.Name);

                        CurrentBehaviorType = behavior;

                        // if it blows up here, you defined a method with the exact same attribute and priority as one already found

                        // wrap in trace class
                        Composite comp = mi.Invoke(null, null) as Composite;
                        string name = behavior.ToString() + "." + mi.Name + "." + attribute.PriorityLevel.ToString();

                        if (SingularSettings.Trace)
                            comp = new CallTrace( name, comp);

                        matchedMethods.Add(attribute, comp);

                        CurrentBehaviorType = 0;
                    }
                }
            }
            // If we found no methods, rofls!
            if (matchedMethods.Count <= 0)
            {
                return null;
            }

            var result = new PrioritySelector();
            foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel))
            {
                result.AddChild(kvp.Value);
                behaviourCount++;
            }

            return result;
        }
Esempio n. 42
0
 public ClassAttribute(WoWClass specificClass)
 {
     SpecificClass = specificClass;
 }
Esempio n. 43
0
 public ClassAttribute(WoWClass specificClass)
 {
     SpecificClass = specificClass;
 }
Esempio n. 44
0
 public bool Match(WoWClass cl, WoWSpec sp, WoWContext cont)
 {
     return(cl == _class && cont == _context);
 }
 public MyTargetIsPlayerClassCondition(WoWClass playerClass)
 {
     PlayerClass = playerClass;
 }
Esempio n. 46
0
        private static void InitPvPBotBasedonClass(string[] args, WoWClass myclass) {
            switch (myclass) {
                case WoWClass.Druid:
                    DruidDPS mydbot = new DruidDPS(wow, ClientInfo, 100);
                    break;
                case WoWClass.Warlock:
                    if (args.Length > 1) {
                        WarlockDemoPVEDPS mywbot = new WarlockDemoPVEDPS(wow, ClientInfo, 100, 1);
                    }
                    else {
                        WarlockDPS mywbot = new WarlockDPS(wow, ClientInfo, 100);
                    }
                    break;
                case WoWClass.DeathKnight:
                    DeathKnightBloodDPS mydkbot = new DeathKnightBloodDPS(wow, ClientInfo, 100);
                    break;
                case WoWClass.Paladin:
                    PaladinDPS mypbot = new PaladinDPS(wow, ClientInfo, 100);
                    break;
                case WoWClass.Mage:
                    MageFireDPS mymbot = new MageFireDPS(wow, ClientInfo, 100);
                    break;
                case WoWClass.Shaman:
                    ShamanRestoPartyHeal mysbot = new ShamanRestoPartyHeal(wow, ClientInfo, 100, 1);
                    break;
                case WoWClass.Priest:
                    PriestDiscPartyHeal mypdbot = new PriestDiscPartyHeal(wow, ClientInfo, 200);
                    break;
                case WoWClass.Warrior:
                    WarriTank mypwbot = new WarriTank(wow, ClientInfo, 100);
                    break;

            }
        }
Esempio n. 47
0
        public void ContextChange(object sender, LuaEventArgs args)
        {
            talent.Reset();
            glyph.Reset();
            spell.Reset();
            line_cds.Clear();
            PlayerAuras.Reset();
            PetAuras.Reset();

            _class = StyxWoW.Me.Class;
            //_spec = Me.Specialization;

            var oldctx = Context;
            Context = (StyxWoW.Me.CurrentMap.IsArena || StyxWoW.Me.CurrentMap.IsBattleground)
                ? WoWContext.PvP
                : WoWContext.PvE;
            if (Context != oldctx) SimcraftImpl.Write("Switching to " + Context + " Mode");

            ooc = DateTime.Now;
            RebuildBehaviors();
        }
Esempio n. 48
0
 private static void InitPvEBotBasedonClass(string[] args, WoWClass myclass) {
     switch (myclass) {
         case WoWClass.Druid:
             DruidFeralComplex mydbot = new DruidFeralComplex(100, 2);
             break;
         case WoWClass.Warlock:
             WarlockDemoComplex mywbot = new WarlockDemoComplex(100, 100);
             break;
         case WoWClass.DeathKnight:
             DeathKnightBloodTank mydkbot = new DeathKnightBloodTank(wow, ClientInfo, 100);
             break;
         case WoWClass.Paladin:
             PaladinRetriComplex mypbot = new PaladinRetriComplex(100, 2);
             break;
         case WoWClass.Mage:
             MageFireComplex mymbot = new MageFireComplex( 100, 20);
             break;
         case WoWClass.Shaman:
             if (new WoWRaid(wow).Raidmembercount > 0) {
                 ShamanRestoRaid10Heal mypdbot = new ShamanRestoRaid10Heal(wow, ClientInfo, 100, 10);
             }
             else {
                 ShamanRestoPartyHeal mysbot = new ShamanRestoPartyHeal(wow, ClientInfo, 100, 10);
             }
             break;
         case WoWClass.Priest:
             if (new WoWRaid(wow).Raidmembercount > 0) {
                 PriestDiscRaid10Heal mypdbot = new PriestDiscRaid10Heal(wow, ClientInfo, 100, 50);
             }
             else {
                 PriestDiscPartyHeal mypdbot = new PriestDiscPartyHeal(wow, ClientInfo, 100);
             }
             break;
         case WoWClass.Rogue:
             RogueComplex myrbot = new RogueComplex(100, 100);
             break;
         case WoWClass.Warrior:
             WarriTank mypwbot = new WarriTank(wow, ClientInfo, 100);
             break;
     }
 }
Esempio n. 49
0
        /// <summary>
        /// populates the cboHealContext dropdown with an object list of all healing context setups
        /// that apply to current character.  will initially clear the list, then populate, and
        /// finally set the current context as selected (or first in list if not applicable)
        /// </summary>
        /// <param name="cls"></param>
        private void InitializeHealContextDropdown(WoWClass cls)
        {
            cboHealContext.Items.Clear();
            if (cls == WoWClass.Shaman)
            {
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.ShamanRestoration, SingularSettings.Instance.Shaman().RestoBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.ShamanRestoration, SingularSettings.Instance.Shaman().RestoInstance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.ShamanRestoration, SingularSettings.Instance.Shaman().RestoRaid));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.None, SingularSettings.Instance.Shaman().OffhealBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.None, SingularSettings.Instance.Shaman().OffhealPVE));
            }

            if (cls == WoWClass.Druid)
            {
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.DruidRestoration, SingularSettings.Instance.Druid().Battleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.DruidRestoration, SingularSettings.Instance.Druid().Instance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.DruidRestoration, SingularSettings.Instance.Druid().Raid));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.None, SingularSettings.Instance.Druid().OffhealBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.None, SingularSettings.Instance.Druid().OffhealPVE));
            }

            if (cls == WoWClass.Monk)
            {
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.MonkMistweaver, SingularSettings.Instance.Monk().MistBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.MonkMistweaver, SingularSettings.Instance.Monk().MistInstance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.MonkMistweaver, SingularSettings.Instance.Monk().MistRaid));
            }

            if (cls == WoWClass.Priest)
            {
/*
 *              cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscBattleground));
 *              cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscInstance));
 *              cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscRaid));
 */
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.PriestHoly, SingularSettings.Instance.Priest().HolyBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.PriestHoly, SingularSettings.Instance.Priest().HolyInstance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.PriestHoly, SingularSettings.Instance.Priest().HolyRaid));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Battlegrounds, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscBattleground));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Instances, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscInstance));
                cboHealContext.Items.Add(new HealContextItem(HealingContext.Raids, WoWSpec.PriestDiscipline, SingularSettings.Instance.Priest().DiscRaid));
            }

            bool needHealPage = cboHealContext.Items.Count > 0;

            cboHealContext.Enabled = needHealPage;
            if (needHealPage && !tabControl1.TabPages.Contains(tabGroupHeal))
            {
                tabControl1.TabPages.Insert(2, tabGroupHeal);
            }
            else if (!needHealPage && tabControl1.TabPages.Contains(tabGroupHeal))
            {
                tabControl1.TabPages.Remove(tabGroupHeal);
            }

            foreach (var obj in cboHealContext.Items)
            {
                HealContextItem ctx = (HealContextItem)obj;
                if (ctx.Spec == TalentManager.CurrentSpec)
                {
                    if (ctx.Context == SingularRoutine.CurrentHealContext)
                    {
                        cboHealContext.SelectedItem = ctx;
                        break;
                    }
                    if (SingularRoutine.CurrentHealContext == HealingContext.Normal && ctx.Spec == WoWSpec.PriestHoly && ctx.Context == HealingContext.Instances)
                    {
                        cboHealContext.SelectedItem = ctx;
                        break;
                    }
                    if (SingularRoutine.CurrentHealContext == HealingContext.Normal && ctx.Spec == WoWSpec.PriestDiscipline && ctx.Context == HealingContext.Instances)
                    {
                        cboHealContext.SelectedItem = ctx;
                        break;
                    }
                }
            }

            if (cboHealContext.SelectedItem == null && cboHealContext.Items.Count > 0)
            {
                foreach (var obj in cboHealContext.Items)
                {
                    HealContextItem ctx = (HealContextItem)obj;
                    if (ctx.Spec == WoWSpec.None)
                    {
                        if (ctx.Context == SingularRoutine.CurrentHealContext)
                        {
                            cboHealContext.SelectedItem = ctx;
                            break;
                        }
                        if (ctx.Context != HealingContext.Battlegrounds && HealingContext.Battlegrounds != SingularRoutine.CurrentHealContext)
                        {
                            cboHealContext.SelectedItem = ctx;
                            break;
                        }
                        if (SingularRoutine.CurrentHealContext == HealingContext.Normal && ctx.Spec == WoWSpec.PriestDiscipline && ctx.Context == HealingContext.Instances)
                        {
                            cboHealContext.SelectedItem = ctx;
                            break;
                        }
                    }
                }
            }

            if (cboHealContext.SelectedItem == null && cboHealContext.Items.Count > 0)
            {
                cboHealContext.SelectedIndex = 0;
            }
        }
Esempio n. 50
0
 public static List<Brain> BrainsForClass(WoWClass wowclass)
 {
     if (!Manager.IsInGame)
         return BrainPool;
     return BrainPool.Where(b => b.Class == Manager.LocalPlayer.Class).ToList();
 }
        public override void Initialize()
        {
            //Caching current class here to avoid issues with loading screens where Class return None and we cant build behaviors
            _myClass = Me.Class;

            Logger.Write("Starting Singular v" + Assembly.GetExecutingAssembly().GetName().Version);
            Logger.Write("Determining talent spec.");
            try
            {
                TalentManager.Update();
            }
            catch (Exception e)
            {
                StopBot(e.ToString());
            }
            Logger.Write("Current spec is " + TalentManager.CurrentSpec.ToString().CamelToSpaced());

            if (!CreateBehaviors())
            {
                return;
            }
            Logger.Write("Behaviors created!");

            // When we actually need to use it, we will.
            EventHandlers.Init();
            MountManager.Init();
            //Logger.Write("Combat log event handler started.");
        }
Esempio n. 52
0
 public RadarUnit(Vector2 pos, float rot, WoWClass wclass) {
     this.DrawColor = RadarUnit.GetColorFromWoWClass(wclass);
     this.Position = pos;
     this.Rotation = rot;
 }
Esempio n. 53
0
        public static TalentTree FromXml(XElement root)
        {
            if (root == null)
            {
                throw new Exception("Element passed in to TalenTree.FromXml can't be null!");
            }

            XAttribute specializationAttribute = root.Attribute("Specialization");

            if (specializationAttribute == null)
            {
                throw new Exception("TalenTree element needs a Spcialization attribute!: " + root);
            }

            string     buildName     = "";
            XAttribute nameAttribute = root.Attribute("Name");

            if (nameAttribute != null)
            {
                buildName = nameAttribute.Value;
            }

            WoWClass   @wowClass         = WoWClass.None;
            XAttribute wowClassAttribute = root.Attribute("Class");

            if (wowClassAttribute != null)
            {
                try
                {
                    @wowClass = (WoWClass)Enum.Parse(typeof(WoWClass), wowClassAttribute.Value);
                }
                catch (Exception ex)
                {
                    Logging.WriteException(ex);
                }
            }

            int specializationIndex;

            if (!int.TryParse(specializationAttribute.Value, out specializationIndex))
            {
                throw new Exception("Could not parse integer in 'Specialization' attribute in TalentTree element.");
            }

            var talentPlacements = new List <TalentPlacement>();
            var talents          = root.Elements("Talent");

            foreach (XElement element in talents)
            {
                int    tab = 0, index = 0, count = 0;
                string name = "";

                foreach (XAttribute attribute in element.Attributes())
                {
                    switch (attribute.Name.ToString().ToLower())
                    {
                    case "tab":
                        if (!int.TryParse(attribute.Value, out tab))
                        {
                            throw new Exception("Could not parse integer in 'Tab' attribute in Talent element: " + element);
                        }
                        break;

                    case "index":
                        if (!int.TryParse(attribute.Value, out index))
                        {
                            throw new Exception("Could not parse integer in 'Index' attribute in Talent element: " + element);
                        }
                        break;

                    case "count":
                        if (!int.TryParse(attribute.Value, out count))
                        {
                            throw new Exception("Could not parse integer in 'Count' attribute in Talent element: " + element);
                        }
                        break;

                    case "name":
                        name = attribute.Value;
                        break;
                    }
                }

                talentPlacements.Add(new TalentPlacement(tab, index, count, name));
            }

            return(new TalentTree(specializationIndex, talentPlacements, @wowClass, buildName));
        }
Esempio n. 54
0
 public BrainInfo(WoWClass wowclass, string specialization)
 {
     Class = wowclass;
     Specialization = specialization;
 }
Esempio n. 55
0
 public Behavior(WoWClass cl, WoWSpec sp, WoWContext cont)
 {
     _class   = cl;
     _spec    = sp;
     _context = cont;
 }
Esempio n. 56
0
        public static Composite GetComposite(object createFrom, WoWClass wowClass, TalentSpec spec, BehaviorType behavior, WoWContext context)
        {
            MethodInfo[] methods = createFrom.GetType().GetMethods();
            var matchedMethods = new Dictionary<int, PrioritySelector>();
            foreach (MethodInfo mi in
                methods.Where(
                    mi =>
                    !mi.IsGenericMethod &&
                    mi.GetParameters().Length == 0)
                    .Where(
                        mi =>
                        mi.ReturnType == typeof(Composite) ||
                        mi.ReturnType.IsSubclassOf(typeof(Composite))))
            {
                //Logger.WriteDebug("[CompositeBuilder] Checking attributes on " + mi.Name);
                bool classMatches = false, specMatches = false, behaviorMatches = false, contextMatches = false;
                int thePriority = 0;
                foreach (object ca in mi.GetCustomAttributes(false))
                {
                    if (ca is ClassAttribute)
                    {
                        var attrib = ca as ClassAttribute;
                        if (attrib.SpecificClass != wowClass)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my class");
                        classMatches = true;
                    }
                    else if (ca is SpecAttribute)
                    {
                        var attrib = ca as SpecAttribute;
                        if (attrib.SpecificSpec != spec)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my spec");
                        specMatches = true;
                    }
                    else if (ca is BehaviorAttribute)
                    {
                        var attrib = ca as BehaviorAttribute;
                        if (attrib.Type != behavior)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my behavior");
                        behaviorMatches = true;
                    }
                    else if (ca is ContextAttribute)
                    {
                        var attrib = ca as ContextAttribute;
                        if ((attrib.SpecificContext & context) == 0)
                        {
                            continue;
                        }
                        //Logger.WriteDebug(mi.Name + " has my context");
                        contextMatches = true;
                    }
                    else if (ca is PriorityAttribute)
                    {
                        var attrib = ca as PriorityAttribute;
                        thePriority = attrib.PriorityLevel;
                    }
                }

                // If all our attributes match, then mark it as wanted!
                if (classMatches && specMatches && behaviorMatches && contextMatches)
                {
                    Logger.WriteDebug(string.Format("{0} is a match!", mi.Name));
                    Logger.Write(string.Format("Using {0} for {1} - {2} (Priority: {3})", mi.Name, spec.ToString().CamelToSpaced().Trim(), behavior, thePriority));
                    Composite matched = null;
                    try
                    {
                        matched = (Composite) mi.Invoke(createFrom, null);
                    }
                    catch (Exception e)
                    {
                        Logger.Write("ERROR Creating composite: " + mi.Name);
                        Logger.Write(e.StackTrace);
                        continue;
                    }
                    if (!matchedMethods.ContainsKey(thePriority))
                    {
                        matchedMethods.Add(thePriority, new PrioritySelector(matched));
                    }
                    else
                    {
                        matchedMethods[thePriority].AddChild(matched);
                    }
                }
            }
            // If we found no methods, rofls!
            if (matchedMethods.Count <= 0)
            {
                return null;
            }
            // Return a sorted list of our created composites
            return new PrioritySelector(matchedMethods.OrderByDescending(mm => mm.Key).Select(mm => mm.Value).ToArray());
        }