예제 #1
0
파일: Data.cs 프로젝트: ucddj/EnhancePoEApp
        public void GetSetAmount()
        {
            int rings = OverallRingAmount / 2;
            int weapons = OverallWeaponAmount / 2;
            int sets = new[] { rings, weapons, OverallHelmetAmount, OverallBootsAmount, OverallGlovesAmount, OverallChestAmount, OverallAmuletAmount, OverallBeltAmount }.Min();

            SetAmount = sets;

            List <string> sectionList = new List <string>();
            bool          filterActive = Properties.Settings.Default.LootfilterActive;


            if (weapons >= SetTargetAmount)
            {
                WeaponActive = false;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(false, WeaponBases, "weapon"));
                }
            }
            else
            {
                WeaponActive = true;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(true, WeaponBases, "weapon"));
                }
            }
            if (OverallChestAmount >= SetTargetAmount)
            {
                ChestActive = false;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(false, ChestBases, "chest"));
                }
            }
            else
            {
                ChestActive = true;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(true, ChestBases, "chest"));
                }
            }
            if (OverallBootsAmount >= SetTargetAmount)
            {
                BootsActive = false;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(false, BootsBases, "boots"));
                }
            }
            else
            {
                BootsActive = true;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(true, BootsBases, "boots"));
                }
            }
            if (OverallGlovesAmount >= SetTargetAmount)
            {
                GlovesActive = false;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(false, GlovesBases, "gloves"));
                }
            }
            else
            {
                GlovesActive = true;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(true, GlovesBases, "gloves"));
                }
            }
            if (OverallHelmetAmount >= SetTargetAmount)
            {
                HelmetActive = false;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(false, HelmetBases, "helmet"));
                }
            }
            else
            {
                HelmetActive = true;
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(true, HelmetBases, "helmet"));
                }
            }

            MainWindow.overlay.Dispatcher.Invoke(() =>
            {
                MainWindow.overlay.FullSetsTextBlock.Text = sets.ToString();
            });

            if (filterActive)
            {
                sectionList.Add(FilterGeneration.GenerateSection(true, RingBases, "ring"));
                sectionList.Add(FilterGeneration.GenerateSection(true, AmuletBases, "amulet"));
                sectionList.Add(FilterGeneration.GenerateSection(true, BeltBases, "belt"));

                string oldFilter = FilterGeneration.OpenLootfilter();
                string newFilter = FilterGeneration.GenerateLootFilter(oldFilter, sectionList);
                FilterGeneration.WriteLootfilter(newFilter);
            }
            //Trace.WriteLine(sets, "set min amount");
        }
예제 #2
0
        public static void CheckActives()
        {
            try
            {
                if (ApiAdapter.FetchError)
                {
                    MainWindow.overlay.WarningMessage           = "Fetching Error...";
                    MainWindow.overlay.ShadowOpacity            = 1;
                    MainWindow.overlay.WarningMessageVisibility = System.Windows.Visibility.Visible;
                    //MainWindow.overlay.RunFetching();
                    return;
                }
                if (Properties.Settings.Default.ShowItemAmount)
                {
                    Data.CalculateItemAmounts();
                }

                if (Properties.Settings.Default.Sound)
                {
                    PreviousActiveItems = new ActiveItemTypes
                    {
                        BootsActive  = ActiveItems.BootsActive,
                        GlovesActive = ActiveItems.GlovesActive,
                        HelmetActive = ActiveItems.HelmetActive,
                        WeaponActive = ActiveItems.WeaponActive,
                        ChestActive  = ActiveItems.ChestActive
                    };
                }

                bool exaltedActive = Properties.Settings.Default.ExaltedRecipe;
                bool filterActive  = Properties.Settings.Default.LootfilterActive;

                SetTargetAmount = 0;
                if (StashTabList.StashTabs.Count > 0)
                {
                    foreach (StashTab s in StashTabList.StashTabs)
                    {
                        GetSetTargetAmount(s);
                    }
                }

                GenerateItemSetList();

                FillItemSets();

                // check for full sets/ missing items
                bool missingChaos = false;
                int  fullSets     = 0;
                // unique missing item classes
                HashSet <string> missingItemClasses     = new HashSet <string>();
                List <string>    deactivatedItemClasses = new List <string> {
                    "Helmets", "BodyArmours", "Gloves", "Boots", "Rings", "Amulets", "Belts", "OneHandWeapons", "TwoHandWeapons"
                };

                foreach (ItemSet set in ItemSetList)
                {
                    if (set.EmptyItemSlots.Count == 0)
                    {
                        if (set.HasChaos)
                        {
                            fullSets++;
                        }
                        else
                        {
                            missingChaos = true;
                        }
                    }
                    else
                    {
                        // all classes which are active over all ilvls
                        foreach (string itemClass in set.EmptyItemSlots)
                        {
                            missingItemClasses.Add(itemClass);
                        }
                    }
                }

                //foreach(string miss in missingItemClasses)
                //{
                //    Trace.WriteLine(miss, "missing");
                //}

                HashSet <string> sectionList = new HashSet <string>();

                if (filterActive)
                {
                    FilterGeneration.LoadCustomStyle();
                    if (Properties.Settings.Default.ExaltedRecipe)
                    {
                        FilterGeneration.LoadCustomStyleInfluenced();
                    }
                }

                if (fullSets == SetTargetAmount && missingChaos)
                {
                    // activate only chaos items
                    if (filterActive)
                    {
                        sectionList.Add(FilterGeneration.GenerateSection(true, "Body Armours", false, true));
                        sectionList.Add(FilterGeneration.GenerateSection(true, "Helmets", false, true));
                        sectionList.Add(FilterGeneration.GenerateSection(true, "Gloves", false, true));
                        sectionList.Add(FilterGeneration.GenerateSection(true, "Boots", false, true));
                        sectionList.Add(FilterGeneration.GenerateSection(true, "OneHandWeapons", false, true));
                        sectionList.Add(FilterGeneration.GenerateSection(true, "TwoHandWeapons", false, true));
                    }
                    ActiveItems.GlovesActive = false;
                    ActiveItems.HelmetActive = false;
                    ActiveItems.ChestActive  = false;
                    ActiveItems.BootsActive  = false;
                    ActiveItems.WeaponActive = false;
                    ActiveItems.ChaosMissing = true;
                }
                else if (fullSets == SetTargetAmount && !missingChaos)
                {
                    //deactivate all
                    if (filterActive)
                    {
                        sectionList.Add(FilterGeneration.GenerateSection(false, "Body Armours"));
                        sectionList.Add(FilterGeneration.GenerateSection(false, "Helmets"));
                        sectionList.Add(FilterGeneration.GenerateSection(false, "Gloves"));
                        sectionList.Add(FilterGeneration.GenerateSection(false, "Boots"));
                        sectionList.Add(FilterGeneration.GenerateSection(false, "OneHandWeapons"));
                        sectionList.Add(FilterGeneration.GenerateSection(false, "TwoHandWeapons"));
                    }
                    ActiveItems.GlovesActive = false;
                    ActiveItems.HelmetActive = false;
                    ActiveItems.ChestActive  = false;
                    ActiveItems.BootsActive  = false;
                    ActiveItems.WeaponActive = false;
                    ActiveItems.ChaosMissing = false;
                }
                else
                {
                    // activate missing classes
                    foreach (string itemClass in missingItemClasses)
                    {
                        switch (itemClass)
                        {
                        case "BodyArmours":
                            sectionList.Add(FilterGeneration.GenerateSection(true, "Body Armours"));
                            ActiveItems.ChestActive = true;
                            break;

                        case "Helmets":
                            sectionList.Add(FilterGeneration.GenerateSection(true, "Helmets"));
                            ActiveItems.HelmetActive = true;
                            break;

                        case "Gloves":
                            sectionList.Add(FilterGeneration.GenerateSection(true, "Gloves"));
                            ActiveItems.GlovesActive = true;
                            break;

                        case "Boots":
                            sectionList.Add(FilterGeneration.GenerateSection(true, "Boots"));
                            ActiveItems.BootsActive = true;
                            break;

                        case "OneHandWeapons":
                        case "TwoHandWeapons":
                            sectionList.Add(FilterGeneration.GenerateSection(true, "TwoHandWeapons"));
                            sectionList.Add(FilterGeneration.GenerateSection(true, "OneHandWeapons"));
                            ActiveItems.WeaponActive = true;
                            deactivatedItemClasses.Remove("OneHandWeapons");
                            deactivatedItemClasses.Remove("TwoHandWeapons");
                            break;
                        }
                        deactivatedItemClasses.Remove(itemClass);
                        //ActiveItems.ChaosMissing = true;
                    }
                    //deactivate rest
                    foreach (string itemClass in deactivatedItemClasses)
                    {
                        switch (itemClass)
                        {
                        case "BodyArmours":
                            sectionList.Add(FilterGeneration.GenerateSection(false, "Body Armours"));
                            ActiveItems.ChestActive = false;
                            break;

                        case "Helmets":
                            sectionList.Add(FilterGeneration.GenerateSection(false, "Helmets"));
                            ActiveItems.HelmetActive = false;
                            break;

                        case "Gloves":
                            sectionList.Add(FilterGeneration.GenerateSection(false, "Gloves"));
                            ActiveItems.GlovesActive = false;
                            break;

                        case "Boots":
                            sectionList.Add(FilterGeneration.GenerateSection(false, "Boots"));
                            ActiveItems.BootsActive = false;
                            break;

                        case "OneHandWeapons":
                            sectionList.Add(FilterGeneration.GenerateSection(false, "OneHandWeapons"));
                            ActiveItems.WeaponActive = false;
                            break;

                        case "TwoHandWeapons":
                            ActiveItems.WeaponActive = false;
                            sectionList.Add(FilterGeneration.GenerateSection(false, "TwoHandWeapons"));
                            break;
                        }
                    }
                }

                // always on
                if (filterActive)
                {
                    sectionList.Add(FilterGeneration.GenerateSection(true, "Rings"));
                    sectionList.Add(FilterGeneration.GenerateSection(true, "Amulets"));
                    sectionList.Add(FilterGeneration.GenerateSection(true, "Belts"));
                }

                //Trace.WriteLine(fullSets, "full sets");
                MainWindow.overlay.Dispatcher.Invoke(() =>
                {
                    MainWindow.overlay.FullSetsText = fullSets.ToString();
                });

                // invoke chaos missing
                if (missingChaos)
                {
                    //ChaosRecipeEnhancer.WarningMessage = "Need lower level items!";
                    MainWindow.overlay.WarningMessage           = "Need lower level items!";
                    MainWindow.overlay.ShadowOpacity            = 1;
                    MainWindow.overlay.WarningMessageVisibility = System.Windows.Visibility.Visible;
                }

                // invoke exalted recipe ready
                if (Properties.Settings.Default.ExaltedRecipe)
                {
                    if (ItemSetShaper.EmptyItemSlots.Count == 0 ||
                        ItemSetElder.EmptyItemSlots.Count == 0 ||
                        ItemSetCrusader.EmptyItemSlots.Count == 0 ||
                        ItemSetWarlord.EmptyItemSlots.Count == 0 ||
                        ItemSetHunter.EmptyItemSlots.Count == 0 ||
                        ItemSetRedeemer.EmptyItemSlots.Count == 0)
                    {
                        MainWindow.overlay.WarningMessage           = "Exalted Recipe ready!";
                        MainWindow.overlay.ShadowOpacity            = 1;
                        MainWindow.overlay.WarningMessageVisibility = System.Windows.Visibility.Visible;
                    }
                }

                // invoke set full
                if (fullSets == SetTargetAmount)
                {
                    MainWindow.overlay.WarningMessage           = "Sets full!";
                    MainWindow.overlay.ShadowOpacity            = 1;
                    MainWindow.overlay.WarningMessageVisibility = System.Windows.Visibility.Visible;
                }

                Trace.WriteLine(fullSets, "full sets");


                if (filterActive)
                {
                    //sectionList.Add(FilterGeneration.GenerateSection(true, "Rings"));
                    //sectionList.Add(FilterGeneration.GenerateSection(true, "Amulets"));
                    //sectionList.Add(FilterGeneration.GenerateSection(true, "Belts"));

                    string oldFilter = FilterGeneration.OpenLootfilter();
                    string newFilter = FilterGeneration.GenerateLootFilter(oldFilter, sectionList);
                    FilterGeneration.WriteLootfilter(newFilter);

                    if (Properties.Settings.Default.ExaltedRecipe)
                    {
                        List <string> sectionListInfluenced = new List <string>();
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "Rings", true));
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "Amulets", true));
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "Belts", true));
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "Helmets", true));
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "Gloves", true));
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "Boots", true));
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "Body Armours", true));
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "OneHandWeapons", true));
                        sectionListInfluenced.Add(FilterGeneration.GenerateSection(true, "TwoHandWeapons", true));

                        string oldFilter2 = FilterGeneration.OpenLootfilter();
                        string newFilter2 = FilterGeneration.GenerateLootFilterInfluenced(oldFilter2, sectionListInfluenced);
                        FilterGeneration.WriteLootfilter(newFilter2);
                    }
                }
                if (Properties.Settings.Default.Sound)
                {
                    if (!(PreviousActiveItems.GlovesActive == ActiveItems.GlovesActive &&
                          PreviousActiveItems.BootsActive == ActiveItems.BootsActive &&
                          PreviousActiveItems.HelmetActive == ActiveItems.HelmetActive &&
                          PreviousActiveItems.ChestActive == ActiveItems.ChestActive &&
                          PreviousActiveItems.WeaponActive == ActiveItems.WeaponActive))
                    {
                        Player.Dispatcher.Invoke(() =>
                        {
                            PlayNotificationSound();
                        });
                    }
                }
            }
            catch (OperationCanceledException ex) when(ex.CancellationToken == Data.ct)
            {
                Trace.WriteLine("abort");
            }
        }