Exemple #1
0
        public void Action()
        {
            if (CountDown > 0)
            {
                return;
            }
            int key = (UpCall.TD.Tribe - 1) * 10 + Aid;
            int Gid;

            Gid = GRt ? AIDMapg[key] : AIDMap[key];

            if (GRt && (Aid == 7 || Aid == 8) || Gid == 0)
            {
                UpCall.DebugLog("Not appropriate kind of troop to produce, deleted.", DebugLevel.W);
                MarkDeleted = true;
                return;
            }
            string url = "build.php?gid=" + Gid;

            if (Gid == 25)
            {
                url += "&s=1";
            }
            string data = UpCall.PageQuery(VillageID, url);

            if (data == null)
            {
                return;
            }
            if (!data.Contains(string.Format("name=\"t{0}\"", Aid)))
            {
                UpCall.DebugLog("Cannot produce this kind of troop before research it.", DebugLevel.W);
                MarkDeleted = true;
                return;
            }

            /*
             * id	34
             * z	10021
             * a	2
             * t1	2000
             * t3	0
             * s1.x	60
             * s1.y	16
             * s1	ok
             * <input type="hidden" name="id" value="34">
             * <input type="hidden" name="z" value="65535">
             * <input type="hidden" name="a" value="2">
             *
             */
            string p_a, p_id, p_z;
            Match  m;

            m = Regex.Match(data, "type=\"hidden\" name=\"id\" value=\"(\\d+?)\"");
            if (m.Success)
            {
                p_id = m.Groups[1].Value;
            }
            else
            {
                UpCall.DebugLog("Parse id error!", DebugLevel.F);
                MarkDeleted = true;
                return;
            }
            m = Regex.Match(data, "type=\"hidden\" name=\"z\" value=\"(\\w+?)\"");
            if (m.Success)
            {
                p_z = m.Groups[1].Value;
            }
            else
            {
                UpCall.DebugLog("Parse z error!", DebugLevel.F);
                MarkDeleted = true;
                return;
            }
            m = Regex.Match(data, "type=\"hidden\" name=\"a\" value=\"(\\d+?)\"");
            if (m.Success)
            {
                p_a = m.Groups[1].Value;
            }
            else
            {
                UpCall.DebugLog("Parse a error!", DebugLevel.F);
                MarkDeleted = true;
                return;
            }
            Dictionary <string, string> PostData = new Dictionary <string, string>();

            PostData["id"]      = p_id;
            PostData["z"]       = p_z;
            PostData["a"]       = p_a;
            PostData["s1.x"]    = rand.Next(10, 70).ToString();
            PostData["s1.y"]    = rand.Next(3, 17).ToString();
            PostData["s1"]      = "ok";
            PostData["t" + Aid] = Amount.ToString();
            data     = UpCall.PageQuery(VillageID, "build.php", PostData);
            LastExec = DateTime.Now;
            NextExec = LastExec.AddSeconds(MinimumInterval);
            Count++;
            if (MaxCount != 0 && Count >= MaxCount)
            {
                MarkDeleted = true;
            }
        }
        public void Action()
        {
            if (CountDown > 0)
            {
                return;
            }
            if (Targets[TargetID].IsEmpty)
            {
                UpCall.DebugLog("Target Is Error!!", DebugLevel.F);
                MarkDeleted = true;
                return;
            }
            if (Settlers)
            {
                var result = UpCall.PageQuery(VillageID, "build.php?id=39&tt=2&z=" + Targets[TargetID].Z.ToString());
                if (result == null)
                {
                    return;
                }
                Match m;
                m = Regex.Match(result, "type=\"submit\" value=\"ok\" name=\"s1\"");
                if (m.Success)
                {
                    Dictionary <string, string> PostDataST = new Dictionary <string, string>();
                    PostDataST["a"]    = "1";
                    PostDataST["s"]    = Targets[TargetID].Z.ToString();
                    PostDataST["id"]   = "39";
                    PostDataST["s1.x"] = rand.Next(40, 70).ToString();
                    PostDataST["s1.y"] = rand.Next(3, 17).ToString();
                    PostDataST["s1"]   = "ok";
                    var datast = UpCall.PageQuery(VillageID, "build.php", PostDataST);
                }
                else
                {
                    UpCall.DebugLog("Unable to Settlers", DebugLevel.F);
                }
                MarkDeleted = true;
                return;
            }
            List <Dictionary <string, string> > PostDataALL = new List <Dictionary <string, string> >();

            for (int w = 0; w < wWaves.Count; w++)
            {
                for (int j = 0; j < wWaves[w]; j++)
                {
                    Dictionary <string, string> PostData = new Dictionary <string, string>();
                    var   data = UpCall.PageQuery(VillageID, "build.php?tt=2&id=39");
                    Match m10;
                    m10 = Regex.Match(data, "type=\"hidden\" name=\"timestamp\" value=\"([^>]*?)\"");
                    string p_timestamp = m10.Groups[1].Value;
                    Match  m11;
                    m11 = Regex.Match(data, "type=\"hidden\" name=\"timestamp_checksum\" value=\"([^>]*?)\"");
                    string p_timestamp_checksum = m11.Groups[1].Value;
                    PostData["timestamp"]          = p_timestamp;
                    PostData["timestamp_checksum"] = p_timestamp_checksum;
                    PostData["b"]     = "1";
                    PostData["dname"] = "";
                    PostData["x"]     = Targets[TargetID].X.ToString();
                    PostData["y"]     = Targets[TargetID].Y.ToString();
                    PostData["s1.x"]  = rand.Next(40, 70).ToString();
                    PostData["s1.y"]  = rand.Next(3, 17).ToString();
                    PostData["s1"]    = "ok";
                    if (Raidtype > 4)
                    {
                        PostData["c"] = "4";
                    }
                    else
                    {
                        PostData["c"] = Raidtype.ToString();
                    }
                    for (int i = 1; i < 12; i++)
                    {
                        PostData["t" + i] = wTroops[w].Troops[i - 1].ToString();
                    }

                    Dictionary <string, string> PostDataF = new Dictionary <string, string>();
                    var result = UpCall.PageQuery(VillageID, "build.php?tt=2&id=39", PostData);
                    if (result.Contains("<p class=\"error\">"))
                    {
                        UpCall.DebugLog("Target is Error!!", DebugLevel.W);
                        MarkDeleted = true;
                        return;
                    }
                    Match m20;
                    m20 = Regex.Match(result, "type=\"hidden\" name=\"timestamp\" value=\"([^>]*?)\"");
                    string p_timestampF = m20.Groups[1].Value;
                    Match  m21;
                    m21 = Regex.Match(result, "type=\"hidden\" name=\"timestamp_checksum\" value=\"([^>]*?)\"");
                    string p_timestamp_checksumF = m21.Groups[1].Value;
                    Match  m22;
                    m22 = Regex.Match(result, "type=\"hidden\" name=\"a\" value=\"(\\d+?)\"");
                    string p_aF = m22.Groups[1].Value;
                    PostDataF["timestamp"]          = p_timestampF;
                    PostDataF["timestamp_checksum"] = p_timestamp_checksumF;
                    PostDataF["a"] = p_aF;
                    //2 RE,3 Nor,4 Raid, 5 SPY1, 6 SPY2
                    if (Raidtype > 4)
                    {
                        PostDataF["c"] = "4";
                        int Tribe = UpCall.TD.Tribe;
                        int spy   = Raidtype - 4;
                        PostDataF["spy"] = spy.ToString();
                        if (Tribe == 3 && wTroops[w].Troops[2] != 0)
                        {
                            PostDataF["t3"] = wTroops[w].Troops[2].ToString();
                        }
                        else if ((Tribe == 1 || Tribe == 2) && wTroops[w].Troops[3] != 0)
                        {
                            PostDataF["t4"] = wTroops[w].Troops[3].ToString();
                        }
                        else
                        {
                            UpCall.DebugLog("NO SCOUT TROOPS", DebugLevel.W);
                            MarkDeleted = true;
                            return;
                        }
                    }
                    else
                    {
                        PostDataF["c"] = Raidtype.ToString();
                        for (int i = 1; i < 12; i++)
                        {
                            PostDataF["t" + i] = wTroops[w].Troops[i - 1].ToString();
                        }
                    }
                    if (Raidtype == 3 && (wTroops[w].Troops[7] != 0))
                    {
                        int RP    = UpCall.TD.Villages[VillageID].Buildings[39].Level;
                        int tkata = GIDMap[kata];
                        if (tkata == 0 || RP < 10)
                        {
                            tkata = 99;
                        }
                        PostDataF["kata"] = tkata.ToString();
                        if ((wTroops[w].Troops[7] >= 20) && (RP == 20))
                        {
                            int tkata2 = GIDMap[kata2];
                            PostDataF["kata2"] = tkata2.ToString();
                        }
                    }
                    PostDataF["kid"]  = Targets[TargetID].Z.ToString();
                    PostDataF["id"]   = "39";
                    PostDataF["s1.x"] = rand.Next(40, 70).ToString();
                    PostDataF["s1.y"] = rand.Next(3, 17).ToString();
                    PostDataF["s1"]   = "ok";

                    PostDataALL.Add(PostDataF);
                }
            }
            //POST ALL Attack
            for (int i = 0; i < PostDataALL.Count; i++)
            {
                UpCall.PageQuery(VillageID, "build.php?tt=2&id=39", PostDataALL[i]);
            }
            Wave++;
            if (TargetID == Targets.Count - 1)
            {
                MarkDeleted = true;
            }
            else
            {
                LastExec = DateTime.Now;
                NextExec = LastExec.AddSeconds(MinimumInterval);
                TargetID++;
            }
        }