private static void AddToAppLootDictionary(Dictionary <string, AppLoot> appLoopDict, List <LootChance> selectOne, AppLootContainerType containerType, IReadOnlyDictionary <string, string> gameNameToAppIdLookup, Dictionary <string, LootQuantitiesLookup> quantitiesLookup) { int normalTotalChance = LootCalculator.TotalChanceValue(selectOne); foreach (LootChance normalSelectOneLootChance in selectOne) { if (!gameNameToAppIdLookup.ContainsKey(normalSelectOneLootChance.GameName)) { continue; } string appId = gameNameToAppIdLookup[normalSelectOneLootChance.GameName]; double percentChance = (normalSelectOneLootChance.Chance / (normalTotalChance * 1.0)) * 100; LootQuantitiesLookup quantityKey = quantitiesLookup[normalSelectOneLootChance.QuantityKey]; AppLootChance newChance = new AppLootChance { Chance = (int)Math.Round(percentChance, 0), Min = quantityKey.Min, Max = quantityKey.Max, Type = containerType, }; if (appLoopDict.ContainsKey(appId)) { AppLoot current = appLoopDict[appId]; //if (current.Chances.Any(c => c.Type == containerType)) continue; current.Chances.Add(newChance); appLoopDict[appId] = current; } else { appLoopDict.Add(appId, new AppLoot { AppId = appId, Chances = new List <AppLootChance> { newChance } }); } } }