Example #1
0
 private void AddDeckList(DeckCard card)
 {
     int index = GetCardIndexOfDeckGridView(card.CardID);
     if (index < 0)
     {
         card.Count = 1;
         this.workDeck.Deck.Cards.Add(card);
         int rowIndex = dgvDeckList.Rows.Add(1,
                                             card.Symbol,
                                             card.CardName,
                                             card.ManaCost);
         DataRow deckRow = this.Cards.Records.Select(string.Format("CardID={0}", card.CardID))[0];
         dgvDeckList.Rows[rowIndex].Tag = card.CardID;
         dgvDeckList.Rows[rowIndex].DefaultCellStyle.ForeColor =
             CommonHelper.CardRarity.GetRarityColor(card.Rarity);
         this.workDeck.Deck.CardRecords.Rows.Add(deckRow.ItemArray);
     }
     else
     {
         AddDeckCardCount(index);
     }
 }
Example #2
0
 private DeckCard GetDeckCardFromWorkDeck(int cardID)
 {
     DeckCard result = new DeckCard();
     foreach (DeckCard card in this.workDeck.Deck.Cards)
     {
         if (card.CardID == cardID)
         {
             result = card;
             break;
         }
     }
     return result;
 }
Example #3
0
        public override void Load(string deckFullPath)
        {
            if (File.Exists(deckFullPath))
            {
                this.DeckFullPath = deckFullPath;
                string[] allLines = File.ReadAllLines(deckFullPath);
                StringBuilder notExistCardMessage = new StringBuilder();
                StringBuilder noEffectCardMessage = new StringBuilder();
                string sql = "SELECT * FROM ListCardTotal WHERE Symbol='{0}' AND CardEnglishName='{1}' LIMIT 1";
                Deck.Cards.Clear();
                Deck.CardRecords.Rows.Clear();
                foreach (string line in allLines)
                {
                    string content = line.Trim();
                    if (!content.StartsWith("//") && content.Length > 0)
                    {
                        if (Regex.IsMatch(content, @"^(SB: )?\d+ \[\w+\] [\p{L}\p{N}\p{P}\p{S} ]+$"))
                        {
                            bool isSideboard = content.StartsWith("SB: ");
                            string[] cardInfo = content.Replace("SB: ", "").Split(' ');
                            DeckCard card = new DeckCard();
                            card.Count = Convert.ToInt32(cardInfo[0]);
                            card.Symbol = cardInfo[1].Substring(1, cardInfo[1].Length - 2);
                            card.CardEnglishName = string.Join(" ", cardInfo, 2, cardInfo.Length - 2);

                            using (DataTable table = dbOperator.ExecuteDataTableScript(string.Format(sql, card.Symbol, card.CardEnglishName)))
                            {
                                if (table != null && table.Rows.Count > 0)
                                {
                                    Deck.CardRecords.Rows.Add(table.Rows[0].ItemArray);
                                    Deck.Name = Path.GetFileNameWithoutExtension(deckFullPath);
                                    Deck.Description = "MWS牌表";
                                    card.CardID = Convert.ToInt32(table.Rows[0]["CardID"]);
                                    card.CardName = table.Rows[0]["CardName"].ToString();
                                    card.ManaCost = table.Rows[0]["ManaCost"].ToString();
                                    if (isSideboard)
                                    {
                                        Deck.SideboardCards.Add(card);
                                    }
                                    else
                                    {
                                        Deck.Cards.Add(card);
                                    }
                                }
                                else
                                {
                                    if (notExistCardMessage.Length == 0)
                                    {
                                        notExistCardMessage.AppendLine("下列卡牌信息不存在:");
                                    }
                                    notExistCardMessage.AppendLine(string.Format("卡牌系列:{0},卡牌名称:{1},卡牌数量:{2}",
                                                                                 card.Symbol,
                                                                                 card.CardEnglishName,
                                                                                 card.Count));
                                }
                            }
                        }
                        else
                        {
                            if (noEffectCardMessage.Length == 0)
                            {
                                noEffectCardMessage.AppendLine();
                                noEffectCardMessage.AppendLine("下列信息无效:");
                            }
                            noEffectCardMessage.AppendLine(content);
                        }
                    }
                }
                string message = notExistCardMessage.ToString() + noEffectCardMessage.ToString();
                if (message.Length > 0)
                {
                    MessageBox.Show(message, "警告信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }