예제 #1
0
        internal static void Construction(object o)
        {
            ArrayList balls = new ArrayList();

            ha         = ConstructionInfo.PrepareHttpAccesser(universe);
            ha.Referer = referer;
            string baseurl = ha.AccessUrl;

            foreach (ProductivityInfo.Ball ball in pi.Balllist)
            {
                ha.AccessUrl = baseurl + ball.AccessParm;
                ha.Cookies   = ccold;
                IEnumerator ie = ccnew.GetEnumerator();
                while (ie.MoveNext())
                {
                    ha.Cookies.Add((Cookie)ie.Current);
                }
                ccnew      = ha.access();
                ha.Referer = baseurl;
                //取得每一个星球
                ConstructionInfo ciloop = ConstructionInfo.AnalyzHtml();
                ciloop.CurrentBallName = ball.Name;
                balls.Add(ciloop);
            }
            referer = ha.AccessUrl;
            ConstructionEventHandler(balls);
        }
예제 #2
0
        private void lb_ball_list_SelectedIndexChanged(object sender, EventArgs e)
        {
            ConstructionInfo ci = (ConstructionInfo)lb_ball_list.SelectedItem;

            if (ci != null)
            {
                lb_cons_list.Items.Clear();
                foreach (Construction c in ci.allCons)
                {
                    lb_cons_list.Items.Add(c);
                }
            }
        }
예제 #3
0
        internal static ConstructionInfo AnalyzHtml()
        {
            ConstructionInfo ci = new ConstructionInfo();
            HtmlDocument     h  = new HtmlAgilityPack.HtmlDocument();

            h.Load(Strings.HTML_PATH);
            //当前金属矿
            int firstN = 0;

            for (int i = 2; i < 8; i++)
            {
                HtmlNode hn_firstcon = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/a", i));
                if (hn_firstcon != null && ("金属矿".Equals(hn_firstcon.InnerText.Trim()) || "机器人工厂".Equals(hn_firstcon.InnerText.Trim())))
                {
                    firstN = i;
                    break;
                }
            }
            if (firstN != 0)
            {
                for (int j = firstN; true; j++)
                {
                    HtmlNode hn_con_name     = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/a", j));
                    HtmlNode hn_con_next_1st = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/b[1]", j));
                    HtmlNode hn_con_next_2nd = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/b[2]", j));
                    HtmlNode hn_con_next_3rd = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/b[3]", j));

                    HtmlNode hn_con_need_1st = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/font/b[1]", j));
                    HtmlNode hn_con_need_2nd = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/font//b[2]", j));
                    HtmlNode hn_con_need_3rd = h.DocumentNode.SelectSingleNode(string.Format(XPATH_CONSTRUCTION + "/font//b[3]", j));

                    if (hn_con_name == null)
                    {
                        break;
                    }
                    else
                    {
                        Construction c = new Construction();
                        c.innerText = hn_con_name.InnerText;
                        //如果是地形改造器,则不需要金属。
                        if ("地形改造器".Equals(c.innerText.Trim()))
                        {
                            c.nextMetal = 0;
                            c.needMetal = 0;
                            if (hn_con_next_1st != null)
                            {
                                c.nextCrystal = ProductivityInfo.ToInt(hn_con_next_1st.InnerText);
                            }
                            if (hn_con_next_2nd != null)
                            {
                                c.nextH = ProductivityInfo.ToInt(hn_con_next_2nd.InnerText);
                            }
                            if (hn_con_need_1st != null)
                            {
                                c.needCrystal = ProductivityInfo.ToInt(hn_con_need_1st.InnerText);
                            }
                            if (hn_con_need_2nd != null)
                            {
                                c.needH = ProductivityInfo.ToInt(hn_con_need_2nd.InnerText);
                            }
                        }
                        else
                        {
                            if (hn_con_next_1st != null)
                            {
                                c.nextMetal = ProductivityInfo.ToInt(hn_con_next_1st.InnerText);
                            }
                            if (hn_con_next_2nd != null)
                            {
                                c.nextCrystal = ProductivityInfo.ToInt(hn_con_next_2nd.InnerText);
                            }
                            if (hn_con_next_3rd != null)
                            {
                                c.nextH = ProductivityInfo.ToInt(hn_con_next_3rd.InnerText);
                            }
                            if (hn_con_need_1st != null)
                            {
                                c.needMetal = ProductivityInfo.ToInt(hn_con_need_1st.InnerText);
                            }
                            if (hn_con_need_2nd != null)
                            {
                                c.needCrystal = ProductivityInfo.ToInt(hn_con_need_2nd.InnerText);
                            }
                            if (hn_con_need_3rd != null)
                            {
                                c.needH = ProductivityInfo.ToInt(hn_con_need_3rd.InnerText);
                            }
                        }
                        ci.allCons.Add(c);
                    }
                }
            }
            return(ci);
        }