public SubconditionAffixControlViewModel(ConditionAffix condition, List <Affix> affixes, StatValueType statValueType, AffixType affixType, PoeCrafting.Entities.ItemBase itemBase)
        {
            _statValueType = statValueType;
            _affixes       = affixes;
            _affixType     = affixType;
            _itemBase      = itemBase;

            AffixName = condition.ModType;

            if (condition.Min1.HasValue)
            {
                FirstStatMin = condition.Min1.Value;
            }
            if (condition.Max1.HasValue)
            {
                FirstStatMax = condition.Max1.Value;
            }
            if (condition.Min2.HasValue)
            {
                SecondStatMin = condition.Min2.Value;
            }
            if (condition.Max2.HasValue)
            {
                SecondStatMax = condition.Max2.Value;
            }
            if (condition.Min3.HasValue)
            {
                ThirdStatMin = condition.Min3.Value;
            }
            if (condition.Max3.HasValue)
            {
                ThirdStatMax = condition.Max3.Value;
            }
        }
        private static ConditionAffix CreateTestAffix(int?min, int?max, string modName)
        {
            ConditionAffix conditionAffix = new ConditionAffix {
                Max1 = max, Min1 = min, ModType = modName
            };

            return(conditionAffix);
        }
        private ConditionResolution ResolveCondition(ConditionAffix affix, Equipment item, AffixType type, StatValueType valueType)
        {
            AffixValueCalculator calculator = new AffixValueCalculator();
            var value = calculator.GetAffixValues(affix.ModType, item, type, valueType);

            return(new ConditionResolution()
            {
                IsPresent = value.Any(),
                IsMatch = value.Any() && IsValueWithinBounds(affix, value),
                Values = value
            });
        }
        private bool IsValueWithinBounds(ConditionAffix affix, List <int> value)
        {
            bool hasRequirement1 = affix.Min1.HasValue || affix.Max1.HasValue;
            bool hasRequirement2 = affix.Min2.HasValue || affix.Max2.HasValue;
            bool hasRequirement3 = affix.Min3.HasValue || affix.Max3.HasValue;

            bool meetsRequirement1 = !hasRequirement1 || (value.Count >= 1 &&
                                                          (!affix.Min1.HasValue || value[0] >= affix.Min1.Value) &&
                                                          (!affix.Max1.HasValue || value[0] <= affix.Max1.Value));

            bool meetsRequirement2 = !hasRequirement2 || (value.Count >= 2 &&
                                                          (!affix.Min2.HasValue || value[1] >= affix.Min2.Value) &&
                                                          (!affix.Max2.HasValue || value[1] <= affix.Max2.Value));

            bool meetsRequirement3 = !hasRequirement3 || (value.Count >= 3 &&
                                                          (!affix.Min3.HasValue || value[2] >= affix.Min3.Value) &&
                                                          (!affix.Max3.HasValue || value[2] <= affix.Max3.Value));

            return(meetsRequirement1 && meetsRequirement2 && meetsRequirement3);
        }
        public ConditionAffix GetCondition()
        {
            if (string.IsNullOrEmpty(_affixName) || (IsMetaAffix && IsTier))
            {
                return(null);
            }

            var condition = new ConditionAffix
            {
                ModType = _affixName,
                Min1    = FirstStatMin,
                Max1    = FirstStatMax,
                Min2    = SecondStatMin,
                Max2    = SecondStatMax,
                Min3    = ThirdStatMin,
                Max3    = ThirdStatMax
            };

            return(condition);
        }
示例#6
0
        public SubconditionAffixControl(ConditionAffix condition, List <Affix> affixes, StatValueType statValueType, AffixType affixType, ItemBase itemBase)
        {
            _statValueType = statValueType;
            _affixes       = affixes;
            _affixType     = affixType;
            _itemBase      = itemBase;

            AffixName = condition.ModType;

            if (condition.Min1.HasValue)
            {
                FirstStatMin = condition.Min1.Value;
            }
            if (condition.Max1.HasValue)
            {
                FirstStatMax = condition.Max1.Value;
            }
            if (condition.Min2.HasValue)
            {
                SecondStatMin = condition.Min2.Value;
            }
            if (condition.Max2.HasValue)
            {
                SecondStatMax = condition.Max2.Value;
            }
            if (condition.Min3.HasValue)
            {
                ThirdStatMin = condition.Min3.Value;
            }
            if (condition.Max3.HasValue)
            {
                ThirdStatMax = condition.Max3.Value;
            }

            DataContext = this;
            InitializeComponent();
        }