Exemplo n.º 1
0
        public bool Login(string _loginToken)
        {
            _getParams.Clear();
            var postParams = new Dictionary <string, string>
            {
                { "user", _user },
                { "pw", _pass },
                { "s1", "Login" },
                { "w", "1366:768" },
                { "login", _loginToken }
            };

            if (_server.Contains("travian.com.tr"))
            {
                postParams = new Dictionary <string, string>
                {
                    { "name", _user },
                    { "password", _pass },
                    { "s1", "Giriş" },
                    { "w", "1366:768" },
                    { "login", _loginToken }
                };
            }

            return(HTTP.PostRequest("https://" + _server + "/index.php", null, _getParams, postParams, ref cookies));
        }
Exemplo n.º 2
0
        public bool ClickRaid(string token, string lid)
        {
            _getParams.Clear();

            var postParams = new Dictionary <string, string>
            {
                { "action", "startRaid" },
                { "a", token },
                { "sort", "distance" },
                { "direction", "asc" },
                { "lid", lid }
            };

            var json     = Info.ResponseBody;
            var jsonData = JsonParser.FromJson(json);

            if (jsonData.Response.Data.List.Slots == null)
            {
                return(false);
            }

            foreach (var list in jsonData.Response.Data.List.Slots)
            {
                postParams.Add("slot[" + list.Key + "]", "on");
            }

            return(HTTP.PostRequest("https://" + _server + "/build.php?gid=16&tt=99", null, _getParams, postParams, ref cookies));
        }
Exemplo n.º 3
0
        public bool ExpandRaidList(string token, string lid)
        {
            _getParams.Clear();
            var postParams = new Dictionary <string, string>
            {
                { "cmd", "raidListSlots" },
                { "lid", lid },
                { "ajaxToken", token }
            };

            if (HTTP.PostRequest("https://" + _server + "/ajax.php?cmd=raidListSlots", null, _getParams, postParams, ref cookies))
            {
                return(Bot.SaveData(Info.ResponseBody));
            }
            return(false);
        }
Exemplo 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));
        }
Exemplo n.º 5
0
        public bool AttackPlayer(string x, string y)
        {
            _getParams = new Dictionary <string, string>
            {
                { "id", "39" },
                { "tt", "2" },
            };

            string ajaxToken;

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

            htmlCrawler = new HtmlCrawler(Info.ResponseBody);
            var aToken = htmlCrawler.GetValueA();

            Dictionary <string, string> attackInfo = htmlCrawler.GetAttackInfo();

            _getParams.Clear();

            var list = Info.AttackUnits;

            var postParams = new Dictionary <string, string>
            {
                { "timestamp", attackInfo["timestamp"] },
                { "timestamp_checksum", attackInfo["timestamp_checksum"] },
                { "b", attackInfo["b"] },
                { "currentDid", attackInfo["currentDid"] },
                { "mpvt_token", attackInfo["mpvt_token"] },
                { "t1", list[0] },
                { "t4", list[3] },
                { "t7", list[6] },
                { "t9", "" },
                { "t2", list[1] },
                { "t5", list[4] },
                { "t8", list[7] },
                { "t10", "" },
                { "t3", list[2] },
                { "t6", list[5] },
                { "t11", "" },
                { "dname", "" },
                { "x", x },
                { "y", y },
                { "c", "3" },
                { "s1", "ok" }
            };

            if (HTTP.PostRequest("https://" + _server + "/build.php?id=39&tt=2", null, _getParams, postParams, ref cookies))
            {
                attackInfo = htmlCrawler.GetAttackInfo();

                postParams = new Dictionary <string, string>
                {
                    { "redeployHero", "" },
                    { "timestamp", attackInfo["timestamp"] },
                    { "timestamp_checksum", attackInfo["timestamp_checksum"] },
                    { "id", "39" },
                    { "a", aToken },
                    { "c", "3" },
                    { "kid", attackInfo["kid"] },
                    { "t1", attackInfo["t1"] },
                    { "t2", attackInfo["t2"] },
                    { "t3", attackInfo["t3"] },
                    { "t4", attackInfo["t4"] },
                    { "t5", attackInfo["t5"] },
                    { "t6", attackInfo["t6"] },
                    { "t7", attackInfo["t7"] },
                    { "t8", attackInfo["t8"] },
                    { "t9", attackInfo["t9"] },
                    { "t10", attackInfo["t10"] },
                    { "t11", attackInfo["t11"] },
                    { "sendReally", "1" },
                    { "troopsSent", "1" },
                    { "currentDid", attackInfo["currentDid"] },
                    { "b", attackInfo["b"] },
                    { "dname", "" },
                    { "x", x },
                    { "y", y },
                    { "s1", "ok" }
                };

                if (list[7] != string.Empty || list[7] != null)
                {
                    postParams.Add("ctar1", "99");
                    postParams.Add("ctar2", "99");
                }

                if (HTTP.PostRequest("https://" + _server + "/build.php?id=39&tt=2", null, _getParams, postParams, ref cookies))
                {
                    Bot.Log("Attacked!", Color.Black);
                }
                return(false);
            }
            else
            {
                Bot.Log("Error while attacking", Color.Black);
                return(false);
            }
        }