Пример #1
0
        private void getCardText(List <int> Deck, List <string> DeckText, List <cardData> CardData)
        {
            for (int i = 0; i < Deck.Count; i++)
            {
                string CardID   = Deck[i].ToString();
                string CardName = YGOProUtils.getInstance().GetCardName(Convert.ToInt32(CardID));
                if (CardName == "")
                {
                    MessageBox.Show(String.Format("Deck is invalid or old version. Program can not find card from ID.{0}Card ID : {1}", Environment.NewLine, CardID.ToString()
                                                  ), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                //add number of card
                int index = DeckText.FindIndex(x => x.Contains(CardName));

                if (index > -1)
                {
                    int CardNumber = Convert.ToInt32(DeckText[index].Substring(DeckText[index].Length - 1, 1));

                    CardNumber++;
                    DeckText[index] = (CardName + " x" + CardNumber.ToString());

                    CardData[index] = (new cardData(Convert.ToInt32(CardID), (CardName + " x" + CardNumber.ToString())));
                    //CardData.Add(new cardData(Convert.ToInt32(CardID), (CardName + " x" + CardNumber.ToString())));
                }
                else
                {
                    DeckText.Add(CardName + " x1");
                    CardData.Add(new cardData(Convert.ToInt32(CardID), CardName + " x1"));
                }
            }
        }
Пример #2
0
        public static YGOProUtils getInstance()
        {
            if (INSTANCE == null)
            {
                INSTANCE = new YGOProUtils();
            }

            return(INSTANCE);
        }
        private void ReadDeck(StringBuilder PlayerDeck)
        {
            var numberOfCard = _replay.DataReader.ReadInt32();

            _playerMainDeck.Clear();
            _playerMainDeckText.Clear();
            _playerExtraDeck.Clear();
            _playerExtraDeckText.Clear();


            //textBox1.Text += "----- Main -----" + Environment.NewLine;
            for (var i = 0; i < numberOfCard; i++)
            {
                var cardId   = _replay.DataReader.ReadInt32().ToString(System.Globalization.CultureInfo.InvariantCulture);
                var cardName = YGOProUtils.getInstance().GetCardName(Convert.ToInt32(cardId));
                if (cardName == "")
                {
                    MessageBox.Show($@"Replay is invalid or old version. Program can not find card from ID.{Environment.NewLine}Card ID : {cardId.ToString()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }
                _playerMainDeck.Add(cardId);

                //add number of card
                var index = _playerMainDeckText.FindIndex(x => x.Contains(cardName));

                if (index > -1)
                {
                    var cardNumber = Convert.ToInt32(_playerMainDeckText[index].Substring(_playerMainDeckText[index].Length - 1, 1));

                    cardNumber++;

                    _playerMainDeckText[index] = (cardName == string.Empty ? "UNKNOWN CARD" : cardName) + " x" + cardNumber.ToString();
                }
                else
                {
                    _playerMainDeckText.Add(cardName + " x1");
                }
            }


            numberOfCard = _replay.DataReader.ReadInt32();

            for (var i = 0; i < numberOfCard; i++)
            {
                var cardId   = _replay.DataReader.ReadInt32().ToString(System.Globalization.CultureInfo.InvariantCulture);
                var cardName = YGOProUtils.getInstance().GetCardName(Convert.ToInt32(cardId));
                if (cardName == "")
                {
                    MessageBox.Show($@"Replay is invalid or old version. Program can not find card from ID.{Environment.NewLine}Card ID : {cardId.ToString()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }
                _playerExtraDeck.Add(cardId);

                //add number of card
                var index = _playerExtraDeckText.FindIndex(x => x.Contains(cardName));
                if (index > -1)
                {
                    var CardNumber = Convert.ToInt32(_playerExtraDeckText[index].Substring(_playerExtraDeckText[index].Length - 1, 1));

                    _playerExtraDeckText[index] = (cardName == string.Empty ? "UNKNOWN CARD" : cardName) + " x" + (++CardNumber).ToString();
                }
                else
                {
                    _playerExtraDeckText.Add(cardName + " x1");
                }
            }

            //sort card by id
            _playerMainDeck.Sort();
            _playerExtraDeck.Sort();
            _playerMainDeckText.Sort();
            _playerExtraDeckText.Sort();

            PlayerDeck.AppendLine("#created by YGOPro Tweaker");
            PlayerDeck.AppendLine("#main");

            foreach (var CardID in _playerMainDeck)
            {
                PlayerDeck.AppendLine(CardID);
            }
            PlayerDeck.AppendLine("#extra");
            foreach (var CardID in _playerExtraDeck)
            {
                PlayerDeck.AppendLine(CardID);
            }
            PlayerDeck.AppendLine("!side");
        }