/// <summary> /// Updates the statistics of the entries in the same way the given character would train this plan. /// </summary> /// <param name="scratchpad">The scratchpad.</param> /// <param name="applyRemappingPoints">if set to <c>true</c> [apply remapping points].</param> /// <param name="trainSkills">When true, the character will train every skill, increasing SP, etc.</param> /// <exception cref="System.ArgumentNullException">scratchpad</exception> public void UpdateStatistics(CharacterScratchpad scratchpad, bool applyRemappingPoints, bool trainSkills) { scratchpad.ThrowIfNull(nameof(scratchpad)); CharacterScratchpad scratchpadWithoutImplants = scratchpad.Clone(); scratchpadWithoutImplants.ClearImplants(); DateTime time = DateTime.Now; // Update the statistics foreach (PlanEntry entry in Items) { // Apply the remapping if (applyRemappingPoints && entry.Remapping != null && entry.Remapping.Status == RemappingPointStatus.UpToDate) { scratchpad.Remap(entry.Remapping); scratchpadWithoutImplants.Remap(entry.Remapping); } // Update entry's statistics entry.UpdateStatistics(scratchpad, scratchpadWithoutImplants, ref time); // Update the scratchpad if (!trainSkills) { continue; } scratchpad.Train(entry.Skill, entry.Level); scratchpadWithoutImplants.Train(entry.Skill, entry.Level); } }
/// <summary> /// Update the plan status : training time, skills already trained, etc /// </summary> private void UpdatePlanningControls() { // Are all the prerequisites trained ? if (m_prerequisites.All(x => m_character.GetSkillLevel(x.Skill) >= x.Level)) { btnPlan.Enabled = false; lblPlanned.Visible = true; lblPlanned.Text = "All skills already trained."; lblTrainTime.Visible = false; return; } // Are all the prerequisites planned ? if (m_plan.AreSkillsPlanned(m_prerequisites.Where(x => m_character.Skills[x.Skill].Level < x.Level))) { btnPlan.Enabled = false; lblPlanned.Visible = true; lblPlanned.Text = "All skills already trained or planned."; lblTrainTime.Visible = false; return; } // Compute the training time var scratchpad = new CharacterScratchpad(m_character); foreach (var entry in m_plan) { scratchpad.Train(entry); } var startTime = scratchpad.TrainingTime; foreach (var prereq in m_prerequisites) { scratchpad.Train(prereq); } var trainingTime = scratchpad.TrainingTime.Subtract(startTime); // update the labels btnPlan.Enabled = true; lblPlanned.Text = String.Empty; lblPlanned.Visible = false; lblTrainTime.Visible = true; lblTrainTime.Text = trainingTime.ToDescriptiveText( DescriptiveTextOptions.IncludeCommas | DescriptiveTextOptions.SpaceText); }
/// <summary> /// Gets a character scratchpad representing this character after the provided skill levels trainings. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="trainings"></param> /// <returns></returns> public CharacterScratchpad After <T>(IEnumerable <T> trainings) where T : ISkillLevel { CharacterScratchpad scratchpad = new CharacterScratchpad(this); scratchpad.Train(trainings); return(scratchpad); }
/// <summary> /// Update the plan status : training time, skills already known, etc /// </summary> private void UpdatePlanningControls() { // Are all the prerequisites known ? if (m_prerequisites.All(x => m_character.GetSkillLevel(x.Skill) > x.Level)) { btnPlan.Enabled = false; lblPlanned.Visible = true; lblPlanned.Text = "All skills already known."; lblTrainTime.Visible = false; return; } // Are all the prequisites planned if (m_plan.AreSkillsPlanned(m_prerequisites)) { btnPlan.Enabled = false; lblPlanned.Visible = true; lblPlanned.Text = "All skills already known or planned."; lblTrainTime.Visible = false; return; } // Compute the training time var scratchpad = new CharacterScratchpad(m_character); foreach (var entry in m_plan) { scratchpad.Train(entry); } var startTime = scratchpad.TrainingTime; foreach (var prereq in m_prerequisites) { scratchpad.Train(prereq); } var trainingTime = scratchpad.TrainingTime - startTime; // update the labels btnPlan.Enabled = true; lblPlanned.Text = ""; lblPlanned.Visible = false; lblTrainTime.Visible = true; lblTrainTime.Text = Skill.TimeSpanToDescriptiveText(trainingTime, DescriptiveTextOptions.IncludeCommas | DescriptiveTextOptions.SpaceText); }
/// <summary> /// Updates the form controls to reflect the status of the Plan specified by the Plan property. /// </summary> private void UpdatePlanStatus() { if (m_loadoutFormat == LoadoutFormat.None) { return; } // Compute the skills to add m_skillsToAdd.Clear(); CharacterScratchpad scratchpad = new CharacterScratchpad(m_character); // Compute the training time for the prerequisites foreach (Item obj in m_objects) { scratchpad.Train(obj.Prerequisites.Where(x => m_character.Skills[x.Skill.ID].Level < x.Level)); } m_skillsToAdd.AddRange(scratchpad.TrainedSkills); // All skills already trained ? if (m_skillsToAdd.Count == 0) { AddToPlanButton.Enabled = false; PlanedLabel.Visible = true; PlanedLabel.Text = @"All skills already trained."; TrainTimeLabel.Visible = false; } // Are skills already planned ? else if (m_plan.AreSkillsPlanned(m_skillsToAdd)) { AddToPlanButton.Enabled = false; PlanedLabel.Visible = true; PlanedLabel.Text = @"All skills already trained or planned."; TrainTimeLabel.Visible = false; } // There is at least one untrained or non-planned skill else { AddToPlanButton.Enabled = true; PlanedLabel.Text = String.Empty; PlanedLabel.Visible = false; TrainTimeLabel.Visible = true; // Compute training time TimeSpan trainingTime = m_character.GetTrainingTimeToMultipleSkills(m_skillsToAdd); TrainTimeLabel.Text = trainingTime.ToDescriptiveText( DescriptiveTextOptions.IncludeCommas | DescriptiveTextOptions.SpaceText); } }
/// <summary> /// Updates the form controls to reflect the status of the Plan specified by the Plan property. /// </summary> private void UpdatePlanStatus() { // Compute the skills to add m_skillsToAdd.Clear(); var scratchpad = new CharacterScratchpad(m_character); foreach (var obj in m_objects) { scratchpad.Train(obj.Prerequisites); } m_skillsToAdd.AddRange(scratchpad.TrainedSkills); // All skills already known ? if (m_skillsToAdd.Count == 0) { AddToPlanButton.Enabled = false; PlanedLabel.Visible = true; PlanedLabel.Text = "All skills already known."; TrainTimeLabel.Visible = false; } // Are skills already planned ? else if (m_plan.AreSkillsPlanned(m_skillsToAdd)) { AddToPlanButton.Enabled = false; PlanedLabel.Visible = true; PlanedLabel.Text = "All skills already known or planned."; TrainTimeLabel.Visible = false; } // There is at least one unknown and non-planned skill else { AddToPlanButton.Enabled = true; PlanedLabel.Text = ""; PlanedLabel.Visible = false; TrainTimeLabel.Visible = true; // Compute training time TimeSpan trainingTime = m_character.GetTrainingTimeToMultipleSkills(m_skillsToAdd); TrainTimeLabel.Text = Skill.TimeSpanToDescriptiveText(trainingTime, DescriptiveTextOptions.IncludeCommas | DescriptiveTextOptions.SpaceText); } }
/// <summary> /// Updates the statistics of the entries in the same way the given character would train this plan. /// </summary> /// <param name="scratchpad">The scratchpad.</param> /// <param name="applyRemappingPoints">if set to <c>true</c> [apply remapping points].</param> /// <param name="trainSkills">When true, the character will train every skill, increasing SP, etc.</param> /// <exception cref="System.ArgumentNullException">scratchpad</exception> public void UpdateOldTrainingTimes(CharacterScratchpad scratchpad, bool applyRemappingPoints, bool trainSkills) { scratchpad.ThrowIfNull(nameof(scratchpad)); // Update the statistics foreach (PlanEntry entry in Items) { // Apply the remapping if (applyRemappingPoints && entry.Remapping != null && entry.Remapping.Status == RemappingPointStatus.UpToDate) { scratchpad.Remap(entry.Remapping); } // Update entry's statistics entry.UpdateOldTrainingTime(scratchpad); // Update the scratchpad if (trainSkills) { scratchpad.Train(entry.Skill, entry.Level); } } }
/// <summary> /// Updates the pie chart display /// </summary> private void UpdatePieChart() { // Prevents updating before OnLoad() completed. if (planSelector.SelectedIndex < 0) { return; } int groupCount = StaticSkills.AllGroups.Count(); CharacterScratchpad scratchpad = new CharacterScratchpad(m_character); // Retrieve the selected Plan if (planSelector.SelectedIndex > 0) { Plan plan = m_character.Plans[planSelector.SelectedIndex - 1]; // Updates the scratchpad foreach (PlanEntry entry in plan) { scratchpad.Train(entry); } } // Get group to index map and groups list List <SkillGroup> groups = new List <SkillGroup>(); Dictionary <StaticSkillGroup, int> indices = new Dictionary <StaticSkillGroup, int>(); foreach (StaticSkillGroup group in StaticSkills.AllGroups) { indices[group] = groups.Count; groups.Add(m_character.SkillGroups[group.ID]); } // Get start SP, before plan decimal[] srcSkillPoints = new decimal[groupCount]; foreach (SkillGroup skillGroup in groups) { int groupIndex = indices[skillGroup.StaticData]; srcSkillPoints[groupIndex] = skillGroup.TotalSP; } // Get target SP and skills count, after plan int[] skillCounts = new int[groupCount]; decimal[] targetSkillPoints = new decimal[groupCount]; foreach (StaticSkill skill in StaticSkills.AllSkills) { Int64 sp = scratchpad.GetSkillPoints(skill); int groupIndex = indices[skill.Group]; targetSkillPoints[groupIndex] += sp; if (sp != 0) { skillCounts[groupIndex]++; } } // Get groups names and descriptions string[] names = new string[groupCount]; string[] descriptions = new string[groupCount]; for (int i = 0; i < srcSkillPoints.Length; i++) { names[i] = groups[i].Name; descriptions[i] = groups[i].Name; decimal srcSP = srcSkillPoints[i]; decimal destSP = targetSkillPoints[i]; StringBuilder description = new StringBuilder(); description.Append($"{names[i]} ({skillCounts[i]} skills, {srcSP:N0} skillpoints"); if (srcSP != destSP) { description.Append($" / {destSP:N0} after plan completion"); } description.Append(")"); descriptions[i] = description.ToString(); } // Merge minor groups if (mergeMinorCheck.Checked) { Merge(ref targetSkillPoints, ref names, ref descriptions); } // Compute the slices displacements int tinyGroups = 0; float[] slicesDiscplacements = new float[targetSkillPoints.Length]; for (int i = 0; i < targetSkillPoints.Length; i++) { slicesDiscplacements[i] = targetSkillPoints[i] < 100000 ? 0.06F + 0.008F * ++tinyGroups : 0.05F; } // Assign and sort skillPieChartControl.Values(targetSkillPoints); skillPieChartControl.Texts(names); skillPieChartControl.ToolTips(descriptions); skillPieChartControl.SliceRelativeDisplacements(slicesDiscplacements); skillPieChartControl.OrderSlices(sortBySizeCheck.Checked); }
/// <summary> /// Update the plan status : training time, skills already trained, etc /// </summary> private void UpdatePlanningControls() { btnPlan.Visible = m_plan != null; lblTrainTime.Visible = TrainingTimeLabel.Visible = m_character != null; if (m_character == null) { return; } btnPlan.Enabled = false; if (!m_prerequisites.Any()) { return; } // Are all the prerequisites trained ? if (m_prerequisites.All(x => m_character.GetSkillLevel(x.Skill) >= x.Level)) { lblPlanned.Show(); lblPlanned.Text = @"All skills already trained."; lblTrainTime.Hide(); return; } if (m_plan == null) { lblPlanned.Show(); lblPlanned.Text = @"Some skills need training."; lblTrainTime.Hide(); return; } // Are all the prerequisites planned ? if (m_plan.AreSkillsPlanned(m_prerequisites.Where(x => m_character.Skills[x.Skill.ID].Level < x.Level))) { lblPlanned.Show(); lblPlanned.Text = @"All skills already trained or planned."; lblTrainTime.Hide(); return; } // Compute the training time CharacterScratchpad scratchpad = new CharacterScratchpad(m_character); foreach (PlanEntry entry in m_plan) { scratchpad.Train(entry); } TimeSpan startTime = scratchpad.TrainingTime; foreach (StaticSkillLevel prereq in m_prerequisites) { scratchpad.Train(prereq); } TimeSpan trainingTime = scratchpad.TrainingTime.Subtract(startTime); // Update the labels lblTrainTime.Text = trainingTime.ToDescriptiveText( DescriptiveTextOptions.IncludeCommas | DescriptiveTextOptions.SpaceText); lblTrainTime.Show(); lblPlanned.Text = string.Empty; lblPlanned.Hide(); btnPlan.Enabled = true; }
/// <summary> /// Update the plan status : training time, skills already trained, etc /// </summary> private void UpdatePlanningControls() { btnPlan.Visible = m_plan != null; lblTrainTime.Visible = TrainingTimeLabel.Visible = m_character != null; if (m_character == null) return; btnPlan.Enabled = false; if (!m_prerequisites.Any()) return; // Are all the prerequisites trained ? if (m_prerequisites.All(x => m_character.GetSkillLevel(x.Skill) >= x.Level)) { lblPlanned.Show(); lblPlanned.Text = @"All skills already trained."; lblTrainTime.Hide(); return; } if (m_plan == null) { lblPlanned.Show(); lblPlanned.Text = @"Some skills need training."; lblTrainTime.Hide(); return; } // Are all the prerequisites planned ? if (m_plan.AreSkillsPlanned(m_prerequisites.Where(x => m_character.Skills[x.Skill.ID].Level < x.Level))) { lblPlanned.Show(); lblPlanned.Text = @"All skills already trained or planned."; lblTrainTime.Hide(); return; } // Compute the training time CharacterScratchpad scratchpad = new CharacterScratchpad(m_character); foreach (PlanEntry entry in m_plan) { scratchpad.Train(entry); } TimeSpan startTime = scratchpad.TrainingTime; foreach (StaticSkillLevel prereq in m_prerequisites) { scratchpad.Train(prereq); } TimeSpan trainingTime = scratchpad.TrainingTime.Subtract(startTime); // Update the labels lblTrainTime.Text = trainingTime.ToDescriptiveText( DescriptiveTextOptions.IncludeCommas | DescriptiveTextOptions.SpaceText); lblTrainTime.Show(); lblPlanned.Text = String.Empty; lblPlanned.Hide(); btnPlan.Enabled = true; }
/// <summary> /// Updates the form controls to reflect the status of the Plan specified by the Plan property. /// </summary> private void UpdatePlanStatus() { // Compute the skills to add m_skillsToAdd.Clear(); CharacterScratchpad scratchpad = new CharacterScratchpad(m_character); Character character = m_character as Character; foreach (var obj in m_objects) { scratchpad.Train(obj.Prerequisites.Where(x => character.Skills[x.Skill].Level < x.Level)); } m_skillsToAdd.AddRange(scratchpad.TrainedSkills); // All skills already trained ? if (m_skillsToAdd.Count == 0) { AddToPlanButton.Enabled = false; PlanedLabel.Visible = true; PlanedLabel.Text = "All skills already trained."; TrainTimeLabel.Visible = false; } // Are skills already planned ? else if (m_plan.AreSkillsPlanned(m_skillsToAdd)) { AddToPlanButton.Enabled = false; PlanedLabel.Visible = true; PlanedLabel.Text = "All skills already trained or planned."; TrainTimeLabel.Visible = false; } // There is at least one untrained or non-planned skill else { AddToPlanButton.Enabled = true; PlanedLabel.Text = String.Empty; PlanedLabel.Visible = false; TrainTimeLabel.Visible = true; // Compute training time TimeSpan trainingTime = m_character.GetTrainingTimeToMultipleSkills(m_skillsToAdd); TrainTimeLabel.Text = trainingTime.ToDescriptiveText( DescriptiveTextOptions.IncludeCommas | DescriptiveTextOptions.SpaceText); } }
/// <summary> /// Updates the pie chart display /// </summary> private void UpdatePieChart() { // Prevents updating before OnLoad() completed. if (planSelector.SelectedIndex < 0) return; int groupCount = StaticSkills.AllGroups.Count(); CharacterScratchpad scratchpad = new CharacterScratchpad(m_character); // Retrieve the selected Plan Plan plan = null; if (planSelector.SelectedIndex > 0) { plan = m_character.Plans[planSelector.SelectedIndex - 1]; // Updates the scratchpad foreach (var entry in plan) scratchpad.Train(entry); } // Get group to index map and groups list List<SkillGroup> groups = new List<SkillGroup>(); Dictionary<StaticSkillGroup, int> indices = new Dictionary<StaticSkillGroup, int>(); foreach (var group in StaticSkills.AllGroups) { indices[group] = groups.Count; groups.Add(m_character.SkillGroups[group.Name]); } // Get start SP, before plan decimal[] srcSkillPoints = new decimal[groupCount]; foreach(var skillGroup in groups) { int groupIndex = indices[skillGroup.StaticData]; srcSkillPoints[groupIndex] = skillGroup.TotalSP; } // Get target SP and skills count, after plan int[] skillCounts = new int[groupCount]; decimal[] targetSkillPoints = new decimal[groupCount]; foreach (StaticSkill skill in StaticSkills.AllSkills) { int sp = scratchpad.GetSkillPoints(skill); int groupIndex = indices[skill.Group]; targetSkillPoints[groupIndex] += sp; if (sp != 0) skillCounts[groupIndex]++; } // Get groups names and descriptions string[] names = new string[groupCount]; string[] descriptions = new string[groupCount]; for(int i=0; i<srcSkillPoints.Length; i++) { names[i] = groups[i].Name; descriptions[i] = groups[i].Name; decimal srcSP = srcSkillPoints[i]; decimal destSP = targetSkillPoints[i]; StringBuilder description = new StringBuilder(); description.AppendFormat(CultureConstants.DefaultCulture, "{0} ({1} skills, {2:#,###} skillpoints", names[i], skillCounts[i], srcSP); if (srcSP != destSP) { description.AppendFormat(CultureConstants.DefaultCulture, " / {0:#,###} after plan completion", destSP); } description.Append(")"); descriptions[i] = description.ToString(); } // Merge minor groups if (mergeMinorCheck.Checked) { Merge(ref targetSkillPoints, ref names, ref descriptions); } // Compute the slices displacements int tinyGroups = 0; float[] slicesDiscplacements = new float[targetSkillPoints.Length]; for(int i=0; i < targetSkillPoints.Length; i++) { slicesDiscplacements[i] = (targetSkillPoints[i] < 100000) ? 0.06F + (0.008F * ++tinyGroups) : 0.05F; } // Assign and sort skillPieChartControl.Values = targetSkillPoints; skillPieChartControl.Texts = names; skillPieChartControl.ToolTips = descriptions; skillPieChartControl.SliceRelativeDisplacements = slicesDiscplacements; skillPieChartControl.OrderSlices(sortBySizeCheck.Checked); }
/// <summary> /// Update the plan status : training time, skills already trained, etc /// </summary> private void UpdatePlanningControls() { // Are all the prerequisites trained ? if (m_prerequisites.All(x => m_character.GetSkillLevel(x.Skill) >= x.Level)) { btnPlan.Enabled = false; lblPlanned.Visible = true; lblPlanned.Text = "All skills already trained."; lblTrainTime.Visible = false; return; } // Are all the prerequisites planned ? if (m_plan.AreSkillsPlanned(m_prerequisites.Where(x => m_character.Skills[x.Skill].Level < x.Level))) { btnPlan.Enabled = false; lblPlanned.Visible = true; lblPlanned.Text = "All skills already trained or planned."; lblTrainTime.Visible = false; return; } // Compute the training time var scratchpad = new CharacterScratchpad(m_character); foreach (var entry in m_plan) { scratchpad.Train(entry); } var startTime = scratchpad.TrainingTime; foreach (var prereq in m_prerequisites) { scratchpad.Train(prereq); } var trainingTime = scratchpad.TrainingTime.Subtract(startTime); // update the labels btnPlan.Enabled = true; lblPlanned.Text = String.Empty; lblPlanned.Visible = false; lblTrainTime.Visible = true; lblTrainTime.Text = trainingTime.ToDescriptiveText( DescriptiveTextOptions.IncludeCommas | DescriptiveTextOptions.SpaceText); }