public Tuple <T, bool?> LevelAction <T>(Func <int, T> action, AbstractClassAbstractionComparisonObject strategy, Treatment treatment)
        {
            if (strategy.MaxItemLevel == strategy.MinItemLevel)
            {
                return(new Tuple <T, bool?>(action(strategy.MaxItemLevel), null));
            }

            List <T> results = new List <T>();

            for (int lvl = strategy.MinItemLevel; lvl <= strategy.MaxItemLevel; lvl++)
            {
                results.Add(action(lvl));
            }

            if (results.Count == 0)
            {
                return(new Tuple <T, bool?>(default(T), false));
            }

            if (treatment == Treatment.highest)
            {
                return(new Tuple <T, bool?>(results.Max(x => x), true));
            }

            if (treatment == Treatment.lowest)
            {
                return(new Tuple <T, bool?>(results.Min(x => x), true));
            }

            return(new Tuple <T, bool?>(results.First(x => x != null), true));
        }
        public bool TestItemClass(ClassBTA itemClass, AbstractClassAbstractionComparisonObject comparisonData)
        {
            var confPrice  = LevelAction(x => itemClass.ConfPrices[x], comparisonData, comparisonData.PriceTreatment);
            var fullPrice  = LevelAction(x => itemClass.FullPrices[x], comparisonData, comparisonData.PriceTreatment);
            var validCount = LevelAction(x => itemClass.ValidItems[x], comparisonData, comparisonData.ValidityTreatment);

            if (confPrice.Item2 == false || fullPrice.Item2 == false || validCount.Item2 == false)
            {
                LoggingFacade.LogDebug($"No results found for:{ itemClass.ClassName }");
                return(false);
            }

            if (confPrice.Item1 < comparisonData.MinimumConfPrice)
            {
                return(false);
            }

            if (fullPrice.Item1 < comparisonData.MinimumFullPrice)
            {
                return(false);
            }

            if ((float)(validCount.Item1) / (float)itemClass.BaseTypes.Count < comparisonData.MinimumValidityRating)
            {
                return(false);
            }

            return(true);
        }
 public IEnumerable <ClassBTA> GetBreakPointClasses(AbstractClassAbstractionComparisonObject comparisonType)
 {
     foreach (var itemclass in this.Classes)
     {
         if (itemclass.Value.IsBreakPointClass(comparisonType))
         {
             yield return(itemclass.Value);
         }
     }
 }
 public bool IsBreakPointClass(AbstractClassAbstractionComparisonObject comparisonType)
 {
     return(comparisonType.Execute(this));
 }