public override async Task <TaskRes> Execute(Account acc)
        {
            var wb = acc.Wb.Driver;
            await HeroHelper.NavigateToHeroAttributes(acc);

            //heroRegeneration
            var reviveButton = acc.Wb.Html.GetElementbyId("heroRegeneration");

            if (reviveButton == null)
            {
                acc.Wb.Log("No revive button!");
                return(TaskRes.Executed);
            }
            if (reviveButton.HasClass("green"))
            {
                wb.ExecuteScript("document.getElementById('heroRegeneration').click()"); //revive hero
                return(TaskRes.Executed);
            }
            else
            {
                //no resources?
                this.NextExecute = DateTime.Now.AddMinutes(10);
                return(TaskRes.Executed);
            }
        }
Exemple #2
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            var wb = acc.Wb.Driver;
            await HeroHelper.NavigateToHeroAttributes(acc);

            HeroHelper.ParseHeroPage(acc);

            float sum = 0;

            for (int i = 0; i < 4; i++)
            {
                sum += acc.Hero.Settings.Upgrades[i];
            }
            if (sum == 0)
            {
                // Upgrade points were not set. Set points to default
                acc.Hero.Settings.Upgrades = new byte[4] {
                    2, 0, 0, 2
                };
                sum = 4;
            }

            var points = acc.Hero.HeroInfo.AvaliblePoints;

            for (int i = 0; i < 4; i++)
            {
                var amount = Math.Ceiling(acc.Hero.Settings.Upgrades[i] * points / sum);
                if (amount == 0)
                {
                    continue;
                }

                var script = $"var attribute = document.getElementById('{domId[i]}');";
                script += "var upPoint = attribute.getElementsByClassName('pointsValueSetter')[1];";
                script += "upPoint.getElementsByTagName('a')[0].click();";

                for (int j = 0; j < (int)amount; j++)
                {
                    // Execute the script (set point) to add 1 point
                    wb.ExecuteScript(script);
                }
                await Task.Delay(AccountHelper.Delay());
            }

            wb.ExecuteScript("document.getElementById('saveHeroAttributes').click();");
            return(TaskRes.Executed);
        }
Exemple #3
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            await HeroHelper.NavigateToHeroAttributes(acc);

            HeroHelper.ParseHeroPage(acc);

            TaskExecutor.RemoveSameTasks(acc, typeof(HeroUpdateInfo), this);

            if (acc.Hero.Settings.AutoRefreshInfo)
            {
                var ran = new Random();

                this.NextExecute = DateTime.Now.AddMinutes(
                    ran.Next(acc.Hero.Settings.MinUpdate, acc.Hero.Settings.MaxUpdate)
                    );
                TaskExecutor.RemoveSameTasks(acc, this);
            }

            return(TaskRes.Executed);
        }