Exemple #1
0
        public string animalFinder(int distance, Village _village, string _animal)
        {
            this.village = _village;
            this.driver = Account.driver;
            string tmp = "";

            for (int y = (int.Parse(this.village.y) - distance); y < (int.Parse(this.village.y) + distance); y++)
            {
                for (int x = (int.Parse(this.village.x) - distance); x < (int.Parse(this.village.x) + distance); x++)
                {
                    this.driver.Navigate().GoToUrl("https://ts3.travian.si/position_details.php?x=" + x + "&y=" + y);
                    string[] str = this.driver.FindElement(By.ClassName("contentContainer")).Text.Split('\n');
                    string fullstring = this.driver.FindElement(By.ClassName("contentContainer")).Text;

                    if (str[2].Contains("Ropaj nezasedeno oazo"))
                    {
                        switch (_animal)
                        {
                            case "Medved":
                                if (fullstring.Contains("Medvedov"))
                                {
                                    tmp += str[0];
                                }
                                break;
                            case "Krokodil":
                                if (fullstring.Contains("Krokodilov"))
                                {
                                    tmp += str[0];
                                }
                                break;
                            case "Tiger":
                                if (fullstring.Contains("Tigrov"))
                                {
                                    tmp += str[0];
                                }
                                break;
                            case "Slon":
                                if (fullstring.Contains("Slonov"))
                                {
                                    tmp += str[0];
                                }
                                break;
                        }
                    }

                    System.Threading.Thread.Sleep(120);
                }
            }

            return tmp;
        }
Exemple #2
0
        public static void Start()
        {
            Account.driver = new FirefoxDriver();

            Account.Login(Account.username, Account.password);
            // Start village creation
            Account.villages = new List<Village>();

            Account.driver.Navigate().GoToUrl(Account.url + "dorf1.php");

            try
            {
                TimeSpan timespan = TimeSpan.FromSeconds(2);
                WebDriverWait wait = new WebDriverWait(Account.driver, timespan);
                wait.Until(ExpectedConditions.ElementIsVisible(By.Id("sidebarBoxVillagelist")));
                Account.driver.FindElement(By.Id("sidebarBoxVillagelist")).FindElement(By.ClassName("addHoverClick")).Click();
                ReadOnlyCollection<IWebElement> villageElements = Account.driver.FindElement(By.Id("sidebarBoxVillagelist")).FindElement(By.ClassName("sidebarBoxInnerBox")).FindElements(By.TagName("li"));

                string name;
                string id;
                string x;
                string y;
                int count = 0;
                foreach (IWebElement village in villageElements)
                {

                    // Parse name and id
                    name = Account.driver.FindElement(By.Id("sidebarBoxVillagelist")).FindElement(By.ClassName("sidebarBoxInnerBox")).FindElements(By.TagName("li"))[count].FindElement(By.ClassName("name")).Text;
                    id = Account.driver.FindElement(By.Id("sidebarBoxVillagelist")).FindElement(By.ClassName("sidebarBoxInnerBox")).FindElements(By.TagName("li"))[count].FindElement(By.TagName("a")).GetAttribute("href");
                    id = id.Replace("&", "").Split('=')[1];

                    //Parse X

                    x = Account.driver.FindElement(By.Id("sidebarBoxVillagelist")).FindElement(By.ClassName("sidebarBoxInnerBox")).FindElements(By.TagName("li"))[count].FindElement(By.ClassName("coordinateX")).Text;

                    x = x.Replace("(", "");
                    bool negative = x.Contains('-');

                    x = new string(x.Where(c => char.IsDigit(c)).ToArray());
                    if (negative) {
                        x = "-" + x;
                    }

                    //Parse Y
                    y = Account.driver.FindElement(By.Id("sidebarBoxVillagelist")).FindElement(By.ClassName("sidebarBoxInnerBox")).FindElements(By.TagName("li"))[count].FindElement(By.ClassName("coordinateY")).Text;

                    y = y.Replace(")", "");
                    negative = y.Contains('-');
                    y = new string(y.Where(c => char.IsDigit(c)).ToArray());
                    if (negative) {
                        y = "-" + y;
                    }

                    Village vil = new Village(id, name, x, y);
                    vil.setNoOfResources();
                    vil.setBuildingsData();
                    vil.setProductionPH();
                    vil.setResourcesData();
                    vil.setWareGranCapacity();
                    villages.Add(vil);
                    count++;
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show(ex.Message);
            }
        }
Exemple #3
0
 public Market(Village village)
 {
     this.village = village;
     this.driver = Account.driver;
     this.marketplaceID = this.village.getMarketId();
 }