/// <param name="deck">HearthMirror deck object</param> /// <param name="matches">Local decks with HsId OR 30 matching cards</param> /// <param name="localDecks">All local decks</param> public ImportedDeck(Mirror.Objects.Deck deck, List <Deck> matches, IList <Deck> localDecks) { Deck = deck; matches = matches ?? new List <Deck>(); var hero = Hearthstone.Database.GetCardFromId(deck.Hero); if (string.IsNullOrEmpty(hero?.PlayerClass) || hero.Id == Hearthstone.Database.UnknownCardId) { Log.Error("No hero found for id " + deck.Hero); return; } Class = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(hero.PlayerClass.ToLower()); var localOptions = localDecks.Where(d => d.Class == Class && !d.Archived && !d.IsArenaDeck) .Select(x => new ExistingDeck(x, deck)); var matchesOptions = matches.Select(x => new ExistingDeck(x, deck)).ToList(); var importOptions = matchesOptions.Concat(localOptions) .GroupBy(x => new { x.Deck.DeckId, x.Deck.Version }).Select(g => g.First()) .OrderByDescending(x => x.Deck.HsId == deck.Id) .ThenByDescending(x => x.MatchingCards) .ThenByDescending(x => x.Deck.LastPlayed); ImportOptions = New.Concat(importOptions); SelectedIndex = matchesOptions.Any(x => !x.ShouldBeNewDeck) ? 1 : 0; }
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.MatchingCards).ThenByDescending(x => x.Deck.LastPlayed)); SelectedIndex = candidates.Any() ? 1 : 0; }
public IEnumerable <string> GetModified() => New.Concat(Update).OrderByDescending(x => Tools.FileUtil.SizePrediction(x));