public static Collection readCollection(string name, List<Tuple<TextBox, TextBox, TextBox, ComboBox>> controlsList) { var collection = new Collection(); collection.name = name; foreach(var row in controlsList) { double minFloatValue = double.Parse(row.Item2.Text); double maxFloatValue = double.Parse(row.Item3.Text); ComboBoxItem selectedItem = (ComboBoxItem)row.Item4.SelectedItem; string selectedValue = (string)selectedItem.Content; CollectionGrade collectionGrade = (CollectionGrade)Enum.Parse(typeof(CollectionGrade), selectedValue); collection.jsonSkins.Add(new Skin(row.Item1.Text, minFloatValue, maxFloatValue, collectionGrade)); } return collection; }
public static List<TradeUpContract> checkCollection(Collection collection) { List<TradeUpContract> contracts = new List<TradeUpContract>(); foreach (CollectionGrade grade in Enum.GetValues(typeof(CollectionGrade))) { if((int)grade == 1) { continue; } var higherTier = collection.jsonSkins.Where(s => s.collectionGrade == grade).ToList(); var lowerTier = collection.jsonSkins.Where(s => s.collectionGrade == (grade - 1)).ToList(); if(higherTier.Count != 0 && lowerTier.Count != 0) { contracts.Add(findBestContract(higherTier, lowerTier)); } } return contracts; }