public static void AddBuildTasksFromFile(Account acc, Village vill, string location) { List <BuildingTask> tasks = new List <BuildingTask>(); try { using (StreamReader sr = new StreamReader(location)) { // If .trbc file, decode into List<BuildTask> if (Path.GetExtension(location).Equals(".TRBC", StringComparison.CurrentCultureIgnoreCase)) { var trbc = JsonConvert.DeserializeObject <TbRoot>(sr.ReadToEnd()); tasks = DecodeTrbc(trbc); } else { tasks = JsonConvert.DeserializeObject <List <BuildingTask> >(sr.ReadToEnd()); } } } catch (Exception) { return; } // User canceled foreach (var task in tasks) { BuildingHelper.AddBuildingTask(acc, vill, task); } BuildingHelper.RemoveCompletedTasks(vill, acc); }
public static void SupplyVillagePlan(Account acc, Village vill) { FarmVillagePlan(acc, vill); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Marketplace, Level = 20 }); //market center? }
public static void DeffVillagePlan(Account acc, Village vill) { FarmVillagePlan(acc, vill); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Barracks, Level = 20 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Academy, Level = 1 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Smithy, Level = 20 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Marketplace, Level = 15 }); }
public static void OffVillagePlan(Account acc, Village vill) { DeffVillagePlan(acc, vill); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Academy, Level = 15 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Stable, Level = 20 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Workshop, Level = 1 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.RallyPoint, Level = 15 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.TournamentSquare, Level = 1 }); }
/// <summary> /// Upgrades storage of the village /// </summary> /// <param name="acc">Account</param> /// <param name="vill">Village</param> /// <param name="building">Storage building</param> private static void UpgradeStorage(Account acc, Village vill, BuildingEnum building) { var task = new BuildingTask() { Building = building, TaskType = Classificator.BuildingType.General }; var current = vill.Build.Buildings.FirstOrDefault(x => x.Type == building && (x.Level != 20 || (x.Level != 19 && x.UnderConstruction)) ); if (current == null) { task.ConstructNew = true; task.Level = 1; } else { task.Level = current.Level + 1; } BuildingHelper.AddBuildingTask(acc, vill, task, false); }
public static void FarmVillagePlan(Account acc, Village vill) { BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.AutoUpgradeResFields, Level = 10, ResourceType = ResTypeEnum.AllResources, BuildingStrategy = BuildingStrategyEnum.BasedOnRes }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 1 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 1 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.RallyPoint, Level = 1 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.MainBuilding, Level = 3 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 3 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 3 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Marketplace, Level = 1 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 4 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 4 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 5 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 5 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.MainBuilding, Level = 5 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 6 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 6 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 7 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 7 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Residence, Level = 10 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Barracks, Level = 1 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.MainBuilding, Level = 10 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 10 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 10 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 15 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 15 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Warehouse, Level = 20 }); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = BuildingType.General, Building = BuildingEnum.Granary, Level = 20 }); }
/// <summary> /// Method will create EquipHero BotTasks that will use resources needed /// </summary> /// <param name="acc">Account</param> /// <param name="vill">Village to use resources in</param> /// <param name="neededRes">Needed resources</param> /// <param name="heroRes">Hero resources</param /// <param name="task">Potential BuildingTask that requires the resources</param> private static HeroEquip UseHeroResources(Account acc, Village vill, ref long[] neededRes, long[] heroRes, BuildingTask task = null) { var useRes = new List <(Classificator.HeroItemEnum, int)>(); for (int i = 0; i < 4; i++) { if (neededRes[i] == 0 || heroRes[i] == 0) { continue; } long resToBeUsed = RoundUpTo100(neededRes[i]); if (heroRes[i] < resToBeUsed) { resToBeUsed = heroRes[i]; } neededRes[i] -= resToBeUsed; HeroItemEnum item = HeroItemEnum.Others_Wood_0; switch (i) { case 0: item = HeroItemEnum.Others_Wood_0; break; case 1: item = HeroItemEnum.Others_Clay_0; break; case 2: item = HeroItemEnum.Others_Iron_0; break; case 3: item = HeroItemEnum.Others_Crop_0; break; } useRes.Add((item, (int)resToBeUsed)); } var heroEquip = new HeroEquip() { Items = useRes, ExecuteAt = DateTime.Now.AddHours(-2), // -2 since sendRes is -1 Vill = vill }; acc.Tasks.Add(heroEquip); // A BuildTask needed the resources. If it was auto-build res fields task, make a new // general building task - so resources actually get used for intended building upgrade if (task != null && task.TaskType == Classificator.BuildingType.AutoUpgradeResFields) { var building = vill.Build.Buildings.FirstOrDefault(x => x.Id == task.BuildingId); var lvl = building.Level; if (building.UnderConstruction) { lvl++; } BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { TaskType = Classificator.BuildingType.General, Building = task.Building, BuildingId = task.BuildingId, Level = ++lvl }, false); } return(heroEquip); }