public void SameBaseTypeRecipeTests_OneItem_NoMatches() { foreach (var strictConditions in new List <bool>() { true, false }) { foreach (var identifiedState in new List <bool>() { true, false }) { foreach (var qualityList in _qualityLists) { List <Item> items = new List <Item>() { new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Magic).WithId("01") .WithTypeLine("Iron Hat").WithQuality(qualityList.Value[0]) .ThatIsIdentified(identifiedState)), }; items.Should().HaveCount(1); items.Select(i => i.Id).Should().OnlyHaveUniqueItems(); SameBaseTypeRecipe recipe = new SameBaseTypeRecipe(60, strictConditions); var matches = recipe.Matches(items).ToList(); matches.Should().NotBeNull(); matches.Should().HaveCount(0); } } } }
public void SameBaseTypeRecipeTests_ThreeItemsSomeIdentified_FindBestMatch() { foreach (var strictConditions in new List <bool>() { true, false }) { foreach (var qualityList in _qualityLists) { List <Item> items = new List <Item>() { new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Normal).WithId("01") .WithTypeLine("Iron Hat").WithQuality(qualityList.Value[0])), new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Rare).WithId("03") .WithTypeLine("Iron Hat").WithQuality(qualityList.Value[2]) .ThatIsIdentified(false)), }; var identifiedItem = new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Magic).WithId("02") .WithTypeLine("Iron Hat").WithQuality(qualityList.Value[1]).ThatIsIdentified(true)); items.Add(identifiedItem); items.Should().HaveCount(3); items.Select(i => i.Id).Should().OnlyHaveUniqueItems(); SameBaseTypeRecipe recipe = new SameBaseTypeRecipe(); var matches = recipe.Matches(items).ToList(); matches.Should().NotBeNull(); matches.Should().HaveCount(1); var match = matches.ElementAt(0); match.Instance.Should().BeOfType <SameBaseTypeRecipe>(); match.IsMatch.Should().BeTrue(); match.Missing.Should().HaveCount(1); match.Missing[0].Should().Be("Item with Magic rarity"); match.MatchedItems.Should().HaveCount(2); match.MatchedItems.Should().NotContain(identifiedItem); match.PercentMatch.Should().BeApproximately(200M / 3M, 0.001M); // When not using strict conditions, we still end up with the unidentified variant, since normal- // quality items count towards the unidentified recipe, and thus we have more than the minimum // match percentage with the normal and rare items. The identified variant is never considered, // since only one item is left, which does not meet the minimum match percentage. if (qualityList.Key) { match.Name.Should().Be( "2 Orbs of Alchemy - Same base type with normal, magic, rare, 20% quality and " + "unidentified"); } else { match.Name.Should().Be( "2 Orbs of Augmentation - Same base type with normal, magic, rare, unidentified"); } } } }
protected static Dictionary <string, List <RecipeResult> > GetRelaxedSameBaseTypeResults() { var itemsByTab = GetUsableCurrentLeagueItemsByTab(); SameBaseTypeRecipe sameBaseTypeRecipe = new SameBaseTypeRecipe(30); return(sameBaseTypeRecipe.Matches(itemsByTab) .GroupBy(r => r.Name) .Select(group => new { Name = group.Key, RecipeGroup = group.OrderByDescending(recipe => recipe.PercentMatch) }) .ToDictionary(g => g.Name, g => g.RecipeGroup.ToList())); }
public void SameBaseTypeRecipeTests_EmptyInput_NoMatches() { foreach (var strictConditions in new List <bool>() { true, false }) { List <Item> items = new List <Item>(); items.Should().HaveCount(0); SameBaseTypeRecipe recipe = new SameBaseTypeRecipe(60, strictConditions); var matches = recipe.Matches(items).ToList(); matches.Should().NotBeNull(); matches.Should().HaveCount(0); } }
public void SameBaseTypeRecipeTests_InvalidGearType_DoNotUse() { foreach (var strictConditions in new List <bool>() { true, false }) { foreach (var identifiedState in new List <bool>() { true, false }) { foreach (var qualityList in _qualityLists) { List <Item> items = new List <Item>() { new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Normal).WithId("01") .WithTypeLine("Small Life Flask").WithQuality(qualityList.Value[0])), new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Magic).WithId("02") .WithTypeLine("Small Life Flask").WithQuality(qualityList.Value[1]) .ThatIsIdentified(identifiedState)), new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Rare).WithId("03") .WithTypeLine("Small Life Flask").WithQuality(qualityList.Value[2]) .ThatIsIdentified(identifiedState)), }; items.Should().HaveCount(3); items.Select(i => i.Id).Should().OnlyHaveUniqueItems(); items.Select(i => (i as Gear).GearType).ShouldAllBeEquivalentTo(GearType.Flask); SameBaseTypeRecipe recipe = new SameBaseTypeRecipe(60, strictConditions); var matches = recipe.Matches(items).ToList(); matches.Should().NotBeNull(); matches.Should().HaveCount(0); } } } }
public void SameBaseTypeRecipeTests_TwoItems_PartialMatch() { foreach (var strictConditions in new List <bool>() { true, false }) { foreach (var identifiedState in new List <bool>() { true, false }) { foreach (var qualityList in _qualityLists) { List <Item> items = new List <Item>() { new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Normal).WithId("01") .WithTypeLine("Iron Hat").WithQuality(qualityList.Value[0])), new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Magic).WithId("02") .WithTypeLine("Iron Hat").WithQuality(qualityList.Value[1]) .ThatIsIdentified(identifiedState)), }; items.Should().HaveCount(2); items.Select(i => i.Id).Should().OnlyHaveUniqueItems(); SameBaseTypeRecipe recipe = new SameBaseTypeRecipe(60, strictConditions); var matches = recipe.Matches(items).ToList(); matches.Should().NotBeNull(); matches.Should().HaveCount(1); var match = matches.ElementAt(0); match.Instance.Should().BeOfType <SameBaseTypeRecipe>(); match.IsMatch.Should().BeTrue(); match.Missing.Should().HaveCount(1); match.Missing[0].Should().Be("Item with Rare rarity"); match.MatchedItems.Should().HaveCount(2); match.PercentMatch.Should().BeApproximately(200M / 3M, 0.001M); if (identifiedState) { if (qualityList.Key) { match.Name.Should().Be( "1 Orb of Alchemy - Same base type with normal, magic, rare, 20% quality"); } else { match.Name.Should().Be( "1 Orb of Augmentation - Same base type with normal, magic, and rare"); } } else { if (qualityList.Key) { match.Name.Should().Be( "2 Orbs of Alchemy - Same base type with normal, magic, rare, 20% quality and " + "unidentified"); } else { match.Name.Should().Be( "2 Orbs of Augmentation - Same base type with normal, magic, rare, unidentified"); } } } } } }
public void SameBaseTypeRecipeTests_ThreeItemsSomeFullQuality_FindBestMatch() { foreach (var strictConditions in new List <bool>() { true, false }) { foreach (var identifiedState in new List <bool>() { true, false }) { List <Item> items = new List <Item>() { new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Normal).WithId("01") .WithTypeLine("Iron Hat")), new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Magic).WithId("02") .WithTypeLine("Iron Hat").WithQuality(20) .ThatIsIdentified(identifiedState)), new Gear(Build.A.JsonProxyItem.WithFrameType((int)Rarity.Rare).WithId("03") .WithTypeLine("Iron Hat").WithQuality(10) .ThatIsIdentified(identifiedState)), }; items.Should().HaveCount(3); items.Select(i => i.Id).Should().OnlyHaveUniqueItems(); SameBaseTypeRecipe recipe = new SameBaseTypeRecipe(60, strictConditions); var matches = recipe.Matches(items).ToList(); matches.Should().NotBeNull(); matches.Should().HaveCount(1); var match = matches.ElementAt(0); match.Instance.Should().BeOfType <SameBaseTypeRecipe>(); match.IsMatch.Should().BeTrue(); if (strictConditions) { // The magic item is not included because it has 20% quality, but the variant being searched // for requires quality != 20%. match.Missing.Should().HaveCount(1); match.Missing[0].Should().Be("Item with Magic rarity"); match.MatchedItems.Should().HaveCount(2); match.PercentMatch.Should().BeApproximately(200M / 3M, 0.001M); } else { match.Missing.Should().HaveCount(0); match.MatchedItems.Should().HaveCount(3); match.PercentMatch.Should().Be(100M); } if (identifiedState) { match.Name.Should().Be( "1 Orb of Augmentation - Same base type with normal, magic, and rare"); } else { match.Name.Should().Be( "2 Orbs of Augmentation - Same base type with normal, magic, rare, unidentified"); } } } }