Esempio n. 1
0
        public bool LoadSettings()
        {
            StringBuilder path = new StringBuilder("CardData\\");

            if (Directory.Exists(path.ToString()) == false)
            {
                Directory.CreateDirectory(path.ToString());
            }

            path.Append("Settings.xml");
            if (File.Exists(path.ToString()) == false)
            {
                return(false);
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(path.ToString());

            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                if (node.Name == "CardDataDir")
                {
                    m_cardDataDir = node.InnerText;
                }
                else if (node.Name == "CardImageDir")
                {
                    m_cardImageDir = node.InnerText;
                }
                else if (node.Name == "SetStartID")
                {
                    for (eExpansion expansion = eExpansion.XLN; expansion != eExpansion.EXPANSION_MAX; expansion++)
                    {
                        String data = node.Attributes[expansion.ToString()].Value;
                        m_setStartIdList.Add(expansion, Int32.Parse(data));
                    }
                }
                else if (node.Name == "SetCardNum")
                {
                    for (eExpansion expansion = eExpansion.XLN; expansion != eExpansion.EXPANSION_MAX; expansion++)
                    {
                        String data = node.Attributes[expansion.ToString()].Value;
                        m_cardSetNumList.Add(expansion, Int32.Parse(data));
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        public void LoadCardData()
        {
            if (Directory.Exists(m_cardDataDir) == false)
            {
                Directory.CreateDirectory(m_cardDataDir);
            }

            for (eExpansion expansion = eExpansion.XLN; expansion != eExpansion.EXPANSION_MAX; expansion++)
            {
                StringBuilder filePath = new StringBuilder(m_cardDataDir);
                filePath.Append(expansion.ToString());
                filePath.Append(".xml");

                if (File.Exists(filePath.ToString()) == false)
                {
                    continue;
                }

                XmlDocument doc = new XmlDocument();
                doc.Load(filePath.ToString());

                foreach (XmlNode node in doc.DocumentElement.ChildNodes)
                {
                    CardData cardData = new CardData();
                    cardData.SetCardSet(expansion.ToString());
                    StringBuilder value = new StringBuilder();

                    value.Append(node.Attributes["ID"].Value);
                    cardData.SetCardID(value.ToString());
                    value.Clear();

                    value.Append(node.Attributes["Name"].Value);
                    cardData.SetCardName(value.ToString());
                    value.Clear();

                    value.Append(node.Attributes["ManaCost"].Value);
                    cardData.SetManaCost(value.ToString());
                    value.Clear();

                    value.Append(node.Attributes["CMC"].Value);
                    cardData.SetCMC(value.ToString());
                    value.Clear();

                    value.Append(node.Attributes["Type"].Value);
                    cardData.SetType(value.ToString());
                    value.Clear();

                    value.Append(node.Attributes["Text"].Value);
                    cardData.SetText(value.ToString());
                    value.Clear();

                    value.Append(node.Attributes["Rarity"].Value);
                    cardData.SetRarity(value.ToString());
                    value.Clear();

                    value.Append(node.Attributes["ImagePath"].Value);
                    cardData.SetImagePath(value.ToString());
                    value.Clear();

                    m_CardList[expansion].Add(cardData.GetCardName(), cardData);
                }
            }
        }