示例#1
0
 public void ParseAttackRang()
 {
     string pageSource = Misc.ReadContent("..\\..\\..\\Samples\\TestFiles\\statistiken.attack.php");
     HtmlParser htmlParser = new HtmlParser(pageSource);
     PlayerData playerData = new PlayerData();
     htmlParser.ParseAttackRang(playerData, "jeza");
     Assert.AreEqual("jeza", playerData.Name);
     Assert.AreEqual(18145, playerData.AttackPoints);
     Assert.AreEqual(23, playerData.AttackRang);
     Assert.AreEqual(2242, playerData.Population);
     Assert.AreEqual(4, playerData.VillageCount);
 }
示例#2
0
 public static bool IsLogedIn(ServerInfo serverInfo,
     string postData)
 {
     string pageSource = Http.SendData(serverInfo.Dorf1Url, postData, serverInfo.CookieContainer,
                                       serverInfo.CookieCollection);
     HtmlParser htmlParser = new HtmlParser(pageSource);
     //Console.WriteLine(pageSource);
     htmlParser.ParseUserId(serverInfo);
     bool uidFound = serverInfo.UserId < 0 ? false : true;
     if (uidFound)
     {
         pageSource = Http.SendData(serverInfo.SpielerUrl + serverInfo.UserId, null, serverInfo.CookieContainer,
                                    serverInfo.CookieCollection);
         htmlParser = new HtmlParser(pageSource);
         htmlParser.ParseAlianceId(serverInfo);
     }
     return uidFound;
 }
示例#3
0
 public void Merchants35()
 {
     string pageSource = Misc.ReadContent("..\\..\\..\\Samples\\TestFiles\\build.php-newdid=73229-gid=17");
     HtmlParser htmlParser = new HtmlParser(pageSource);
     Marketplace marketplace = new Marketplace();
     const int villageId = 73229;
     marketplace.VillageId = villageId;
     htmlParser.ParseMarketplace(marketplace);
     Assert.AreEqual(0, marketplace.AvailableMerchants);
     Assert.AreEqual(20, marketplace.TotalMerchants);
     Assert.AreEqual(2000, marketplace.TotalCarry);
     Village village = new Village(villageId, "some name");
     htmlParser.ParseVillageProduction(village);
     Assert.AreEqual(3736, village.WoodAvailable);
     Assert.AreEqual(1000, village.WoodProduction);
     Assert.AreEqual(3736, village.ClayAvailable);
     Assert.AreEqual(1000, village.ClayProduction);
     Assert.AreEqual(5036, village.IronAvailable);
     Assert.AreEqual(1000, village.IronProduction);
     Assert.AreEqual(15804, village.CropAvailable);
     Assert.AreEqual(442, village.CropProduction);
     Assert.AreEqual(160000, village.CapacityWarehouse);
     Assert.AreEqual(160000, village.CapacityGranary);
 }
 private bool SendResources(SendResourcesParameters parameters)
 {
     //id=33&r1=&r2=&r3=20000&r4=&dname=&x=-16&y=-93&s1.x=27&s1.y=14&s1=ok
     //id=33&r1=172&r2=206&r3=172&r4=100&dname=&x=-15&y=-93&s1.x=35&s1.y=5&s1=ok
     //<input type="hidden" name="id" value="33">
     //<input type="hidden" name="a" value="83117">
     //<input type="hidden" name="sz" value="47406">
     //<input type="hidden" name="kid" value="395278">
     Random rnd = new Random();
     String button = String.Format(CultureInfo.InvariantCulture,
                                   "&s1.x={0}&s1.y={1}&s1=ok",
                                   rnd.Next(0, 79),
                                   rnd.Next(0, 19));
     StringBuilder resources = new StringBuilder();
     resources.Append("&r1=" + parameters.WoodAmount);
     resources.Append("&r2=" + parameters.ClayAmount);
     resources.Append("&r3=" + parameters.IronAmount);
     resources.Append("&r4=" + parameters.CropAmount);
     String postData = String.Format(CultureInfo.InvariantCulture,
                                     "id=33{0}&dname=&x={1}&y={2}{3}",
                                     resources,
                                     parameters.DestinationVillageX,
                                     parameters.DestinationVillageY,
                                     button);
     string url = String.Format(CultureInfo.InvariantCulture, "{0}?newdid={1}&gid=17", serverInfo.BuildUrl,
                                parameters.SourceVillageId);
     string pageSource = Http.SendData(url, postData, serverInfo.CookieContainer, serverInfo.CookieCollection);
     HtmlParser htmlParser = new HtmlParser(pageSource);
     int sz = htmlParser.ParseMarketPlaceHiddenData();
     if (sz == -1)
     {
         return false;
     }
     //id=33&a=83117&sz=47406&kid=395278&r1=&r2=&r3=20000&r4=&s1.x=24&s1.y=11&s1=ok
     //id=33&a=93284&sz=53492&kid=395279&r1=172&r2=206&r3=172&r4=100&s1.x=26&s1.y=10&s1=ok
     button = String.Format(CultureInfo.InvariantCulture,
                            "&s1.x={0}&s1.y={1}&s1=ok",
                            rnd.Next(0, 79),
                            rnd.Next(0, 19));
     postData = String.Format(CultureInfo.InvariantCulture,
                              "id=33&a={0}&sz={1}&kid={2}{3}{4}",
                              parameters.SourceVillageId,
                              sz,
                              Misc.ConvertXY(parameters.DestinationVillageX, parameters.DestinationVillageY),
                              resources,
                              button);
     Http.SendData(url, postData, serverInfo.CookieContainer, serverInfo.CookieCollection);
     return true;
 }
 private bool EnoughResources(SendResourcesParameters parameters)
 {
     string url = String.Format(CultureInfo.InvariantCulture, "{0}?newdid={1}", serverInfo.Dorf1Url,
                                parameters.SourceVillageId);
     string pageSource = Http.SendData(url, null, serverInfo.CookieContainer, serverInfo.CookieCollection);
     HtmlParser htmlParser = new HtmlParser(pageSource);
     Village village = new Village(parameters.SourceVillageId, "noName");
     htmlParser.ParseVillageProduction(village);
     if (village.WoodAvailable < parameters.WoodAmount
         || village.ClayAvailable < parameters.ClayAmount
         || village.IronAvailable < parameters.IronAmount
         || village.CropAvailable < parameters.CropAmount)
     {
         return false;
     }
     return true;
 }
 private int GetAvailableUnitCount(ActionParameters parameters)
 {
     int villageId = parameters.VillageId;
     string url = String.Format(CultureInfo.InvariantCulture, "{0}?newdid={1}", serverInfo.Dorf1Url, villageId);
     string pageSource = Http.SendData(url, null, serverInfo.CookieContainer, serverInfo.CookieCollection);
     HtmlParser htmlParser = new HtmlParser(pageSource);
     htmlParser.ParseUnitsInVillage(serverInfo, villageId);
     Unit units = serverInfo.GetVillage(villageId).GetUnit(parameters.UnitName);
     return units != null ? units.UnitCount : 0;
 }
示例#7
0
        private void GetStats(ServerInfo serverInfo,
            int number,
            string username,
            AlianceData data)
        {
            PlayerData playerData = new PlayerData {Number = number};
            //rank=&name=jasa&submit.x=7&submit.y=8&submit=submit
            string postData = String.Format("&rank=1&name={0}&submit.x=7&submit.y=8&submit=submit", username);
            textBoxStatus.Text += postData + "\r\n";
            string pageSource = Http.SendData(serverInfo.StatistikAttack, postData, serverInfo.CookieContainer,
                                              serverInfo.CookieCollection);
            HtmlParser htmlParser = new HtmlParser(pageSource);
            htmlParser.ParseAttackRang(playerData, username);

            postData = String.Format("&rank=1&name={0}&submit.x=7&submit.y=8&submit=submit", username);
            textBoxStatus.Text += postData + "\r\n";
            pageSource = Http.SendData(serverInfo.StatistikDefense, postData, serverInfo.CookieContainer,
                                       serverInfo.CookieCollection);
            htmlParser = new HtmlParser(pageSource);
            htmlParser.ParseDefenseRang(playerData, username);

            postData = String.Format("?rank=1&name={0}&submit.x=7&submit.y=8&submit=submit", username);
            pageSource = Http.SendData(serverInfo.StatistikRang, postData, serverInfo.CookieContainer,
                                       serverInfo.CookieCollection);
            htmlParser = new HtmlParser(pageSource);
            htmlParser.ParseRang(playerData, username);

            data.AddPlayerData(playerData);
            textBoxStatus.Text += playerData + "\r\n";
        }
示例#8
0
 public static void UpdateVillages(ServerInfo serverInfo)
 {
     serverInfo.Villages.Clear();
     string pageSource = Http.SendData(serverInfo.Dorf1Url, null, serverInfo.CookieContainer,
                                       serverInfo.CookieCollection);
     HtmlParser htmlParser = new HtmlParser(pageSource);
     htmlParser.ParseVillages(serverInfo);
     Console.WriteLine("User: {1}[{0}]", serverInfo.UserId, serverInfo.Username);
     Console.WriteLine("AlianceId: {0}", serverInfo.AlianceId);
     Console.WriteLine("Villages:");
     Console.WriteLine("Id        Name");
     foreach (Village village in serverInfo.Villages)
     {
         Console.WriteLine("{1,-10}{0}", village.VillageName, village.VillageId);
     }
 }