Example #1
0
 public void VillageInfo()
 {
     HtmlDocument htmlDocument = new HtmlDocument();
     htmlDocument.Load("..\\..\\Test Files\\village.php.html");
     HtmlParser htmlParser = new HtmlParser(htmlDocument);
     Valley valley = htmlParser.GetVillageDetails();
     Assert.IsNotNull(valley, "valley is null!");
     Assert.AreEqual("gajo123", valley.Name, "Name!");
     Assert.AreEqual(267054, valley.VillageId, "Vilalge id!");
     Assert.AreEqual(-80, valley.X, "X coordinate!");
     Assert.AreEqual(67, valley.Y, "Y coordinate!");
     Assert.AreEqual("allianz.php?aid=0", valley.AllianceUrl, "Alliance url!");
     Assert.AreEqual(0, valley.AllianceId, "Alliance Id!");
     Assert.AreEqual("", valley.Alliance, "Alliance name!");
     Assert.AreEqual("novakm", valley.Player, "Player name!");
     Assert.AreEqual("spieler.php?uid=11436", valley.PlayerUrl, "Player url!");
     Assert.AreEqual(11436, valley.PlayerId, "User id!");
     Assert.AreEqual(36, valley.Population, "Village Population!");
     Assert.AreEqual("a2b.php?z=267054", valley.SendTroopsUrl, "SendTroopsUrl!");
     //UNICODE CRAP
     //Assert.AreEqual("» Pošlji enote", valley.SendTroopsText, "SendTroopsText!");
 }
Example #2
0
 public void VillageInfoProtection()
 {
     HtmlDocument htmlDocument = new HtmlDocument();
     htmlDocument.Load("..\\..\\Test Files\\karte.php.protection.html");
     HtmlParser htmlParser = new HtmlParser(htmlDocument);
     Valley valley = htmlParser.GetVillageDetails();
     Assert.IsNotNull(valley, "valley is null!");
     Assert.AreEqual("", valley.SendTroopsUrl, "SendTroopsUrl!");
     Assert.AreEqual("Začetniška zaščita do 05.06.10 18:33.", valley.SendTroopsText, "SendTroopsText!");
 }
Example #3
0
 private void GetMapInfoAt(int x, int y)
 {
     string servername = settings.LoginData.Servername;
     string url = String.Format(CultureInfo.InvariantCulture, "{0}karte.php?xp={1}&yp={2}&s1.x=32&s1.y=11&s1=ok",
                                servername, x, y);
     htmlDocument = htmlWeb.Load(url);
     HtmlParser htmlParser = new HtmlParser(htmlDocument);
     List<Valley> villagesFromMap = htmlParser.GetVillagesFromMap();
     List<Valley> oasesFromMap = htmlParser.GetOasesFromMap();
     List<Valley> updatedValleys = new List<Valley>();
     //List<Valley> existingValleys = map.Valleys;
     foreach (Valley valley in villagesFromMap)
     {
         url = String.Format(CultureInfo.InvariantCulture, "{0}{1}", servername, valley.VillageUrl);
         htmlDocument = htmlWeb.Load(url);
         htmlParser = new HtmlParser(htmlDocument);
         Valley villageDetails = htmlParser.GetVillageDetails();
         ValleyType valleyType = GetValleyType(villageDetails);
         //UpdateStatus(valleyType.ToString());
         villageDetails.AddUrl(valley.VillageUrl).AddType(valleyType);
         updatedValleys.Add(villageDetails);
     }
     foreach (Valley valley in oasesFromMap)
     {
         url = String.Format(CultureInfo.InvariantCulture, "{0}{1}", servername, valley.VillageUrl);
         htmlDocument = htmlWeb.Load(url);
         htmlParser = new HtmlParser(htmlDocument);
         Valley oasesDetails = htmlParser.GetOasesDetails();
         updatedValleys.Add(oasesDetails);
     }
     map.AddVillages(updatedValleys);
     //map.AddVillages(oasesFromMap);
     UpdateStatus(String.Format(CultureInfo.InvariantCulture, "Found {2} villages and {3} oases around ({0}|{1})",
                                x, y, villagesFromMap.Count, oasesFromMap.Count));
 }