Ejemplo n.º 1
0
        private string GetLeanItemLink(ItemSlot _Slot, string _ItemLink)
        {
            if (_ItemLink == "0")
            {
                return("");
            }
            var newItemLink = _ItemLink;

            try
            {
                while ((newItemLink.EndsWith(":0") || newItemLink.EndsWith("x0")) && newItemLink.Length > 2)
                {
                    newItemLink = newItemLink.Substring(0, newItemLink.Length - 2);
                }
                while (newItemLink.EndsWith(":") || newItemLink.EndsWith("x"))
                {
                    newItemLink = newItemLink.Substring(0, newItemLink.Length - 1);
                }
                if (newItemLink == "0" || newItemLink == "")
                {
                    return("");
                }
                return(_Slot.ToString() + "x" + newItemLink);
            }
            catch (Exception)
            {
                return(_Slot.ToString() + "x" + _ItemLink);
            }
        }
Ejemplo n.º 2
0
        public void AddLeanItemLink(ref string _ItemStr, ItemSlot _Slot, string _ItemLink)
        {
            var leanItemLink = GetLeanItemLink(_Slot, _ItemLink);

            if (leanItemLink != "")
            {
                _ItemStr = _ItemStr + leanItemLink + "+";
            }
        }
Ejemplo n.º 3
0
        public PlayerData.ItemInfo GenerateItemInfo(ItemSlot _Slot, SQLGemInfo _GemInfo)
        {
            int[] gemIDs = new int[4];
            gemIDs[0] = _GemInfo.GemID1;
            gemIDs[1] = _GemInfo.GemID2;
            gemIDs[2] = _GemInfo.GemID3;
            gemIDs[3] = _GemInfo.GemID4;

            return(GenerateItemInfo(_Slot, gemIDs));
        }
Ejemplo n.º 4
0
 public PlayerData.ItemInfo GenerateItemInfo(ItemSlot _Slot, int[] _GemIDs = null)
 {
     PlayerData.ItemInfo itemInfo = new PlayerData.ItemInfo();
     itemInfo.Slot      = _Slot;
     itemInfo.ItemID    = ItemID;
     itemInfo.EnchantID = EnchantID;
     itemInfo.SuffixID  = SuffixID;
     itemInfo.UniqueID  = UniqueID;
     itemInfo.GemIDs    = _GemIDs;
     return(itemInfo);
 }
Ejemplo n.º 5
0
        public bool GetPlayerGearGems(SQLPlayerData _PlayerData, out SQLPlayerGearGems _ResultGearGems)
        {
            var conn = OpenConnection();

            try
            {
                const int ITEMSLOT_COLUMN = 0;
                const int GEMID1_COLUMN   = 1;
                const int GEMID2_COLUMN   = 2;
                const int GEMID3_COLUMN   = 3;
                const int GEMID4_COLUMN   = 4;
                using (var cmd = new NpgsqlCommand("SELECT itemslot, gemid1, gemid2, gemid3, gemid4 FROM PlayerGearGemsTable WHERE gearid=:ID", conn))
                {
                    {
                        var idParam = new NpgsqlParameter("ID", NpgsqlDbType.Integer);
                        idParam.Value = (int)_PlayerData.PlayerGearID;
                        cmd.Parameters.Add(idParam);
                    }
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows == true)
                        {
                            _ResultGearGems = SQLPlayerGearGems.CreateEmpty();
                            while (reader.Read() == true)
                            {
                                SQLGemInfo gemInfo  = new SQLGemInfo();
                                ItemSlot   itemSlot = (ItemSlot)reader.GetInt16(ITEMSLOT_COLUMN);
                                gemInfo.GemID1 = reader.GetInt32(GEMID1_COLUMN);
                                gemInfo.GemID2 = reader.GetInt32(GEMID2_COLUMN);
                                gemInfo.GemID3 = reader.GetInt32(GEMID3_COLUMN);
                                gemInfo.GemID4 = reader.GetInt32(GEMID4_COLUMN);
                                _ResultGearGems.Gems.Add(itemSlot, gemInfo);
                            }
                            return(true);
                        }
                    }
                }
            }
            finally
            {
                CloseConnection();
            }
            _ResultGearGems = SQLPlayerGearGems.CreateEmpty();
            return(false);
        }
Ejemplo n.º 6
0
        public bool GetModelViewerIDAndSlot(ItemSlot _ItemSlot, out int _RetModelViewerID, out int _RetModelViewerSlot, bool _RefreshIfNotFound = true)
        {
            if (ItemModelViewerID == 0 || ItemModelViewerSlot == 0)
            {
                if (_RefreshIfNotFound == false)
                {
                    _RetModelViewerID   = 0;
                    _RetModelViewerSlot = 0;
                    return(false);
                }
                if (_ItemSlot != ItemSlot.Unknown)
                {
                    if (sm_ItemSlotToModelSlotConverter.ContainsKey(_ItemSlot) == false)
                    {
                        _RetModelViewerID   = 0;
                        _RetModelViewerSlot = 0;
                        return(false);
                    }
                    if (sm_ItemIDsRequireWowheadModel.Contains(int.Parse(ItemID)) == false && _ItemSlot != ItemSlot.Chest)
                    {
                        _RetModelViewerID   = GetModelID(true);
                        _RetModelViewerSlot = sm_ItemSlotToModelSlotConverter[_ItemSlot];
                        return(true);
                    }
                }

                {
                    try
                    {
                        if (UnableToGetViewerID == true)
                        {
                            throw new Exception("");
                        }
                        var webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://www.wowhead.com/item=" + ItemID + "&xml");
                        webRequest.Timeout          = 5000;
                        webRequest.ReadWriteTimeout = 5000;
                        webRequest.UserAgent        = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36";
                        webRequest.Proxy            = null;
                        using (var webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse())
                        {
                            using (System.IO.StreamReader reader = new System.IO.StreamReader(webResponse.GetResponseStream()))
                            {
                                string xmlItemData         = reader.ReadToEnd();
                                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                                doc.LoadXml(xmlItemData);
                                var    rootElement = doc.DocumentElement;
                                string jsonCDATA   = rootElement["item"]["json"].InnerText;
                                if (rootElement["item"]["icon"].Attributes[0].Name == "displayId")
                                {
                                    ItemModelViewerID = int.Parse(rootElement["item"]["icon"].Attributes[0].Value);
                                }
                                else
                                {
                                    throw new Exception("");
                                }

                                int    slotbakIndex = jsonCDATA.IndexOf("\"slotbak\":") + "\"slotbak\":".Length;
                                string slotbak      = jsonCDATA.Substring(slotbakIndex, jsonCDATA.IndexOf(',', slotbakIndex) - slotbakIndex);
                                ItemModelViewerSlot = short.Parse(slotbak);

                                //if(rootElement["item"]["inventorySlot"].Attributes[0].Name == "id")
                                //    ItemModelViewerSlot = short.Parse(rootElement["item"]["inventorySlot"].Attributes[0].Value);
                                //else
                                //    throw new Exception("");

                                Logger.ConsoleWriteLine("GetModelViewerIDAndSlot(): Successfully grabbed new data from Wowhead for ItemID: " + ItemID, ConsoleColor.Green);
                                Hidden.ApplicationInstance.Instance.m_ItemInfoUpdated = true;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        UnableToGetViewerID = true;
                        Logger.ConsoleWriteLine("GetModelViewerIDAndSlot(): Exception was thrown, failed to grab new data from Wowhead for ItemID: " + ItemID + ", ExceptionData: " + ex.ToString(), ConsoleColor.Red);
                        _RetModelViewerID   = 0;
                        _RetModelViewerSlot = 0;
                        return(false);
                    }
                }
            }
            _RetModelViewerID   = ItemModelViewerID;
            _RetModelViewerSlot = ItemModelViewerSlot;
            return(true);
        }
Ejemplo n.º 7
0
 static string GenerateGearDataStr(int _ItemID, ItemSlot _Slot)
 {
     return(((int)_Slot).ToString() + ":" + _ItemID.ToString() + ":0:0:0");
 }