Ejemplo n.º 1
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.º 2
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.º 3
0
        public int GenerateNewPlayerGearDataEntry(PlayerData.GearData _GearData, WowVersionEnum _WowVersion)
        {
            if (_GearData == null)
            {
                return(0);
            }

            Dictionary <ItemSlot, SQLIngameItemID> ingameItemIDs = new Dictionary <ItemSlot, SQLIngameItemID>();

            foreach (ItemSlot slot in Enum.GetValues(typeof(ItemSlot)))
            {
                ingameItemIDs.Add(slot, new SQLIngameItemID(0));
            }
            foreach (var item in _GearData.Items)
            {
                SQLIngameItemID itemID = GenerateNewIngameItemEntry(new SQLIngameItemInfo(item.Value));
                ingameItemIDs.AddOrSet(item.Key, itemID);
            }

            int gearDataEntryID = 0;
            var conn            = OpenConnection();

            try
            {
                using (var cmd = new NpgsqlCommand("INSERT INTO playergeartable(id, head, neck, shoulder, shirt, chest, belt, legs, feet, wrist, gloves, finger_1, finger_2, trinket_1, trinket_2, back, main_hand, off_hand, ranged, tabard) VALUES (DEFAULT, :Head, :Neck, :Shoulder, :Shirt, :Chest, :Belt, :Legs, :Feet, :Wrist, :Gloves, :Finger_1, :Finger_2, :Trinket_1, :Trinket_2, :Back, :Main_Hand, :Off_Hand, :Ranged, :Tabard) RETURNING id", conn))
                {
                    cmd.Parameters.Add(new NpgsqlParameter("Head", NpgsqlDbType.Integer)).Value      = (int)ingameItemIDs[ItemSlot.Head];
                    cmd.Parameters.Add(new NpgsqlParameter("Neck", NpgsqlDbType.Integer)).Value      = (int)ingameItemIDs[ItemSlot.Neck];
                    cmd.Parameters.Add(new NpgsqlParameter("Shoulder", NpgsqlDbType.Integer)).Value  = (int)ingameItemIDs[ItemSlot.Shoulder];
                    cmd.Parameters.Add(new NpgsqlParameter("Shirt", NpgsqlDbType.Integer)).Value     = (int)ingameItemIDs[ItemSlot.Shirt];
                    cmd.Parameters.Add(new NpgsqlParameter("Chest", NpgsqlDbType.Integer)).Value     = (int)ingameItemIDs[ItemSlot.Chest];
                    cmd.Parameters.Add(new NpgsqlParameter("Belt", NpgsqlDbType.Integer)).Value      = (int)ingameItemIDs[ItemSlot.Belt];
                    cmd.Parameters.Add(new NpgsqlParameter("Legs", NpgsqlDbType.Integer)).Value      = (int)ingameItemIDs[ItemSlot.Legs];
                    cmd.Parameters.Add(new NpgsqlParameter("Feet", NpgsqlDbType.Integer)).Value      = (int)ingameItemIDs[ItemSlot.Feet];
                    cmd.Parameters.Add(new NpgsqlParameter("Wrist", NpgsqlDbType.Integer)).Value     = (int)ingameItemIDs[ItemSlot.Wrist];
                    cmd.Parameters.Add(new NpgsqlParameter("Gloves", NpgsqlDbType.Integer)).Value    = (int)ingameItemIDs[ItemSlot.Gloves];
                    cmd.Parameters.Add(new NpgsqlParameter("Finger_1", NpgsqlDbType.Integer)).Value  = (int)ingameItemIDs[ItemSlot.Finger_1];
                    cmd.Parameters.Add(new NpgsqlParameter("Finger_2", NpgsqlDbType.Integer)).Value  = (int)ingameItemIDs[ItemSlot.Finger_2];
                    cmd.Parameters.Add(new NpgsqlParameter("Trinket_1", NpgsqlDbType.Integer)).Value = (int)ingameItemIDs[ItemSlot.Trinket_1];
                    cmd.Parameters.Add(new NpgsqlParameter("Trinket_2", NpgsqlDbType.Integer)).Value = (int)ingameItemIDs[ItemSlot.Trinket_2];
                    cmd.Parameters.Add(new NpgsqlParameter("Back", NpgsqlDbType.Integer)).Value      = (int)ingameItemIDs[ItemSlot.Back];
                    cmd.Parameters.Add(new NpgsqlParameter("Main_Hand", NpgsqlDbType.Integer)).Value = (int)ingameItemIDs[ItemSlot.Main_Hand];
                    cmd.Parameters.Add(new NpgsqlParameter("Off_Hand", NpgsqlDbType.Integer)).Value  = (int)ingameItemIDs[ItemSlot.Off_Hand];
                    cmd.Parameters.Add(new NpgsqlParameter("Ranged", NpgsqlDbType.Integer)).Value    = (int)ingameItemIDs[ItemSlot.Ranged];
                    cmd.Parameters.Add(new NpgsqlParameter("Tabard", NpgsqlDbType.Integer)).Value    = (int)ingameItemIDs[ItemSlot.Tabard];
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.Read() == true)
                        {
                            gearDataEntryID = reader.GetInt32(0);
                        }
                    }
                }
                if (gearDataEntryID != 0 && _WowVersion != WowVersionEnum.Vanilla)
                {
                    //There may be gems we should add to the geardata!
                    Dictionary <ItemSlot, SQLGemInfo> gems = new Dictionary <ItemSlot, SQLGemInfo>();
                    foreach (var item in _GearData.Items)
                    {
                        if (item.Value.GemIDs != null)
                        {
                            SQLGemInfo gemInfo = new SQLGemInfo(item.Value.GemIDs);
                            if (gemInfo.IsNull() == false)
                            {
                                gems.Add(item.Key, gemInfo);
                            }
                        }
                    }
                    if (gems.Count > 0)
                    {
                        GenerateNewPlayerGearGemEntries(gearDataEntryID, gems);
                    }
                }
            }
            finally
            {
                CloseConnection();
            }
            return(gearDataEntryID);
        }