예제 #1
0
        private void InsertCards(SqlCeConnection conn, int deckIndex, MtgDeck deck)
        {
            var deckList = deck.GetContents();

            foreach (var card in deckList)
            {
                var cmdText = string.Format("insert into deck{0} (Card) values (@card)", deckIndex.ToString("000"));
                var cmd = new SqlCeCommand(cmdText, conn);
                cmd.Parameters.AddWithValue("@card", card);
                cmd.ExecuteNonQuery();
            }
        }
예제 #2
0
        public IDeck ParseDeck(string deck)
        {
            var retVal = new MtgDeck();

            var deckLines = deck.Split(new []{'\r', '\n'}, StringSplitOptions.RemoveEmptyEntries);
            var sideboard = false;

            foreach(var line in deckLines)
            {
                if (line.ToLower().Contains("sideboard"))
                {
                    sideboard = true;
                    continue;
                }
                if (line.StartsWith("//"))
                {
                    continue;
                }
                if (!line.Contains(' '))
                {
                    continue;
                }

                var countString = line.Split(' ')[0];
                int countNum;
                if (!int.TryParse(countString, out countNum))
                {
                    continue;
                }

                var cardName = line.Substring(line.IndexOf(' ')).Trim();
                for (int i = 0; i < countNum; i++)
                {
                    if (sideboard)
                    {
                        retVal.AddSideboardCard(cardName);
                    }
                    else
                    {
                        retVal.AddCard(cardName);
                    }
                }
            }

            return retVal;
        }
예제 #3
0
 private void InsertDecklist(SqlCeConnection conn, int deckIndex, MtgDeck deck)
 {
     CreateDecklistTable(conn, deckIndex);
     InsertCards(conn, deckIndex, deck);
 }