public static void UpdateDorf1Info(Account acc) { var activeVill = acc.Villages.FirstOrDefault(x => x.Active); if (activeVill == null) { return; } //remove any further UpdateDorf1 BotTasks for this village (if below 5min) acc.Tasks.RemoveAll(x => x.GetType() == typeof(UpdateDorf1) && x.Vill == activeVill && x.ExecuteAt < DateTime.Now.AddMinutes(5) ); UpdateCurrentlyBuilding(acc, activeVill); var resFields = ResourceParser.GetResourcefields(acc.Wb.Html, acc.AccInfo.ServerVersion); foreach (var field in resFields) { var building = activeVill.Build.Buildings.FirstOrDefault(x => x.Id == field.Id); building.Level = field.Level; building.Type = field.Type; building.UnderConstruction = field.UnderConstruction; } }
public void ParseReturnsResourceItems() { var target = new ResourceParser(reswFileContents); var actual = target.Parse(); Assert.IsNotNull(actual); }
/// <summary> /// Place all your resources in DumpInventory/bin/debug/myresourcefolder before running. /// Change folder or language if you wish to. /// Those changes HAVE TO BE DONE BEFORE INSTANTIATING FFXIVLIB /// </summary> /// <param name="args"></param> static void Main(string[] args) { // Default folder is Resources, you may override it here Constants.ResourceParser.RESOURCES_FOLDER = "myresourcefolder"; // ja, fr, de or en. Defaults to en if not set Constants.ResourceParser.RESOURCES_LANGUAGE = "en"; FFXIVLIB instance = new FFXIVLIB(); // Just timing how long it takes Stopwatch objSw = new Stopwatch(); objSw.Start(); foreach (Item item in instance.GetSelfInventory()) { Console.WriteLine("{0} x{1}", ResourceParser.GetItemName(item), item.Amount); } objSw.Stop(); // You can check the stopwatch here and note the time. Console.ReadLine(); objSw.Reset(); objSw.Start(); // In cache values foreach (Item item in instance.GetSelfInventory()) { Console.WriteLine("{0} x{1}", ResourceParser.GetItemName(item), item.Amount); } objSw.Stop(); // You can check the stopwatch value here and compare. Profit Console.ReadLine(); }
public void ValidateTelemetryItem_DefaultActivity_DefaultResource() { using ActivitySource activitySource = new ActivitySource(ActivitySourceName); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Client, parentContext: default, startTime: DateTime.UtcNow); var resource = CreateTestResource(); var monitorTags = TraceHelper.EnumerateActivityTags(activity); var telemetryItem = new TelemetryItem(activity, ref monitorTags); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); telemetryItem.SetResource(resourceParser.RoleName, resourceParser.RoleInstance); Assert.Equal("RemoteDependency", telemetryItem.Name); Assert.Equal(TelemetryItem.FormatUtcTimestamp(activity.StartTimeUtc), telemetryItem.Time); Assert.StartsWith("unknown_service", telemetryItem.Tags[ContextTagKeys.AiCloudRole.ToString()]); Assert.Equal(Dns.GetHostName(), telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()]); Assert.NotNull(telemetryItem.Tags[ContextTagKeys.AiOperationId.ToString()]); Assert.NotNull(telemetryItem.Tags[ContextTagKeys.AiInternalSdkVersion.ToString()]); Assert.Throws <KeyNotFoundException>(() => telemetryItem.Tags[ContextTagKeys.AiOperationParentId.ToString()]); }
public void GeneratePartAEnvelope_Activity_WithParentSpanId() { using ActivitySource activitySource = new ActivitySource(ActivitySourceName); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Client, parentContext: new ActivityContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded), startTime: DateTime.UtcNow); var resource = CreateTestResource(); var monitorTags = TraceHelper.EnumerateActivityTags(activity); var telemetryItem = new TelemetryItem(activity, ref monitorTags); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); telemetryItem.SetResource(resourceParser.RoleName, resourceParser.RoleInstance); Assert.Equal("RemoteDependency", telemetryItem.Name); Assert.Equal(TelemetryItem.FormatUtcTimestamp(activity.StartTimeUtc), telemetryItem.Time); Assert.StartsWith("unknown_service", telemetryItem.Tags[ContextTagKeys.AiCloudRole.ToString()]); Assert.Equal(Dns.GetHostName(), telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()]); Assert.NotNull(telemetryItem.Tags[ContextTagKeys.AiOperationId.ToString()]); Assert.NotNull(telemetryItem.Tags[ContextTagKeys.AiInternalSdkVersion.ToString()]); Assert.Equal(activity.ParentSpanId.ToHexString(), telemetryItem.Tags[ContextTagKeys.AiOperationParentId.ToString()]); }
public static IHtmlString Get(this LocalizationHelper helper, string key, params object[] replaceValues) { var parsedResource = ResourceParser.Parse(key); var resourceValue = helper.HtmlHelper.ViewContext.HttpContext.GetGlobalResourceObject(parsedResource.ResourceSet, parsedResource.ResourceKey).ToString(); return(helper.HtmlHelper.Raw(ResourceFormatter.Format(resourceValue, replaceValues))); }
private static void UpdateDorf1Info(Account acc) { //update server version acc.AccInfo.ServerVersion = (acc.Wb.Html.GetElementbyId("sidebarBoxDailyquests") == null ? Classificator.ServerVersionEnum.T4_5 : Classificator.ServerVersionEnum.T4_4); var activeVill = acc.Villages.FirstOrDefault(x => x.Active); if (activeVill == null) { return; } //remove any further UpdateDorf1 BotTasks for this village (if below 5min) acc.Tasks.RemoveAll(x => x.GetType() == typeof(UpdateDorf1) && x.vill == activeVill && x.ExecuteAt < DateTime.Now.AddMinutes(5) ); UpdateCurrentlyBuilding(acc, activeVill); activeVill.Res.Production = ResourceParser.GetProduction(acc.Wb.Html); var resFields = ResourceParser.GetResourcefields(acc.Wb.Html, acc.AccInfo.ServerVersion); foreach (var field in resFields) { var building = activeVill.Build.Buildings.FirstOrDefault(x => x.Id == field.Id); building.Level = field.Level; building.Type = field.Type; building.UnderConstruction = field.UnderConstruction; } }
public void GeneratePartAEnvelope_Activity_WithResource() { using ActivitySource activitySource = new ActivitySource(ActivitySourceName); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Client, parentContext: default, startTime: DateTime.UtcNow); var resource = CreateTestResource(serviceName: "my-service", serviceInstance: "my-instance"); var monitorTags = TraceHelper.EnumerateActivityTags(activity); var telemetryItem = new TelemetryItem(activity, ref monitorTags); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); telemetryItem.SetResource(resourceParser.RoleName, resourceParser.RoleInstance); Assert.Equal("RemoteDependency", telemetryItem.Name); Assert.Equal(TelemetryItem.FormatUtcTimestamp(activity.StartTimeUtc), telemetryItem.Time); Assert.Equal("my-service", telemetryItem.Tags[ContextTagKeys.AiCloudRole.ToString()]); Assert.Equal("my-instance", telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()]); Assert.Equal(activity.TraceId.ToHexString(), telemetryItem.Tags[ContextTagKeys.AiOperationId.ToString()]); Assert.Equal(SdkVersionUtils.SdkVersion, telemetryItem.Tags[ContextTagKeys.AiInternalSdkVersion.ToString()]); Assert.Throws <KeyNotFoundException>(() => telemetryItem.Tags[ContextTagKeys.AiOperationParentId.ToString()]); }
public void ParseHandlesMissingResourceItemComments() { var reswFileContents = File.ReadAllText("ResourcesWithoutComments.resw"); var target = new ResourceParser(reswFileContents); var actual = target.Parse(); Assert.IsNotNull(actual); CollectionAssert.AllItemsAreNotNull(actual); }
public void NullResource() { var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(null); Assert.Null(resourceParser.RoleName); Assert.Null(resourceParser.RoleInstance); }
public override async Task <TaskRes> Execute(HtmlDocument htmlDoc, ChromeDriver wb, Files.Models.AccModels.Account acc) { var building = vill.Build.Buildings.FirstOrDefault(x => x.Type == Classificator.BuildingEnum.Residence || x.Type == Classificator.BuildingEnum.Palace || x.Type == Classificator.BuildingEnum.CommandCenter); if (building == null) { //update dorg, no buildingId found? TaskExecutor.AddTask(acc, new UpdateDorf2() { ExecuteAt = DateTime.Now, vill = vill }); Console.WriteLine($"There is no Residence/Palace/CommandCenter in this village!"); return(TaskRes.Executed); } await acc.Wb.Navigate($"{acc.AccInfo.ServerUrl}/build.php?s=1&id={building.Id}"); var cost = htmlDoc.DocumentNode.Descendants("div").FirstOrDefault(x => x.HasClass("resourceWrapper")); if (cost == null) { this.ErrorMessage = "Could not train settlers. Will retry in 5min"; this.NextExecute = DateTime.Now.AddMinutes(5); //retry in 5min return(TaskRes.Executed); } var resources = ResourceParser.GetResourceCost(cost); var enoughResAt = ResourcesHelper.EnoughResourcesOrTransit(acc, vill, resources); if (enoughResAt <= DateTime.Now.AddMilliseconds(1)) //we have enough res, create new settler! { wb.ExecuteScript($"document.getElementsByName('t10')[0].value='1'"); await Task.Delay(AccountHelper.Delay()); wb.ExecuteScript($"document.getElementById('s1').click()"); //Train settler vill.Troops.Settlers++; if (vill.Troops.Settlers < 3) { //In 1 minute, do the same task (to get total of 3 settlers) this.NextExecute = DateTime.Now.AddSeconds(1); } else { if (acc.NewVillages.AutoSettleNewVillages) { //parse in training table this.PostTaskCheck.Add(NewVillage); } } return(TaskRes.Executed); } else { //Not enough res, wait for production/transit res this.NextExecute = enoughResAt.AddSeconds(60 * AccountHelper.Delay()); return(TaskRes.Executed); } }
public void ServiceNameFromResource() { var resource = CreateTestResource(serviceName: "my-service"); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); Assert.Equal("my-service", resourceParser.RoleName); Assert.Equal(Dns.GetHostName(), resourceParser.RoleInstance); }
public void ServiceNameAndInstanceAndNamespaceFromResource() { var resource = CreateTestResource(serviceName: "my-service", serviceNamespace: "my-namespace", serviceInstance: "my-instance"); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); Assert.Equal("my-namespace.my-service", resourceParser.RoleName); Assert.Equal("my-instance", resourceParser.RoleInstance); }
private static void Main(string[] args) { FFXIVLIB instance = new FFXIVLIB(); foreach (int quest in instance.GetQuests()) { Console.WriteLine(ResourceParser.GetQuestName(quest)); } Console.ReadLine(); }
public void DefaultResource() { var resource = CreateTestResource(); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); Assert.StartsWith("unknown_service", resourceParser.RoleName); Assert.Equal(Dns.GetHostName(), resourceParser.RoleInstance); }
public void ServiceNamespaceFromResource() { var resource = CreateTestResource(serviceNamespace: "my-namespace"); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); Assert.StartsWith("my-namespace.unknown_service", resourceParser.RoleName); Assert.Equal(Dns.GetHostName(), resourceParser.RoleInstance); }
public void ParseReturnedResourceItemsContainsComment() { var target = new ResourceParser(reswFileContents); var actual = target.Parse(); foreach (var item in actual) { Assert.IsNotNull(item.Comment); } }
public void RoleNameAndInstanceIsAssignedOnce() { var resource1 = CreateTestResource(serviceName: "my-service1", serviceInstance: "my-instance1"); var resource2 = CreateTestResource(serviceName: "my-service2", serviceInstance: "my-instance2"); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource1); resourceParser.UpdateRoleNameAndInstance(resource2); Assert.Equal("my-service1", resourceParser.RoleName); Assert.Equal("my-instance1", resourceParser.RoleInstance); }
static void Main(string[] args) { FFXIVLIB instance = new FFXIVLIB(); while (true) { Console.WriteLine(instance.GetServerName()); Player p = instance.GetPlayerInfo(); Console.WriteLine("{0} - {1}", ResourceParser.GetZoneName(p.Zone), ResourceParser.GetZoneName(p.Subzone)); Thread.Sleep(1000); } }
public void ParseWithMissingResourceItemCommentsSetsCommentsNull() { var reswFileContents = File.ReadAllText("ResourcesWithoutComments.resw"); var target = new ResourceParser(reswFileContents); var actual = target.Parse(); Assert.IsNotNull(actual); CollectionAssert.AllItemsAreNotNull(actual); foreach (var item in actual) { Assert.IsTrue(string.IsNullOrEmpty(item.Comment)); } }
static void Main(string[] args) { FFXIVLIB instance = new FFXIVLIB(); while (true) { var nodeList = instance.GetEntityByType(TYPE.Player); foreach (Entity e in nodeList) { Console.WriteLine("{0} {1}{2}", e.Name, ResourceParser.GetJobShortname(e.Job), e.Level); } Thread.Sleep(2000); Console.Clear(); } }
/// <summary> /// Checks if we have enough resources to build the building. If we don't have enough resources, /// method sets NextExecute DateTime. /// </summary> /// <param name="node">Node of the contract</param> /// <returns>Whether we have enough resources</returns> private bool IsEnoughRes(Account acc, HtmlNode node) { var resWrapper = node.Descendants().FirstOrDefault(x => x.HasClass("resourceWrapper")); var cost = ResourceParser.GetResourceCost(resWrapper).ToArray(); // We have enough resources, go on and build it if (ResourcesHelper.IsEnoughRes(Vill.Res.Stored.Resources.ToArray(), cost)) { return(true); } ResourcesHelper.NotEnoughRes(acc, Vill, cost, this, this.Task); return(false); }
public bool Login(string userName, string password) { //Must log out before logging in. if (loggedIn) { return(false); } var networkCredential = new NetworkCredential(userName, password); var tempCredentialCache = new CredentialCache { { server, "Basic", networkCredential } }; try { var webRequest = WebRequest.Create(server + ApplicationLocator); webRequest.Credentials = tempCredentialCache; var response = webRequest.GetResponse(); using (var stream = response.GetResponseStream()) using (var reader = new StreamReader(stream)) { appResources = ResourceParser.ParseApplication(reader.ReadToEnd()); } //Assign the credentials to use for future requests. credentialCache = tempCredentialCache; loggedIn = true; return(true); } catch (WebException we) { if (we.Response == null) { throw; } if (((HttpWebResponse)we.Response).StatusCode != HttpStatusCode.Unauthorized) { throw; } Console.WriteLine("Invalid user/password."); return(false); } }
public void RoleInstanceIsSetToHostNameByDefault() { using ActivitySource activitySource = new ActivitySource(ActivitySourceName); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Server, null, startTime: DateTime.UtcNow); var resource = CreateTestResource(); var monitorTags = TraceHelper.EnumerateActivityTags(activity); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); var telemetryItem = new TelemetryItem(activity, ref monitorTags, resourceParser.RoleName, resourceParser.RoleInstance, "00000000-0000-0000-0000-000000000000"); Assert.Equal(Dns.GetHostName(), telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()]); }
public void RoleInstanceIsNotOverwrittenIfSetViaServiceInstanceId() { using ActivitySource activitySource = new ActivitySource(ActivitySourceName); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Server, null, startTime: DateTime.UtcNow); var resource = CreateTestResource(null, null, "serviceinstance"); var monitorTags = TraceHelper.EnumerateActivityTags(activity); var resourceParser = new ResourceParser(); resourceParser.UpdateRoleNameAndInstance(resource); var telemetryItem = new TelemetryItem(activity, ref monitorTags, resourceParser.RoleName, resourceParser.RoleInstance, "00000000-0000-0000-0000-000000000000"); Assert.Equal("serviceinstance", telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()]); }
public static void UpdateDorf1Info(Account acc) { var vill = acc.Villages.FirstOrDefault(x => x.Active); if (vill == null) { return; } //remove any further UpdateDorf1 BotTasks for this village (if below 5min) acc.Tasks.RemoveAll(x => x.GetType() == typeof(UpdateDorf1) && x.Vill == vill && x.ExecuteAt < DateTime.Now.AddMinutes(5) ); UpdateCurrentlyBuilding(acc, vill); var dorf1Movements = TroopsMovementParser.ParseDorf1Movements(acc.Wb.Html); // Check attacks if there are incoming attacks and alerts aren't disabled and task isn't already on task list if (dorf1Movements.Any(x => x.Type == Classificator.MovementTypeDorf1.IncomingAttack) && vill.Deffing.AlertType != Models.VillageModels.AlertTypeEnum.Disabled) { AddTaskIfNotExistInVillage(acc, vill, new CheckAttacks() { ExecuteAt = DateTime.Now, Priority = TaskPriority.High }); } vill.TroopMovements.Dorf1Movements = dorf1Movements; var resFields = ResourceParser.GetResourcefields(acc.Wb.Html, acc.AccInfo.ServerVersion); foreach (var field in resFields) { var building = vill.Build.Buildings.FirstOrDefault(x => x.Id == field.Id); building.Level = field.Level; building.Type = field.Type; building.UnderConstruction = field.UnderConstruction; } }
private static void Main(string[] args) { FFXIVLIB instance = new FFXIVLIB(); while (true) { Entity myself = instance.GetEntityById(0); if (myself.IsCasting) { Console.WriteLine("{0} is casting {1} {2}%", myself.Name, ResourceParser.GetActionName(myself.CastingSpellId), myself.CastingPercentage); } else { Console.WriteLine("{0} is not casting", myself.Name); } Thread.Sleep(300); } }
public VMExceptionHandler Read(ModuleDefinition Module, ResourceParser Parser) { TryStart = Parser.ReadEncryptedByte(); TryEnd = Parser.ReadEncryptedByte(); HandlerStart = Parser.ReadEncryptedByte(); HandlerEnd = Parser.ReadEncryptedByte(); EHType = (VMExceptionHandlerType)Parser.ReadEncryptedByte(); switch (EHType) { case VMExceptionHandlerType.Catch: CatchType = (ITypeDescriptor)Module.LookupMember(Parser.ReadEncryptedByte()); break; case VMExceptionHandlerType.Filter: Filter = Parser.ReadEncryptedByte(); break; default: Parser.ReadEncryptedByte(); break; } return(this); }
public override async Task <TaskRes> Execute(Account acc) { // Check if the account has enough culture points if (acc.AccInfo.CulturePoints.MaxVillages <= acc.AccInfo.CulturePoints.VillageCount) { // TODO: this shouldn't be here? acc.Wb.Log("Don't have enough culture points"); this.Vill.Expansion.ExpansionAvailable = true; return(TaskRes.Executed); } if (acc.NewVillages.Locations.Count == 0) { if (acc.NewVillages.AutoFindVillages) // Find new village to settle { TaskExecutor.AddTaskIfNotExists(acc, new FindVillageToSettle() { Vill = AccountHelper.GetMainVillage(acc), ExecuteAt = DateTime.MinValue.AddHours(10), Priority = TaskPriority.High }); this.NextExecute = DateTime.MinValue.AddHours(11); } return(TaskRes.Executed); } await acc.Wb.Navigate($"{acc.AccInfo.ServerUrl}/karte.php"); await Task.Delay(AccountHelper.Delay() * 3); var newVillage = acc.NewVillages.Locations.FirstOrDefault(); //acc.NewVillage.NewVillages.Remove(coords); //remove it after settling and changing the vill name?? string kid = MapHelper.KidFromCoordinates(newVillage.Coordinates, acc).ToString(); string url = $"{acc.AccInfo.ServerUrl}/build.php?id=39&tt=2"; switch (acc.AccInfo.ServerVersion) { case Classificator.ServerVersionEnum.T4_4: // https://low4.ttwars.com/build.php?id=39&tt=2&kid=7274&a=6 url += $"&kid={kid}&a=6"; break; case Classificator.ServerVersionEnum.T4_5: // https://tx3.travian.com/build.php?id=39&tt=2&mapid=123&s=1&gid=16 url += $"&mapid={kid}&s=1&gid=16"; break; } await acc.Wb.Navigate(url); // Check if we have enough resource var costNode = acc.Wb.Html.DocumentNode.Descendants("div").FirstOrDefault(x => x.HasClass("resourceWrapper")); var cost = ResourceParser.GetResourceCost(costNode); if (!ResourcesHelper.IsEnoughRes(Vill, cost.ToArray())) { ResourcesHelper.NotEnoughRes(acc, Vill, cost, this); return(TaskRes.Executed); } if (!await DriverHelper.ClickById(acc, "btn_ok")) { return(TaskRes.Retry); } newVillage.SettlersSent = true; this.Vill.Expansion.ExpansionAvailable = false; return(TaskRes.Executed); }
public override async Task <TaskRes> Execute(Account acc) { var building = Vill.Build.Buildings .FirstOrDefault(x => x.Type == Classificator.BuildingEnum.Residence || x.Type == Classificator.BuildingEnum.Palace || x.Type == Classificator.BuildingEnum.CommandCenter ); if (!await VillageHelper.EnterBuilding(acc, building, "&s=1")) { return(TaskRes.Executed); } var settler = TroopsData.TribeSettler(acc.AccInfo.Tribe); var troopNode = acc.Wb.Html.DocumentNode.Descendants("img").FirstOrDefault(x => x.HasClass("u" + (int)settler)); if (troopNode == null) { acc.Wb.Log("No new settler can be trained, probably because 3 settlers are already (being) trained"); SendSettlersTask(acc); return(TaskRes.Executed); } while (!troopNode.HasClass("details")) { troopNode = troopNode.ParentNode; } var div = troopNode.Descendants("div"); Vill.Troops.Settlers = (int)Parser.RemoveNonNumeric(div.FirstOrDefault(x => x.HasClass("tit")).Descendants("span").FirstOrDefault().InnerText); string innertext = ""; switch (acc.AccInfo.ServerVersion) { case Classificator.ServerVersionEnum.T4_4: innertext = troopNode.ChildNodes.First(x => x.Name == "a").InnerText; break; case Classificator.ServerVersionEnum.T4_5: // no expansion slot if (div.FirstOrDefault(x => x.HasClass("noExpansionSlot")) != null) { if (Vill.Troops.Settlers >= 3) { if (acc.NewVillages.AutoSettleNewVillages) { TaskExecutor.AddTaskIfNotExists(acc, new SendSettlers() { ExecuteAt = DateTime.Now.AddHours(-3), Vill = this.Vill, // For high speed servers, you want to train settlers asap Priority = 1000 < acc.AccInfo.ServerSpeed ? TaskPriority.High : TaskPriority.Medium, }); } acc.Wb.Log("Have enoung settlers"); } else { acc.Wb.Log("Don't have enough expansion slot or settlers are training."); } return(TaskRes.Executed); } innertext = div.FirstOrDefault(x => x.HasClass("cta")).Descendants("a").FirstOrDefault().InnerText; break; } var maxNum = Parser.RemoveNonNumeric(innertext); Vill.Troops.Settlers = (int)TroopsParser.ParseAvailable(troopNode); var costNode = troopNode.Descendants("div").FirstOrDefault(x => x.HasClass("resourceWrapper")); var cost = ResourceParser.GetResourceCost(costNode); if (!ResourcesHelper.IsEnoughRes(Vill, cost.ToArray())) { ResourcesHelper.NotEnoughRes(acc, Vill, cost, this); return(TaskRes.Executed); } acc.Wb.Driver.ExecuteScript($"document.getElementsByName('t10')[0].value='{maxNum}'"); await Task.Delay(AccountHelper.Delay()); // Click Train button await TbsCore.Helpers.DriverHelper.ExecuteScript(acc, "document.getElementById('s1').click()"); Vill.Troops.Settlers += (int)maxNum; if (Vill.Troops.Settlers < 3) { // random train next settlers after 30 - 60 mins var ran = new Random(); this.NextExecute = DateTime.Now.AddMinutes(ran.Next(30, 60)); } else { if (acc.NewVillages.AutoSettleNewVillages) { SendSettlersTask(acc); } } return(TaskRes.Executed); }