コード例 #1
0
ファイル: Travian.cs プロジェクト: haxcat5/TraviAnt
        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
ファイル: Travian.cs プロジェクト: haxcat5/TraviAnt
        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);
            }
        }