Esempio n. 1
0
        public bool StartRaid()
        {
            _getParams = new Dictionary <string, string>
            {
                { "tt", "99" },
                { "id", "39" }
            };

            if (!HTTP.GetRequest("http://" + _server + "/build.php", _getParams, _server, true))
            {
                return(false);
            }

            Bot.Log("Navigated to farmlist", Color.Black);
            htmlCrawler = new HtmlCrawler(Info.ResponseBody);
            var ajaxToken = htmlCrawler.GetAjaxToken();
            var aToken    = htmlCrawler.GetValueA();

            lidList = htmlCrawler.GetLid();

            if (lidList.Count < 1)
            {
                return(false);
            }

            if (ExcludeLastList)
            {
                if (raidTurn >= lidList.Count - 1)
                {
                    raidTurn = 0;
                }
            }
            else
            {
                if (raidTurn >= lidList.Count)
                {
                    raidTurn = 0;
                }
            }

            if (ExpandRaidList(ajaxToken, lidList[raidTurn]))
            {
                if (ClickRaid(aToken, lidList[raidTurn]))
                {
                    var randomDelay = rnd.Next(Math.Min(Min, max), Math.Max(Min, max) + 1);
                    //0s - 2min 30s = 150s
                    var      delay     = (75 * randomDelay) + 30000;
                    TimeSpan t         = TimeSpan.FromMilliseconds(delay);
                    string   delayTime = $"{t.Hours:D2}:{t.Minutes:D2}:{t.Seconds:D2}";
                    Bot.Log("List: " + raidTurn + " - Raid sent! Waiting " + delayTime + " before next raid.", Color.Black);
                    raidTurn++;
                    Thread.Sleep(delay);
                    return(true);
                }
                Bot.Log("Raid failed", Color.Black);
                return(false);
            }
            else
            {
                Bot.Log("Error while expanding raidlist", Color.Black);
                return(false);
            }
        }
Esempio n. 2
0
        public bool BuyAnimals()
        {
            _getParams.Clear();

            if (!HTTP.GetRequest("http://" + _server + "/build.php", _getParams, _server, true))
            {
                return(false);
            }

            htmlCrawler = new HtmlCrawler(Info.ResponseBody);
            string token;

            token = htmlCrawler.GetAjaxToken();

            var postParams = new Dictionary <string, string>
            {
                { "", "" },
                { "cmd", "paymentWizard" },
                { "goldProductId", "" },
                { "goldProductLocation", "" },
                { "location", "" },
                { "activeTab", "buyGold" },
                { "ajaxToken", token }
            };

            CookieCollection t = new CookieCollection();

            if (!HTTP.PostAjaxRequest("https://" + _server + "/ajax.php?cmd=paymentWizard", _server, cookies,
                                      _getParams, postParams, ref t))
            {
                return(false);
            }

            if (Bot.GetErrorMessage(Info.ResponseBody))
            {
                return(false);
            }

            postParams["activeTab"] = "paymentFeatures";

            if (!HTTP.PostAjaxRequest("https://" + _server + "/ajax.php?cmd=paymentWizard", _server, cookies,
                                      _getParams, postParams, ref t))
            {
                return(false);
            }

            if (Bot.GetErrorMessage(Info.ResponseBody))
            {
                return(false);
            }

            postParams = new Dictionary <string, string>
            {
                { "cmd", "premiumFeature" },
                { "featureKey", "buyAnimal5" },
                { "context", "paymentWizard" },
                { "ajaxToken", token }
            };

            if (!HTTP.PostAjaxRequest("https://" + _server + "/ajax.php?cmd=premiumFeature", _server, cookies,
                                      _getParams, postParams, ref t))
            {
                return(false);
            }

            if (Bot.GetErrorMessage(Info.ResponseBody))
            {
                return(false);
            }

            postParams = new Dictionary <string, string>
            {
                { "cmd", "getGoldAmount" },
                { "ajaxToken", token }
            };
            if (HTTP.PostAjaxRequest("https://" + _server + "/ajax.php?cmd=getGoldAmount", _server, cookies, _getParams, postParams, ref t))
            {
                // Hata mesajı varsa false döndürür
                return(!Bot.GetErrorMessage(Info.ResponseBody));
            }
            return(false);
        }
Esempio n. 3
0
        public bool CreateFarmlist()
        {
            _getParams.Clear();

            string ajaxToken, aToken;

            if (!HTTP.GetRequest("http://" + _server + "/spieler.php?uid=1", _getParams, _server, true))
            {
                return(false);
            }

            htmlCrawler = new HtmlCrawler(Info.ResponseBody);
            ajaxToken   = htmlCrawler.GetAjaxToken();
            List <Coordinates> coordinates = htmlCrawler.GetCoordinates();

            _getParams = new Dictionary <string, string>
            {
                { "tt", "99" },
                { "id", "39" }
            };

            if (!HTTP.GetRequest("http://" + _server + "/build.php", _getParams, _server, true))
            {
                return(false);
            }

            htmlCrawler = new HtmlCrawler(Info.ResponseBody);
            Bot.Log("Navigated to farmlist", Color.Black);
            lidList = htmlCrawler.GetLid();

            if (lidList.Count < 1)
            {
                Bot.Log("No farmlists detected!", Color.Red);
                return(false);
            }

            int addToList;

            for (addToList = 0; addToList < lidList.Count; addToList++)
            {
                if (ExpandRaidList(ajaxToken, lidList[addToList]))
                {
                    var farmCoordinates = coordinates.GetRange((0 + (addToList * 100)), 100);
                    foreach (Coordinates c in farmCoordinates)
                    {
                        if (ClickAdd(ajaxToken, lidList[addToList], c.X, c.Y))
                        {
                            Bot.Log("List: " + addToList + " - Farm added. X: " + c.X + " Y: " + c.Y + " %" + (farmCoordinates.IndexOf(c) + 1), Color.DarkGreen);
                        }
                        else
                        {
                            Bot.Log("Error while adding farm to farmlist.", Color.DarkRed);
                            return(false);
                        }
                    }
                }
                else
                {
                    Bot.Log("Error while expanding raidlist", Color.DarkRed);
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 4
0
        public bool TrainTroops(string id)
        {
            _getParams = new Dictionary <string, string>
            {
                { "id", id },
                { "fastUP", "0" }
            };

            if (!HTTP.GetRequest("http://" + _server + "/build.php", _getParams, _server, true))
            {
                return(false);
            }

            htmlCrawler = new HtmlCrawler(Info.ResponseBody);

            if (htmlCrawler.isSessionExpired(content))
            {
                return(false);
            }

            if (htmlCrawler.isBuildingThere(content))
            {
                var zToken              = htmlCrawler.GetValueZ();
                var ajaxToken           = htmlCrawler.GetAjaxToken();
                var troopResourceParams = htmlCrawler.GetTroopResource(ajaxToken);
                if (DoNpc)
                {
                    if (Npc(troopResourceParams, ajaxToken))
                    {
                        Bot.Log("NPC done.", Color.Black);
                    }
                }
                htmlCrawler = new HtmlCrawler(Info.ResponseBody);
                var      troopsForRes = htmlCrawler.TroopsForRes();
                string[] trainType    = new string[4]
                {
                    "0", "0", "0", "0"
                };

                if (troopsForRes.Count > 0)
                {
                    trainType[_trainTroopType] = troopsForRes[_trainTroopType];
                }
                else
                {
                    return(false);
                }

                var postParams = new Dictionary <string, string>
                {
                    { "id", id },
                    { "z", zToken },
                    { "a", "2" },
                    { "s", "1" },
                    { "t1", trainType[0] },
                    { "t2", trainType[1] },
                    { "t3", trainType[2] },
                    { "t4", trainType[3] },
                    { "s1", "ok" }
                };

                if (!HTTP.PostRequest("https://" + _server + "/build.php", null, _getParams, postParams, ref cookies))
                {
                    return(false);
                }

                var randomDelay = rnd.Next(Math.Min(Min, max), Math.Max(Min, max) + 1);
                //0s - 2min 30s = 150s
                var      delay     = (75 * randomDelay) + 2000;
                TimeSpan t         = TimeSpan.FromMilliseconds(delay);
                string   delayTime = $"{t.Hours:D2}:{t.Minutes:D2}:{t.Seconds:D2}";
                Bot.Log("Troops trained: " + troopsForRes[_trainTroopType] + " Waiting " + delayTime + " before next raid.", Color.Black);
                Thread.Sleep(delay);
                return(true);
            }

            Bot.Log("Barracks is destroyed. Trying to build it up.", Color.Black);
            return(BuildBuildings() && TrainTroops(id));
        }