internal void AddCard(CardInstance value, int qty) { if (value == null) { return; } foreach (var ci in CardsCollection.Where(ci => ci.BorderBrush != null)) { ci.BorderBrush = null; } var card = CardsCollection.Where(ci => ci.CardId == value.CardId).FirstOrDefault(); if (card != null) { card.Quantity += qty; //if already in deck, inc qty card.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 100, 15)); } else { card = value; card.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 100, 15)); card.Quantity = qty; CardsCollection.Add(card); } if (LimitCardCount) { trackerFactory.GetService <IDeckService>().EnforceCardLimit(card); } HashSet <CardInstance> cards_silent = new HashSet <CardInstance>(); new TriggerChanceUpdater(CardsCollection, cards_silent); DeckFileReader.UpdateGui(cards_silent, false); }
private static async Task ProcessExternalFilesUpdate(MainWindow mainWindow) { DeckFileReader dfr = TrackerFactory.DefaultTrackerFactory.GetTracker().dfr; if (TrackerFactory.DefaultTrackerFactory.GetTracker().ActiveDeck != null) { HashSet <CardInstance> cards = new HashSet <CardInstance>(); new TriggerChanceUpdater(TrackerFactory.DefaultTrackerFactory.GetTracker(). ActiveDeck.SelectedVersion.Cards, cards); mainWindow.Dispatcher.Invoke(() => DeckFileReader.UpdateGui(cards, false)); } for (;;) { HashSet <CardInstance> cards = new HashSet <CardInstance>(); HashSet <CardInstance> cards_silent = new HashSet <CardInstance>(); bool reset = dfr.ReadSentFile(cards, cards_silent); if (cards.Count() == 0 && dfr.isGameStarted() == false) { if (dfr.ReadDecks()) { mainWindow.Dispatcher.Invoke(() => { TrackerFactory.DefaultTrackerFactory.GetMessanger() .Send(new DeckListResetFilters(), ControlMessangerContext.DeckList_DeckFilterControl); }); TrackerFactory.DefaultTrackerFactory.GetFileManager().SaveDatabase(); } Deck active_deck = dfr.UpdateActiveDeck(); if (active_deck != null) { mainWindow.Dispatcher.Invoke(() => { TrackerFactory.DefaultTrackerFactory.GetTracker().ActiveDeck = active_deck; }); } } bool update = dfr.UpdateHandCount(); if (cards.Count() > 0) { await mainWindow.Dispatcher.Invoke(async() => { // Play red if (reset == false) { DeckFileReader.UpdateGui(cards, true); await Task.Delay(300); } else { dfr.CleanupActiveDeck(); } // Stop red and update fields DeckFileReader.UpdateGui(cards, false); // Play silent (trigger chances) DeckFileReader.UpdateGui(cards_silent, false); TrackerFactory.DefaultTrackerFactory.GetTracker().UpdateActiveDeck(); }); } else if (update) { TrackerFactory.DefaultTrackerFactory.GetTracker().UpdateActiveDeck(); } await Task.Delay(dfr.isGameStarted()? 100 : 1000); } }