示例#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);
            }
        }
示例#2
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);
        }