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 = 0; if (deck.HasVersions) { var counts = deck.VersionsIncludingSelf.Select(v => GetMatchingCards(tmp, deck.GetVersion(v))); if (counts.Any(c => c == 30)) { MatchingCards = 30; } } if (MatchingCards != 30) { MatchingCards = GetMatchingCards(tmp, deck); } NewVersion = MatchingCards == 30 ? new SerializableVersion(0, 0) : (MatchingCards < 26 ? SerializableVersion.IncreaseMajor(deck.Version) : SerializableVersion.IncreaseMinor(deck.Version)); ShouldBeNewDeck = MatchingCards < 15; }
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)); }
private void MenuItemSaveVersionMajor_OnClick(object sender, RoutedEventArgs e) => SaveDeckWithOverwriteCheck(SerializableVersion.IncreaseMajor(_newDeck.Version));
public static SaveOperation MajorIncrement(Deck deck) => new SaveOperation { Version = SerializableVersion.IncreaseMajor(deck.Version) };