public static void LoadPlayerCreatedDecksFromFile() { string path = Path.Combine(Config.SavedDataFolder(), Config.SavedDecksFile()); List <string> lines = File.ReadAllLines(path).ToList(); List <string> decksToLoad = new List <string>(); string input = ""; for (int i = 0; i < lines.Count; i++) { input = input + lines[i] + "\n"; if (lines.Count == i + 1) { decksToLoad.Add(input); input = ""; } else { if (lines[i + 1].StartsWith("###")) { decksToLoad.Add(input); input = ""; } } } decksToLoad.ForEach(x => CurrentDecks.Add(DeckSerializer.Deserialize(x))); Log.Info("Successfully loaded player created decks from file."); }
public static void EditDeck(string oldName, string newName, Card heroCard) { Deck deckToEdit = CurrentDecks.First(x => x.Name == oldName); deckToEdit.Name = newName; deckToEdit.HeroDbfId = heroCard.DbfId; }
public static void SavePlayerCreatedDecksToFile() { List <string> deckStrings = CurrentDecks.Select(x => DeckSerializer.Serialize(x, true)).ToList(); string path = Path.Combine(Config.SavedDataFolder(), Config.SavedDecksFile()); File.WriteAllLines(path, deckStrings); Log.Info("Successfully saved player created decks to file."); }
public static void CreateNewDeck(Card heroCard, string name) { Deck newDeck = new Deck(); newDeck.HeroDbfId = heroCard.DbfId; newDeck.Name = name; newDeck.Format = FormatType.FT_STANDARD; CurrentDecks.Add(newDeck); }
private static void AddTestDeck() { Deck testDeck = new Deck(); testDeck.Name = "TESTDECK"; testDeck.HeroDbfId = 7; testDeck.Format = FormatType.FT_STANDARD; testDeck.CardDbfIds.Add(2757, 2); testDeck.CardDbfIds.Add(2507, 2); testDeck.CardDbfIds.Add(1688, 2); CurrentDecks.Add(testDeck); }
public static Deck GetDeckFromCurrentDeckListView(DeckListView listView) { return(CurrentDecks.Find(x => x.Name == listView.Name)); }
public static void DeleteDeck(string deckName) { CurrentDecks.Remove(CurrentDecks.First(x => x.Name == deckName)); }
public static void ImportDecksFromHearthstone() { var decks = HearthMirror.Reflection.GetDecks(); List <HearthDb.Deckstrings.Deck> convertedDecks = new List <Deck>(); int success = 0; int attempted = 0; if (decks != null) { foreach (var deck in decks) { if (CurrentDecks.All(x => x.Name != deck.Name)) { if (deck.Cards.Count > 0) { HearthDb.Deckstrings.Deck convertedDeck = new Deck { Name = deck.Name, Format = GameTagConverter.ParseEnum <FormatType>(deck.Type.ToString()), HeroDbfId = Cards.GetCardFromId(deck.Hero).DbfId }; foreach (var card in deck.Cards) { convertedDeck.CardDbfIds.Add(Cards.GetCardFromId(card.Id).DbfId, card.Count); } Log.Info($"Imported deck '{deck.Name}' from Hearthstone Application"); success += 1; convertedDecks.Add(convertedDeck); } else { attempted += 1; Log.Error($"Unable to import deck '{deck.Name}' due to cards not being loaded in memory."); } } } CurrentDecks.AddRange(convertedDecks); if (success == 0) { MessageBox.Show( $"Unable to import decks from Hearthstone, ensure that you have opened the decks in-game before you attempt to import.", "Unable to import decks", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (success > 0 && attempted > 0) { MessageBox.Show( $"{convertedDecks.Count} Decks have been successfully imported from the Hearthstone Application, however {attempted} decks were unable to be imported due to issues finding card information in memory.", "Success with warning.", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (success > 0) { MessageBox.Show( $"{convertedDecks.Count} Decks have been successfully imported from the Hearthstone Application.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("You must have Hearthstone running in order to import the decks from your collection", "Hearthstone Not Running", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void ClearLoadedData() { RecordedGames.Clear(); CurrentDecks.Clear(); }