public void CalculateExpectedValue() { if (!Items.Any()) { ExpectedFilterValue = FilterValue; return; } float minValueBoss = float.MaxValue; float maxValueBoss = float.MinValue; float minValueLeague = float.MaxValue; float maxValueLeague = float.MinValue; float minValueCraftedFated = float.MaxValue; float maxValueCraftedFated = float.MinValue; float minValue = float.MaxValue; float maxValue = float.MinValue; bool isLeagueOnly = true; bool hasLeague = false; bool hasCoreLeague = false; bool hasLabyrinth = false; bool isBossOnly = true; bool hasBoss = false; bool isCraftedOnly = true; bool isUnobtainable = true; int minExpectedTier = 1; UniqueValue minExpected = UniqueValue.Unknown; // Determine Expected Value foreach (UniqueItem uniqData in Items) { if (uniqData.Unobtainable) { continue; } isUnobtainable = false; if (uniqData.IsCrafted || uniqData.IsFated || uniqData.IsPurchased) { if (!uniqData.IsLowConfidence) { if (minValueCraftedFated > uniqData.ChaosValue) { minValueCraftedFated = uniqData.ChaosValue; } if (maxValueCraftedFated < uniqData.ChaosValue) { maxValueCraftedFated = uniqData.ChaosValue; } } continue; } isCraftedOnly = false; if (uniqData.IsCoreDrop) { isLeagueOnly = false; hasCoreLeague = hasCoreLeague || uniqData.League.Length != 0; if (uniqData.IsLimitedDrop) { if (uniqData.IsLabyrinthDrop) { hasLabyrinth = true; } else { hasBoss = true; } if (!uniqData.IsLowConfidence) { if (minValueBoss > uniqData.ChaosValue) { minValueBoss = uniqData.ChaosValue; } if (maxValueBoss < uniqData.ChaosValue) { maxValueBoss = uniqData.ChaosValue; } } } else { isBossOnly = false; if (!uniqData.IsLowConfidence && uniqData.Links != 6) { if (minValue > uniqData.ChaosValue) { minValue = uniqData.ChaosValue; } if (maxValue < uniqData.ChaosValue) { maxValue = uniqData.ChaosValue; } } } } else { hasLeague = true; if (!uniqData.IsLowConfidence) { if (minValueLeague > uniqData.ChaosValue) { minValueLeague = uniqData.ChaosValue; } if (maxValueLeague < uniqData.ChaosValue) { maxValueLeague = uniqData.ChaosValue; } } } } if (isUnobtainable) { ExpectedFilterValue = UniqueValue.Chaos10; // unique exists in permanent leagues only return; } else if (isCraftedOnly) { minValue = minValueCraftedFated; maxValue = maxValueCraftedFated; minExpected = UniqueValue.ChaosLess1Crafted; } else if (isLeagueOnly) { minValue = minValueLeague; maxValue = maxValueLeague; minExpected = UniqueValue.ChaosLess1League; } else if (isBossOnly) { minValue = minValueBoss; maxValue = maxValueBoss; if (hasBoss) { minExpected = UniqueValue.ChaosLess1Boss; } else { minExpected = UniqueValue.ChaosLess1Labyrinth; } } else if (hasLeague) { if (minValueLeague > 6.0f) { minExpected = UniqueValue.ChaosLess1Shared; } else { minExpected = UniqueValue.ChaosLess1; } } else if (hasBoss) { minExpected = UniqueValue.ChaosLess1Boss; } else if (hasCoreLeague) { minExpected = UniqueValue.ChaosLess1League; } else if (hasLabyrinth) { minExpected = UniqueValue.ChaosLess1; } else { minExpectedTier = 0; } // Set Expected Value if (minValue > maxValue) //no confident value { ExpectedFilterValue = FilterValue; } else //confident value { ExpectedFilterValue = UniqueValue.ValueOf(minValue); if (ExpectedFilterValue.Tier <= 1) { if (maxValue > 50.0f) { ExpectedFilterValue = UniqueValue.Chaos2to10; } else if (maxValue > 9.0f || (minValue > 0.95f && maxValue > 1.8f)) { ExpectedFilterValue = UniqueValue.Chaos1to2; } else if (maxValue > 2.0f || minValue > 0.95f) { ExpectedFilterValue = UniqueValue.ChaosLess1; } } else if (ExpectedFilterValue.Value == UniqueValueEnum.Chaos1to2 && minValue > 1.9f && maxValue > 4.9f) { ExpectedFilterValue = UniqueValue.Chaos2to10; } } if (ExpectedFilterValue.Tier <= minExpectedTier) { ExpectedFilterValue = minExpected; } }
private UniqueValue CalculateExpectedValue() { if (!Items.Any()) { return(FilterValue); } if (Items.Count == 1) { float val = Items[0].ChaosValue; if (val < 0.01 || Items[0].IsLowConfidence || (val >= FilterValue.LowValue && val <= FilterValue.HighValue)) { return(FilterValue); } return(UniqueValue.ValueOf(val)); } bool isUnobtainable = true; float minVal = float.MaxValue; float maxVal = float.MinValue; float minValLimited = float.MaxValue; float maxValLimited = float.MinValue; float minValLeague = float.MaxValue; float maxValLeague = float.MinValue; float minValCrafted = float.MaxValue; float maxValCrafted = float.MinValue; int minTier = 0; float filterVal = FilterValue.LowValue + (FilterValue.HighValue - FilterValue.LowValue) / 2.0f; foreach (UniqueItem uniq in Items) { if (uniq.IsUnobtainable) { continue; } isUnobtainable = false; if (uniq.IsPurchased || uniq.IsCrafted || uniq.IsFated) { if (uniq.Count > 0) { minValCrafted = Math.Min(minValCrafted, uniq.ChaosValue); maxValCrafted = Math.Max(maxValCrafted, uniq.ChaosValue); } continue; } if (uniq.Count == 0) { minTier = Math.Min(minTier, 1); continue; } if (!uniq.IsCoreDrop) { minValLeague = Math.Min(minValLeague, uniq.ChaosValue); maxValLeague = Math.Max(maxValLeague, uniq.ChaosValue); if (uniq.ChaosValue >= 8.0f) { minTier = Math.Max(minTier, 1); } continue; } if (uniq.Source.Length > 0 && !uniq.IsProphecyDrop) // IsProphecyDrop || uniq.IsLabyrinthDrop || uniq.IsBossDrop { minValLimited = Math.Min(minValLimited, uniq.ChaosValue); maxValLimited = Math.Max(maxValLimited, uniq.ChaosValue); if (uniq.ChaosValue >= 5.0f) { minTier = Math.Max(minTier, 1); } continue; } if (uniq.Leagues.Any(x => x.Length == 0)) { if (uniq.IsLowConfidence) { if (minVal > maxVal) { minVal = filterVal; maxVal = filterVal; } if (uniq.ChaosValue >= 40.0f) { minTier = Math.Max(minTier, 3); } if (uniq.ChaosValue >= 15.0f) { minTier = Math.Max(minTier, 2); } else if (uniq.ChaosValue >= 5.0f) { minTier = Math.Max(minTier, 1); } continue; } else { minVal = Math.Min(minVal, uniq.ChaosValue); maxVal = Math.Max(maxVal, uniq.ChaosValue); } } else { minValLimited = Math.Min(minValLimited, uniq.ChaosValue); maxValLimited = Math.Max(maxValLimited, uniq.ChaosValue); if (uniq.ChaosValue >= 15.0f) { minTier = Math.Max(minTier, 2); } if (uniq.ChaosValue >= 5.0f) { minTier = Math.Max(minTier, 1); } } } if (isUnobtainable) { return(UniqueValue.Chaos15); } if (minVal > maxVal) { if (minValLimited <= maxValLimited) { minVal = minValLimited; maxVal = maxValLimited; } else if (minValLeague <= maxValLeague) { minVal = minValLeague; maxVal = maxValLeague; minTier = Math.Max(minTier, 2); } else if (minValCrafted <= maxValCrafted) { minVal = minValCrafted; maxVal = maxValCrafted; minTier = Math.Max(minTier, 2); } else { return(FilterValue); } } if (minVal >= 14.0f) { return(UniqueValue.Chaos15); } if (minVal >= 4.7f || maxVal >= 100.0f || minTier == 3) { return(UniqueValue.Chaos5to15); } if (minVal >= 2.95f || maxVal >= 15.0f || minTier == 2) { return(UniqueValue.Chaos3to5); } if (maxVal >= 7.0f || minTier == 1) { return(UniqueValue.Limited); } return(UniqueValue.Worthless); }