Exemple #1
0
 public Player(string _Name, WowRealm _Realm, CharacterDataHistoryItem _Character, GuildDataHistoryItem _Guild, HonorDataHistoryItem _Honor, GearDataHistoryItem _Gear, ArenaDataHistoryItem _Arena, TalentsDataHistoryItem _Talents)
 {
     Name             = _Name;
     Realm            = _Realm;
     Character        = _Character.Data;
     Guild            = _Guild.Data;
     Honor            = _Honor.Data;
     Gear             = _Gear.Data;
     Arena            = _Arena.Data;
     TalentPointsData = _Talents.Data;
     Uploader         = _Character.Uploader;
     if (_Guild.Uploader.GetTime() > Uploader.GetTime())
     {
         Uploader = _Guild.Uploader;
     }
     if (_Honor.Uploader.GetTime() > Uploader.GetTime())
     {
         Uploader = _Honor.Uploader;
     }
     if (_Gear.Uploader.GetTime() > Uploader.GetTime())
     {
         Uploader = _Gear.Uploader;
     }
     if (_Arena.Uploader.GetTime() > Uploader.GetTime())
     {
         Uploader = _Arena.Uploader;
     }
     if (_Talents.Uploader.GetTime() > Uploader.GetTime())
     {
         Uploader = _Talents.Uploader;
     }
     LastSeen = Uploader.GetTime();
 }
Exemple #2
0
        public float GetPercentageSameItems(GearData _GearData)
        {
            int sameCount = 0;

            foreach (var item in _GearData.Items)
            {
                if (Items[item.Key].IsSame(item.Value) == false)
                {
                    if (item.Key == ItemSlot.Finger_1 || item.Key == ItemSlot.Finger_2)
                    {
                        if (Items[ItemSlot.Finger_1].IsSame(item.Value) ||
                            Items[ItemSlot.Finger_2].IsSame(item.Value))
                        {
                            sameCount++;
                        }
                    }
                    else if (item.Key == ItemSlot.Trinket_1 || item.Key == ItemSlot.Trinket_2)
                    {
                        if (Items[ItemSlot.Trinket_1].IsSame(item.Value) ||
                            Items[ItemSlot.Trinket_2].IsSame(item.Value))
                        {
                            sameCount++;
                        }
                    }
                }
                else
                {
                    sameCount++;
                }
            }
            return((float)sameCount / (float)Items.Count);
        }
Exemple #3
0
 public Player(SerializationInfo _Info, StreamingContext _Context)
 {
     Name      = _Info.GetString("Name");
     Realm     = (WowRealm)_Info.GetInt32("Realm");
     Character = (CharacterData)_Info.GetValue("Character", typeof(CharacterData));
     Guild     = (GuildData)_Info.GetValue("Guild", typeof(GuildData));
     Honor     = (HonorData)_Info.GetValue("Honor", typeof(HonorData));
     Gear      = (GearData)_Info.GetValue("Gear", typeof(GearData));
     LastSeen  = (DateTime)_Info.GetValue("LastSeen", typeof(DateTime));
     Uploader  = (UploadID)_Info.GetValue("Uploader", typeof(UploadID));
 }
Exemple #4
0
        public void AddToHistory(GearData _GearData, UploadID _Uploader)
        {
            var extraGear = _GearData._GenerateExtraItemSets();

            if (extraGear != null)
            {
                for (int i = 0; i < extraGear.Count; ++i)
                {
                    UploadID slightyOlderUploadId = new UploadID(_Uploader.GetContributorID(), _Uploader.GetTime().AddMilliseconds(0 - i));
                    UtilityClass.AddToHistory.RunGeneric(GearHistory, extraGear[i], slightyOlderUploadId);
                }
            }
            UtilityClass.AddToHistory.RunGeneric(GearHistory, _GearData, _Uploader);
        }
Exemple #5
0
        public bool Update(System.Xml.XmlNode _PlayerNode, UploadID _Uploader /*Contains LastSeen*/, DateTime _LastSeen, PlayerHistory _PlayerHistory, WowVersionEnum _WowVersion)
        {
            var newCharacter = new PlayerData.CharacterData(_PlayerNode);
            var newGuild     = new PlayerData.GuildData(_PlayerNode);
            var newGear      = new PlayerData.GearData(_PlayerNode, _WowVersion);
            var newHonor     = new PlayerData.HonorData(_PlayerNode, _WowVersion);

            if (newGear.Items.Count == 0 && newGuild.GuildName == "nil" && newGuild.GuildRank == "nil" && newHonor.CurrentRank == 0 && _WowVersion == WowVersionEnum.Vanilla)
            {
                return(true);
            }

            PlayerData.ArenaData newArena = null;
            string newTalentPointsData    = null;

            if (_WowVersion == WowVersionEnum.TBC)
            {
                newArena = new PlayerData.ArenaData(_PlayerNode);
                _PlayerHistory.AddToHistory(newArena, _Uploader);
                newTalentPointsData = XMLUtility.GetChildValue(_PlayerNode, "TalentsData", "");
                _PlayerHistory.AddTalentsToHistory(newTalentPointsData, _Uploader);
            }

            _PlayerHistory.AddToHistory(newCharacter, _Uploader);
            _PlayerHistory.AddToHistory(newGuild, _Uploader);
            if (newGear.Items.Count > 0)
            {
                _PlayerHistory.AddToHistory(newGear, _Uploader);
            }
            _PlayerHistory.AddToHistory(newHonor, _Uploader);
            if (_LastSeen > LastSeen)
            {
                Uploader  = _Uploader;
                LastSeen  = _LastSeen;
                Character = newCharacter;
                Guild     = newGuild;
                if (newGear.Items.Count > 0)
                {
                    Gear = newGear;
                }
                Honor            = newHonor;
                Arena            = newArena;
                TalentPointsData = newTalentPointsData;
                return(false);
            }

            return(true);
        }
Exemple #6
0
        public string GetDiffString(GearData _Gear)
        {
            string gearItemsDebugInfo = "";

            foreach (ItemSlot slot in Enum.GetValues(typeof(ItemSlot)))
            {
                ItemInfo myItem    = null;
                ItemInfo otherItem = null;
                if (Items.TryGetValue(slot, out myItem) == false)
                {
                    myItem = null;
                }
                if (_Gear.Items.TryGetValue(slot, out otherItem) == false)
                {
                    otherItem = null;
                }

                if (myItem != null && otherItem == null)
                {
                    gearItemsDebugInfo += "My" + myItem.GetAsString() + "!=" +
                                          "Other{null}, ";
                }
                else if (myItem == null && otherItem != null)
                {
                    gearItemsDebugInfo += "My{null}!=" +
                                          "Other" + otherItem.GetAsString() + ", ";
                }
                else if (myItem != null && otherItem != null)
                {
                    if (myItem.IsSame(otherItem) == false)
                    {
                        gearItemsDebugInfo += "My" + myItem.GetAsString() + "!=" +
                                              "Other" + otherItem.GetAsString() + ", ";
                    }
                }
                else
                {
                    if (myItem != null || otherItem != null)
                    {
                        Logger.ConsoleWriteLine("ERROR\nERROR\nERROR\nERROR\nERROR\nERROR\nERROR\nERROR\n, this is unexpected and should never happen!\nERROR\nERROR\nERROR\nERROR\nERROR\nERROR");
                    }
                }
            }
            return("{" + gearItemsDebugInfo + "}");
        }
Exemple #7
0
        public bool Update(UploadID _Uploader /*Contains LastSeen*/, DateTime _LastSeen, PlayerHistory _PlayerHistory, WowVersionEnum _WowVersion
                           , PlayerData.CharacterData _NewCharacter, PlayerData.GuildData _NewGuild, PlayerData.GearData _NewGear, PlayerData.HonorData _NewHonor, PlayerData.ArenaData _NewArena = null, string _NewTalents = null)
        {
            if (_WowVersion == WowVersionEnum.TBC)
            {
                if (_NewArena != null)
                {
                    _PlayerHistory.AddToHistory(_NewArena, _Uploader);
                }
                if (_NewTalents != null)
                {
                    _PlayerHistory.AddTalentsToHistory(_NewTalents, _Uploader);
                }
            }

            _PlayerHistory.AddToHistory(_NewCharacter, _Uploader);
            _PlayerHistory.AddToHistory(_NewGuild, _Uploader);
            if (_NewGear.Items.Count > 0)
            {
                _PlayerHistory.AddToHistory(_NewGear, _Uploader);
            }
            _PlayerHistory.AddToHistory(_NewHonor, _Uploader);
            if (_LastSeen > LastSeen)
            {
                Uploader  = _Uploader;
                LastSeen  = _LastSeen;
                Character = _NewCharacter;
                Guild     = _NewGuild;
                if (_NewGear.Items.Count > 0)
                {
                    Gear = _NewGear;
                }
                Honor            = _NewHonor;
                Arena            = _NewArena;
                TalentPointsData = _NewTalents;
                return(false);
            }

            return(true);
        }
Exemple #8
0
        //Can only be used accurately during PlayerHistory ADDING, this is only using temporary data generated ONCE and never saved!
        public List <GearData> _GenerateExtraItemSets()
        {
            if (ExtraItems == null || ExtraItems.Count == 0)
            {
                return(null);
            }

            List <GearData> newGearDataSets = new List <GearData>();
            GearData        lastGearData    = this;
            GearData        newGearData     = new GearData();

            for (int i = 0; i < ExtraItems.Count + 1; ++i)
            {
                ItemInfo extraItem = null;
                if (i < ExtraItems.Count)
                {
                    extraItem = ExtraItems[i];
                }
                if (extraItem == null || newGearData.Items.ContainsKey(extraItem.Slot) == true)
                {
                    foreach (var lastItemData in lastGearData.Items)
                    {
                        if (newGearData.Items.ContainsKey(lastItemData.Key) == false)
                        {
                            newGearData.Items.Add(lastItemData.Key, lastItemData.Value);
                        }
                    }
                    newGearDataSets.Add(newGearData);
                    lastGearData = newGearData;
                    if (extraItem == null)//Last ExtraItem, and we allready added it. so just exit the for loop here
                    {
                        break;
                    }
                    newGearData = new GearData();
                }
                newGearData.Items.Add(extraItem.Slot, extraItem);
            }
            return(newGearDataSets);
        }
 public GearDataHistoryItem(SerializationInfo _Info, StreamingContext _Context)
 {
     Data     = (GearData)_Info.GetValue("Data", typeof(GearData));
     Uploader = (UploadID)_Info.GetValue("Uploader", typeof(UploadID));
 }
Exemple #10
0
 //public GearDataHistoryItem()
 //{ }
 public GearDataHistoryItem(GearData _Gear, UploadID _Uploader)
 {
     Data     = _Gear;
     Uploader = _Uploader;
 }
Exemple #11
0
 public GearSet(GearDataHistoryItem _HistoryItem)
 {
     Gear     = _HistoryItem.Data;
     Count    = 0;
     LastUsed = _HistoryItem.Uploader.GetTime();
 }
        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);
        }
Exemple #13
0
        public bool IsSame(GearData _GearData)
        {
            try
            {
                //if (Items[ItemSlot.Finger_1].IsSame(_GearData.Items[ItemSlot.Finger_1]) == false)
                //{
                //    if(Items[ItemSlot.Finger_2].IsSame(_GearData.Items[ItemSlot.Finger_1]) == true)
                //}
                //if (Items[ItemSlot.Trinket_1].IsSame(_GearData.Items[ItemSlot.Trinket_1]) == false)
                //{

                //}
                //if (item.Key == ItemSlot.Finger_1 || item.Key == ItemSlot.Finger_2)
                //{
                //    if (Items[ItemSlot.Finger_1].IsSame(_GearData.Items[ItemSlot.Finger_2]) == false)
                //        return false;
                //}
                //else if (item.Key == ItemSlot.Trinket_1 || item.Key == ItemSlot.Trinket_2)
                //{
                //    if (Items[ItemSlot.Trinket_1].IsSame(_GearData.Items[ItemSlot.Trinket_2]) == false)
                //        return false;
                //}
                foreach (var item in _GearData.Items)
                {
                    if (Items[item.Key].IsSame(item.Value) == false)
                    {
                        if (item.Key == ItemSlot.Finger_1 || item.Key == ItemSlot.Finger_2)
                        {
                            if (Items[ItemSlot.Finger_1].IsSame(item.Value) ||
                                Items[ItemSlot.Finger_2].IsSame(item.Value))
                            {
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (item.Key == ItemSlot.Trinket_1 || item.Key == ItemSlot.Trinket_2)
                        {
                            if (Items[ItemSlot.Trinket_1].IsSame(item.Value) ||
                                Items[ItemSlot.Trinket_2].IsSame(item.Value))
                            {
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }