public static void Calculate(Dictionary <string, List <ContainerInfo> > containersLoot) { StatsByLootTier.Clear(); StatsByContainerNameAndTier.Clear(); // Create empty stats for every loot tier for (int i = 0; i <= 8; i++) { StatsByLootTier[i] = new Stats(null, i); } foreach (var kvp in containersLoot) { var containerInfoGroups = kvp.Value.GroupContainerInfosByTier(); foreach (var containerInfoGroup in containerInfoGroups) { if (containerInfoGroup.Key == -1) // Player container { continue; } // Don't add chest stats to StatsByLootTier if (!ContainerInfo.IsChest(kvp.Key)) { var containerByTier = StatsByLootTier[containerInfoGroup.Key]; foreach (var container in containerInfoGroup.Value) { containerByTier.TotalContainers++; foreach (var item in container.Items) { containerByTier.ProcessItem(item); } } } var containerStats = new Stats(kvp.Key, containerInfoGroup.Key); foreach (var container in containerInfoGroup.Value) { containerStats.TotalContainers++; foreach (var item in container.Items) { containerStats.ProcessItem(item); } } StatsByContainerNameAndTier.Add(containerStats); } } }
private void OnLoadFilesComplete() { if (chkGeneratecontainersLootJson.Checked) { var workignOutputJsonFolder = Path.Combine(txtOutputPath.Text, DateTime.Now.ToString("yyyy-MM-dd HH-mm") + " containers json"); if (!Directory.Exists(workignOutputJsonFolder)) { Directory.CreateDirectory(workignOutputJsonFolder); } foreach (var kvp in containersLoot) { var containersLootJson = JsonConvert.SerializeObject(kvp.Value); File.WriteAllText(Path.Combine(workignOutputJsonFolder, $"{kvp.Key}.json"), containersLootJson); } return; } var workignOutputFolder = Path.Combine(txtOutputPath.Text, DateTime.Now.ToString("yyyy-MM-dd HH-mm")); if (!Directory.Exists(workignOutputFolder)) { Directory.CreateDirectory(workignOutputFolder); } // Calculate the stats StatsCalculator.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 stats in StatsCalculator.StatsByContainerNameAndTier) { var dr = dt.NewRow(); dr["Name"] = stats.ContainerName; dr["Tier"] = stats.Tier; dr["Hits"] = stats.TotalContainers; dr["Average Items"] = stats.TotalItems / (float)stats.TotalContainers; dr["Total Items"] = stats.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(); // Output stats by tier foreach (var kvp in StatsCalculator.StatsByLootTier) { File.WriteAllText(Path.Combine(workignOutputFolder, "Tier " + kvp.Key + " (No Chests).txt"), kvp.Value.ToString()); } // Output stats by container name foreach (var stats in StatsCalculator.StatsByContainerNameAndTier) { File.WriteAllText(Path.Combine(workignOutputFolder, "Container " + stats.ContainerName + $" (T{stats.Tier}).txt"), stats.ToString()); } // Audit all the containers for anomolies File.Delete(Path.Combine(workignOutputFolder, "Tier Container Audit.txt")); foreach (var stats in StatsCalculator.StatsByContainerNameAndTier) { // Chests of the same name can contain multiple tiers if (ContainerInfo.IsChest(stats.ContainerName)) { continue; } outputAuditLine = false; ContainerTierAuditSpells(stats, 1, Mag.Shared.Spells.Spell.BuffLevels.I, Mag.Shared.Spells.Spell.BuffLevels.III); ContainerTierAuditSpells(stats, 2, Mag.Shared.Spells.Spell.BuffLevels.III, Mag.Shared.Spells.Spell.BuffLevels.V); ContainerTierAuditSpells(stats, 3, Mag.Shared.Spells.Spell.BuffLevels.IV, Mag.Shared.Spells.Spell.BuffLevels.VI); ContainerTierAuditSpells(stats, 4, Mag.Shared.Spells.Spell.BuffLevels.IV, Mag.Shared.Spells.Spell.BuffLevels.VI); ContainerTierAuditSpells(stats, 5, Mag.Shared.Spells.Spell.BuffLevels.V, Mag.Shared.Spells.Spell.BuffLevels.VII); ContainerTierAuditSpells(stats, 6, Mag.Shared.Spells.Spell.BuffLevels.VI, Mag.Shared.Spells.Spell.BuffLevels.VII); ContainerTierAuditSpells(stats, 7, Mag.Shared.Spells.Spell.BuffLevels.VI, Mag.Shared.Spells.Spell.BuffLevels.VIII); ContainerTierAuditSpells(stats, 8, Mag.Shared.Spells.Spell.BuffLevels.VI, Mag.Shared.Spells.Spell.BuffLevels.VIII); ContainerTierAuditWieldReqs(stats, 1, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 2, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 0, 250 }); ContainerTierAuditWieldReqs(stats, 3, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 0, 250, 300 }); ContainerTierAuditWieldReqs(stats, 4, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 0, 250, 300, 325 }); ContainerTierAuditWieldReqs(stats, 5, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 300, 325, 350 }); ContainerTierAuditWieldReqs(stats, 6, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 350, 370, 400 }); ContainerTierAuditWieldReqs(stats, 7, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 370, 400, 420 }); ContainerTierAuditWieldReqs(stats, 8, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 400, 420, 430 }); ContainerTierAuditWieldReqs(stats, 1, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 2, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 0, 250 }); ContainerTierAuditWieldReqs(stats, 3, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 0, 250, 270 }); ContainerTierAuditWieldReqs(stats, 4, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 250, 270, 290 }); ContainerTierAuditWieldReqs(stats, 5, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 270, 290, 315 }); ContainerTierAuditWieldReqs(stats, 6, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 315, 335, 360 }); ContainerTierAuditWieldReqs(stats, 7, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 335, 360, 375 }); ContainerTierAuditWieldReqs(stats, 8, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 360, 375, 385 }); ContainerTierAuditWieldReqs(stats, 1, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 2, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 3, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 4, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0, 290 }); ContainerTierAuditWieldReqs(stats, 5, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0, 290, 310 }); ContainerTierAuditWieldReqs(stats, 6, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0, 290, 310, 330, 355 }); ContainerTierAuditWieldReqs(stats, 7, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 330, 355, 375 }); ContainerTierAuditWieldReqs(stats, 8, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 355, 375, 385 }); if (outputAuditLine) { File.AppendAllText(Path.Combine(workignOutputFolder, "Tier Container Audit.txt"), Environment.NewLine); } } }