public ItemInfo(string _ItemLink, WowVersionEnum _WowVersion) { if (_WowVersion == WowVersionEnum.Vanilla) { string[] itemLinkData = _ItemLink.Split(new char[] { ':' }); Slot = (ItemSlot)int.Parse(itemLinkData[0]); ItemID = int.Parse(itemLinkData[1]); EnchantID = int.Parse(itemLinkData[2]); SuffixID = int.Parse(itemLinkData[3]); UniqueID = int.Parse(itemLinkData[4]); } else if (_WowVersion == WowVersionEnum.TBC) { string[] itemLinkData = _ItemLink.Split(new char[] { ':' }); Slot = (ItemSlot)int.Parse(itemLinkData[0]); ItemID = int.Parse(itemLinkData[1]); EnchantID = int.Parse(itemLinkData[2]); GemIDs = new int[4]; bool anyGems = false; for (int i = 0; i < 4; ++i) { GemIDs[i] = int.Parse(itemLinkData[3 + i]); if (GemIDs[i] != 0) { anyGems = true; } } if (anyGems == false) { GemIDs = null; } SuffixID = int.Parse(itemLinkData[7]); UniqueID = int.Parse(itemLinkData[8]); } }
private void InitData(string _GearDataString, WowVersionEnum _WowVersion) { try { if (_GearDataString == "") { return; } string[] itemData = _GearDataString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (itemData.Length >= 4) { Items.Clear(); } ExtraItems = new List <ItemInfo>(); foreach (string itemLink in itemData) { var newItem = new ItemInfo(itemLink, _WowVersion); if (Items.ContainsKey(newItem.Slot) == false) { Items.Add(newItem.Slot, newItem); } else { ExtraItems.Add(newItem); } } } catch (Exception) { } }
public SQLPlayerID GenerateNewPlayerEntry(SQLUploadID _UploadID, PlayerData.Player _PlayerData) { WowVersionEnum wowVersion = VF_RealmPlayersDatabase.StaticValues.GetWowVersion(_PlayerData.Realm); SQLPlayerID playerID = new SQLPlayerID(); var conn = OpenConnection(); try { using (var cmd = new NpgsqlCommand("INSERT INTO playertable(id, name, realm, latestuploadid) VALUES (DEFAULT, :Name, :Realm, :LatestUploadID) RETURNING id", conn)) { cmd.Parameters.Add(new NpgsqlParameter("Name", NpgsqlDbType.Text)).Value = _PlayerData.Name; cmd.Parameters.Add(new NpgsqlParameter("Realm", NpgsqlDbType.Integer)).Value = (int)_PlayerData.Realm; cmd.Parameters.Add(new NpgsqlParameter("LatestUploadID", NpgsqlDbType.Integer)).Value = (int)0; using (var reader = cmd.ExecuteReader()) { if (reader.Read() == true) { playerID = new SQLPlayerID(reader.GetInt32(0)); } } } } finally { CloseConnection(); } if (playerID.IsValid() == false) { return(playerID); } return(UpdateLatestPlayerDataEntry(playerID, _UploadID, _PlayerData)); }
public string CreateGuildListInfo(VF_RealmPlayersDatabase.WowVersionEnum _WowVersion, int _GuildCount) { if (_WowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC) { string guildListInfo = "<h1>Guilds<span class='badge badge-inverse'>" + _GuildCount + " Guilds</span></h1>" + "<p>Guilds on the realm. Sorted by current progress.</p><p>The progress is automatically generated by looking at instance-boss specific items players have within the guild. <br />Unfortunately guild progress is not yet supported for TBC content.</p>"; return(guildListInfo); } else { string guildListInfo = "<h1>Guilds<span class='badge badge-inverse'>" + _GuildCount + " Guilds</span></h1>" + "<p>Guilds on the realm. Sorted by current progress.</p><p>The progress is automatically generated by looking at instance-boss specific items players have within the guild.</p>"; return(guildListInfo); } }
public SQLPlayerID UpdateLatestPlayerDataEntry(SQLPlayerID _PlayerID, SQLUploadID _UploadID, PlayerData.Player _PlayerData) { WowVersionEnum wowVersion = VF_RealmPlayersDatabase.StaticValues.GetWowVersion(_PlayerData.Realm); SQLPlayerData playerData = new SQLPlayerData(); playerData.PlayerID = _PlayerID; playerData.UploadID = _UploadID; playerData.UpdateTime = _PlayerData.LastSeen; playerData.PlayerCharacter = _PlayerData.Character; playerData.PlayerGuildID = GenerateNewPlayerGuildDataEntry(_PlayerData.Guild); playerData.PlayerHonorID = GenerateNewPlayerHonorDataEntry(_PlayerData.Honor, wowVersion); playerData.PlayerGearID = GenerateNewPlayerGearDataEntry(_PlayerData.Gear, wowVersion); if (wowVersion != WowVersionEnum.Vanilla) { playerData.PlayerArenaID = GenerateNewPlayerArenaInfoEntry(_PlayerData.Arena); playerData.PlayerTalentsID = GenerateNewPlayerTalentsDataEntry(_PlayerData.TalentPointsData); } else { playerData.PlayerArenaID = 0; playerData.PlayerTalentsID = 0; } if (GenerateNewPlayerDataEntry(playerData) == true) { if (UpdatePlayerEntry(playerData.PlayerID, playerData.UploadID) == false) { VF_RealmPlayersDatabase.Logger.ConsoleWriteLine("Error in UpdateLatestPlayerDataEntry, could not UpdatePlayerEntry!!!"); return(SQLPlayerID.Invalid()); } } else { VF_RealmPlayersDatabase.Logger.ConsoleWriteLine("Error in UpdateLatestPlayerDataEntry, could not GenerateNewPlayerDataEntry!!!"); return(SQLPlayerID.Invalid()); } return(_PlayerID); }
public static VF_RealmPlayersDatabase.ItemDropDatabase GetItemDropDatabase(System.Web.UI.Page _Page, WowVersionEnum _WowVersion, NotLoadedDecision _Decision = NotLoadedDecision.SpinWait) { Hidden.ApplicationInstance.Instance.GetItemInfoCache(_WowVersion, _Decision == NotLoadedDecision.SpinWait); var itemDropDatabase = Hidden.ApplicationInstance.Instance.GetItemDropDatabase(); if (itemDropDatabase == null && _Decision == NotLoadedDecision.RedirectAndWait) { PageUtility.RedirectErrorLoading(_Page, "itemdropdatabase"); } return(itemDropDatabase); }
public RealmPlayersServer.ItemInfo GetItemInfo(int _ItemID, VF_RealmPlayersDatabase.WowVersionEnum _WowVersion) { if (_WowVersion != VF_RealmPlayersDatabase.WowVersionEnum.Vanilla && _WowVersion != VF_RealmPlayersDatabase.WowVersionEnum.TBC) { Logger.ConsoleWriteLine("ERROR, WowVersion was not Vanilla or TBC!!!"); return(null); } if (_WowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC) { if (m_ItemInfoCacheTBC == null) { lock (m_ItemInfoLockTBC) { try { if (m_ItemInfoCacheTBC == null) { if (System.IO.File.Exists(g_RPPDBDir + "VF_ItemInfoCache.dat")) { Dictionary <int, ItemInfo> itemInfoCache = new Dictionary <int, ItemInfo>(); if (VF_RealmPlayersDatabase.Utility.LoadSerialize(g_RPPDBDir + "VF_ItemInfoCacheTBC.dat", out itemInfoCache)) { m_ItemInfoCacheTBC = itemInfoCache; } } } } catch (Exception ex) { Logger.LogException(ex); } } } if (m_ItemInfoCacheTBC == null) { return(null); } ItemInfo itemInfo = null; if (m_ItemInfoCacheTBC.TryGetValue(_ItemID, out itemInfo) == true) { return(itemInfo); } try { var webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://realmplayers.com/ItemTooltip.aspx?item=" + System.Web.HttpUtility.UrlEncode("?item=" + _ItemID + "-1")); webRequest.Timeout = 2000; webRequest.ReadWriteTimeout = 2000; using (var webResponse = webRequest.GetResponse()) { using (var streamReader = new System.IO.StreamReader(webResponse.GetResponseStream())) { itemInfo = new ItemInfo(_ItemID, streamReader.ReadToEnd(), ""); lock (m_ItemInfoLockTBC) { if (m_ItemInfoCacheTBC.ContainsKey(_ItemID) == false) { m_ItemInfoCacheTBC.Add(_ItemID, itemInfo); } } } } } catch (Exception) { itemInfo = null; } return(itemInfo); } else if (_WowVersion == VF_RealmPlayersDatabase.WowVersionEnum.Vanilla) { if (m_ItemInfoCache == null) { lock (m_ItemInfoLock) { try { if (m_ItemInfoCache == null) { if (System.IO.File.Exists(g_RPPDBDir + "VF_ItemInfoCache.dat")) { Dictionary <int, ItemInfo> itemInfoCache = new Dictionary <int, ItemInfo>(); if (VF_RealmPlayersDatabase.Utility.LoadSerialize(g_RPPDBDir + "VF_ItemInfoCache.dat", out itemInfoCache)) { m_ItemInfoCache = itemInfoCache; } } } } catch (Exception ex) { Logger.LogException(ex); } } } if (m_ItemInfoCache == null) { return(null); } ItemInfo itemInfo = null; if (m_ItemInfoCache.TryGetValue(_ItemID, out itemInfo) == true) { return(itemInfo); } try { var webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://realmplayers.com/ItemTooltip.aspx?item=" + System.Web.HttpUtility.UrlEncode("?item=" + _ItemID + "-0")); webRequest.Timeout = 2000; webRequest.ReadWriteTimeout = 2000; using (var webResponse = webRequest.GetResponse()) { using (var streamReader = new System.IO.StreamReader(webResponse.GetResponseStream())) { itemInfo = new ItemInfo(_ItemID, streamReader.ReadToEnd(), ""); lock (m_ItemInfoLock) { if (m_ItemInfoCache.ContainsKey(_ItemID) == false) { m_ItemInfoCache.Add(_ItemID, itemInfo); } } } } } catch (Exception) { itemInfo = null; } return(itemInfo); } return(null); }
public static ItemInfo GetItemInfo(int _ItemID, WowVersionEnum _WowVersion) { return(Hidden.ApplicationInstance.Instance.GetItemInfo(_ItemID, _WowVersion)); }
public TimeSlice(TimeSlice _PreviousTimeSlice, string _DataString, Dictionary <int, string> _UnitIDsToName, List <int> _RaidMemberIDs, string _Zone, WowVersionEnum _WowVersion, Dictionary <int, string> _BuffIDsToName, string _AddonVersion) { Dictionary <int, UnitData> previousUnitDatas = null; if (_PreviousTimeSlice != null) { previousUnitDatas = _PreviousTimeSlice.UnitDatas; if (_PreviousTimeSlice.UnitBuffs != null) { UnitBuffs = new Dictionary <int, List <BuffInfo> >(); foreach (var buffData in _PreviousTimeSlice.UnitBuffs) { if (buffData.Value != null) { foreach (BuffInfo buffInfo in buffData.Value) { UnitBuffs.AddToList(buffData.Key, buffInfo); } } } } if (_PreviousTimeSlice.UnitDebuffs != null) { UnitDebuffs = new Dictionary <int, List <BuffInfo> >(); foreach (var buffData in _PreviousTimeSlice.UnitDebuffs) { if (buffData.Value != null) { foreach (BuffInfo buffInfo in buffData.Value) { UnitDebuffs.AddToList(buffData.Key, buffInfo); } } } } TimeSliceCounter = _PreviousTimeSlice.TimeSliceCounter + 1; } Zone = _Zone; string[] splitData = _DataString.Split(','); string[] headerAndFirst = splitData[0].Split(':'); Time = int.Parse(headerAndFirst[0]); Event = headerAndFirst[1]; //if (Event.Contains("Sir Zeliek")) // Event = Event.Replace("Sir Zeliek", "The Four Horsemen"); //else if (Event.Contains("Highlord Mograine")) // Event = Event.Replace("Highlord Mograine", "The Four Horsemen"); splitData[0] = headerAndFirst[2]; foreach (string unitData in splitData) { if (unitData != "") { if (unitData.Contains('=')) {//ID to Name convertion //try { if (unitData.StartsWith("B.")) { if (_AddonVersion != "1.8.9" && _AddonVersion != "1.9.0") { try { //BuffID Definition for 1.8.9, TODO: Implement parsing! //unitData = "B.AGGRO_TEST_WHATEVER=3" string[] idToBuffData = unitData.Substring(2).Split('='); string buffName = idToBuffData[0]; int buffID = int.Parse(idToBuffData[1]); _BuffIDsToName.AddOrSet(buffID, buffName); } catch (Exception) { } } } else { string[] idToNameData = unitData.Split('='); string unitName = idToNameData[0]; int unitID = int.Parse(idToNameData[1]); if (_UnitIDsToName.ContainsKey(unitID) == false) { _UnitIDsToName.Add(unitID, unitName); } else if (unitName.StartsWith("VF_PET_")) { _UnitIDsToName[unitID] = unitName; } } } //catch (Exception) {} } else if (unitData.StartsWith("R")) { try { GroupMemberIDs = new List <int>(); //Raid Definition for 1.8.3, TODO: Implement parsing! //unitData = "R 32 92 82 71 80 93 2 3 492 1" <-- numbers are UnitIDs var raidMembers = unitData.Split(' '); for (int i = 1; i < raidMembers.Length; ++i) {//Start from 1, skip "R" int raidMemberID = int.Parse(raidMembers[i]); if (_RaidMemberIDs.Contains(raidMemberID) == false) { _RaidMemberIDs.Add(raidMemberID); } GroupMemberIDs.Add(raidMemberID); } } catch (Exception ex) { Logger.LogException(ex); } } else if (unitData.StartsWith("Z")) { try { //Zone Definition for 1.9.7, TODO: Implement parsing! //unitData = "Z Molten Core" } catch (Exception ex) { Logger.LogException(ex); } } else if (unitData.StartsWith("B") || unitData.StartsWith("D")) { if (_AddonVersion != "1.8.9" && _AddonVersion != "1.9.0") { bool isBuff = unitData.StartsWith("B"); bool isDebuff = unitData.StartsWith("D"); try { if (isBuff == isDebuff) { throw new Exception("UNEXPECTED ERROR"); } //Buff Data for 1.8.9, TODO: Implement parsing! //"B12 3 2 4 5" <-- 12 is playerID, other numbers are BuffIDs string dataString = ""; if (unitData.StartsWith("BF")) { //Means that there was 16 buffs active, which means the buffs info might not be 100% accurate! //TODO: do something useful with this information! dataString = unitData.Substring(2); } else { dataString = unitData.Substring(1); } string[] buffData = dataString.Split('.'); if (buffData.Length == 4 || buffData.Length == 5) { int bSI = 0; int unitID = int.Parse(buffData[bSI++]); int buffCount = -1; if (buffData.Length == 5) { buffCount = int.Parse(buffData[bSI++]); } string[] eqBuffs = buffData[bSI++].Split(' '); string[] subBuffs = buffData[bSI++].Split(' '); string[] addBuffs = buffData[bSI++].Split(' '); List <BuffInfo> currUnitBuffs = null; if (isBuff == true) { if (UnitBuffs == null) { UnitBuffs = new Dictionary <int, List <BuffInfo> >(); } if (UnitBuffs.ContainsKey(unitID) == false) { UnitBuffs.Add(unitID, new List <BuffInfo>()); } currUnitBuffs = UnitBuffs[unitID]; } else if (isDebuff == true) { if (UnitDebuffs == null) { UnitDebuffs = new Dictionary <int, List <BuffInfo> >(); } if (UnitDebuffs.ContainsKey(unitID) == false) { UnitDebuffs.Add(unitID, new List <BuffInfo>()); } currUnitBuffs = UnitDebuffs[unitID]; } try { bool unexpectedAddError = false; bool unexpectedSubError = false; bool unexpectedEqError = false; foreach (var buff in addBuffs) { if (buff == "") { continue; } BuffInfo buffInfo; buffInfo.BuffID = int.Parse(buff); buffInfo.LastUpdatedTimeSlice = this.TimeSliceCounter; int buffIndex = currUnitBuffs.FindIndex((_Value) => _Value.BuffID == buffInfo.BuffID); if (buffIndex >= 0) { unexpectedAddError = true; currUnitBuffs[buffIndex] = buffInfo; } else { currUnitBuffs.Add(buffInfo); } } foreach (var buff in subBuffs) { if (buff == "") { continue; } int buffID = int.Parse(buff); int buffIndex = currUnitBuffs.FindIndex((_Value) => _Value.BuffID == buffID); if (buffIndex >= 0) { currUnitBuffs.RemoveAt(buffIndex); } else { unexpectedSubError = true; } } foreach (var buff in eqBuffs) { if (buff == "") { continue; } BuffInfo buffInfo; buffInfo.BuffID = int.Parse(buff); buffInfo.LastUpdatedTimeSlice = this.TimeSliceCounter; int buffIndex = currUnitBuffs.FindIndex((_Value) => _Value.BuffID == buffInfo.BuffID); if (buffIndex >= 0) { currUnitBuffs[buffIndex] = buffInfo; } else { unexpectedEqError = true; currUnitBuffs.Add(buffInfo); } } if (unexpectedAddError) { Logger.ConsoleWriteLine("Buff already exists when adding UnitBuff!!! unitData = \"" + unitData + "\"", ConsoleColor.Red); } if (unexpectedSubError) { Logger.ConsoleWriteLine("Buff does not exists when removing UnitBuff!!! unitData = \"" + unitData + "\"", ConsoleColor.Red); } if (unexpectedEqError) { Logger.ConsoleWriteLine("Buff does not exists when equaling UnitBuff!!! unitData = \"" + unitData + "\"", ConsoleColor.Red); } const int ADDON_REFRESH_EQ_RATE = 20 * 2;//20 is from refreshrate in addon and we double it just to be safe List <int> removeBuffIDs = new List <int>(); foreach (var buffInfo in currUnitBuffs) { if (this.TimeSliceCounter - buffInfo.LastUpdatedTimeSlice > ADDON_REFRESH_EQ_RATE) { removeBuffIDs.Add(buffInfo.BuffID); } } foreach (var removeBuffID in removeBuffIDs) { int buffIndex = currUnitBuffs.FindIndex((_Value) => _Value.BuffID == removeBuffID); currUnitBuffs.RemoveAt(buffIndex); } } catch (Exception ex) { Logger.LogException(ex); } } else { Logger.ConsoleWriteLine("Unexpected error when parsing UnitBuffs!!! unitData = \"" + unitData + "\"", ConsoleColor.Red); } } catch (Exception) { } } } else { try { UnitData newUnitData = UnitData.Create(unitData, previousUnitDatas, _WowVersion); if (_UnitIDsToName.ContainsKey(newUnitData.I.UnitID) == true) { UnitDatas.Add(newUnitData.I.UnitID, newUnitData); ChangedUnitDatas.Add(newUnitData.I.UnitID); } else { Logger.ConsoleWriteLine("UnitID(" + newUnitData.I.UnitID + ") was never introduced, this UnitID is automatically discarded completely", ConsoleColor.Red); } } catch (Exception) {} } } } if (previousUnitDatas != null) { foreach (var previousUnitData in previousUnitDatas) { //INVESTIGATE: Possible bug here. Should add EMPTY UnitDatas, since all these are delta values and now same unitdata change will be registered several times? //INVESTIGATE_RESULT: not a bug! UnitDatas automatically accumulates since it tries fetch the previous from the "previousUnitDtas" array and then add its values! if (UnitDatas.ContainsKey(previousUnitData.Key) == false) { UnitDatas.Add(previousUnitData.Key, previousUnitData.Value.CreateCopy()); } } } }
public GearData(System.Xml.XmlNode _PlayerNode, WowVersionEnum _WowVersion) { InitData(XMLUtility.GetChildValue(_PlayerNode, "ItemsData", ""), _WowVersion); }
public Dictionary <int, ItemInfo> GetItemInfoCache(WowVersionEnum _WowVersion, bool _WaitForLoad = true) { if (_WowVersion == WowVersionEnum.Vanilla) { if (m_ItemInfoCacheVanilla == null && _WaitForLoad == true) { if (_WaitForLoad == true) { Monitor.Enter(m_ItemInfoLock); } else { if (Monitor.TryEnter(m_ItemInfoLock) == false) { return(m_ItemInfoCacheVanilla); } } try { if (m_ItemInfoCacheVanilla == null) { if (System.IO.File.Exists(Constants.RPPDbDir + "VF_ItemInfoCache.dat")) { Dictionary <int, ItemInfo> itemInfoCache = new Dictionary <int, ItemInfo>(); if (VF_RealmPlayersDatabase.Utility.LoadSerialize(Constants.RPPDbDir + "VF_ItemInfoCache.dat", out itemInfoCache)) { m_ItemInfoCacheVanilla = itemInfoCache; } } if (m_ItemDropDatabase == null) { m_ItemDropDatabase = new ItemDropDatabase(Constants.RPPDbDir + "Database\\"); } } if (m_ItemInfoCacheVanilla == null) { m_ItemInfoCacheVanilla = new Dictionary <int, ItemInfo>(); } } catch (Exception ex) { Logger.LogException(ex); } Monitor.Exit(m_ItemInfoLock); return(m_ItemInfoCacheVanilla); } else { return(m_ItemInfoCacheVanilla); } } else if (_WowVersion == WowVersionEnum.TBC) { if (m_ItemInfoCacheTBC == null && _WaitForLoad == true) { if (_WaitForLoad == true) { Monitor.Enter(m_ItemInfoLock); } else { if (Monitor.TryEnter(m_ItemInfoLock) == false) { return(m_ItemInfoCacheTBC); } } try { if (m_ItemInfoCacheTBC == null) { if (System.IO.File.Exists(Constants.RPPDbDir + "VF_ItemInfoCacheTBC.dat")) { Dictionary <int, ItemInfo> itemInfoCache = new Dictionary <int, ItemInfo>(); if (VF_RealmPlayersDatabase.Utility.LoadSerialize(Constants.RPPDbDir + "VF_ItemInfoCacheTBC.dat", out itemInfoCache)) { m_ItemInfoCacheTBC = itemInfoCache; } } if (m_ItemDropDatabase == null) { m_ItemDropDatabase = new ItemDropDatabase(Constants.RPPDbDir + "Database\\"); } } if (m_ItemInfoCacheTBC == null) { m_ItemInfoCacheTBC = new Dictionary <int, ItemInfo>(); } } catch (Exception ex) { Logger.LogException(ex); } Monitor.Exit(m_ItemInfoLock); return(m_ItemInfoCacheTBC); } else { return(m_ItemInfoCacheTBC); } } return(null); }
public static string GetAjaxTooltip(string _RequestString, Func <int, WowVersionEnum, ItemInfo> _GetItemInfo = null) { { try { var query = System.Web.HttpUtility.ParseQueryString(_RequestString.Substring(_RequestString.IndexOf('?') + 1)); string itemStrRaw = query["item"]; string suffixStr = query["rand"]; string uniqStr = query["uniq"]; string enchStr = query["ench"]; string pcsStr = query["pcs"]; string gemsStr = query["gems"]; WowVersionEnum wowVersion = WowVersionEnum.Vanilla; string[] itemStrSplitResult = itemStrRaw.Split('-'); if (itemStrSplitResult.Length > 1 && itemStrSplitResult.Last() == "1") { wowVersion = WowVersionEnum.TBC; } else if (itemStrSplitResult.Length > 1 && itemStrSplitResult.Last() == "0") { wowVersion = WowVersionEnum.Vanilla; } string itemStr = itemStrSplitResult.First(); int itemID = 0; if (int.TryParse(itemStr, out itemID) == false) { return(""); } int suffixID = 0; int uniqueID = 0; if (suffixStr != null) { string[] suffixStrSplit = suffixStr.Split('+'); if (int.TryParse(suffixStrSplit.First(), out suffixID) == false) { suffixID = 0; } if (suffixStrSplit.Length > 1 && int.TryParse(suffixStrSplit[1], out uniqueID) == false) { uniqueID = 0; } if (int.TryParse(uniqStr, out uniqueID) == false) { uniqueID = 0; } } int enchantID = 0; if (int.TryParse(enchStr, out enchantID) == false) { enchantID = 0; } int[] gems = null; if (gemsStr != "" && gemsStr != null) { string[] gemStrSplit = gemsStr.Split(':'); gems = new int[gemStrSplit.Length]; for (int i = 0; i < gems.Length; ++i) { gems[i] = int.Parse(gemStrSplit[i]); } } var itemInfo = _GetItemInfo(itemID, wowVersion); if (itemInfo == null) { return(""); } string ajaxResult = itemInfo.GetAjaxTooltip(wowVersion, itemID, suffixID, enchantID, uniqueID, gems, pcsStr); ajaxResult = ajaxResult.Replace("registerItem('" + itemStr, "registerItem('" + itemStrRaw); return(ajaxResult); } catch (Exception) { } } return(""); }
public ItemInfo GetItemInfo(int _ItemID, WowVersionEnum _WowVersion) { try { var itemInfoCache = GetItemInfoCache(_WowVersion, true); if (itemInfoCache == null) { return(null); } ItemInfo itemInfo = null; //m_ItemInfoLock.AcquireReaderLock(1000); Monitor.Enter(m_ItemInfoLock); if (itemInfoCache.ContainsKey(_ItemID) == true) { itemInfo = itemInfoCache[_ItemID]; Monitor.Exit(m_ItemInfoLock); } else { Monitor.Exit(m_ItemInfoLock); foreach (string itemDatabaseAddress in m_CurrentItemDatabaseOrder) { try { //System.Net.WebClient webClient = new System.Net.WebClient(); //var cook = new System.Collections.Specialized.NameValueCollection(); //cook.Add("dbVersion", "0"); System.Net.CookieContainer cookieContainer = new System.Net.CookieContainer(); //cookieContainer.Add(new Uri(itemDatabaseAddress), new System.Net.Cookie("PHPSESSID", "d617cebcf593d37bde6c9c8caa01ef18")); var webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(itemDatabaseAddress + "ajax.php?item=" + _ItemID); webRequest.Timeout = 5000; webRequest.ReadWriteTimeout = 5000; if (itemDatabaseAddress.Contains("database.wow-one.com")) { if (_WowVersion == WowVersionEnum.Vanilla) { cookieContainer = DatabaseWowOneCookies_Get();//Hämta rätt cookies när det är vanilla //cookieContainer.SetCookies(new Uri("http://database.wow-one.com"), "dbVersion=0"); } } else { if (_WowVersion == WowVersionEnum.TBC) { continue;//Bara stöd för database.wow-one.com när det är TBC } } webRequest.CookieContainer = cookieContainer; using (var webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse()) { using (System.IO.StreamReader reader = new System.IO.StreamReader(webResponse.GetResponseStream())) { string ajaxItemData = reader.ReadToEnd(); if (ajaxItemData.StartsWith("$WowheadPower.registerItem"))//Success? { string[] itemData = ajaxItemData.Split('{', '}'); if (itemData.Length == 3)//Success!(?) { itemInfo = new ItemInfo(_ItemID, ajaxItemData, itemDatabaseAddress); if ( ( itemDatabaseAddress.Contains("database.wow-one.com") && ( (_WowVersion == WowVersionEnum.Vanilla && webResponse.Headers.Get("Set-Cookie").Contains("dbVersion=0")) || (_WowVersion == WowVersionEnum.TBC && webResponse.Headers.Get("Set-Cookie").Contains("dbVersion=1")) ) ) || itemDatabaseAddress.Contains("db.vanillagaming.org") || itemDatabaseAddress.Contains("db.valkyrie-wow.com")) { lock (m_ItemInfoLock) { if (itemInfoCache.ContainsKey(_ItemID) == false) { itemInfoCache.Add(_ItemID, itemInfo); } else { itemInfoCache[_ItemID] = itemInfo; } m_ItemInfoUpdated = true; } if (itemDatabaseAddress != m_CurrentItemDatabaseOrder.First()) { var newItemDatabaseOrder = new List <string>(StaticValues.ItemDatabaseAddresses); newItemDatabaseOrder.Remove(itemDatabaseAddress); newItemDatabaseOrder.Insert(0, itemDatabaseAddress); m_CurrentItemDatabaseOrder = newItemDatabaseOrder; } } else { DatabaseWowOneCookies_Clear(); } break; } } } } } catch (Exception) { } } //http://db.vanillagaming.org/ajax.php?item=19146 //http://db.vanillagaming.org/ajax.php?item=19146 //http://db.vanillagaming.org/images/icons/large/inv_bracer_04.jpg } return(itemInfo); } catch (Exception ex) { Logger.LogException(ex); return(null); } }
public static List <ItemStat> GenerateGearStats(IEnumerable <DatabaseItemInfo> _Items, WowVersionEnum _WowVersion) { List <ItemStat> totalStats = new List <ItemStat>(); foreach (var item in _Items) { try { var itemInfo = DatabaseAccess.GetItemInfo(item.ItemID, _WowVersion); var stats = ItemStats.ParseAjaxTooltip(itemInfo.GetAjaxTooltip(_WowVersion, item.ItemID, item.SuffixID, item.EnchantID, item.UniqueID, item.GemIDs)); foreach (var stat in stats) { ItemStat[] addStats = null; int normalValue = 0; int enchantValue = 0; int gemValue = 0; if (stat.Enchant == true) { enchantValue = stat.Value; } else if (stat.Gem == true) { gemValue = stat.Value; } else { normalValue = stat.Value; } if (stat.Type == ItemStatType.Spell_Damage_and_Healing) { addStats = new ItemStat[] { new ItemStat(ItemStatType.Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Spell_Healing, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Frost_Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Nature_Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Arcane_Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Shadow_Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Fire_Spell_Damage, normalValue, enchantValue, gemValue) }; } else if (stat.Type == ItemStatType.Spell_Damage) { addStats = new ItemStat[] { new ItemStat(ItemStatType.Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Frost_Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Nature_Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Arcane_Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Shadow_Spell_Damage, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Fire_Spell_Damage, normalValue, enchantValue, gemValue) }; } else if (stat.Type == ItemStatType.All_Resistances) { addStats = new ItemStat[] { new ItemStat(ItemStatType.Shadow_Resistance, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Fire_Resistance, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Nature_Resistance, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Frost_Resistance, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Arcane_Resistance, normalValue, enchantValue, gemValue) }; } else if (stat.Type == ItemStatType.Attack_Power) { addStats = new ItemStat[] { new ItemStat(ItemStatType.Attack_Power, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Ranged_Attack_Power, normalValue, enchantValue, gemValue) }; } else if (stat.Type == ItemStatType.HMp5) { addStats = new ItemStat[] { new ItemStat(ItemStatType.Hp5, normalValue, enchantValue, gemValue) , new ItemStat(ItemStatType.Mp5, normalValue, enchantValue, gemValue) }; } else { addStats = new ItemStat[] { new ItemStat(stat.Type, normalValue, enchantValue, gemValue) }; } foreach (var addStat in addStats) { if (addStat.StatType == ItemStatType.Unknown) { continue; } int statIndex = totalStats.FindIndex((ItemStat _Stat) => { return(addStat.StatType == _Stat.StatType); }); if (statIndex != -1) { var currStat = totalStats[statIndex]; currStat.NormalValue += addStat.NormalValue; currStat.EnchantValue += addStat.EnchantValue; currStat.GemValue += addStat.GemValue; totalStats[statIndex] = currStat; } else { totalStats.Add(addStat); } } } } catch (Exception) {} } List <ItemStatType> removeStats = new List <ItemStatType>(); int spellDmg = GetStat(totalStats, ItemStatType.Spell_Damage); if (spellDmg == GetStat(totalStats, ItemStatType.Frost_Spell_Damage)) { removeStats.Add(ItemStatType.Frost_Spell_Damage); } if (spellDmg == GetStat(totalStats, ItemStatType.Fire_Spell_Damage)) { removeStats.Add(ItemStatType.Fire_Spell_Damage); } if (spellDmg == GetStat(totalStats, ItemStatType.Arcane_Spell_Damage)) { removeStats.Add(ItemStatType.Arcane_Spell_Damage); } if (spellDmg == GetStat(totalStats, ItemStatType.Nature_Spell_Damage)) { removeStats.Add(ItemStatType.Nature_Spell_Damage); } if (spellDmg == GetStat(totalStats, ItemStatType.Shadow_Spell_Damage)) { removeStats.Add(ItemStatType.Shadow_Spell_Damage); } int spellResistance = 0; if (spellResistance == GetStat(totalStats, ItemStatType.Frost_Resistance)) { removeStats.Add(ItemStatType.Frost_Resistance); } if (spellResistance == GetStat(totalStats, ItemStatType.Fire_Resistance)) { removeStats.Add(ItemStatType.Fire_Resistance); } if (spellResistance == GetStat(totalStats, ItemStatType.Arcane_Resistance)) { removeStats.Add(ItemStatType.Arcane_Resistance); } if (spellResistance == GetStat(totalStats, ItemStatType.Nature_Resistance)) { removeStats.Add(ItemStatType.Nature_Resistance); } if (spellResistance == GetStat(totalStats, ItemStatType.Shadow_Resistance)) { removeStats.Add(ItemStatType.Shadow_Resistance); } if (GetStat(totalStats, ItemStatType.Attack_Power) == GetStat(totalStats, ItemStatType.Ranged_Attack_Power)) { removeStats.Add(ItemStatType.Ranged_Attack_Power); } foreach (var removeStat in removeStats) { int removeIndex = totalStats.FindIndex((_Value) => _Value.StatType == removeStat); if (removeIndex != -1) { totalStats.RemoveAt(removeIndex); } } return(totalStats); }
public int GenerateNewPlayerHonorDataEntry(PlayerData.HonorData _HonorData, WowVersionEnum _WowVersion) { if (_HonorData == null) { return(0); } int resultHonorID = 0; var conn = OpenConnection(); try { using (var cmd = new NpgsqlCommand("INSERT INTO playerhonortable(id, todayhk, todayhonor, yesterdayhk, yesterdayhonor, lifetimehk) VALUES (DEFAULT, :TodayHK, :TodayHonor, :YesterdayHK, :YesterdayHonor, :LifetimeHK) RETURNING id", conn)) { { var todayHKParam = new NpgsqlParameter("TodayHK", NpgsqlDbType.Integer); todayHKParam.Value = _HonorData.TodayHK; cmd.Parameters.Add(todayHKParam); } { var todayHonorParam = new NpgsqlParameter("TodayHonor", NpgsqlDbType.Integer); if (_WowVersion == WowVersionEnum.Vanilla) { todayHonorParam.Value = 0; } else { todayHonorParam.Value = _HonorData.TodayHonorTBC; } cmd.Parameters.Add(todayHonorParam); } { var yesterdayHKParam = new NpgsqlParameter("YesterdayHK", NpgsqlDbType.Integer); yesterdayHKParam.Value = _HonorData.YesterdayHK; cmd.Parameters.Add(yesterdayHKParam); } { var yesterdayHonorParam = new NpgsqlParameter("YesterdayHonor", NpgsqlDbType.Integer); yesterdayHonorParam.Value = _HonorData.YesterdayHonor; cmd.Parameters.Add(yesterdayHonorParam); } { var lifetimeHKParam = new NpgsqlParameter("LifetimeHK", NpgsqlDbType.Integer); lifetimeHKParam.Value = _HonorData.LifetimeHK; cmd.Parameters.Add(lifetimeHKParam); } using (var reader = cmd.ExecuteReader()) { if (reader.Read() == true) { resultHonorID = reader.GetInt32(0); } } } if (_WowVersion == WowVersionEnum.Vanilla && resultHonorID != 0) { using (var cmd = new NpgsqlCommand("INSERT INTO playerhonorvanillatable(playerhonorid, currentrank, currentrankprogress, todaydk, thisweekhk, thisweekhonor, lastweekhk, lastweekhonor, lastweekstanding, lifetimedk, lifetimehighestrank) VALUES (:ID, :CurrentRank, :CurrentRankProgress, :TodayDK, :ThisWeekHK, :ThisWeekHonor, :LastWeekHK, :LastWeekHonor, :LastWeekStanding, :LifetimeDK, :LifetimeHighestRank) RETURNING playerhonorid", conn)) { cmd.Parameters.Add(new NpgsqlParameter("ID", NpgsqlDbType.Integer)).Value = (int)resultHonorID; cmd.Parameters.Add(new NpgsqlParameter("CurrentRank", NpgsqlDbType.Smallint)).Value = _HonorData.CurrentRank; cmd.Parameters.Add(new NpgsqlParameter("CurrentRankProgress", NpgsqlDbType.Real)).Value = _HonorData.CurrentRankProgress; cmd.Parameters.Add(new NpgsqlParameter("TodayDK", NpgsqlDbType.Integer)).Value = _HonorData.TodayDK; cmd.Parameters.Add(new NpgsqlParameter("ThisWeekHK", NpgsqlDbType.Integer)).Value = _HonorData.ThisWeekHK; cmd.Parameters.Add(new NpgsqlParameter("ThisWeekHonor", NpgsqlDbType.Integer)).Value = _HonorData.ThisWeekHonor; cmd.Parameters.Add(new NpgsqlParameter("LastWeekHK", NpgsqlDbType.Integer)).Value = _HonorData.LastWeekHK; cmd.Parameters.Add(new NpgsqlParameter("LastWeekHonor", NpgsqlDbType.Integer)).Value = _HonorData.LastWeekHonor; cmd.Parameters.Add(new NpgsqlParameter("LastWeekStanding", NpgsqlDbType.Integer)).Value = _HonorData.LastWeekStanding; cmd.Parameters.Add(new NpgsqlParameter("LifetimeDK", NpgsqlDbType.Integer)).Value = _HonorData.LifetimeDK; cmd.Parameters.Add(new NpgsqlParameter("LifetimeHighestRank", NpgsqlDbType.Smallint)).Value = _HonorData.LifetimeHighestRank; using (var reader = cmd.ExecuteReader()) { if (reader.Read() == true) { if (resultHonorID == reader.GetInt32(0)) { return(resultHonorID); } } } } } } finally { CloseConnection(); } return(resultHonorID); }
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); }
public static bool HasPlayerNameChanged(Dictionary <string, PlayerHistory> _PlayersHistory, string _Name, WowVersionEnum _WowVersion, out string _OldName) { _OldName = _Name; PlayerHistory thisHistory = null; if (_PlayersHistory.TryGetValue(_Name, out thisHistory) == false) { return(false); } var lastCharHistory = thisHistory.CharacterHistory.Last(); if (lastCharHistory.Data.Level < 60) { return(false);//No one name changes a character below lvl 60 right? } if (thisHistory.HonorHistory.Last().Data.LifetimeHK < 500) { return(false);//If someone has less than 500 HKs they probably were not important to note, makes the algorithm faster if we can skip already here } var firstCharHistory = thisHistory.CharacterHistory.First(); if (firstCharHistory.Data.Level < 60) { return(false); //Assume false for now, only care about 60s from nowhere /* * //This player have level history, check if the history makes sense * for(int i = thisHistory.CharacterHistory.Count - 1; i >= 0; --i) * { * var charHistory = thisHistory.CharacterHistory[i]; * if(charHistory.Data.Level < 60) * { * int beforelevel60Hks = thisHistory.GetHonorItemAtTime(charHistory.Uploader.GetTime()).Data.LifetimeHK; * int afterlevel60HKs = thisHistory.GetHonorItemAtTime(thisHistory.CharacterHistory[i+1].Uploader.GetTime()).Data.LifetimeHK; * * if(beforelevel60Hks > afterlevel60HKs) * { * return true;//This is very strange, return true so that we can review this at another time * } * else * { * if(beforelevel60Hks < 500 && afterlevel60HKs > * } * } * } * return false; */ } else { var firstHonorHistory = thisHistory.HonorHistory.First(); if (firstHonorHistory.Data.LifetimeHK < 500) { return(false); //If someone had less than 500 HKs when transfering they probably were not important to note, makes the algorithm faster if we can skip already here } DateTime earliestPlayerTime = firstHonorHistory.Uploader.GetTime(); List <KeyValuePair <string, PlayerHistory> > candidates = new List <KeyValuePair <string, PlayerHistory> >(); foreach (var playerHistory in _PlayersHistory) { if (playerHistory.Value.CharacterHistory.Count < 1 || playerHistory.Value.HonorHistory.Count < 1 || playerHistory.Value.GearHistory.Count < 1) { continue; } if (playerHistory.Value.CharacterHistory.Last().Data.Class != lastCharHistory.Data.Class) { continue;//It is not possible to change class, so ignore all that arnt same class } if (playerHistory.Value.GetLatestDateTime() < earliestPlayerTime) { //Only possible if they were not updated after(assuming no other character have been made in the old name yet) if (playerHistory.Value.HonorHistory.Last().Data.LifetimeHighestRank != firstHonorHistory.Data.LifetimeHighestRank) { continue; //Must have same LifetimehighestRank } if (playerHistory.Value.HonorHistory.Last().Data.LifetimeHK <= firstHonorHistory.Data.LifetimeHK) { //Only possible if they did not have more HKs(cant go backwards in lifetime HK count) int hkDiff = firstHonorHistory.Data.LifetimeHK - playerHistory.Value.HonorHistory.Last().Data.LifetimeHK; if (hkDiff > 300) { continue; //Too big difference, hard to calculate } if (hkDiff != 0) { hkDiff -= firstHonorHistory.Data.ThisWeekHK; if (hkDiff != 0) { hkDiff -= firstHonorHistory.Data.LastWeekHK; if (hkDiff != 0) { hkDiff += playerHistory.Value.HonorHistory.Last().Data.ThisWeekHK + playerHistory.Value.HonorHistory.Last().Data.LastWeekHK; } } } if (hkDiff == 0) { //Very high chance of being the correct player if (playerHistory.Key != _Name) { //Only add if "not this" for obvious reasons //This check is placed all the way inside here for small performance gain candidates.Add(playerHistory); } } } } } if (candidates.Count == 0) { return(false);//No HK matches } var firstGearHistory = thisHistory.GearHistory.First(); foreach (var candidate in candidates) { var candidateLastGearHistory = candidate.Value.GearHistory.Last(); bool allGearSame = true; foreach (var item in firstGearHistory.Data.Items) { if (candidateLastGearHistory.Data.Items.ContainsKey(item.Key)) { if (candidateLastGearHistory.Data.Items[item.Key].ItemID != item.Value.ItemID) { allGearSame = false; break; } } } if (allGearSame == true) { //Extremely high chance of this being the correct one! good enough for me! _OldName = candidate.Key; if (sm_PlayerNameChanged.ContainsKey(_Name) == false) { if (sm_PlayerNameChanged.TryAdd(_Name, _OldName) == true) { Logger.ConsoleWriteLine("Name Change Detected: " + _OldName + "->" + _Name, ConsoleColor.Green); } } return(true); } else { //Can still be the correct candidate //if atleast 80% of the gear equipped exists in the candidates history we have found our guy! if (StaticValues.GetFaction(candidate.Value.CharacterHistory.First().Data.Race) != StaticValues.GetFaction(lastCharHistory.Data.Race)) { //If faction is different we need to exclude all PVP items var itemDropDatabase = DatabaseAccess.GetItemDropDatabase(null, _WowVersion, NotLoadedDecision.SpinWait).GetDatabase(); int itemCount = 0;//firstGearHistory.Data.Items.Count; foreach (var item in firstGearHistory.Data.Items) { List <VF_RealmPlayersDatabase.ItemDropDataItem> itemDropInfoList = null; if (itemDropDatabase.TryGetValue(item.Value.ItemID, out itemDropInfoList) == true) { bool wasPvpItem = false; foreach (var itemdropInfo in itemDropInfoList) { if (((int)itemdropInfo.m_Boss >= (int)VF_RealmPlayersDatabase.WowBoss.PVPOffsetFirst && (int)itemdropInfo.m_Boss <= (int)VF_RealmPlayersDatabase.WowBoss.PVPOffsetLast) || ((int)itemdropInfo.m_Boss >= (int)VF_RealmPlayersDatabase.WowBoss.PVPSetFirst && (int)itemdropInfo.m_Boss <= (int)VF_RealmPlayersDatabase.WowBoss.PVPSetLast)) { ++itemCount; wasPvpItem = true; break; } } if (wasPvpItem == true) { continue; } } if (candidate.Value.HaveItem(item.Value) == true)//Pretty expensive, but whatever! { ++itemCount; } } if ((float)itemCount / (float)firstGearHistory.Data.Items.Count > 0.75f) { _OldName = candidate.Key; if (sm_PlayerNameChanged.ContainsKey(_Name) == false) { if (sm_PlayerNameChanged.TryAdd(_Name, _OldName) == true) { Logger.ConsoleWriteLine("Name Change Detected: " + _OldName + "->" + _Name, ConsoleColor.Green); } } return(true); } } else { int itemCount = 0;//firstGearHistory.Data.Items.Count; foreach (var item in firstGearHistory.Data.Items) { if (candidate.Value.HaveItem(item.Value) == true)//Pretty expensive, but whatever! { ++itemCount; } } if ((float)itemCount / (float)firstGearHistory.Data.Items.Count > 0.75f) { _OldName = candidate.Key; if (sm_PlayerNameChanged.ContainsKey(_Name) == false) { if (sm_PlayerNameChanged.TryAdd(_Name, _OldName) == true) { Logger.ConsoleWriteLine("Name Change Detected: " + _OldName + "->" + _Name, ConsoleColor.Green); } } return(true); } } } } } return(false); }
public static UnitData Create(string _DataString, Dictionary <int, UnitData> _UnitDatas, WowVersionEnum _WowVersion) { UnitData newData = new UnitData(); if (_WowVersion == WowVersionEnum.Vanilla) { C_InterfaceVanilla.SetAccumParseData(newData, _DataString, _UnitDatas); return(newData); } else //if (_WowVersion == WowVersionEnum.TBC) { C_InterfaceTBC.SetAccumParseData(newData, _DataString, _UnitDatas); return(newData); } }
//public string GetTooltipHtml(int _SuffixID, int _EnchantID) //{ // string specifiedToolTip = ItemTooltipHtml; // if (_SuffixID != 0) // { // if (specifiedToolTip.Contains("Random Bonuses")) // { // specifiedToolTip = specifiedToolTip.Replace("Random Bonuses", ""); // } // } // if(_EnchantID != 0) // { // specifiedToolTip = specifiedToolTip.Replace("Durability", Code.EnchantIDs.GetValue(_EnchantID) + "<br />Durability"); // } // return specifiedToolTip; //} public string GetAjaxTooltip(WowVersionEnum _WowVersion, int _ItemID, int _SuffixID, int _EnchantID, int _UniqueID, int[] _GemIDs = null, string _PiecesStr = "") { string specifiedAjaxResult = AjaxTooltip; if (_SuffixID != 0) { if (specifiedAjaxResult.Contains("Random Bonuses")) { string suffixStr = Code.SuffixIDs.GetValue(_SuffixID, _UniqueID); if (suffixStr.Count((char _Char) => { return(_Char == '+'); }) > 1) { suffixStr = suffixStr.Replace(" +", "<br /><!---->+"); } specifiedAjaxResult = specifiedAjaxResult.Replace("Random Bonuses", "<!---->" + suffixStr); specifiedAjaxResult = specifiedAjaxResult.Replace(">" + ItemName + "<", ">" + ItemName + " " + Code.SuffixIDs.GetName(_SuffixID) + "<"); } } if (_EnchantID != 0) { string enchantString = ""; if (_WowVersion == WowVersionEnum.TBC) { enchantString = Code.EnchantIDs.GetValueTBC(_EnchantID); } else { enchantString = Code.EnchantIDs.GetValue(_EnchantID); } if (specifiedAjaxResult.Contains("Durability")) { specifiedAjaxResult = specifiedAjaxResult.Replace("Durability", "<span class=\\\"q2\\\">" + enchantString + "<\\/Span><br />Durability"); } else { specifiedAjaxResult = specifiedAjaxResult.Replace("Requires", "<span class=\\\"q2\\\">" + enchantString + "<\\/Span><br />Requires"); } } if (String.IsNullOrEmpty(_PiecesStr) == false) { string[] pieces = _PiecesStr.Split(new string[] { "%3a", ":" }, StringSplitOptions.RemoveEmptyEntries); foreach (string piece in pieces) { int hrefPos = specifiedAjaxResult.IndexOf("<a href=\\\"?item=" + piece + "\\\">"); specifiedAjaxResult = specifiedAjaxResult.Insert(hrefPos, "<span class=\\\"q8\\\">"); specifiedAjaxResult = specifiedAjaxResult.Insert(specifiedAjaxResult.IndexOf("<\\/a>", hrefPos) + "<\\/a>".Length, "<\\/Span>"); } int itemSetPos = specifiedAjaxResult.IndexOf("<a href=\\\"?itemset="); int setNumPos = specifiedAjaxResult.IndexOf("<\\/a> (", itemSetPos); setNumPos += "<\\/a> (".Length; specifiedAjaxResult = specifiedAjaxResult.Substring(0, setNumPos) + pieces.Length.ToString() + specifiedAjaxResult.Substring(setNumPos + 1); for (int i = 2; i <= pieces.Length; ++i) { string setStr = ">(" + i.ToString() + ") Set: <a href"; int setStrPos = specifiedAjaxResult.IndexOf(setStr); if (setStrPos != -1) { specifiedAjaxResult = specifiedAjaxResult.Insert(setStrPos, " class=\\\"q2\\\""); } } } string jsItemStr = "" + ItemID + ((_SuffixID != 0) ? ("r" + _SuffixID) : "") + ((_UniqueID != 0) ? ("u" + _UniqueID) : "") + ((_EnchantID != 0) ? ("e" + _EnchantID) : ""); if (_GemIDs != null && _GemIDs.Length > 0) { int prevGemStrIndex = 0; bool skippedGems = false; for (int i = 0; i < _GemIDs.Length; ++i) { int gemStrStart = specifiedAjaxResult.IndexOf("<span class=\\\"socket-", prevGemStrIndex); if (gemStrStart == -1) { break; } int gemStrEnd = specifiedAjaxResult.IndexOf("<\\/span>", gemStrStart); if (_GemIDs[i] != 0) { var gemInfo = Code.GemIDs.GetGemInfo(_GemIDs[i]); var gemItemInfo = Hidden.ApplicationInstance.Instance.GetItemInfo(gemInfo.ItemID, WowVersionEnum.TBC); if (gemItemInfo == null) { specifiedAjaxResult = specifiedAjaxResult.Substring(0, gemStrStart) + "<span class=\\\"socket-meta\\\">" + Code.EnchantIDs.GetValueTBC(_GemIDs[i]) + specifiedAjaxResult.Substring(gemStrEnd); skippedGems = true; } else { string socketType = specifiedAjaxResult.Substring(gemStrStart + "<span class=\\\"socket-".Length, 10); if (socketType.StartsWith("red")) { socketType = "red"; } else if (socketType.StartsWith("yellow")) { socketType = "yellow"; } else if (socketType.StartsWith("blue")) { socketType = "blue"; } else if (socketType.StartsWith("meta")) { socketType = "meta"; } else { Logger.ConsoleWriteLine("Invalid SocketType: \"" + socketType + "\""); } if ((socketType.StartsWith("red") && ((gemInfo.Color & Code.GemIDs.ColorRed) != Code.GemIDs.ColorRed)) || (socketType.StartsWith("yellow") && ((gemInfo.Color & Code.GemIDs.ColorYellow) != Code.GemIDs.ColorYellow)) || (socketType.StartsWith("blue") && ((gemInfo.Color & Code.GemIDs.ColorBlue) != Code.GemIDs.ColorBlue)) || (socketType.StartsWith("meta") && ((gemInfo.Color & Code.GemIDs.ColorMeta) != Code.GemIDs.ColorMeta))) { skippedGems = true; } var gemStats = Code.EnchantIDs.GetValueTBC(_GemIDs[i]); if (gemStats == "") { gemStats = "Unknown Gem"; } specifiedAjaxResult = specifiedAjaxResult.Substring(0, gemStrStart) + "<span class=\\\"socket-" + socketType + "\\\" style=\\\"background: url(http://database.wow-one.com/" + gemItemInfo.GetIconImageAddress("small") + ") no-repeat left center\\\">" + gemStats + specifiedAjaxResult.Substring(gemStrEnd); } } else { skippedGems = true; } prevGemStrIndex = gemStrStart + 1; } if (skippedGems == false && specifiedAjaxResult.IndexOf("<span class=\\\"socket-", prevGemStrIndex) == -1) { //Means all sockets are in use //Enable socket bonus specifiedAjaxResult = specifiedAjaxResult.Replace("<span class=\\\"q0\\\">Socket Bonus:", "Socket Bonus:<span class=\\\"q2\\\">"); } jsItemStr = jsItemStr + "g" + _GemIDs[0]; for (int i = 1; i < _GemIDs.Length; ++i) { jsItemStr = jsItemStr + "," + _GemIDs[i]; } } specifiedAjaxResult = specifiedAjaxResult.Replace("registerItem(" + ItemID, "registerItem('" + jsItemStr + "'"); return(specifiedAjaxResult); }
public string CreateInventoryInfo(List <PlayerItemInfo> _Items, PlayerRace _Race, PlayerClass _Class, PlayerSex _Sex, WowRealm _Realm = WowRealm.All, WowVersionEnum _WowVersion = WowVersionEnum.Vanilla) { string invInfo = ""; string currentItemDatabase = DatabaseAccess.GetCurrentItemDatabaseAddress(); var itemSummaryDB = Hidden.ApplicationInstance.Instance.GetItemSummaryDatabase(); string modelEqString = ""; var itemIDs = _Items.Select((_Value) => _Value.ItemID); foreach (var item in _Items) { var itemInfo = DatabaseAccess.GetItemInfo(item.ItemID, _WowVersion); if (itemInfo == null) { invInfo += "<div class='equipment-slot' id='" + CharacterViewer.ItemSlotToIDConversion[item.Slot] + "'><div class='quality' id='epic'></div><img src='assets/img/icons/inv_misc_questionmark.png'/></div>"; } else { string currInvInfo = "<div class='equipment-slot' id='" + CharacterViewer.ItemSlotToIDConversion[item.Slot] + "'>" + "<img class='itempic' src='" + "http://realmplayers.com/" + itemInfo.GetIconImageAddress() + "'/>" + "<div class='quality' id='" + CharacterViewer.ItemQualityConversion[itemInfo.ItemQuality] + "'></div>" + "<img class='itemframe' src='assets/img/icons/ItemNormalFrame.png'/>" + CharacterViewer.GenerateItemLink(currentItemDatabase, item, _WowVersion, itemInfo.GenerateSetPcsStr(itemIDs)); if (item.Slot == ItemSlot.Head && ModelViewerOptions.HideHead == true) { } else { if ((_Class == VF_RealmPlayersDatabase.PlayerClass.Hunter && (item.Slot == ItemSlot.Main_Hand || item.Slot == ItemSlot.Off_Hand)) || (_Class != VF_RealmPlayersDatabase.PlayerClass.Hunter && item.Slot == ItemSlot.Ranged)) { } else { int modelViewerID = 0; int modelViewerSlot = 0; if (itemInfo.GetModelViewerIDAndSlot(item.Slot, out modelViewerID, out modelViewerSlot, true) == true) { if (item.Slot == ItemSlot.Off_Hand) { if (itemInfo.AjaxTooltip.Contains("Shield") == false) { modelViewerSlot = 22; } } if (modelViewerID != 0) { modelEqString = modelEqString + "," + modelViewerSlot + "," + modelViewerID; } } } } //List<Tuple<DateTime, string>> players = null; if (_Realm != WowRealm.All) { int usageCount = itemSummaryDB.GetItemUsageCount(_Realm, item); currInvInfo += "<a class='itemplayersframe' href='ItemUsageInfo.aspx?realm=" + StaticValues.ConvertRealmParam(_Realm) + "&item=" + item.ItemID + (item.SuffixID != 0 ? "&suffix=" + item.SuffixID : "") + "'>" + usageCount + "</a>"; } currInvInfo += "</div>"; invInfo += currInvInfo; } } invInfo += "<img style='position: absolute;z-index: 1; pointer-events: none;' src='assets/img/bg/CharacterBackgroundTransparent.png'></img>"; string modelViewerQuery = PageUtility.GetQueryString(Request, "modelviewer", "unknown").ToLower(); if (modelViewerQuery != "false" && modelEqString != "" && ModelViewerOptions.View3DModel == true) { if (modelEqString[0] == ',')//För att bli av med det första "," { modelEqString = modelEqString.Substring(1); } //modelEqString = "1,33743,3,33653,5,33650,6,31110,7,31115,8,31111,9,31127,10,33651,13,25629"; string modelCharString = ((_Race == VF_RealmPlayersDatabase.PlayerRace.Undead) ? "Scourge" : _Race.ToString().Replace("_", "")) + _Sex.ToString();// "orcmale"; invInfo += "<div style='z-index: 0; position: absolute; margin: 33px 77px; width:385px; height:512px;'><object type='application/x-shockwave-flash' data='http://wow.zamimg.com/modelviewer/ZAMviewerfp11.swf' width='385' height='512' id='dsjkgbdsg2346' style='visibility: visible;'>" + "<param name='quality' value='low'>" + "<param name='allowscriptaccess' value='always'>" + "<param name='allowfullscreen' value='false'>" + "<param name='menu' value='false'>" + "<param name='bgcolor' value='#181818'>" + "<param name='wmode' value='direct'>" + "<param name='flashvars' value='hd=false&model=" + modelCharString + "&modelType=16&contentPath=http://wow.zamimg.com/modelviewer/&equipList=" + modelEqString + "'>" + "</object></div>"; } else { invInfo += "<img class='characterimage' src='" + StaticValues.GetRaceCrestImageUrl(_Race) + "'></img>"; } Hidden.ApplicationInstance.Instance.BackupItemInfos(); return(invInfo); }
public static List <DamageDataSession> ParseFile(string _Filename, ref List <string> _SessionsDebugData, WowVersionEnum _WowVersion = WowVersionEnum.Unknown) { if (_SessionsDebugData == null) { _SessionsDebugData = new List <string>(); } else { _SessionsDebugData.Add("------------\"" + _Filename + "\"------------"); } string fullFile = System.IO.File.ReadAllText(_Filename); string[] data = fullFile.Split(new string[] { "\r\nVF_" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < data.Length; ++i) { string fixedData = data[i]; fixedData = fixedData.Substring(fixedData.IndexOf('{') + 1); fixedData = fixedData.Substring(0, fixedData.LastIndexOf("\r\n}")); if (data[i].StartsWith("RaidDamageData") && (_WowVersion == WowVersionEnum.Unknown || _WowVersion == WowVersionEnum.Vanilla)) { return(_ParseData(fixedData, ref _SessionsDebugData, WowVersionEnum.Vanilla)); } else if (data[i].StartsWith("RaidStatsData") && (_WowVersion == WowVersionEnum.Unknown || _WowVersion == WowVersionEnum.TBC)) { return(_ParseData(fixedData, ref _SessionsDebugData, WowVersionEnum.TBC)); } } return(new List <DamageDataSession>()); }
public void GenerateGearStats(List <PlayerItemInfo> _Items, WowVersionEnum _WowVersion) { //m_GearStatsHTML { string gearStatsStr = "<h4 style='width:555px;text-align:center;'>Total Item Stats</h4>";//<div style='width:555px;text-align:center;'><h3>Total Gear Stats</h3></div> gearStatsStr += "<table style='width:555px;'><tbody><tr><td style='vertical-align:top'>"; var gearStats = Code.GearAnalyze.GenerateGearStats(_Items, _WowVersion); #region GearStats Ordering var gearStatsSorted = gearStats.OrderBy((_Value) => { switch (_Value.StatType) { case RealmPlayersServer.Code.ItemStatType.Armor: return(0); case RealmPlayersServer.Code.ItemStatType.Stamina: return(10); case RealmPlayersServer.Code.ItemStatType.Agility: return(20); case RealmPlayersServer.Code.ItemStatType.Strength: return(30); case RealmPlayersServer.Code.ItemStatType.Spirit: return(40); case RealmPlayersServer.Code.ItemStatType.Intellect: return(50); case RealmPlayersServer.Code.ItemStatType.Health: return(60); case RealmPlayersServer.Code.ItemStatType.Mana: return(70); case RealmPlayersServer.Code.ItemStatType.Mp5: return(80); case RealmPlayersServer.Code.ItemStatType.Defense: return(90); case RealmPlayersServer.Code.ItemStatType.Block_Chance: return(100); case RealmPlayersServer.Code.ItemStatType.Dodge_Chance: return(120); case RealmPlayersServer.Code.ItemStatType.Parry_Chance: return(130); case RealmPlayersServer.Code.ItemStatType.Block_Value: return(140); case RealmPlayersServer.Code.ItemStatType.Attack_Power: return(150); case RealmPlayersServer.Code.ItemStatType.Attack_Speed: return(155); case RealmPlayersServer.Code.ItemStatType.Crit_Chance: return(160); case RealmPlayersServer.Code.ItemStatType.Hit_Chance: return(170); case RealmPlayersServer.Code.ItemStatType.Spell_Damage: return(180); case RealmPlayersServer.Code.ItemStatType.Spell_Damage_and_Healing: return(190); case RealmPlayersServer.Code.ItemStatType.Spell_Healing: return(200); case RealmPlayersServer.Code.ItemStatType.Frost_Spell_Damage: return(210); case RealmPlayersServer.Code.ItemStatType.Fire_Spell_Damage: return(220); case RealmPlayersServer.Code.ItemStatType.Shadow_Spell_Damage: return(230); case RealmPlayersServer.Code.ItemStatType.Nature_Spell_Damage: return(240); case RealmPlayersServer.Code.ItemStatType.Spell_Crit_Chance: return(250); case RealmPlayersServer.Code.ItemStatType.Spell_Hit_Chance: return(260); case RealmPlayersServer.Code.ItemStatType.Shadow_Resistance: return(500); case RealmPlayersServer.Code.ItemStatType.Fire_Resistance: return(510); case RealmPlayersServer.Code.ItemStatType.Frost_Resistance: return(520); case RealmPlayersServer.Code.ItemStatType.Nature_Resistance: return(530); case RealmPlayersServer.Code.ItemStatType.Arcane_Resistance: return(540); case RealmPlayersServer.Code.ItemStatType.All_Resistances: return(550); //Not really in use case RealmPlayersServer.Code.ItemStatType.Unknown: return(-2); case RealmPlayersServer.Code.ItemStatType.Item_Level: return(99999); default: return(-1); } }).ToList(); #endregion int column2Start = (int)Math.Ceiling((float)gearStatsSorted.Count / 3.0f); int column3Start = (int)Math.Floor(2.0f * ((float)gearStatsSorted.Count / 3.0f)); int counter = 0; foreach (var gearStat in gearStatsSorted) { if (gearStat.StatType == Code.ItemStatType.Item_Level) { continue; } if (counter == column2Start || counter == column3Start) { gearStatsStr += "</td><td style='vertical-align:top'>"; } ++counter; string valuePrefix = ""; string statTypeCompareStr = gearStat.StatType.ToString().ToLower(); if (statTypeCompareStr.Contains("chance")) { valuePrefix = "%"; } else if (statTypeCompareStr.Contains("speed")) { valuePrefix = "%"; } gearStatsStr += gearStat.StatType.ToString().Replace('_', ' ') + ": <font color='#fff'>" + gearStat.NormalValue + valuePrefix + "</font>"; if (gearStat.EnchantValue != 0) { gearStatsStr += " + <font color='#00ff00'>" + gearStat.EnchantValue + valuePrefix + "</font>"; } gearStatsStr += "<br />"; } //gearStatsStr += "</td><td style='vertical-align:top'>"; //foreach (var gearStat in gearStatsEnchants) //{ // gearStatsStr += gearStat.Type.ToString().Replace('_', ' ') + ": 0 + <font color='#00ff00'>" + gearStat.Value + "</font><br />"; //} ////foreach (var gearStat in gearStats) ////{ //// if (gearStat.Enchant == true) //// { //// gearStatsStr += gearStat.Type.ToString().Replace('_', ' ') + ": " + gearStat.Value + "<br />"; //// } ////} gearStatsStr += "</td></tr></tbody></table>"; m_GearStatsHTML = new MvcHtmlString(gearStatsStr); } }
public static List <DamageDataSession> _ParseData(string _Data, ref List <string> _SessionDebugData, WowVersionEnum _WowVersion) { List <DamageDataSession> damageDataSessions = new List <DamageDataSession>(); if (_SessionDebugData == null) { _SessionDebugData = new List <string>(); } else { _SessionDebugData.Add("------------NEW SESSIONS PARSEDATA------------"); } /*if (_Data.Contains("Highlord Mograine")) * { * Console.WriteLine("Detected 4HM, replacing Highlord Mograine with The Four Horsemen!"); * _Data = _Data.Replace("Highlord Mograine", "The Four Horsemen"); * _Data = _Data.Replace("Dead_Y=The Four Horsemen", ""); * _Data = _Data.Replace("Dead_T=The Four Horsemen", ""); * _Data = _Data.Replace("Dead_C=The Four Horsemen", ""); * _Data = _Data.Replace("Dead_S=The Four Horsemen", ""); * //Assume there was no deaths * }*/ string sessionSplitStr = null; string dataSplitStr = null; if (_WowVersion == WowVersionEnum.TBC) { sessionSplitStr = "\r\n\t{"; dataSplitStr = "\r\n\t\t\""; } else { sessionSplitStr = "= {"; dataSplitStr = "= \""; } string[] dataSessions = _Data.Split(new string[] { sessionSplitStr }, StringSplitOptions.None); for (int i = dataSessions.Length - 1; i >= 0; --i) { if (dataSessions[i].Length > 100) { bool TimeSynch_UseServerTime = false; string[] currSessionData = dataSessions[i].Split(new string[] { dataSplitStr }, StringSplitOptions.None); //Logger.ConsoleWriteLine("Started session with " + currSessionData.Length + " timeSlices", ConsoleColor.Green); DamageDataSession newSession = new DamageDataSession(); List <int> raidMemberIDs = new List <int>(); string currZone = "Unknown"; TimeSlice lastTimeSlice = null; if (currSessionData.Length > 100) { Logger.ConsoleWriteLine("Parsing " + currSessionData.Length + " timeSlices.", ConsoleColor.White); } DateTime startParseDateTime = DateTime.UtcNow; for (int u = currSessionData.Length - 1; u >= 0; --u) { string currTimeSlice = currSessionData[u]; if (currTimeSlice.Contains('\"')) { string timeSlice = currTimeSlice.Substring(0, currTimeSlice.LastIndexOf("\",")); if (timeSlice.StartsWith("Session:Info:") == true) {//Session info data string[] sessionInfoSplit = timeSlice.Split(new string[] { "Session:Info:", "," }, StringSplitOptions.RemoveEmptyEntries); for (int o = 0; o < sessionInfoSplit.Length; ++o) { string[] nameValue = sessionInfoSplit[o].Split('='); if (nameValue.Length == 2) { if (nameValue[0] == "Date") { DateTime parsedSessionDate; if (System.DateTime.TryParse(nameValue[1], System.Globalization.CultureInfo.InvariantCulture , System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal, out parsedSessionDate)) { newSession.StartDateTime = parsedSessionDate; } } else if (nameValue[0] == "Time") { int newStartTime = 0; if (int.TryParse(nameValue[1], out newStartTime)) { newSession.StartTime = newStartTime; } } else if (nameValue[0] == "ServerTime") { var hourMinute = nameValue[1].Split(':'); if (hourMinute.Length >= 2) { int serverHour = 0; int serverMinute = 0; if (int.TryParse(hourMinute[0], out serverHour) == true) { if (int.TryParse(hourMinute[1], out serverMinute) == true) { newSession.StartServerTime = serverHour * 3600 + serverMinute * 60; } } } } else if (nameValue[0] == "Realm") { newSession.Realm = nameValue[1]; } else if (nameValue[0] == "Player") { newSession.Player = nameValue[1]; } else if (nameValue[0] == "Zone") { currZone = nameValue[1]; } else if (nameValue[0] == "AddonVersion") { newSession.AddonVersion = nameValue[1]; Logger.ConsoleWriteLine(newSession.StartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + " VF_RaidDamage " + newSession.AddonVersion, ConsoleColor.Cyan); } else if (nameValue[0].StartsWith("RaidID")) { string[] raid_Name_ID_Remain = nameValue[1].Split('-'); string raidName = RaidID_RaidNameConvert(raid_Name_ID_Remain[0]); int raidID = -1; int raidRemaining = -1; if (int.TryParse(raid_Name_ID_Remain[1], out raidID) == false) { raidID = -1; } if (int.TryParse(raid_Name_ID_Remain[2], out raidRemaining) == false) { raidRemaining = -1; } if (newSession.RaidIDData.ContainsKey(raidName) == false) { if (lastTimeSlice != null) { DamageDataSession.RaidIDEntry raidIDEntry = new DamageDataSession.RaidIDEntry(); raidIDEntry.RaidID = raidID; raidIDEntry.RaidResetDate = newSession.StartDateTime.AddSeconds((lastTimeSlice.Time - newSession.StartTime) + raidRemaining); raidIDEntry.LastSeen = newSession.StartDateTime.AddSeconds((lastTimeSlice.Time - newSession.StartTime)); newSession.RaidIDData.AddToList(raidName, raidIDEntry); } } else { if (lastTimeSlice != null) { var raidIDData = newSession.RaidIDData[raidName].Last(); if (raidIDData.RaidID == raidID) { //RaidID allready exists, update LastSeen raidIDData.LastSeen = newSession.StartDateTime.AddSeconds((lastTimeSlice.Time - newSession.StartTime)); } else { //New RaidID while in the same session! DamageDataSession.RaidIDEntry raidIDEntry = new DamageDataSession.RaidIDEntry(); raidIDEntry.RaidID = raidID; raidIDEntry.RaidResetDate = newSession.StartDateTime.AddSeconds((lastTimeSlice.Time - newSession.StartTime) + raidRemaining); raidIDEntry.LastSeen = newSession.StartDateTime.AddSeconds((lastTimeSlice.Time - newSession.StartTime)); newSession.RaidIDData.AddToList(raidName, raidIDEntry); } } } } } } } else if (timeSlice.StartsWith("Session:TimeSynch:") == true) { //TimeSynch data DateTime timeSynchLocalDate = DateTime.MinValue; int timeSynchLocalTime = -1; int timeSynchServerTime = -1; string[] sessionTimeSynchSplit = timeSlice.Split(new string[] { "Session:TimeSynch:", "," }, StringSplitOptions.RemoveEmptyEntries); for (int o = 0; o < sessionTimeSynchSplit.Length; ++o) { string[] nameValue = sessionTimeSynchSplit[o].Split('='); if (nameValue.Length == 2) { if (nameValue[0] == "Date") { DateTime parsedSessionDate; if (System.DateTime.TryParse(nameValue[1], System.Globalization.CultureInfo.InvariantCulture , System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal, out parsedSessionDate)) { timeSynchLocalDate = parsedSessionDate; } } else if (nameValue[0] == "Time") { int newStartTime = 0; if (int.TryParse(nameValue[1], out newStartTime)) { timeSynchLocalTime = newStartTime; } } else if (nameValue[0] == "ServerTime") { var hourMinute = nameValue[1].Split(':'); if (hourMinute.Length >= 2) { int serverHour = 0; int serverMinute = 0; if (int.TryParse(hourMinute[0], out serverHour) == true) { if (int.TryParse(hourMinute[1], out serverMinute) == true) { timeSynchServerTime = serverHour * 3600 + serverMinute * 60; } } } } } } if (timeSynchLocalDate != DateTime.MinValue && timeSynchLocalTime != -1 && timeSynchServerTime != -1) { int localTimeSecondsPassed = (timeSynchLocalTime - newSession.StartTime); int localDateSecondsPassed = (int)((timeSynchLocalDate - newSession.StartDateTime).TotalSeconds); if (Math.Abs(localTimeSecondsPassed - localDateSecondsPassed) > 4) { Logger.ConsoleWriteLine("Potentially not accurate time keeping, localTimeDiff=" + localTimeSecondsPassed + ", localDateDiff=" + localDateSecondsPassed, ConsoleColor.Red); } newSession.StartServerTime = timeSynchServerTime - localTimeSecondsPassed; TimeSynch_UseServerTime = true; } } else if (timeSlice.StartsWith("Session:Loot:") == true) { //Loot data //Grab time so we know DateTime currSliceDateTime = newSession.StartDateTime; if (lastTimeSlice != null) { currSliceDateTime = currSliceDateTime.AddSeconds(lastTimeSlice.Time - newSession.StartTime); } //Grab time so we know string[] sessionLootSplit = timeSlice.Split(new string[] { "Session:Loot:", ";" }, StringSplitOptions.RemoveEmptyEntries); for (int o = 0; o < sessionLootSplit.Length; ++o) { string[] nameValue = sessionLootSplit[o].Split('='); if (nameValue[0].StartsWith("BL-")) { //Boss Loot string bossName = nameValue[0].Substring(3); var itemDrops = nameValue[1].Split(','); List <int> itemIDs = new List <int>(); foreach (var itemDrop in itemDrops) { int itemID = 0; if (int.TryParse(itemDrop.Split(':').First(), out itemID) == true) { itemIDs.Add(itemID); } } if (itemIDs.Count > 0) { var bossLootIndex = newSession.BossLoot.FindIndex((_Value) => _Value.Item2 == bossName); if (bossLootIndex != -1) { newSession.BossLoot[bossLootIndex].Item3.AddRangeUnique(itemIDs); } else { newSession.BossLoot.Add(Tuple.Create(currSliceDateTime, bossName, itemIDs)); } } } else if (nameValue[0].StartsWith("PL-")) { //Player Loot string playerName = nameValue[0].Substring(3); int itemID = 0; if (int.TryParse(nameValue[1].Split(':').First(), out itemID) == true) { newSession.PlayerLoot.Add(Tuple.Create(currSliceDateTime, playerName, itemID)); } } } } else if (timeSlice.StartsWith("Session:Debug:") == true) { //Debug data, ignorera _SessionDebugData.Add(timeSlice); } else if (timeSlice.StartsWith("Session:") == false) {//Timeslice data TimeSlice newTimeSlice = new TimeSlice(lastTimeSlice, timeSlice, newSession.UnitIDToNames, raidMemberIDs, currZone, _WowVersion, newSession.BuffIDToNames, newSession.AddonVersion); newSession.TimeSlices.Add(newTimeSlice); lastTimeSlice = newTimeSlice; } else { Logger.ConsoleWriteLine("Unknown Session/TimeSlice Data: \"" + timeSlice + "\"", ConsoleColor.Red); } } if (u % 50 == 49) { if ((DateTime.UtcNow - startParseDateTime).Seconds > 1) { Logger.ConsoleWriteLine("Parsed " + (currSessionData.Length - u) + " timeSlices", ConsoleColor.White); } else { Console.Write("."); } } } foreach (var raidMemberID in raidMemberIDs) { if (newSession.UnitIDToNames.ContainsKey(raidMemberID)) { newSession.RaidMembers.Add(newSession.UnitIDToNames[raidMemberID]); } } if (TimeSynch_UseServerTime == true && newSession.StartServerTime >= 0) { int serverTimeHours = (int)(newSession.StartServerTime / 3600); int serverTimeMinutes = (int)((newSession.StartServerTime - serverTimeHours * 3600) / 60); int serverTimeSeconds = newSession.StartServerTime - serverTimeHours * 3600 - serverTimeMinutes * 60; int hourDiff = serverTimeHours - newSession.StartDateTime.Hour; int minuteDiff = serverTimeMinutes - newSession.StartDateTime.Minute; int secondDiff = serverTimeSeconds - newSession.StartDateTime.Second; int addHour = -1; if (TimeZoneInfo.Local.IsDaylightSavingTime(newSession.StartDateTime) == true) { addHour = -2; } hourDiff = hourDiff + addHour; while (hourDiff > 12) { hourDiff -= 24; } while (hourDiff < -12) { hourDiff += 24; } string oldDateTimeUTC = newSession.StartDateTime.ToString("yyyy-MM-dd HH:mm:ss"); newSession.StartDateTime = newSession.StartDateTime.AddHours(hourDiff).AddMinutes(minuteDiff).AddSeconds(secondDiff); if (newSession.StartDateTime > DateTime.UtcNow && newSession.Realm == "Nostralia") { hourDiff -= 24; newSession.StartDateTime = newSession.StartDateTime.AddHours(-24); } for (int qq = 0; qq < newSession.BossLoot.Count; ++qq) { var bossLootValue = newSession.BossLoot[qq]; newSession.BossLoot[qq] = new Tuple <DateTime, string, List <int> >(bossLootValue.Item1.AddHours(hourDiff).AddMinutes(minuteDiff).AddSeconds(secondDiff), bossLootValue.Item2, bossLootValue.Item3); } for (int qq = 0; qq < newSession.PlayerLoot.Count; ++qq) { var playerLootValue = newSession.PlayerLoot[qq]; newSession.PlayerLoot[qq] = new Tuple <DateTime, string, int>(playerLootValue.Item1.AddHours(hourDiff).AddMinutes(minuteDiff).AddSeconds(secondDiff), playerLootValue.Item2, playerLootValue.Item3); } Logger.ConsoleWriteLine("TimeSynched to ServerTime. old StartDateTimeUTC(" + oldDateTimeUTC + "), new StartDateTimeUTC(" + newSession.StartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + ")", ConsoleColor.White); } if (newSession.StartDateTime < DateTime.UtcNow || newSession.Player == "IAmFromTheFuture") { damageDataSessions.Add(newSession); } else { Logger.ConsoleWriteLine("Session was discarded because it had a StartDateTime that was from the future! StartDateTime(" + newSession.StartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + ")", ConsoleColor.Red); } if (currSessionData.Length > 100) { Logger.ConsoleWriteLine("Done with session", ConsoleColor.Green); } else { Console.Write("."); } } } return(damageDataSessions); }
public bool IsItemInfoCacheLoaded(WowVersionEnum _WowVersion) { return((_WowVersion == WowVersionEnum.Vanilla && m_ItemInfoCacheVanilla != null) || (_WowVersion == WowVersionEnum.TBC && m_ItemInfoCacheTBC != null)); }
public GearData(string _GearDataString, WowVersionEnum _WowVersion) { InitData(_GearDataString, _WowVersion); }
public int Stats_GetTotalMaxLevels(VF_RealmPlayersDatabase.WowVersionEnum _WowVersion) { int maxLevel = VF_RealmPlayersDatabase.StaticValues.GetMaxLevel(_WowVersion); return((int)Stats_GetTotals((PlayerData.Player _Player) => { return ((_Player.Character.Level == maxLevel) ? 1 : 0); })); }
public static List <ItemStat> GenerateGearStats(GearData _Gear, WowVersionEnum _WowVersion) { return(GenerateGearStats(_Gear.Items.Values, _WowVersion)); }