public bool ReadSentFile(HashSet <CardInstance> cards, HashSet <CardInstance> cards_silent) { if (!File.Exists(sent_path)) { return(true); } if (TrackerFactory.DefaultTrackerFactory.GetTracker().ActiveDeck == null) { return(true); } try { PropertiesObservableCollection <CardInstance> activeDeck = TrackerFactory.DefaultTrackerFactory.GetTracker(). ActiveDeck.SelectedVersion.Cards; string[] f = File.ReadAllLines(sent_path); int i = f.Count() - 1; for (; i > -1; --i) { if (f[i].Contains("=== Started Match")) { game_started = true; wait_for_prohpecy = false; muligan_ended = false; Game game = new Game(); game.Deck = TrackerFactory.DefaultTrackerFactory.GetTracker(). ActiveDeck; game.DeckId = TrackerFactory.DefaultTrackerFactory.GetTracker(). ActiveDeck.DeckId; game.DeckVersionId = TrackerFactory.DefaultTrackerFactory.GetTracker(). ActiveDeck.SelectedVersionId; string[] options = f[i].Split(';'); game.OpponentName = options[2].Substring(" opponent = ".Length); DeckAttributes attr = (DeckAttributes)options[3].Substring(" opponent_deck = ".Length); game.OpponentClass = ClassAttributesHelper.FindClassByAttribute(attr).DefaultIfEmpty(DeckClass.Neutral).FirstOrDefault(); game.Outcome = GameOutcome.Defeat; game.OrderOfPlay = options[4].Substring(" first player = ".Length) == "you" ? OrderOfPlay.First : OrderOfPlay.Second; game.Type = GameType.PlayCasual; game.PlayerRank = (PlayerRank)Int32.Parse(options[5].Substring(" rank = ".Length)); string opponent_rank = options[6].Substring(" opponent_rank = ".Length); if (opponent_rank != "") { game.OpponentRank = (PlayerRank)Int32.Parse(opponent_rank); } for (int option = 0; option < options.Length; ++option) { if (options[option].Contains("[queueName] = ")) { string queueName = options[option].Substring(" [queueName] = ".Length); if (queueName == "HydraOneVsOne") { game.Type = GameType.PlayRanked; } else if (queueName == "HydraSinglePlayer") { game.Type = GameType.PlayCasual; } } } TrackerFactory.DefaultTrackerFactory.GetTracker().Games.Add(game); if (i != f.Count() - 1) { i++; } break; } } if (i < 0) { i = 0; } for (; i < f.Count(); ++i) { if (f[i].Contains("=== Ended Match")) { if (TrackerFactory.DefaultTrackerFactory.GetTracker().Games.Count > 0) { TrackerFactory.DefaultTrackerFactory.GetTracker().Games.Last <Game>().Outcome = f[i].Substring("=== Ended Match, you ".Length) == "lost.===" ? GameOutcome.Defeat : GameOutcome.Victory; } foreach (var currentCard in activeDeck) { if (currentCard.tempCreated == true) { to_delete.Add(currentCard); continue; } currentCard.resetPlayed(); cards.Add(currentCard); } TrackerFactory.DefaultTrackerFactory.GetTracker().ActiveDeck.hand = 0; new TriggerChanceUpdater.TriggerChanceUpdater(activeDeck); File.Delete(sent_path); game_started = false; wait_for_prohpecy = false; return(true); } if (f[i].Contains("muligan ended")) { muligan_ended = true; continue; } bool draw_found = false; bool prophecy_found = false; if (wait_for_prohpecy) { prophecy_draw.ForEach(draw_string => prophecy_found = prophecy_found || f[i].Contains(draw_string)); draw_found = prophecy_found; } draw_from_deck.ForEach(draw_string => draw_found = draw_found || f[i].Contains(draw_string)); if (draw_found) { foreach (var draw_string in draw_from_deck) { if (wait_for_prohpecy && prophecy_found) { wait_for_prohpecy = false; } else if (muligan_ended == false && f[i].Contains("player played mulligan_hand")) { break; } else if (!f[i].Contains(draw_string)) { continue; } int offset = f[i].IndexOf("card=") + ("card=").Length; string played = f[i].Substring(offset); // Mechanic like Elusive Schemer if (draw_string == "player played multiPresent_hand") { CardInstance ToDeck = activeDeck.Where(ci => ci.Card.Name == played). DefaultIfEmpty(CardInstance.Unknown).FirstOrDefault(); if (ToDeck.Card.Name != "Unknown") { ToDeck.decPlayed(); } else { Card card = TrackerFactory.DefaultTrackerFactory.GetCardsDatabase().FindCardByName(played); if (card == Card.Unknown) { break; } ToDeck = new CardInstance(card); ToDeck.tempCreated = true; try { activeDeck.Add(ToDeck); } catch { } } cards.Add(ToDeck); break; } // only for played prophecy spells if (draw_string == "player played surgeStart_reactionPile") { // don't allow read if that called last one if (i == f.Count() - 1) { wait_for_prohpecy = true; // and apply prophecy wait reader File.Delete(sent_path); return(false); } var prophecy = f[i + 1]; if (prophecy.Contains(prophecy_draw[0]) || prophecy.Contains(prophecy_draw[1])) { offset = f[i + 1].IndexOf("card=") + ("card=").Length; played = f[i + 1].Substring(offset); } } CardInstance currentCard = activeDeck.Where(ci => ci.Card.Name == played). DefaultIfEmpty(CardInstance.Unknown).FirstOrDefault(); if (currentCard != CardInstance.Unknown) { currentCard.incPlayed(); cards.Add(currentCard); } break; } new TriggerChanceUpdater.TriggerChanceUpdater(activeDeck, cards_silent); } } File.Delete(sent_path); } catch { } return(false); }