Exemple #1
0
        private void MsPrefixOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (_changingBase)
            {
                return;
            }

            if (e.PropertyName == nameof(ModSelectorViewModel.SelectedValues))
            {
                RecalculateItem();
                return;
            }
            if (e.PropertyName != nameof(ModSelectorViewModel.SelectedAffix))
            {
                return;
            }

            using (Monitor.Enter())
            {
                var ms = (ModSelectorViewModel)sender;

                foreach (var other in MsPrefix)
                {
                    if (other != ms)
                    {
                        var blockedPrefixes = MsPrefix.Where(m => m != other).Select(m => m.SelectedAffix);
                        other.Affixes = _prefixes.Except(blockedPrefixes).ToList();
                    }
                }
            }
        }
Exemple #2
0
        public CraftingViewModel(EquipmentData equipmentData)
            : base(equipmentData,
                   equipmentData.ItemBases.Where(b => equipmentData.AffixesPerItemType.ContainsKey(b.ItemType)))
        {
            MsPrefix.ForEach(ms => ms.PropertyChanged += MsPrefixOnPropertyChanged);
            MsSuffix.ForEach(ms => ms.PropertyChanged += MsSuffixOnPropertyChanged);

            Init();
        }
        protected override IEnumerable <IGrouping <ModLocation, StatIdValuePair> > RecalculateItemSpecific(out int requiredLevel)
        {
            var selectedPrefixes = MsPrefix.Where(s => !s.IsEmptySelection).ToArray();
            var selectedSuffixes = MsSuffix.Where(s => !s.IsEmptySelection).ToArray();

            if (selectedPrefixes.Length + selectedSuffixes.Length == 0)
            {
                Item.Frame = FrameType.White;
            }
            else if (selectedPrefixes.Length <= 1 && selectedSuffixes.Length <= 1)
            {
                Item.Frame = FrameType.Magic;
                var typeline = "";

                if (selectedPrefixes.Length > 0)
                {
                    var pref = selectedPrefixes[0];
                    typeline = pref.Query().Name + " ";
                }

                typeline += Item.BaseType;

                if (selectedSuffixes.Length > 0)
                {
                    var suff = selectedSuffixes[0];
                    typeline += " " + suff.Query().Name;
                }

                Item.TypeLine = typeline;
            }
            else
            {
                Item.Frame = FrameType.Rare;
            }
            UpdateItemNameLine();

            requiredLevel = selectedPrefixes.Concat(selectedSuffixes)
                            .Select(ms => ms.Query().RequiredLevel)
                            .DefaultIfEmpty()
                            .Max();

            return
                (from ms in MsPrefix.Concat(MsSuffix)
                 where !ms.IsEmptySelection
                 let location = ms.Query().Domain == ModDomain.Crafted ? ModLocation.Crafted : ModLocation.Explicit
                                from tuple in ms.GetStatValues()
                                group tuple by location);
        }
Exemple #4
0
        RecalculateItemSpecific(out int requiredLevel)
        {
            var selectedPrefixes = MsPrefix.Where(s => !s.IsEmptySelection).ToArray();
            var selectedSuffixes = MsSuffix.Where(s => !s.IsEmptySelection).ToArray();

            if (selectedPrefixes.Length + selectedSuffixes.Length == 0)
            {
                Item.Frame = FrameType.White;
            }
            else if (selectedPrefixes.Length <= 1 && selectedSuffixes.Length <= 1)
            {
                Item.Frame = FrameType.Magic;
                var typeline = "";

                if (selectedPrefixes.Length > 0)
                {
                    var pref = selectedPrefixes[0];
                    typeline = pref.Query().Name + " ";
                }

                typeline += Item.BaseType;

                if (selectedSuffixes.Length > 0)
                {
                    var suff = selectedSuffixes[0];
                    typeline += " " + suff.Query().Name;
                }

                Item.TypeLine = typeline;
            }
            else
            {
                Item.Frame = FrameType.Rare;
            }
            UpdateItemNameLine();

            requiredLevel = selectedPrefixes.Concat(selectedSuffixes)
                            .Select(ms => ms.Query().RequiredLevel)
                            .DefaultIfEmpty()
                            .Max();

            var(craftedMs, explicitMs) = MsPrefix.Concat(MsSuffix)
                                         .Where(s => !s.IsEmptySelection)
                                         .Partition(s => s.Query().Domain == ModDomain.Crafted);
            return(explicitMs.SelectMany(s => s.GetStatValues()), craftedMs.SelectMany(s => s.GetStatValues()));
        }
Exemple #5
0
        protected override IEnumerable <ItemMod> RecalculateItemSpecific()
        {
            var selectedPreff = MsPrefix.Where(s => !s.IsEmptySelection).ToArray();
            var selectedSuff  = MsSuffix.Where(s => !s.IsEmptySelection).ToArray();

            if (selectedPreff.Length + selectedSuff.Length == 0)
            {
                Item.Frame = FrameType.White;
            }
            else if (selectedPreff.Length <= 1 && selectedSuff.Length <= 1)
            {
                Item.Frame = FrameType.Magic;
                var typeline = "";

                if (selectedPreff.Length > 0)
                {
                    var pref = selectedPreff[0];
                    typeline = pref.Query().First().Name + " ";
                }

                typeline += Item.BaseType;

                if (selectedSuff.Length > 0)
                {
                    var suff = selectedSuff[0];
                    typeline += " " + suff.Query().First().Name;
                }

                Item.TypeLine = typeline;
            }
            else
            {
                Item.Frame    = FrameType.Rare;
                Item.NameLine = "Crafted " + Item.BaseType;
            }

            var prefixes = selectedPreff.SelectMany(p => p.GetExactMods());
            var suffixes = selectedSuff.SelectMany(p => p.GetExactMods());

            return(prefixes.Concat(suffixes)
                   .GroupBy(m => m.Attribute)
                   .Select(g => g.Aggregate((m1, m2) => m1.Sum(m2))));
        }
Exemple #6
0
        protected override void UpdateBaseSpecific()
        {
            _prefixes = CreateAffixes(_allPrefixes).ToList();
            _suffixes = CreateAffixes(_allSuffixes).ToList();

            _changingBase = true;
            MsPrefix.ForEach(ms => ms.Affixes = _prefixes);
            foreach (var ms in MsPrefix)
            {
                var blockedPrefixes = MsPrefix.Where(m => m != ms).Select(m => m.SelectedAffix);
                ms.Affixes = _prefixes.Except(blockedPrefixes).ToList();
            }
            MsSuffix.ForEach(ms => ms.Affixes = _suffixes);
            foreach (var ms in MsSuffix)
            {
                var blockedSuffixes = MsSuffix.Where(m => m != ms).Select(m => m.SelectedAffix);
                ms.Affixes = _suffixes.Except(blockedSuffixes).ToList();
            }
            _changingBase = false;
        }
Exemple #7
0
        public CraftingViewModel(EquipmentData equipmentData)
            : base(equipmentData, SelectCraftableBases(equipmentData))
        {
            _allPrefixes = equipmentData.ModDatabase[ModGenerationType.Prefix];
            _allSuffixes = equipmentData.ModDatabase[ModGenerationType.Suffix];

            MsPrefix = new[] {
                new ModSelectorViewModel(EquipmentData.StatTranslator),
                new ModSelectorViewModel(EquipmentData.StatTranslator),
                new ModSelectorViewModel(EquipmentData.StatTranslator)
            };
            MsPrefix.ForEach(ms => ms.PropertyChanged += MsPrefixOnPropertyChanged);
            MsSuffix = new[] {
                new ModSelectorViewModel(EquipmentData.StatTranslator),
                new ModSelectorViewModel(EquipmentData.StatTranslator),
                new ModSelectorViewModel(EquipmentData.StatTranslator)
            };
            MsSuffix.ForEach(ms => ms.PropertyChanged += MsSuffixOnPropertyChanged);

            Init();
        }
Exemple #8
0
        protected override void UpdateBaseSpecific()
        {
            var aaff = EquipmentData.AffixesPerItemType[Item.ItemType];

            _prefixes = aaff.Where(a => a.ModType == ModType.Prefix).ToList();
            _suffixes = aaff.Where(a => a.ModType == ModType.Suffix).ToList();

            _changingBase = true;
            MsPrefix.ForEach(ms => ms.Affixes = _prefixes);
            foreach (var ms in MsPrefix)
            {
                var blockedPrefixes = MsPrefix.Where(m => m != ms).Select(m => m.SelectedAffix);
                ms.Affixes = _prefixes.Except(blockedPrefixes).ToList();
            }
            MsSuffix.ForEach(ms => ms.Affixes = _suffixes);
            foreach (var ms in MsSuffix)
            {
                var blockedSuffixes = MsSuffix.Where(m => m != ms).Select(m => m.SelectedAffix);
                ms.Affixes = _suffixes.Except(blockedSuffixes).ToList();
            }
            _changingBase = false;
        }