Exemplo n.º 1
0
        public void Action()
        {
            if (MinimumDelay > 0)
            {
                return;
            }

            string data = UpCall.CheckBuildingExistAndQuery(VillageID, 16);

            if (data == null)
            {
                MinimumDelay = 60;
                return;
            }

            hero_status = CheckIfHeroHome();
            if (hero_status == -1)
            {
                UpCall.CallStatusUpdate(this, new Travian.StatusChanged()
                {
                    ChangedData = Travian.ChangedType.Queue,
                    VillageID   = VillageID
                });
                UpCall.DebugLog("英雄不属于该村,无法探险!", DebugLevel.II);
                MarkDeleted = true;
                return;
            }
            else if (hero_status == 1)
            {
                UpCall.CallStatusUpdate(this, new Travian.StatusChanged()
                {
                    ChangedData = Travian.ChangedType.Queue,
                    VillageID   = VillageID
                });
                UpCall.DebugLog("英雄目前不在家,等待英雄返回!", DebugLevel.II);
                return;
            }

            bool bAvail = false;
            List <HeroAdventureInfo> InfoList = UpCall.TD.Adv_Sta.HeroAdventures;

            for (int i = 0; i < InfoList.Count; i++)
            {
                TimeSpan ts = CheckDurAvail(InfoList[i].duration);
                if (ts == TimeSpan.MinValue)
                {
                    continue;
                }
                bAvail = true;
                break;
            }

            //	如果当前的探险地方尚未初始化或全部都不合适,则尝试重新抓取
            if (!UpCall.TD.Adv_Sta.bIsHeroAdventureInitialize || !bAvail)
            {
                UpCall.doFetchHeroAdventures(VillageID);
            }

            cur_adv_pt = new TPoint(0, 0);
            int HeroLoc = UpCall.TD.Adv_Sta.HeroLocate;

            for (int i = 0; i < InfoList.Count; i++)
            {
                TimeSpan ts = CheckDurAvail(InfoList[i].duration);
                if (ts == TimeSpan.MinValue)
                {
                    UpCall.DebugLog(
                        "跳过(" + InfoList[i].axis_x + "|" + InfoList[i].axis_y + ")的探险",
                        DebugLevel.II);
                    continue;
                }

                TPoint tp = new TPoint(InfoList[i].axis_x, InfoList[i].axis_y);
                data = UpCall.PageQuery(HeroLoc, "start_adventure.php?from=list&kid=" + tp.Z.ToString());
                if (data == null)
                {
                    continue;
                }
                Match m_test = Regex.Match(data, "type=\"submit\" value=\".*?\" name=\"start\"");
                if (!m_test.Success)
                {
                    continue;
                }

                Dictionary <string, string> PostData = new Dictionary <string, string>();
                MatchCollection             mc       = Regex.Matches(
                    data, "<input type=\"hidden\" name=\"([^\"]*?)\" value=\"([^\"]*?)\" />");
                string key, val;
                foreach (Match m in mc)
                {
                    key           = m.Groups[1].Value;
                    val           = m.Groups[2].Value;
                    PostData[key] = val;
                }
                UpCall.PageQuery(HeroLoc, "start_adventure.php", PostData);
                UpCall.PageQuery(HeroLoc, "build.php?gid=16&tt=1");

                MinimumDelay = Convert.ToInt32(ts.TotalSeconds);
                cur_adv_pt   = tp;
                break;
            }

            if (cur_adv_pt.IsEmpty)
            {
                MinimumDelay = 3600;
                UpCall.DebugLog("探险位置不存在或行程过长", DebugLevel.II);
            }
            else
            {
                UpCall.DebugLog("前往(" + cur_adv_pt.X + "|" + cur_adv_pt.Y + ")探险", DebugLevel.II);
            }
            hero_status = 2;
            UpCall.CallStatusUpdate(this, new Travian.StatusChanged()
            {
                ChangedData = Travian.ChangedType.Queue,
                VillageID   = VillageID
            });
        }