Esempio n. 1
0
        public static async void ShowMissingCardsMessage(this MetroWindow window, Deck deck)
        {
            if (!deck.MissingCards.Any())
            {
                await window.ShowMessageAsync("No missing cards",
                                              "No cards were missing when you last exported this deck. (or you have not recently exported this deck)",
                                              Affirmative, new Settings { AffirmativeButtonText = "OK" });

                return;
            }
            var message   = "The following cards were not found:\n";
            var totalDust = 0;
            var sets      = new List <string>();

            foreach (var card in deck.MissingCards)
            {
                message += "\n• " + card.LocalizedName;
                if (card.Count == 2)
                {
                    message += " x2";
                }

                if (card.Set == HearthDbConverter.SetConverter(CardSet.NAXX))
                {
                    sets.Add("and the Naxxramas DLC ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.PROMO))
                {
                    sets.Add("and Promotion cards ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.REWARD))
                {
                    sets.Add("and the Reward cards ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.BRM))
                {
                    sets.Add("and the Blackrock Mountain DLC ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.LOE))
                {
                    sets.Add("and the League of Explorers DLC ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.KARA))
                {
                    sets.Add("and the One Night in Karazhan DLC ");
                }
                else
                {
                    totalDust += card.DustCost * card.Count;
                }
            }
            message += $"\n\nYou need {totalDust} dust {string.Join("", sets.Distinct())}to craft the missing cards.";
            await window.ShowMessageAsync("Export incomplete", message, Affirmative, new Settings { AffirmativeButtonText = "OK" });
        }
        public static async Task <MessageDialogResult> ShowMissingCardsMessage(this MetroWindow window, Deck deck, bool exportDialog)
        {
            if (!deck.MissingCards.Any())
            {
                return(await window.ShowMessageAsync("No missing cards",
                                                     "No cards were missing when you last exported this deck. (or you have not recently exported this deck)",
                                                     Affirmative, new Settings { AffirmativeButtonText = "OK" }));
            }
            var message   = "You are missing the following cards:\n";
            var totalDust = 0;
            var sets      = new List <string>();

            foreach (var card in deck.MissingCards)
            {
                message += "\n• " + card.LocalizedName;
                if (card.Count == 2)
                {
                    message += " x2";
                }

                if (card.Set == HearthDbConverter.SetConverter(CardSet.NAXX))
                {
                    sets.Add("and the Naxxramas DLC ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.PROMO))
                {
                    sets.Add("and Promotion cards ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.HOF))
                {
                    sets.Add("and the Hall of Fame cards ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.BRM))
                {
                    sets.Add("and the Blackrock Mountain DLC ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.LOE))
                {
                    sets.Add("and the League of Explorers DLC ");
                }
                else if (card.Set == HearthDbConverter.SetConverter(CardSet.KARA))
                {
                    sets.Add("and the One Night in Karazhan DLC ");
                }
                else
                {
                    totalDust += card.DustCost * card.Count;
                }
            }
            message += $"\n\nYou need {totalDust} dust {string.Join("", sets.Distinct())}to craft the missing cards.";
            var style    = exportDialog ? AffirmativeAndNegative : Affirmative;
            var settings = new Settings {
                AffirmativeButtonText = "OK"
            };

            if (exportDialog)
            {
                settings.AffirmativeButtonText = "Export";
                settings.NegativeButtonText    = "Cancel";
                message += "\n\nExport anyway? (this will not craft the cards)";
            }
            return(await window.ShowMessageAsync("Missing cards", message, style, settings));
        }
Esempio n. 3
0
        private void UpdateDbListView()
        {
            if (_newDeck == null)
            {
                return;
            }
            var    selectedClass = _newDeck.Class;
            string selectedNeutral;
            int    selectedManaCost;
            string selectedSet;

            try
            {
                selectedNeutral = MenuFilterType.Items.Cast <RadioButton>().First(x => x.IsChecked.HasValue && x.IsChecked.Value).Name.Substring(15);
            }
            catch (Exception)
            {
                selectedNeutral = "All";
            }
            try
            {
                if (!int.TryParse(MenuFilterMana.Items.Cast <RadioButton>().First(x => x.IsChecked.HasValue && x.IsChecked.Value).Content.ToString().Substring(0, 1),
                                  out selectedManaCost))
                {
                    selectedManaCost = -1;
                }
            }
            catch (Exception)
            {
                selectedManaCost = -1;
            }
            try
            {
                int value;
                int.TryParse(MenuFilterSet.Items.Cast <RadioButton>().First(x => x.IsChecked.HasValue && x.IsChecked.Value).Name.Substring(14), out value);
                selectedSet = value > 0 ? HearthDbConverter.SetConverter((CardSet)value) : "All";
            }
            catch (Exception)
            {
                selectedSet = "All";
            }
            if (selectedClass == "Select a Class")
            {
                ListViewDB.Items.Clear();
            }
            else
            {
                ListViewDB.Items.Clear();

                var formattedInput = Helper.RemoveDiacritics(TextBoxDBFilter.Text.ToLowerInvariant(), true);
                var words          = formattedInput.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var card in Database.GetActualCards())
                {
                    var cardName = Helper.RemoveDiacritics(card.LocalizedName.ToLowerInvariant(), true);
                    if (!Config.Instance.UseFullTextSearch && !cardName.Contains(formattedInput) &&
                        card.AlternativeNames.All(x => x == null || !Helper.RemoveDiacritics(x.ToLowerInvariant(), true).Contains(formattedInput)) &&
                        (!string.IsNullOrEmpty(card.RaceOrType) && formattedInput != card.RaceOrType.ToLowerInvariant()))
                    {
                        continue;
                    }
                    if (Config.Instance.UseFullTextSearch &&
                        words.Any(
                            w =>
                            !cardName.Contains(w) && !(!string.IsNullOrEmpty(card.Text) && card.Text.ToLowerInvariant().Contains(w)) &&
                            card.AlternativeNames.All(x => x == null || !Helper.RemoveDiacritics(x.ToLowerInvariant(), true).Contains(formattedInput)) &&
                            card.AlternativeTexts.All(x => x == null || !x.ToLowerInvariant().Contains(formattedInput)) &&
                            (!string.IsNullOrEmpty(card.RaceOrType) && w != card.RaceOrType.ToLowerInvariant()) &&
                            (w != card.Rarity.ToString().ToLowerInvariant())))
                    {
                        continue;
                    }

                    // mana filter
                    if (selectedManaCost > -1 && ((selectedManaCost < 9 || card.Cost < 9) && (selectedManaCost != card.Cost)))
                    {
                        continue;
                    }
                    if (selectedSet != "All" && !string.Equals(selectedSet, card.Set, StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }
                    if (!_newDeck.IsArenaDeck && !_newDeck.IsBrawlDeck && !(CheckBoxIncludeWild.IsChecked ?? true) && Helper.WildOnlySets.Contains(card.Set))
                    {
                        continue;
                    }
                    switch (selectedNeutral)
                    {
                    case "All":
                        if (card.GetPlayerClass == selectedClass || card.GetPlayerClass == "Neutral")
                        {
                            ListViewDB.Items.Add(card);
                        }
                        break;

                    case "Class":
                        if (card.GetPlayerClass == selectedClass)
                        {
                            ListViewDB.Items.Add(card);
                        }
                        break;

                    case "Neutral":
                        if (card.GetPlayerClass == "Neutral")
                        {
                            ListViewDB.Items.Add(card);
                        }
                        break;
                    }
                }

                Helper.SortCardCollection(ListViewDB.Items, Config.Instance.CardSortingClassFirst);
            }
        }