private void buildButton_Click(object sender, EventArgs e) //build button { var acc = getSelectedAcc(); var vill = getSelectedVillage(acc); var indicies = buildingsList.SelectedIndices; if (indicies.Count > 0) { selectedBuilding = vill.Build.Buildings[indicies[0]]; } else { return; //no building selected :( } if (buildRadioButton.Checked) { var task = new BuildingTask { TaskType = BuildingHelper.BuildingType.General, Level = (int)buildLevelUpDown.Value, BuildingId = selectedBuilding.Id }; //Create building task, construct new building if (selectedBuilding.Type == Classificator.BuildingEnum.Site) { Enum.TryParse(buildTypeComboBox.SelectedItem.ToString(), out Classificator.BuildingEnum building); task.Building = building; task.ConstructNew = true; } else //upgrade existing building { task.Building = selectedBuilding.Type; } BuildingHelper.AddBuildingTask(acc, vill, task); } else if (demolishRadioButton.Checked) { DemolishTask dt = new DemolishTask { Building = selectedBuilding.Type, BuildingId = selectedBuilding.Id, Level = (int)buildLevelUpDown.Value }; vill.Build.DemolishTasks.Add(dt); //TODO: ReStartDemolish TaskExecutor.AddTaskIfNotExistInVillage(acc, vill, new DemolishBuilding() { ExecuteAt = DateTime.Now, vill = vill }); } UpdateBuildTab(); }
private void AutBuildResButton_Click(object sender, EventArgs e) //auto res build button { var acc = GetSelectedAcc(); var vill = GetSelectedVillage(acc); var task = new BuildingTask { TaskType = BuildingType.AutoUpgradeResFields, Level = (int)autoBuildResLevel.Value, ResourceType = (ResTypeEnum)autoBuildResType.SelectedIndex, BuildingStrategy = (BuildingStrategyEnum)autoBuildResStrat.SelectedIndex }; BuildingHelper.AddBuildingTask(acc, vill, task); UpdateUc(); }
private void button2_Click(object sender, EventArgs e) { var acc = GetSelectedAcc(); var vill = GetSelectedVillage(acc); Enum.TryParse(prereqCombo.SelectedItem.ToString(), out BuildingEnum building); BuildingHelper.AddBuildingPrerequisites(acc, vill, building); BuildingHelper.AddBuildingTask(acc, vill, new BuildingTask() { Building = building, Level = 1, TaskType = BuildingType.General }); UpdateUc(); }
/// <summary> /// For auto-building resource bonus building /// </summary> /// <param name="acc">Account</param> /// <param name="vill">Village</param> private void CheckResourceBonus(Account acc, Village vill) { // If enabled and MainBuilding is above level 5 if (vill.Build.AutoBuildResourceBonusBuildings && vill.Build.Buildings.Any(x => x.Type == BuildingEnum.MainBuilding && x.Level >= 5)) { var bonusBuilding = CheckBonusBuildings(vill); if (bonusBuilding != BuildingEnum.Site) { var bonusTask = new BuildingTask() { TaskType = BuildingType.General, Building = bonusBuilding, Level = 5, }; BuildingHelper.AddBuildingTask(acc, vill, bonusTask, false); } } }
private void button5_Click(object sender, EventArgs e) //all villages select from file { var acc = getSelectedAcc(); string location = IoHelperForms.PromptUserForBuidTasksLocation(); List <BuildingTask> tasks; using (StreamReader sr = new StreamReader(location)) { tasks = JsonConvert.DeserializeObject <List <BuildingTask> >(sr.ReadToEnd()); } foreach (var vill in acc.Villages) { foreach (var task in tasks) { BuildingHelper.AddBuildingTask(acc, vill, task); } BuildingHelper.RemoveCompletedTasks(vill, acc); } }
private void buildButton_Click(object sender, EventArgs e) //build button { var acc = GetSelectedAcc(); var vill = GetSelectedVillage(acc); var indicies = buildingsList.SelectedIndices; if (indicies.Count > 0) { selectedBuilding = vill.Build.Buildings[indicies[0]]; } else { return; //no building selected :( } if (buildRadioButton.Checked) { var task = new BuildingTask { TaskType = BuildingType.General, Level = (int)buildLevelUpDown.Value, BuildingId = selectedBuilding.Id }; // Building already planned on this ID var plannedBuilding = vill.Build.Tasks.FirstOrDefault(x => x.BuildingId == task.BuildingId); //Create building task, construct new building if (selectedBuilding.Type == BuildingEnum.Site) { if (plannedBuilding == null) // No building has been planned on this ID { Enum.TryParse(buildTypeComboBox.SelectedItem.ToString(), out BuildingEnum building); task.Building = building; task.ConstructNew = true; } else // Building was already planned { task.Building = plannedBuilding.Building; } } else //upgrade existing building { task.Building = selectedBuilding.Type; } BuildingHelper.AddBuildingTask(acc, vill, task); } else if (demolishRadioButton.Checked) { DemolishTask dt = new DemolishTask { Building = selectedBuilding.Type, BuildingId = selectedBuilding.Id, Level = (int)buildLevelUpDown.Value }; vill.Build.DemolishTasks.Add(dt); //TODO: ReStartDemolish TaskExecutor.AddTaskIfNotExistInVillage(acc, vill, new DemolishBuilding() { Vill = vill }); } UpdateUc(); }