public static void Calculate(Dictionary <string, Dictionary <int, List <IdentResponse> > > containersLoot) { StatsByLootTier.Clear(); StatsByContainerName.Clear(); // Create empty stats for every loot tier for (int i = -1; i <= 8; i++) { StatsByLootTier[i] = new Stats(); } foreach (var kvp in containersLoot) { var containerByTier = StatsByLootTier[TierCalculator.GetTierByContainerName(kvp.Key)]; var containerStats = new Stats(); foreach (var container in kvp.Value) { foreach (var item in container.Value) { containerByTier.ProcessItem(item); containerStats.ProcessItem(item); } } StatsByContainerName[kvp.Key] = containerStats; } }
private void ContainerTierAuditSpellsInner(string containerName, int tier, ItemGroups.ItemGroupStats itemGroupStats, Mag.Shared.Spells.Spell.BuffLevels minBuffLevel, Mag.Shared.Spells.Spell.BuffLevels maxBuffLevel) { foreach (var item in itemGroupStats.Items) { if (!item.LongValues.ContainsKey(IntValueKey.ItemWorkmanship)) { continue; } foreach (var spellId in item.Spells) { var spell = Mag.Shared.Spells.SpellTools.GetSpell(spellId); if (spell.BuffLevel == Mag.Shared.Spells.Spell.BuffLevels.None) { continue; } if (spell.BuffLevel < minBuffLevel || spell.BuffLevel > maxBuffLevel) { File.AppendAllText(Path.Combine(txtOutputPath.Text, "Tier Container Audit.txt"), $"containerName: {containerName.PadRight(30)}, tier: {tier}, item: 0x{item.Id:X8}:{item.StringValues[StringValueKey.Name].PadRight(30)}, has spell: {spell}, Calculated Item Tier: {TierCalculator.Calculate(new List<IdentResponse> { item })}" + Environment.NewLine); outputAuditLine = true; } } } }
private void ContainerTierAuditWieldReqsInner(string containerName, int tier, ItemGroups.ItemGroupStats itemGroupStats, int wieldRequirements, HashSet <int> wieldSkillType, HashSet <int> validWieldDifficulties) { foreach (var item in itemGroupStats.Items) { if (!item.LongValues.ContainsKey(IntValueKey.ItemWorkmanship)) { continue; } if (!item.LongValues.ContainsKey(IntValueKey.WieldRequirements)) { continue; } if (item.LongValues[IntValueKey.WieldRequirements] != wieldRequirements) { continue; } if (!item.LongValues.ContainsKey(IntValueKey.WieldSkillType)) { continue; } if (!wieldSkillType.Contains(item.LongValues[IntValueKey.WieldSkillType])) { continue; } if (!item.LongValues.ContainsKey(IntValueKey.WieldDifficulty)) { continue; } if (!validWieldDifficulties.Contains(item.LongValues[IntValueKey.WieldDifficulty])) { File.AppendAllText(Path.Combine(txtOutputPath.Text, "Tier Container Audit.txt"), $"containerName: {containerName.PadRight(30)}, tier: {tier}, item: 0x{item.Id:X8}:{item.StringValues[StringValueKey.Name].PadRight(30)}, has WieldRequirements: {item.LongValues[IntValueKey.WieldRequirements]}, WieldSkillType: {item.LongValues[IntValueKey.WieldSkillType]}, WieldDifficulty: {item.LongValues[IntValueKey.WieldDifficulty]}, Calculated Item Tier: {TierCalculator.Calculate(new List<IdentResponse> { item })}" + Environment.NewLine); outputAuditLine = true; } } }
private void OnLoadFilesComplete() { var sb = new StringBuilder(); // Calculate the loot tiers TierCalculator.Calculate(containersLoot); // Populate the Containers tab var dt = new DataTable(); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Tier", typeof(int)); dt.Columns.Add("Hits", typeof(int)); dt.Columns.Add("Average Items", typeof(float)); dt.Columns.Add("Total Items", typeof(int)); foreach (var kvp in containersLoot) { var dr = dt.NewRow(); dr["Name"] = kvp.Key; dr["Tier"] = TierCalculator.GetTierByContainerName(kvp.Key); dr["Hits"] = kvp.Value.Count; var totalItems = 0; foreach (var containers in kvp.Value) { totalItems += containers.Value.Count; } dr["Average Items"] = totalItems / (float)kvp.Value.Count; dr["Total Items"] = totalItems; dt.Rows.Add(dr); } dataGridView1.DataSource = dt; dataGridView1.Columns["Hits"].DefaultCellStyle.Format = "N0"; dataGridView1.Columns["Average Items"].DefaultCellStyle.Format = "0.0"; dataGridView1.Columns["Total Items"].DefaultCellStyle.Format = "N0"; for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (i == 0) { continue; } dataGridView1.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridView1.AutoResizeColumns(); // Calculate the stats StatsCalculator.Calculate(containersLoot); // Output stats by tier sb.Clear(); foreach (var kvp in StatsCalculator.StatsByLootTier) { sb.AppendLine(); sb.AppendLine("========== Tier " + kvp.Key + " =========="); sb.Append(kvp.Value); } txtRawOutput1.Text = sb.ToString(); // Output stats by container name sb.Clear(); foreach (var kvp in StatsCalculator.StatsByContainerName) { sb.AppendLine(); sb.AppendLine("========== Container Name " + kvp.Key + " =========="); sb.Append(kvp.Value); } txtRawOutput2.Text = sb.ToString(); }