예제 #1
0
        public TravianTaskAdded DoBuildUpgrade(TravianTaskBuild task)
        {
            chrome.Navigate().GoToUrl(task.villageUrl);
            chrome.Navigate().GoToUrl(task.href);
            var content  = chrome.FindElement(By.Id("content"));
            var levelStr = content.FindElement(By.ClassName("level")).Text;

            task.level = Convert.ToInt16(new String(levelStr.Where(Char.IsDigit).ToArray()));
            if (task.level >= task.DesiredLvl)
            {
                return(new TravianTaskAdded("Done", "", 0, task.IsResource));
            }
            var upgradeBtn = chrome.FindElement(By.ClassName("upgradeButtonsContainer")).FindElement(By.ClassName("section1")).FindElement(By.TagName("button"));

            if (upgradeBtn.GetAttribute("class").Contains("gold"))
            {
                try
                {
                    content.FindElement(By.ClassName("errorMessage"));
                    return(new TravianTaskAdded("Need Resources", "", 0, task.IsResource));
                }
                catch
                {
                    return(new TravianTaskAdded("Busy", "", 0, task.IsResource));
                }
            }
            if (upgradeBtn.GetAttribute("class").Contains("green"))
            {
                var Time = content.FindElement(By.ClassName("clocks")).Text;

                var WhichLevelLongStr = upgradeBtn.FindElement(By.ClassName("button-content")).Text;
                var ButtonLevel       = Convert.ToInt16(new String(WhichLevelLongStr.Where(Char.IsDigit).ToArray()));

                if (ButtonLevel > task.DesiredLvl)
                {
                    return(new TravianTaskAdded("Done", "", 0, task.IsResource));
                }

                upgradeBtn.Click();
                return(new TravianTaskAdded("Doing", Time, ButtonLevel, task.IsResource));
            }
            return(new TravianTaskAdded("ERROR", "", 0, task.IsResource));
        }
예제 #2
0
        private void Add_task_to_tasklist(Building building, bool Build_or_field)
        {
            var Task = new TravianTaskBuild(building.name, building.href, building.level, CurrentVillage.Url, CurrentVillage.Number, (int)numericUpDown1.Value, "New", Build_or_field);

            TaskBuildBuildList.Add(Task);
        }