Ejemplo n.º 1
0
 public static Remark ParseRemark(HtmlNode remarkNode)
 {
     var remark = new Remark();
     //发现物
     var discoveryNode = remarkNode.SelectSingleNode("a[@title!='']");
     if (discoveryNode!=null)
     {
         var levelNode = discoveryNode.PreviousSibling.PreviousSibling;
         var typeNode = levelNode.PreviousSibling.PreviousSibling;
         remark.DiscoveryType = Enum.Parse(typeof(DisType), typeRegex.Match(typeNode.Attributes["src"].Value).Groups["type"].Value).ToString();
         remark.DiscoveryLevel = Int32.Parse(levelNode.InnerText.Substring(0, 1));
         remark.DiscoveryExp = Int32.Parse(discoveryNode.Attributes["title"].Value.Remove(0,5));
         remark.Discovery = discoveryNode.InnerText;
     }
     //奖励物
     var awardNode = remarkNode.SelectSingleNode("span[@style='color:#804000;']");
     if (awardNode != null)
         remark.AwardItem = awardNode.InnerText;
     //相关任务
     var relativeNodes = remarkNode.SelectNodes("descendant::a[@style='color:#C000C0;' or @style='color:DarkBlue;']");
     if (relativeNodes != null)
     {
         foreach (HtmlNode relativeNode in relativeNodes)
         {
             IList<int> questList = null;
             IList<string> foundNameList = null;
             if (relativeNode.InnerText.StartsWith("前:"))
             {
                 foundNameList = remark.PreFoundName;
                 questList = remark.PreQuestID;
             }
             else
             {
                 questList = remark.FollowQuestID;
             }
             var match = questRegex.Match(relativeNode.Attributes["href"].Value);
             if (relativeNode.InnerText.StartsWith("前:港口-") == false)
                 questList.Add(Int32.Parse(match.Groups["id"].Value));
             else
                 foundNameList.Add(relativeNode.InnerText.Replace("前:港口-",""));
         }
     }
     //接受城市
     //last br next a
     var cityNodes = remarkNode.SelectNodes("descendant::a[@class='MisCity']");
     if (cityNodes != null)
     {
         cityNodes.All(node =>
         {
             if (node.InnerText == "南美开拓港" || node.InnerText == "东南亚开拓港" ||
                 node.InnerText == "掠夺地图" || node.InnerText == "沉船资讯")
                 return true;
             remark.FromCityList.Add(node.InnerText);
             return true;
         });
     }
     return remark;
 }
Ejemplo n.º 2
0
 public static Remark ParseRemark(HtmlNode remarkNode)
 {
     var remark=new Remark();
     //发现物
     var levelNode = remarkNode.SelectSingleNode("font[@color='red']");
     if (levelNode != null)
     {
         //level node
         //discover.do?act=look&amp;discover_id=3642
         var typeNode = levelNode.PreviousSibling;
         remark.DiscoveryType = typeNode.Attributes["alt"].Value;
         var linkNode = levelNode.NextSibling;
         var discoveryNode = linkNode.SelectSingleNode("font[@color='red']");
         remark.DiscoveryLevel = Int32.Parse(levelNode.InnerText.Substring(0, 1));
         remark.DiscoveryID = Int32.Parse(discoveryRegex.Match(linkNode.Attributes["href"].Value).Groups["id"].Value);
         remark.Discovery = discoveryNode.InnerText;
     }
     //奖励物
     var awardNode = remarkNode.SelectSingleNode("font[@color='#804000']");
     if (awardNode!=null)
         remark.AwardItem = awardNode.InnerText;
     //相关任务
     var relativeNodes = remarkNode.SelectNodes("font[@color='#00008b' or @color='#c000c0']");
     if (relativeNodes != null)
     {
         foreach (HtmlNode relativeNode in relativeNodes)
         {
             IList<int> questList=null;
             IList<string> foundNameList = null;
             if (relativeNode.InnerText == "前:")
             {
                 foundNameList = remark.PreFoundName;
                 questList=remark.PreQuestID;
             }
             else
             {
                 questList=remark.FollowQuestID;
             }
             var questNode = relativeNode.NextSibling;
             while (questNode != null && questNode.Name != "#text")
             {
                 var match = questRegex.Match(questNode.Attributes["href"].Value);
                 if (match.Success)
                     questList.Add(Int32.Parse(match.Groups["id"].Value));
                 else
                     foundNameList.Add(questNode.InnerText);
                 questNode = questNode.NextSibling;
             }
         }
     }
     //接受城市
     //last br next a
     var cityNodes = remarkNode.SelectNodes("br[last()]/following-sibling::a");
     if (cityNodes != null)
     {
         cityNodes.All(node =>
         {
             if (node.InnerText == "南美开拓港" || node.InnerText == "东南亚开拓港" ||
                 node.InnerText == "掠夺地图" || node.InnerText == "沉船资讯")
                 return true;
             remark.FromCityList.Add(node.InnerText);
             return true;
         });
     }
     return remark;
 }