예제 #1
0
        private void ParsePacks()
        {
            HtmlNodeCollection parent = m_CardPage.DocumentNode.SelectNodes("//tr[@class='row']");

            if (parent == null)
            {
                return;
            }

            foreach (HtmlNode childs in parent)
            {
                if (childs.InnerText.Contains("[") || childs.InnerText.Contains("]"))
                {
                    continue;
                }

                DatabaseCard.Pack Set = new DatabaseCard.Pack();

                HtmlNode rd = childs.SelectSingleNode(".//td[@class='t_center']");
                if (rd != null)
                {
                    Set.ReleaseDate = HttpUtility.HtmlDecode(rd.InnerText);
                    rd = null;
                }

                HtmlNode pn = childs.SelectSingleNode(".//td//b");
                if (pn != null)
                {
                    string packName = pn.InnerText.ToTitleCase();
                    Set.PackName = HttpUtility.HtmlDecode(packName);
                    if (m_OutputLanguage == "en")
                    {
                        Set.EnglishPackName = packName;
                    }
                    pn = null;
                }

                bool set = false;
                HtmlNodeCollection cid = childs.SelectNodes(".//td");
                if (cid != null)
                {
                    foreach (HtmlNode child in cid)
                    {
                        if (set)
                        {
                            Set.CardID = HttpUtility.HtmlDecode(child.InnerText);
                            break;
                        }
                        else
                        {
                            set = true;
                        }
                    }
                    cid = null;
                }

                HtmlNode ra = childs.SelectSingleNode(".//td//img");
                if (ra != null)
                {
                    Set.Rarity = HttpUtility.HtmlDecode(ra.Attributes["alt"].Value);
                    ra         = null;
                }
                else
                {
                    switch (m_OutputLanguage)
                    {
                    case "en":
                    case "de": Set.Rarity = "Common"; break;

                    case "it": Set.Rarity = "Comune"; break;

                    case "es": Set.Rarity = "Común"; break;

                    case "fr": Set.Rarity = "Commune"; break;

                    case "ja": Set.Rarity = "共通"; break;
                    }
                }

                this.Card.Packs.Add(Set);
            }
        }
예제 #2
0
        private List <DatabaseCard.Pack> GetPacks(int langValue)
        {
            List <DatabaseCard.Pack> Packs = new List <DatabaseCard.Pack>();

            if (m_CardPage == null)
            {
                return(Packs);
            }

            var allTables = m_CardPage.DocumentNode.SelectNodes("//tr[@class='cardtablerow']//td[@class='cardtablespanrow']");

            if (allTables != null)
            {
                foreach (var textTable in allTables)
                {
                    if (textTable.SelectSingleNode(".//a[@title='Yu-Gi-Oh! Trading Card Game']") != null ||
                        textTable.SelectSingleNode(".//a[@title='Yu-Gi-Oh! Official Card Game']") != null)
                    {
                        var setLangTable = textTable.SelectNodes(".//table[@class='collapsible autocollapse navbox-inner']");

                        if (setLangTable != null)
                        {
                            foreach (var setLang in setLangTable)
                            {
                                var langNode = setLang.SelectSingleNode(".//div[@style='font-size: 110%;']");
                                if (langNode == null)
                                {
                                    continue;
                                }
                                string lang = langNode.InnerText.ToLower();
                                if ((lang.Contains(m_Languages[langValue]) || (langValue == 0 ? lang.Contains(m_Languages[langValue] + "—worldwide") : false)))
                                {
                                    var setLine = setLang.SelectNodes(".//table[@class='wikitable sortable card-list cts']//tr");
                                    if (setLine != null)
                                    {
                                        bool isSet = false;
                                        foreach (var setInfo in setLine)
                                        {
                                            if (isSet)
                                            {
                                                var detailedInfo = setInfo.SelectNodes(".//td");
                                                if (detailedInfo != null)
                                                {
                                                    DatabaseCard.Pack Set = new DatabaseCard.Pack();
                                                    for (int i = 0; i < detailedInfo.Count; ++i)
                                                    {
                                                        string content = detailedInfo[i].InnerText.Trim();

                                                        if (i == 0)
                                                        {
                                                            Set.ReleaseDate = content;
                                                        }
                                                        else if (i == 1)
                                                        {
                                                            Set.CardID = content;
                                                        }
                                                        else if (i == 2)
                                                        {
                                                            Set.EnglishPackName = content;
                                                            if (langValue == 0)
                                                            {
                                                                Set.PackName = content;
                                                            }
                                                        }
                                                        else if (i == 3 && langValue == 0)
                                                        {
                                                            Set.Rarity = content;
                                                        }
                                                        else if (i == 3 && langValue > 0)
                                                        {
                                                            Set.PackName = content;
                                                        }
                                                        else if (i == 4 && (lang.Contains(m_Languages[5]) || langValue > 0))
                                                        {
                                                            Set.Rarity = content;
                                                        }
                                                    }
                                                    Packs.Add(Set);
                                                }
                                                detailedInfo = null;
                                            }
                                            else
                                            {
                                                isSet = true;
                                            }
                                        }
                                    }
                                    setLine = null;
                                }
                                langNode = null;
                            }
                        }
                        setLangTable = null;
                    }
                }
            }
            allTables = null;

            return(Packs);
        }