예제 #1
0
        protected void RecalculateItem()
        {
            if (Monitor.IsBusy)
            {
                return;
            }

            Item.NameLine = "";
            Item.TypeLine = Item.BaseType.Name;

            var(explicitStats, craftedStats) = RecalculateItemSpecific(out var requiredLevel);

            Item.ExplicitMods = CreateItemMods(explicitStats).ToList();
            Item.CraftedMods  = CreateItemMods(craftedStats).ToList();
            Item.ImplicitMods = CreateItemMods(MsImplicits.SelectMany(ms => ms.GetStatValues())).ToList();

            var quality = SelectedBase.CanHaveQuality
                ? _qualitySlider.Value
                : 0;

            Item.Properties = new ObservableCollection <ItemMod>(Item.BaseType.GetRawProperties(quality));
            ApplyLocals();

            if (Item.IsWeapon)
            {
                ApplyElementalMods(Item.Mods);
            }

            if (MsImplicits.Any())
            {
                var implicits = MsImplicits.Select(ms => ms.Query());
                requiredLevel = Math.Max(requiredLevel, implicits.Max(m => m.RequiredLevel));
            }
            Item.UpdateRequirements((80 * requiredLevel) / 100);
        }
예제 #2
0
        private void UpdateBase()
        {
            if (SelectedBase == null)
            {
                return;
            }

            using (Monitor.Enter())
            {
                var ibase = SelectedBase;
                Item = new Item(ibase);

                MsImplicits.ForEach(ms => ms.PropertyChanged -= MsOnPropertyChanged);
                var modSelectors = new List <ModSelectorViewModel>();
                foreach (var implicitMod in ibase.ImplicitMods)
                {
                    var modSelector = new ModSelectorViewModel(EquipmentData.StatTranslator, false)
                    {
                        Affixes = new[]
                        {
                            new Affix(implicitMod)
                        }
                    };
                    modSelector.PropertyChanged += MsOnPropertyChanged;
                    modSelectors.Add(modSelector);
                }
                MsImplicits = modSelectors;

                ShowQualitySlider = ibase.CanHaveQuality;

                UpdateBaseSpecific();
            }
        }
예제 #3
0
        private void ApplyLocals()
        {
            foreach (var pair in Item.GetModsAffectingProperties())
            {
                ItemMod        prop      = pair.Key;
                List <ItemMod> applymods = pair.Value;

                List <ItemMod> percm  = applymods.Where(m => Regex.IsMatch(m.Attribute, @"(?<!\+)#%")).ToList();
                List <ItemMod> valuem = applymods.Except(percm).ToList();

                if (valuem.Count > 0)
                {
                    IReadOnlyList <float> val = valuem
                                                .Select(m => m.Values)
                                                .Aggregate((l1, l2) => l1.Zip(l2, (f1, f2) => f1 + f2)
                                                           .ToList());
                    IReadOnlyList <float> nval = prop.Values
                                                 .Zip(val, (f1, f2) => f1 + f2)
                                                 .ToList();
                    prop.ValueColors = prop.ValueColors
                                       .Select((c, i) => val[i] == nval[i] ? prop.ValueColors[i] : ValueColoring.LocallyAffected)
                                       .ToList();
                    prop.Values = nval;
                }

                Func <float, float> roundf = val => (float)Math.Round(val);

                if (prop.Attribute.Contains("Critical"))
                {
                    roundf = f => (float)(Math.Round(f * 10) / 10);
                }
                else if (prop.Attribute.Contains("per Second"))
                {
                    roundf = f => (float)(Math.Round(f * 100) / 100);
                }

                if (percm.Count > 0)
                {
                    var perc = 1f + percm.Select(m => m.Values[0]).Sum() / 100f;
                    prop.ValueColors = prop.ValueColors.Select(c => ValueColoring.LocallyAffected).ToList();
                    prop.Values      = prop.Values.Select(v => roundf(v * perc)).ToList();
                }
            }
        }