internal static void PersistentUpdateStats() { int worldId = Trinity.Player.WorldID; if (worldId <= 0 || Trinity.Player.ActorClass == ActorClass.Invalid) { return; } // Total stats string filename = Path.Combine(FileManager.LoggingPath, String.Format("FullStats - {0}.xml", Trinity.Player.ActorClass)); PersistentTotalStats = PersistentUpdateOne(filename); // World ID stats filename = Path.Combine(FileManager.LoggingPath, String.Format("WorldStats {1} - {0}.xml", Trinity.Player.ActorClass, worldId)); if (!WorldStatsDictionary.ContainsKey(worldId)) { WorldStatsDictionary.Add(worldId, new PersistentStats()); } WorldStatsDictionary[worldId] = PersistentUpdateOne(filename); // Sets LastSaved to now for the rest of the things TimeSpan TotalRunningTime = DateTime.UtcNow.Subtract(ItemDropStats.ItemStatsWhenStartedBot); PersistentLastSaved.TotalRunningTime = TotalRunningTime; PersistentLastSaved.TotalDeaths = Trinity.TotalDeaths; PersistentLastSaved.TotalLeaveGames = Trinity.TotalLeaveGames; PersistentLastSaved.TotalJoinGames = Trinity.TotalGamesJoined; PersistentLastSaved.TotalProfileRecycles = Trinity.TotalProfileRecycles; PersistentLastSaved.TotalXp = ItemDropStats.TotalXP; PersistentLastSaved.LastXp = ItemDropStats.LastXP; PersistentLastSaved.NextLvXp = ItemDropStats.NextLevelXP; PersistentLastSaved.TotalGold = ItemDropStats.TotalGold; PersistentLastSaved.LastGold = ItemDropStats.LastGold; PersistentLastSaved.Level = ItemDropStats.Level; PersistentLastSaved.ParagonLevel = ItemDropStats.ParagonLevel; UpdateItemsDroppedStats(PersistentLastSaved.ItemsDropped, ItemDropStats.ItemsDroppedStats); UpdateItemsPickedStats(PersistentLastSaved.ItemsPicked, ItemDropStats.ItemsPickedStats); }
internal static void LogStats(FileStream LogStream, PersistentStats aPersistentStats) { var ts = aPersistentStats; // Create whole new file using (StreamWriter LogWriter = new StreamWriter(LogStream)) { LogWriter.WriteLine("===== Misc Statistics ====="); LogWriter.WriteLine("Total tracking time: " + ((int)ts.TotalRunningTime.TotalHours).ToString() + "h " + ts.TotalRunningTime.Minutes.ToString() + "m " + ts.TotalRunningTime.Seconds.ToString() + "s"); LogWriter.WriteLine("Total deaths: " + ts.TotalDeaths.ToString() + " [" + Math.Round(ts.TotalDeaths / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); LogWriter.WriteLine("Total games (approx): " + ts.TotalLeaveGames.ToString() + " [" + Math.Round(ts.TotalLeaveGames / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); if (ts.TotalLeaveGames == 0 && ts.TotalJoinGames > 0) { if (ts.TotalJoinGames == 1 && ts.TotalProfileRecycles > 1) { LogWriter.WriteLine("(a profile manager/death handler is interfering with join/leave game events, attempting to guess total runs based on profile-loops)"); LogWriter.WriteLine("Total full profile cycles: " + ts.TotalProfileRecycles.ToString() + " [" + Math.Round(ts.TotalProfileRecycles / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); } else { LogWriter.WriteLine("Total games joined: " + ts.TotalJoinGames.ToString() + " [" + Math.Round(ts.TotalJoinGames / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); } } LogWriter.WriteLine("Total XP gained: " + Math.Round(ts.TotalXp / (float)1000000, 2).ToString("0.00") + " million [" + Math.Round(ts.TotalXp / ts.TotalRunningTime.TotalHours / 1000000, 2).ToString("0.00") + " million per hour]"); LogWriter.WriteLine("Total Gold gained: " + Math.Round(ts.TotalGold / (float)1000, 2).ToString("0.00") + " Thousand [" + Math.Round(ts.TotalGold / ts.TotalRunningTime.TotalHours / 1000, 2).ToString("0.00") + " Thousand per hour]"); LogWriter.WriteLine(""); LogWriter.WriteLine("===== Item DROP Statistics ====="); // Item stats if (ts.ItemsDropped.Total > 0) { LogWriter.WriteLine("Items:"); LogWriter.WriteLine("Total items dropped: " + ts.ItemsDropped.Total.ToString() + " [" + Math.Round(ts.ItemsDropped.Total / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); LogWriter.WriteLine(""); LogWriter.WriteLine("Items dropped by quality: "); for (int iThisQuality = 0; iThisQuality <= 3; iThisQuality++) { if (ts.ItemsDropped.TotalPerQuality[iThisQuality] > 0) { LogWriter.WriteLine("- " + ItemDropStats.ItemQualityTypeStrings[iThisQuality] + ": " + ts.ItemsDropped.TotalPerQuality[iThisQuality].ToString() + " [" + Math.Round(ts.ItemsDropped.TotalPerQuality[iThisQuality] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsDropped.TotalPerQuality[iThisQuality] / ts.ItemsDropped.Total) * 100, 2).ToString("0.00") + " %}"); //intell if (iThisQuality == 3) { for (int itemLevel = 1; itemLevel <= 63; itemLevel++) if (ts.ItemsDropped.TotalPerQPerL[iThisQuality, itemLevel] > 0) LogWriter.WriteLine("--- ilvl " + itemLevel.ToString() + " " + ItemDropStats.ItemQualityTypeStrings[iThisQuality] + ": " + ts.ItemsDropped.TotalPerQPerL[iThisQuality, itemLevel].ToString() + " [" + Math.Round(ts.ItemsDropped.TotalPerQPerL[iThisQuality, itemLevel] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsDropped.TotalPerQPerL[iThisQuality, itemLevel] / ts.ItemsDropped.Total) * 100, 2).ToString("0.00") + " %}"); } } // Any at all this quality? } // For loop on quality LogWriter.WriteLine(""); } // End of item stats // Key stats if (ts.ItemsDropped.TotalInfernalKeys > 0) { LogWriter.WriteLine("Infernal Key Drops:"); LogWriter.WriteLine("Total Keys: " + ts.ItemsDropped.TotalInfernalKeys.ToString() + " [" + Math.Round(ts.ItemsDropped.TotalInfernalKeys / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); } // End of key stats //LogWriter.WriteLine(""); LogWriter.WriteLine(""); LogWriter.WriteLine("===== Item PICKUP Statistics ====="); // Item stats if (ts.ItemsPicked.Total > 0) { LogWriter.WriteLine("Items:"); LogWriter.WriteLine("Total items picked up: " + ts.ItemsPicked.Total.ToString() + " [" + Math.Round(ts.ItemsPicked.Total / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); LogWriter.WriteLine(""); LogWriter.WriteLine("Items picked up by quality: "); for (int iThisQuality = 0; iThisQuality <= 3; iThisQuality++) { if (ts.ItemsPicked.TotalPerQuality[iThisQuality] > 0) { LogWriter.WriteLine("- " + ItemDropStats.ItemQualityTypeStrings[iThisQuality] + ": " + ts.ItemsPicked.TotalPerQuality[iThisQuality].ToString() + " [" + Math.Round(ts.ItemsPicked.TotalPerQuality[iThisQuality] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsPicked.TotalPerQuality[iThisQuality] / ts.ItemsPicked.Total) * 100, 2).ToString("0.00") + " %}"); //intell if (iThisQuality == 3) { for (int itemLevel = 1; itemLevel <= 63; itemLevel++) if (ts.ItemsPicked.TotalPerQPerL[iThisQuality, itemLevel] > 0) LogWriter.WriteLine("--- ilvl " + itemLevel.ToString() + " " + ItemDropStats.ItemQualityTypeStrings[iThisQuality] + ": " + ts.ItemsPicked.TotalPerQPerL[iThisQuality, itemLevel].ToString() + " [" + Math.Round(ts.ItemsPicked.TotalPerQPerL[iThisQuality, itemLevel] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsPicked.TotalPerQPerL[iThisQuality, itemLevel] / ts.ItemsPicked.Total) * 100, 2).ToString("0.00") + " %}"); } } // Any at all this quality? } // For loop on quality LogWriter.WriteLine(""); if (ItemDropStats.TotalFollowerItemsIgnored > 0) { LogWriter.WriteLine(" (note: " + ItemDropStats.TotalFollowerItemsIgnored.ToString() + " follower items ignored for being ilvl <60 or blue)"); } } // End of item stats // Potion stats if (ts.ItemsPicked.TotalPotions > 0) { LogWriter.WriteLine("Potion Pickups:"); LogWriter.WriteLine("Total potions: " + ts.ItemsPicked.TotalPotions.ToString() + " [" + Math.Round(ts.ItemsPicked.TotalPotions / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); LogWriter.WriteLine(""); } // End of potion stats // Gem stats if (ts.ItemsPicked.TotalGems > 0) { LogWriter.WriteLine("Gem Pickups:"); LogWriter.WriteLine("Total gems: " + ts.ItemsPicked.TotalGems.ToString() + " [" + Math.Round(ts.ItemsPicked.TotalGems / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); for (int iThisGemType = 0; iThisGemType <= 3; iThisGemType++) { if (ts.ItemsPicked.GemsPerType[iThisGemType] > 0) { LogWriter.WriteLine("- " + ItemDropStats.GemTypeStrings[iThisGemType] + ": " + ts.ItemsPicked.GemsPerType[iThisGemType].ToString() + " [" + Math.Round(ts.ItemsPicked.GemsPerType[iThisGemType] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsPicked.GemsPerType[iThisGemType] / ts.ItemsPicked.TotalGems) * 100, 2).ToString("0.00") + " %}"); for (int itemLevel = 1; itemLevel <= 63; itemLevel++) if (ts.ItemsPicked.GemsPerTPerL[iThisGemType, itemLevel] > 0) LogWriter.WriteLine("--- ilvl " + itemLevel.ToString() + " " + ItemDropStats.GemTypeStrings[iThisGemType] + ": " + ts.ItemsPicked.GemsPerTPerL[iThisGemType, itemLevel].ToString() + " [" + Math.Round(ts.ItemsPicked.GemsPerTPerL[iThisGemType, itemLevel] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsPicked.GemsPerTPerL[iThisGemType, itemLevel] / ts.ItemsPicked.TotalGems) * 100, 2).ToString("0.00") + " %}"); } // Any at all this quality? } // For loop on quality } // End of gem stats // Key stats if (ts.ItemsPicked.TotalInfernalKeys > 0) { LogWriter.WriteLine("Infernal Key Pickups:"); LogWriter.WriteLine("Total Keys: " + ts.ItemsPicked.TotalInfernalKeys.ToString() + " [" + Math.Round(ts.ItemsPicked.TotalInfernalKeys / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); } // End of key stats LogWriter.WriteLine("===== End Of Report ====="); LogWriter.Flush(); LogStream.Flush(); } }
internal static void PersistentUpdateStats() { int worldId = Trinity.Player.WorldID; if (worldId <= 0 || Trinity.Player.ActorClass == ActorClass.Invalid) return; // Total stats string filename = Path.Combine(FileManager.LoggingPath, String.Format("FullStats - {0}.xml", Trinity.Player.ActorClass)); PersistentTotalStats = PersistentUpdateOne(filename); // World ID stats filename = Path.Combine(FileManager.LoggingPath, String.Format("WorldStats {1} - {0}.xml", Trinity.Player.ActorClass, worldId)); if (!WorldStatsDictionary.ContainsKey(worldId)) WorldStatsDictionary.Add(worldId, new PersistentStats()); WorldStatsDictionary[worldId] = PersistentUpdateOne(filename); // Sets LastSaved to now for the rest of the things TimeSpan TotalRunningTime = DateTime.UtcNow.Subtract(ItemDropStats.ItemStatsWhenStartedBot); PersistentLastSaved.TotalRunningTime = TotalRunningTime; PersistentLastSaved.TotalDeaths = Trinity.TotalDeaths; PersistentLastSaved.TotalLeaveGames = Trinity.TotalLeaveGames; PersistentLastSaved.TotalJoinGames = Trinity.TotalGamesJoined; PersistentLastSaved.TotalProfileRecycles = Trinity.TotalProfileRecycles; PersistentLastSaved.TotalXp = ItemDropStats.TotalXP; PersistentLastSaved.LastXp = ItemDropStats.LastXP; PersistentLastSaved.NextLvXp = ItemDropStats.NextLevelXP; PersistentLastSaved.TotalGold = ItemDropStats.TotalGold; PersistentLastSaved.LastGold = ItemDropStats.LastGold; PersistentLastSaved.Level = ItemDropStats.Level; PersistentLastSaved.ParagonLevel = ItemDropStats.ParagonLevel; UpdateItemsDroppedStats(PersistentLastSaved.ItemsDropped, ItemDropStats.ItemsDroppedStats); UpdateItemsPickedStats(PersistentLastSaved.ItemsPicked, ItemDropStats.ItemsPickedStats); }
internal static PersistentStats PersistentUpdateOne(String aFilename) { PersistentStats updated = new PersistentStats(); // Load from file var xml = new XmlSerializer(updated.GetType()); if (File.Exists(aFilename)) { try { using (var reader = new StreamReader(aFilename)) { updated = xml.Deserialize(reader) as PersistentStats; if (updated.IsReset) updated.Reset(); } } catch { File.Delete(aFilename); } } else { updated.Reset(); } // If we are in new session (started times don't match) we clear PersistentLastSaved, // because we want to add all we now have. // However, after reset, we don't want to do that, because we are (hopefully) curious // only about new stuff if (updated.WhenStartedSession != ItemDropStats.ItemStatsWhenStartedBot && !updated.IsReset) { PersistentLastSaved.Reset(); } // Add the differences TimeSpan TotalRunningTime = DateTime.UtcNow.Subtract(ItemDropStats.ItemStatsWhenStartedBot); updated.IsReset = false; updated.WhenStartedSession = ItemDropStats.ItemStatsWhenStartedBot; updated.TotalRunningTime += TotalRunningTime - PersistentLastSaved.TotalRunningTime; updated.TotalDeaths += Trinity.TotalDeaths - PersistentLastSaved.TotalDeaths; updated.TotalLeaveGames += Trinity.TotalLeaveGames - PersistentLastSaved.TotalLeaveGames; updated.TotalJoinGames += Trinity.TotalGamesJoined - PersistentLastSaved.TotalJoinGames; updated.TotalProfileRecycles += Trinity.TotalProfileRecycles - PersistentLastSaved.TotalProfileRecycles; updated.TotalXp += ItemDropStats.TotalXP - PersistentLastSaved.TotalXp; updated.LastXp += ItemDropStats.LastXP - PersistentLastSaved.LastXp; updated.NextLvXp += ItemDropStats.NextLevelXP - PersistentLastSaved.NextLvXp; updated.TotalGold = ItemDropStats.TotalGold; updated.LastGold = ItemDropStats.LastGold; updated.Level = ItemDropStats.Level; updated.ParagonLevel = ItemDropStats.ParagonLevel; // Adds difference between now and LastSaved, and set LastSaved to now updated.AddItemsDroppedStats(PersistentLastSaved.ItemsDropped, ItemDropStats.ItemsDroppedStats); updated.AddItemsPickedStats(PersistentLastSaved.ItemsPicked, ItemDropStats.ItemsPickedStats); // Write the PersistentTotalStats using (var writer = new StreamWriter(aFilename)) { xml.Serialize(writer, updated); writer.Flush(); } return updated; }
internal static void LogStats(FileStream LogStream, PersistentStats aPersistentStats) { var ts = aPersistentStats; // Create whole new file using (StreamWriter LogWriter = new StreamWriter(LogStream)) { LogWriter.WriteLine("===== Misc Statistics ====="); LogWriter.WriteLine("Total tracking time: " + ((int)ts.TotalRunningTime.TotalHours).ToString() + "h " + ts.TotalRunningTime.Minutes.ToString() + "m " + ts.TotalRunningTime.Seconds.ToString() + "s"); LogWriter.WriteLine("Total deaths: " + ts.TotalDeaths.ToString() + " [" + Math.Round(ts.TotalDeaths / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); LogWriter.WriteLine("Total games (approx): " + ts.TotalLeaveGames.ToString() + " [" + Math.Round(ts.TotalLeaveGames / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); if (ts.TotalLeaveGames == 0 && ts.TotalJoinGames > 0) { if (ts.TotalJoinGames == 1 && ts.TotalProfileRecycles > 1) { LogWriter.WriteLine("(a profile manager/death handler is interfering with join/leave game events, attempting to guess total runs based on profile-loops)"); LogWriter.WriteLine("Total full profile cycles: " + ts.TotalProfileRecycles.ToString() + " [" + Math.Round(ts.TotalProfileRecycles / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); } else { LogWriter.WriteLine("Total games joined: " + ts.TotalJoinGames.ToString() + " [" + Math.Round(ts.TotalJoinGames / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); } } LogWriter.WriteLine("Total XP gained: " + Math.Round(ts.TotalXp / (float)1000000, 2).ToString("0.00") + " million [" + Math.Round(ts.TotalXp / ts.TotalRunningTime.TotalHours / 1000000, 2).ToString("0.00") + " million per hour]"); LogWriter.WriteLine("Total Gold gained: " + Math.Round(ts.TotalGold / (float)1000, 2).ToString("0.00") + " Thousand [" + Math.Round(ts.TotalGold / ts.TotalRunningTime.TotalHours / 1000, 2).ToString("0.00") + " Thousand per hour]"); LogWriter.WriteLine(""); LogWriter.WriteLine("===== Item DROP Statistics ====="); // Item stats if (ts.ItemsDropped.Total > 0) { LogWriter.WriteLine("Items:"); LogWriter.WriteLine("Total items dropped: " + ts.ItemsDropped.Total.ToString() + " [" + Math.Round(ts.ItemsDropped.Total / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); LogWriter.WriteLine(""); LogWriter.WriteLine("Items dropped by quality: "); for (int iThisQuality = 0; iThisQuality <= 3; iThisQuality++) { if (ts.ItemsDropped.TotalPerQuality[iThisQuality] > 0) { LogWriter.WriteLine("- " + ItemQualityTypeStrings[iThisQuality] + ": " + ts.ItemsDropped.TotalPerQuality[iThisQuality].ToString() + " [" + Math.Round(ts.ItemsDropped.TotalPerQuality[iThisQuality] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsDropped.TotalPerQuality[iThisQuality] / ts.ItemsDropped.Total) * 100, 2).ToString("0.00") + " %}"); //intell if (iThisQuality == 3) { for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ts.ItemsDropped.TotalPerQPerL[iThisQuality, itemLevel] > 0) { LogWriter.WriteLine("--- ilvl " + itemLevel.ToString() + " " + ItemQualityTypeStrings[iThisQuality] + ": " + ts.ItemsDropped.TotalPerQPerL[iThisQuality, itemLevel].ToString() + " [" + Math.Round(ts.ItemsDropped.TotalPerQPerL[iThisQuality, itemLevel] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsDropped.TotalPerQPerL[iThisQuality, itemLevel] / ts.ItemsDropped.Total) * 100, 2).ToString("0.00") + " %}"); } } } } // Any at all this quality? } // For loop on quality LogWriter.WriteLine(""); } // End of item stats // Key stats if (ts.ItemsDropped.TotalInfernalKeys > 0) { LogWriter.WriteLine("Infernal Key Drops:"); LogWriter.WriteLine("Total Keys: " + ts.ItemsDropped.TotalInfernalKeys.ToString() + " [" + Math.Round(ts.ItemsDropped.TotalInfernalKeys / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); } // End of key stats //LogWriter.WriteLine(""); LogWriter.WriteLine(""); LogWriter.WriteLine("===== Item PICKUP Statistics ====="); // Item stats if (ts.ItemsPicked.Total > 0) { LogWriter.WriteLine("Items:"); LogWriter.WriteLine("Total items picked up: " + ts.ItemsPicked.Total.ToString() + " [" + Math.Round(ts.ItemsPicked.Total / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); LogWriter.WriteLine(""); LogWriter.WriteLine("Items picked up by quality: "); for (int iThisQuality = 0; iThisQuality <= 3; iThisQuality++) { if (ts.ItemsPicked.TotalPerQuality[iThisQuality] > 0) { LogWriter.WriteLine("- " + ItemQualityTypeStrings[iThisQuality] + ": " + ts.ItemsPicked.TotalPerQuality[iThisQuality].ToString() + " [" + Math.Round(ts.ItemsPicked.TotalPerQuality[iThisQuality] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsPicked.TotalPerQuality[iThisQuality] / ts.ItemsPicked.Total) * 100, 2).ToString("0.00") + " %}"); //intell if (iThisQuality == 3) { for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ts.ItemsPicked.TotalPerQPerL[iThisQuality, itemLevel] > 0) { LogWriter.WriteLine("--- ilvl " + itemLevel.ToString() + " " + ItemQualityTypeStrings[iThisQuality] + ": " + ts.ItemsPicked.TotalPerQPerL[iThisQuality, itemLevel].ToString() + " [" + Math.Round(ts.ItemsPicked.TotalPerQPerL[iThisQuality, itemLevel] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsPicked.TotalPerQPerL[iThisQuality, itemLevel] / ts.ItemsPicked.Total) * 100, 2).ToString("0.00") + " %}"); } } } } // Any at all this quality? } // For loop on quality LogWriter.WriteLine(""); if (totalFollowerItemsIgnored > 0) { LogWriter.WriteLine(" (note: " + totalFollowerItemsIgnored.ToString() + " follower items ignored for being ilvl <60 or blue)"); } } // End of item stats // Potion stats if (ts.ItemsPicked.TotalPotions > 0) { LogWriter.WriteLine("Potion Pickups:"); LogWriter.WriteLine("Total potions: " + ts.ItemsPicked.TotalPotions.ToString() + " [" + Math.Round(ts.ItemsPicked.TotalPotions / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); LogWriter.WriteLine(""); } // End of potion stats // Gem stats if (ts.ItemsPicked.TotalGems > 0) { LogWriter.WriteLine("Gem Pickups:"); LogWriter.WriteLine("Total gems: " + ts.ItemsPicked.TotalGems.ToString() + " [" + Math.Round(ts.ItemsPicked.TotalGems / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); for (int iThisGemType = 0; iThisGemType <= 3; iThisGemType++) { if (ts.ItemsPicked.GemsPerType[iThisGemType] > 0) { LogWriter.WriteLine("- " + GemTypeStrings[iThisGemType] + ": " + ts.ItemsPicked.GemsPerType[iThisGemType].ToString() + " [" + Math.Round(ts.ItemsPicked.GemsPerType[iThisGemType] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsPicked.GemsPerType[iThisGemType] / ts.ItemsPicked.TotalGems) * 100, 2).ToString("0.00") + " %}"); for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ts.ItemsPicked.GemsPerTPerL[iThisGemType, itemLevel] > 0) { LogWriter.WriteLine("--- ilvl " + itemLevel.ToString() + " " + GemTypeStrings[iThisGemType] + ": " + ts.ItemsPicked.GemsPerTPerL[iThisGemType, itemLevel].ToString() + " [" + Math.Round(ts.ItemsPicked.GemsPerTPerL[iThisGemType, itemLevel] / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour] {" + Math.Round((ts.ItemsPicked.GemsPerTPerL[iThisGemType, itemLevel] / ts.ItemsPicked.TotalGems) * 100, 2).ToString("0.00") + " %}"); } } } // Any at all this quality? } // For loop on quality } // End of gem stats // Key stats if (ts.ItemsPicked.TotalInfernalKeys > 0) { LogWriter.WriteLine("Infernal Key Pickups:"); LogWriter.WriteLine("Total Keys: " + ts.ItemsPicked.TotalInfernalKeys.ToString() + " [" + Math.Round(ts.ItemsPicked.TotalInfernalKeys / ts.TotalRunningTime.TotalHours, 2).ToString("0.00") + " per hour]"); } // End of key stats LogWriter.WriteLine("===== End Of Report ====="); LogWriter.Flush(); LogStream.Flush(); } }
private static PersistentStats PersistentUpdateOne(String aFilename) { PersistentStats updated = new PersistentStats(); // Load from file var xml = new XmlSerializer(updated.GetType()); if (File.Exists(aFilename)) { try { using (var reader = new StreamReader(aFilename)) { updated = xml.Deserialize(reader) as PersistentStats; if (updated.IsReset) { updated.Reset(); } } } catch { File.Delete(aFilename); } } else { updated.Reset(); } // If we are in new session (started times don't match) we clear PersistentLastSaved, // because we want to add all we now have. // However, after reset, we don't want to do that, because we are (hopefully) curious // only about new stuff if (updated.WhenStartedSession != ItemStatsWhenStartedBot && !updated.IsReset) { PersistentLastSaved.Reset(); } // Add the differences TimeSpan TotalRunningTime = DateTime.UtcNow.Subtract(ItemStatsWhenStartedBot); updated.IsReset = false; updated.WhenStartedSession = ItemStatsWhenStartedBot; updated.TotalRunningTime += TotalRunningTime - PersistentLastSaved.TotalRunningTime; updated.TotalDeaths += TotalDeaths - PersistentLastSaved.TotalDeaths; updated.TotalLeaveGames += TotalLeaveGames - PersistentLastSaved.TotalLeaveGames; updated.TotalJoinGames += TotalGamesJoined - PersistentLastSaved.TotalJoinGames; updated.TotalProfileRecycles += TotalProfileRecycles - PersistentLastSaved.TotalProfileRecycles; updated.TotalXp += TotalXP - PersistentLastSaved.TotalXp; updated.LastXp += LastXP - PersistentLastSaved.LastXp; updated.NextLvXp += NextLevelXP - PersistentLastSaved.NextLvXp; updated.TotalGold = TotalGold; updated.LastGold = LastGold; updated.Level = Level; updated.ParagonLevel = ParagonLevel; // Adds difference between now and LastSaved, and set LastSaved to now updated.AddItemsDroppedStats(PersistentLastSaved.ItemsDropped, ItemsDroppedStats); updated.AddItemsPickedStats(PersistentLastSaved.ItemsPicked, ItemsPickedStats); // Write the PersistentTotalStats using (var writer = new StreamWriter(aFilename)) { xml.Serialize(writer, updated); writer.Flush(); } return(updated); }
/// <summary> /// Full Output Of Item Stats /// </summary> internal static void OutputReport() { using (new PerformanceLogger("OutputReport")) { if (!ZetaDia.Service.IsValid) { return; } if (!ZetaDia.Service.Platform.IsConnected) { return; } if (!ZetaDia.IsInGame) { return; } if (ZetaDia.Me.IsFullyValid()) { return; } if (!Trinity.Settings.Advanced.OutputReports) { return; } if (Player.WorldID <= 0 || Trinity.Player.ActorClass == ActorClass.Invalid) { return; } /* * Check is Lv 60 or not * If lv 60 use Paragon * If not lv 60 use normal xp/hr */ try { Level = Trinity.Player.Level; if (Player.Level < 70) { if (!(TotalXP == 0 && LastXP == 0 && NextLevelXP == 0)) { if (LastXP > Player.CurrentExperience) { TotalXP += NextLevelXP; } else { TotalXP += ZetaDia.Me.CurrentExperience - LastXP; } } LastXP = Player.CurrentExperience; NextLevelXP = Player.ExperienceNextLevel; } else { if (!(TotalXP == 0 && LastXP == 0 && NextLevelXP == 0)) { // We have leveled up if (NextLevelXP < Player.ParagonExperienceNextLevel) { TotalXP += NextLevelXP + Player.ParagonCurrentExperience; } else // We have not leveled up { TotalXP += NextLevelXP - Player.ParagonExperienceNextLevel; } } LastXP = Player.ParagonCurrentExperience; NextLevelXP = Player.ParagonExperienceNextLevel; } PersistentStats.PersistentOutputReport(); TimeSpan totalRunningTime = DateTime.UtcNow.Subtract(ItemStatsWhenStartedBot); string runStatsPath = Path.Combine(FileManager.LoggingPath, String.Format("RunStats - {0}.log", Player.ActorClass)); // Create whole new file using (FileStream logStream = File.Open(runStatsPath, FileMode.Create, FileAccess.Write, FileShare.Read)) { using (var logWriter = new StreamWriter(logStream)) { logWriter.WriteLine("===== Misc Statistics ====="); logWriter.WriteLine("Total tracking time: " + ((int)totalRunningTime.TotalHours) + "h " + totalRunningTime.Minutes + "m " + totalRunningTime.Seconds + "s"); logWriter.WriteLine("Total deaths: " + Trinity.TotalDeaths + " [" + Math.Round(Trinity.TotalDeaths / totalRunningTime.TotalHours, 2) + " per hour]"); logWriter.WriteLine("Total games (approx): " + Trinity.TotalLeaveGames + " [" + Math.Round(Trinity.TotalLeaveGames / totalRunningTime.TotalHours, 2) + " per hour]"); logWriter.WriteLine("Total Caches Opened:" + Trinity.TotalBountyCachesOpened); if (Trinity.TotalLeaveGames == 0 && Trinity.TotalGamesJoined > 0) { if (Trinity.TotalGamesJoined == 1 && Trinity.TotalProfileRecycles > 1) { logWriter.WriteLine("(a profile manager/death handler is interfering with join/leave game events, attempting to guess total runs based on profile-loops)"); logWriter.WriteLine("Total full profile cycles: " + Trinity.TotalProfileRecycles + " [" + Math.Round(Trinity.TotalProfileRecycles / totalRunningTime.TotalHours, 2) + " per hour]"); } else { logWriter.WriteLine("(your games left value may be bugged @ 0 due to profile managers/routines etc., now showing games joined instead:)"); logWriter.WriteLine("Total games joined: " + Trinity.TotalGamesJoined + " [" + Math.Round(Trinity.TotalGamesJoined / totalRunningTime.TotalHours, 2) + " per hour]"); } } logWriter.WriteLine("Total XP gained: " + Math.Round(TotalXP / (float)1000000, 2) + " million [" + Math.Round(TotalXP / totalRunningTime.TotalHours / 1000000, 2) + " million per hour]"); if (LastGold == 0) { LastGold = Player.Coinage; } if (Player.Coinage - LastGold >= 500000) { LastGold = Player.Coinage; } else { TotalGold += Player.Coinage - LastGold; LastGold = Player.Coinage; } logWriter.WriteLine("Total Gold gained: " + Math.Round(TotalGold / (float)1000, 2) + " Thousand [" + Math.Round(TotalGold / totalRunningTime.TotalHours / 1000, 2) + " Thousand per hour]"); logWriter.WriteLine(""); logWriter.WriteLine("===== Item DROP Statistics ====="); // Item stats if (ItemsDroppedStats.Total > 0) { logWriter.WriteLine("Items:"); logWriter.WriteLine("Total items dropped: " + ItemsDroppedStats.Total + " [" + Math.Round(ItemsDroppedStats.Total / totalRunningTime.TotalHours, 2) + " per hour]"); logWriter.WriteLine("Items dropped by ilvl: "); for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ItemsDroppedStats.TotalPerLevel[itemLevel] > 0) { logWriter.WriteLine("- ilvl" + itemLevel + ": " + ItemsDroppedStats.TotalPerLevel[itemLevel] + " [" + Math.Round(ItemsDroppedStats.TotalPerLevel[itemLevel] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsDroppedStats.TotalPerLevel[itemLevel] / ItemsDroppedStats.Total) * 100, 2) + " %}"); } } logWriter.WriteLine(""); logWriter.WriteLine("Items dropped by quality: "); for (int iThisQuality = 0; iThisQuality <= 3; iThisQuality++) { if (ItemsDroppedStats.TotalPerQuality[iThisQuality] > 0) { logWriter.WriteLine("- " + ItemQualityTypeStrings[iThisQuality] + ": " + ItemsDroppedStats.TotalPerQuality[iThisQuality] + " [" + Math.Round(ItemsDroppedStats.TotalPerQuality[iThisQuality] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsDroppedStats.TotalPerQuality[iThisQuality] / ItemsDroppedStats.Total) * 100, 2) + " %}"); for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ItemsDroppedStats.TotalPerQPerL[iThisQuality, itemLevel] > 0) { logWriter.WriteLine("--- ilvl " + itemLevel + " " + ItemQualityTypeStrings[iThisQuality] + ": " + ItemsDroppedStats.TotalPerQPerL[iThisQuality, itemLevel] + " [" + Math.Round(ItemsDroppedStats.TotalPerQPerL[iThisQuality, itemLevel] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsDroppedStats.TotalPerQPerL[iThisQuality, itemLevel] / ItemsDroppedStats.Total) * 100, 2) + " %}"); } } } // Any at all this quality? } // For loop on quality logWriter.WriteLine(""); } // End of item stats // Gem stats if (ItemsDroppedStats.TotalGems > 0) { logWriter.WriteLine("Gem Drops:"); logWriter.WriteLine("Total gems: " + ItemsDroppedStats.TotalGems + " [" + Math.Round(ItemsDroppedStats.TotalGems / totalRunningTime.TotalHours, 2) + " per hour]"); for (int iThisGemType = 0; iThisGemType <= 3; iThisGemType++) { if (ItemsDroppedStats.GemsPerType[iThisGemType] > 0) { logWriter.WriteLine("- " + GemTypeStrings[iThisGemType] + ": " + ItemsDroppedStats.GemsPerType[iThisGemType] + " [" + Math.Round(ItemsDroppedStats.GemsPerType[iThisGemType] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsDroppedStats.GemsPerType[iThisGemType] / ItemsDroppedStats.TotalGems) * 100, 2) + " %}"); for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ItemsDroppedStats.GemsPerTPerL[iThisGemType, itemLevel] > 0) { logWriter.WriteLine("--- ilvl " + itemLevel + " " + GemTypeStrings[iThisGemType] + ": " + ItemsDroppedStats.GemsPerTPerL[iThisGemType, itemLevel] + " [" + Math.Round(ItemsDroppedStats.GemsPerTPerL[iThisGemType, itemLevel] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsDroppedStats.GemsPerTPerL[iThisGemType, itemLevel] / ItemsDroppedStats.TotalGems) * 100, 2) + " %}"); } } } // Any at all this quality? } // For loop on quality } // End of gem stats // Key stats if (ItemsDroppedStats.TotalInfernalKeys > 0) { logWriter.WriteLine("Infernal Key Drops:"); logWriter.WriteLine("Total Keys: " + ItemsDroppedStats.TotalInfernalKeys + " [" + Math.Round(ItemsDroppedStats.TotalInfernalKeys / totalRunningTime.TotalHours, 2) + " per hour]"); } // End of key stats logWriter.WriteLine(""); logWriter.WriteLine(""); logWriter.WriteLine("===== Item PICKUP Statistics ====="); // Item stats if (ItemsPickedStats.Total > 0) { logWriter.WriteLine("Items:"); logWriter.WriteLine("Total items picked up: " + ItemsPickedStats.Total + " [" + Math.Round(ItemsPickedStats.Total / totalRunningTime.TotalHours, 2) + " per hour]"); logWriter.WriteLine("Item picked up by ilvl: "); for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ItemsPickedStats.TotalPerLevel[itemLevel] > 0) { logWriter.WriteLine("- ilvl" + itemLevel + ": " + ItemsPickedStats.TotalPerLevel[itemLevel] + " [" + Math.Round(ItemsPickedStats.TotalPerLevel[itemLevel] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsPickedStats.TotalPerLevel[itemLevel] / ItemsPickedStats.Total) * 100, 2) + " %}"); } } logWriter.WriteLine(""); logWriter.WriteLine("Items picked up by quality: "); for (int iThisQuality = 0; iThisQuality <= 3; iThisQuality++) { if (ItemsPickedStats.TotalPerQuality[iThisQuality] > 0) { logWriter.WriteLine("- " + ItemQualityTypeStrings[iThisQuality] + ": " + ItemsPickedStats.TotalPerQuality[iThisQuality] + " [" + Math.Round(ItemsPickedStats.TotalPerQuality[iThisQuality] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsPickedStats.TotalPerQuality[iThisQuality] / ItemsPickedStats.Total) * 100, 2) + " %}"); for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ItemsPickedStats.TotalPerQPerL[iThisQuality, itemLevel] > 0) { logWriter.WriteLine("--- ilvl " + itemLevel + " " + ItemQualityTypeStrings[iThisQuality] + ": " + ItemsPickedStats.TotalPerQPerL[iThisQuality, itemLevel] + " [" + Math.Round(ItemsPickedStats.TotalPerQPerL[iThisQuality, itemLevel] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsPickedStats.TotalPerQPerL[iThisQuality, itemLevel] / ItemsPickedStats.Total) * 100, 2) + " %}"); } } } // Any at all this quality? } // For loop on quality logWriter.WriteLine(""); if (TotalFollowerItemsIgnored > 0) { logWriter.WriteLine(" (note: " + TotalFollowerItemsIgnored + " follower items ignored for being ilvl <60 or blue)"); } } // End of item stats // Gem stats if (ItemsPickedStats.TotalGems > 0) { logWriter.WriteLine("Gem Pickups:"); logWriter.WriteLine("Total gems: " + ItemsPickedStats.TotalGems + " [" + Math.Round(ItemsPickedStats.TotalGems / totalRunningTime.TotalHours, 2) + " per hour]"); for (int iThisGemType = 0; iThisGemType <= 3; iThisGemType++) { if (ItemsPickedStats.GemsPerType[iThisGemType] > 0) { logWriter.WriteLine("- " + GemTypeStrings[iThisGemType] + ": " + ItemsPickedStats.GemsPerType[iThisGemType] + " [" + Math.Round(ItemsPickedStats.GemsPerType[iThisGemType] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsPickedStats.GemsPerType[iThisGemType] / ItemsPickedStats.TotalGems) * 100, 2) + " %}"); for (int itemLevel = 1; itemLevel <= 63; itemLevel++) { if (ItemsPickedStats.GemsPerTPerL[iThisGemType, itemLevel] > 0) { logWriter.WriteLine("--- ilvl " + itemLevel + " " + GemTypeStrings[iThisGemType] + ": " + ItemsPickedStats.GemsPerTPerL[iThisGemType, itemLevel] + " [" + Math.Round(ItemsPickedStats.GemsPerTPerL[iThisGemType, itemLevel] / totalRunningTime.TotalHours, 2) + " per hour] {" + Math.Round((ItemsPickedStats.GemsPerTPerL[iThisGemType, itemLevel] / ItemsPickedStats.TotalGems) * 100, 2) + " %}"); } } } // Any at all this quality? } // For loop on quality } // End of gem stats // Key stats if (ItemsPickedStats.TotalInfernalKeys > 0) { logWriter.WriteLine("Infernal Key Pickups:"); logWriter.WriteLine("Total Keys: " + ItemsPickedStats.TotalInfernalKeys + " [" + Math.Round(ItemsPickedStats.TotalInfernalKeys / totalRunningTime.TotalHours, 2) + " per hour]"); } // End of key stats logWriter.WriteLine("===== End Of Report ====="); logWriter.Flush(); logStream.Flush(); } } } catch (NullReferenceException) { // do nothing... db read error } catch (AccessViolationException) { // do nothing... db read error. } catch (Exception ex) { Logger.Log(LogCategory.UserInformation, "Error generating item report! Try deleting TrinityLogs directory to fix."); Logger.Log(LogCategory.UserInformation, "{0}", ex.ToString()); } } }