public ExistingDeck(Deck deck, HearthMirror.Objects.Deck newDeck) { Deck = deck; var tmp = new Deck { Cards = new ObservableCollection<Card>(newDeck.Cards.Select(x => new Card { Id = x.Id, Count = x.Count })) }; MatchingCards = 30 - (deck - tmp).Count(x => x.Count > 0); NewVersion = MatchingCards == 30 ? new SerializableVersion(0, 0) : (MatchingCards < 26 ? SerializableVersion.IncreaseMajor(deck.Version) : SerializableVersion.IncreaseMinor(deck.Version)); }
public ImportedDeck(HearthMirror.Objects.Deck deck, List<Deck> candidates) { Deck = deck; candidates = candidates ?? new List<Deck>(); var hero = HearthDb.Cards.All[deck.Hero]; Class = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(hero.Class.ToString().ToLower()); ImportOptions = New.Concat(candidates.Concat(DeckList.Instance.Decks.Where(x => x.Class == Class && !x.Archived && !x.IsArenaDeck)).Distinct() .Select(x => new ExistingDeck(x, deck)).OrderByDescending(x => x.MatchingCards).ThenByDescending(x => x.Deck.LastPlayed)); SelectedIndex = candidates.Any() ? 1 : 0; }
public ImportedDeck(HearthMirror.Objects.Deck deck, List<Deck> candidates) { Deck = deck; candidates = candidates ?? new List<Deck>(); var hero = Database.GetCardFromId(deck.Hero); if(string.IsNullOrEmpty(hero?.PlayerClass) || hero.Id == Database.UnknownCardId) { Log.Error("No hero found for id " + deck.Hero); return; } Class = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(hero.PlayerClass.ToLower()); ImportOptions = New.Concat(candidates.Concat(DeckList.Instance.Decks.Where(x => x.Class == Class && !x.Archived && !x.IsArenaDeck)).Distinct() .Select(x => new ExistingDeck(x, deck)).OrderByDescending(x => x.Deck.HsId == deck.Id).ThenByDescending(x => x.MatchingCards).ThenByDescending(x => x.Deck.LastPlayed)); SelectedIndex = candidates.Any() ? 1 : 0; }
public void ImportArenaDeck(HearthMirror.Objects.Deck deck) { var arenaDeck = new Deck { Class = Database.GetCardFromId(deck.Hero).PlayerClass, HsId = deck.Id, Cards = new ObservableCollection<Card>(deck.Cards.Select(x => { var card = Database.GetCardFromId(x.Id); card.Count = x.Count; return card; })), LastEdited = DateTime.Now, IsArenaDeck = true }; arenaDeck.Name = Helper.ParseDeckNameTemplate(Config.Instance.ArenaDeckNameTemplate, arenaDeck); DeckList.Instance.Decks.Add(arenaDeck); DeckPickerList.UpdateDecks(); SelectDeck(arenaDeck, true); }
public static async void ShowNewArenaDeckMessageAsync(this MetroWindow window, HearthMirror.Objects.Deck deck) { if(_awaitingMainWindowOpen) return; _awaitingMainWindowOpen = true; if(window.WindowState == WindowState.Minimized) Core.TrayIcon.ShowMessage("New arena deck detected!"); while(window.Visibility != Visibility.Visible || window.WindowState == WindowState.Minimized) await Task.Delay(100); var result = await window.ShowMessageAsync("New arena deck detected!", "You can change this behaviour to \"auto save&import\" or \"manual\" in [options > tracker > importing]", AffirmativeAndNegative, new Settings { AffirmativeButtonText = "Import", NegativeButtonText = "Cancel" }); if(result == MessageDialogResult.Affirmative) { Log.Info("...saving new arena deck."); Core.MainWindow.ImportArenaDeck(deck); } else Log.Info("...discarded by user."); Core.Game.IgnoredArenaDecks.Add(deck.Id); _awaitingMainWindowOpen = false; }