/// <summary> /// Returns the specified deck from hearth_decks.db /// </summary> /// <param name="deckName"></param> /// <returns></returns> public static Deck DeckFromName(string deckName, CardClass heroClass) { string query = $"select archetype, num_games, card_name from AllInfo where deck_name = '{deckName}';"; var Deck = new DataTable(); using (var conn = new SQLiteConnection(connection)) { conn.Open(); //var cmd = new SQLiteCommand(query, conn); using (var adapter = new SQLiteDataAdapter { SelectCommand = new SQLiteCommand(query, conn) }) { adapter.Fill(Deck); } } var cards = new List <Card>(); //var col = Deck.Columns[4]; foreach (DataRow row in Deck.Rows) { cards.Add(Cards.FromName(row.ItemArray[2].ToString())); } Archetype archetype = DeckHelper.Map <Archetype>(Deck.Rows[0].ItemArray[0].ToString()); int numGames = (int)(long)Deck.Rows[0].ItemArray[1]; return(new Deck(heroClass, archetype, deckName, numGames, cards)); }
public static Deck GetMostPopular(CardClass heroClass) { string query = $"select * from AllInfo where num_games = (select max(num_games) from AllInfo where hero_class = '{heroClass.ToString()}');"; var Deck = new DataTable(); using (var conn = new SQLiteConnection(connection)) { //var cmd = new SQLiteCommand(query, conn); using (var adapter = new SQLiteDataAdapter { SelectCommand = new SQLiteCommand(query, conn) }) { adapter.Fill(Deck); } } var cards = new List <Card>(); //var col = Deck.Columns[4]; foreach (DataRow row in Deck.Rows) { cards.Add(Cards.FromName(row.ItemArray[4].ToString())); } Archetype archetype = DeckHelper.Map <Archetype>(Deck.Rows[0].ItemArray[1].ToString()); string deckName = Deck.Rows[0].ItemArray[2].ToString(); int numGames = (int)(long)Deck.Rows[0].ItemArray[3]; return(new Deck(heroClass, archetype, deckName, numGames, cards)); }