public override async Task Update() { IsLoadingDecks = true; Note = _repository.GetGameNote()?.ToString(); var deck = _repository.GetOpponentDeck(); Cards.Clear(); deck.Cards.ForEach(c => Cards.Add(c)); PlayerClass = deck.Class.ToString(); Decks.Clear(); await Task.Run(() => { var alldecks = _repository .GetAllDecksWithTag(Strings.ArchetypeTag) .Select(d => new ArchetypeDeck(d)) .ToList(); var results = ViewModelHelper.MatchArchetypes(deck, alldecks); results.ForEach(r => Decks.Add(r)); results.ForEach(r => _log.Info($"{r.Deck.Name} [{r.Similarity}, {r.Containment}]")); var firstDeck = Decks.FirstOrDefault(); if (firstDeck != null && firstDeck.Similarity > MatchResult.THRESHOLD) { DeckSelected(firstDeck); } IsLoadingDecks = false; IsNoteFocused = true; }); }
public override async Task Update() { IsNoteFocused = true; IsLoadingDecks = true; Note = _repository.GetGameNote()?.ToString(); Deck deck; if (EndGame.Settings.Get(Strings.DeveloperMode).Bool) { deck = _repository.GetOpponentDeckLive(); } else { deck = _repository.GetOpponentDeck(); } Cards.Clear(); deck.Cards.ForEach(c => Cards.Add(c)); PlayerClass = deck.Class.ToString(); Decks.Clear(); if (Cards.Count <= 0) { EndGame.Logger.Debug("NoteVM: Opponent deck is empty, skipping"); IsLoadingDecks = false; return; } await Task.Run(() => { var alldecks = _repository .GetAllDecksWithTag(Strings.ArchetypeTag) .Select(d => new ArchetypeDeck(d)) .ToList(); var format = EndGame.Data.GetGameFormat(); var results = ViewModelHelper.MatchArchetypes(format, deck, alldecks); results.ForEach(r => Decks.Add(r)); results.ForEach(r => _log.Debug($"Archetype: ({r.Similarity}, {r.Containment}) " + $"{r.Deck.DisplayName} ({r.Deck.Class})")); var firstDeck = Decks.FirstOrDefault(); if (firstDeck != null && firstDeck.Similarity > MatchResult.THRESHOLD) { DeckSelected(firstDeck); } IsLoadingDecks = false; }); }
private void Update() { Note = _repository.GetGameNote()?.ToString(); var deck = _repository.GetOpponentDeck(); Cards.Clear(); deck.Cards.ForEach(c => Cards.Add(c)); PlayerClass = deck.Klass.ToString(); Decks.Clear(); var alldecks = _repository.GetAllArchetypeDecks(); var results = ViewModelHelper.MatchArchetypes(deck, alldecks); results.ForEach(r => Decks.Add(r)); results.ForEach(r => _log.Info($"{r.Deck.Name} [{r.Similarity}, {r.Containment}]")); var firstDeck = Decks.FirstOrDefault(); if (firstDeck != null && firstDeck.Similarity > MatchResult.THRESHOLD) { DeckSelected(firstDeck); } }