private async void CalculateDpsAndCorrectionAllSessions()
		{
			UpdateDpsAllSessions();
			Mouse.OverrideCursor = Cursors.Wait;
			await Task.Run(() =>
			{
				var corrections = _profile.Sessions.Select(session => DpsUtils.FindHighestDpsCorrection(_profile, session)).ToList();

				var correction = new ConfigurationCorrection
				{
					AccuracyPoints = (int) Math.Round(corrections.Average(c => c.AccuracyPoints)),
					AlacrityPoints = (int) Math.Round(corrections.Average(c => c.AlacrityPoints)),
					CriticalPoints = (int) Math.Round(corrections.Average(c => c.CriticalPoints)),
					MasteryPoints = (int) Math.Round(corrections.Average(c => c.MasteryPoints)),
					PowerPoints = (int) Math.Round(corrections.Average(c => c.PowerPoints)),
					Dps = corrections.Average(c => c.Dps)
				};

				ConfigurationViewModel.CorrectionViewModel.UpdateCorrection(correction);
				NewDps.NewValue = correction.Dps;
				NewDps.Difference = correction.Dps - _profile.Dps;
				OnPropertyChanged(nameof(NewDps));
			});
			Mouse.OverrideCursor = null;
		}
Beispiel #2
0
		static void Main()
		{
			const string profilePath = @"data/profile.json";
			const double budgetMin = 1000.0;
			const double budgetMax = 10000.0;
			const double budgetStep = (budgetMax - budgetMin) / 30.0;

			List<ConfigurationCorrection> budgetCorrections = new List<ConfigurationCorrection>();
			if (!File.Exists(profilePath))
			{
				Directory.CreateDirectory("data");
				DataManager.SaveProfile(DataManager.DefaultProfile, profilePath);
			}
			Profile profile = DataManager.LoadProfile(profilePath);

			Console.WriteLine($"Calculating distributions based on \"{profilePath}\"...");

			for (int i = 0; i <= 30; i ++)
			{
				var budget = budgetMin + budgetStep * i;

				Console.WriteLine("Budget [{0}]", budget);
				profile.Configuration.BaseMasteryPoints = (int) budget;
				var correction = DpsUtils.FindHighestDpsCorrection(profile, (int) budget);
				budgetCorrections.Add(correction);
			}
			WriteBudget("Optimal distribution:", budgetCorrections);

			List<ConfigurationCorrection> badBudgetCorrections = new List<ConfigurationCorrection>();


			#region All power
			badBudgetCorrections.Clear();
			profile = DataManager.LoadProfile(profilePath);
			for (int i = 0; i <= 30; i ++)
			{
				var budget = budgetMin + budgetStep*i;

				Console.WriteLine("All power budget [{0}]", budget);

				profile.Configuration.BaseMasteryPoints = (int) budget;
				profile.Configuration.AccuracyPoints = budgetCorrections[i].AccuracyPoints;
				profile.Configuration.AlacrityPoints = budgetCorrections[i].AlacrityPoints;
				profile.Configuration.CriticalPoints = budgetCorrections[i].CriticalPoints;
				profile.Configuration.PowerPoints = budgetCorrections[i].PowerPoints + budgetCorrections[i].MasteryPoints;
				profile.Configuration.AugmentMasteryPoints = 0;

				var correction = new ConfigurationCorrection
				{
					Dps = DpsUtils.CalculateDps(profile),
					AccuracyPoints = profile.Configuration.AccuracyPoints,
					PowerPoints = profile.Configuration.PowerPoints,
					AlacrityPoints = profile.Configuration.AlacrityPoints,
					CriticalPoints = profile.Configuration.CriticalPoints,
					MasteryPoints = profile.Configuration.AugmentMasteryPoints
				};
				badBudgetCorrections.Add(correction);
			}
			WriteBudget("Optimal (all power):", badBudgetCorrections, true);
			#endregion

			#region All mastery
			badBudgetCorrections.Clear();
			profile = DataManager.LoadProfile(profilePath);
			for (int i = 0; i <= 30; i ++)
			{
				var budget = budgetMin + budgetStep*i;

				Console.WriteLine("All mastery budget [{0}]", budget);

				profile.Configuration.BaseMasteryPoints = (int) budget;
				profile.Configuration.AccuracyPoints = budgetCorrections[i].AccuracyPoints;
				profile.Configuration.AlacrityPoints = budgetCorrections[i].AlacrityPoints;
				profile.Configuration.CriticalPoints = budgetCorrections[i].CriticalPoints;
				profile.Configuration.AugmentMasteryPoints = budgetCorrections[i].PowerPoints + budgetCorrections[i].MasteryPoints;
				profile.Configuration.PowerPoints = 0;

				var correction = new ConfigurationCorrection
				{
					Dps = DpsUtils.CalculateDps(profile),
					AccuracyPoints = profile.Configuration.AccuracyPoints,
					PowerPoints = profile.Configuration.PowerPoints,
					AlacrityPoints = profile.Configuration.AlacrityPoints,
					CriticalPoints = profile.Configuration.CriticalPoints,
					MasteryPoints = profile.Configuration.AugmentMasteryPoints
				};
				badBudgetCorrections.Add(correction);
			}
			WriteBudget("Optimal (all mastery):", badBudgetCorrections, true);
			#endregion

			#region More critical/alacrity
			badBudgetCorrections.Clear();
			profile = DataManager.DefaultProfile;
			for (int i = 0; i <= 30; i ++)
			{
				var budget = budgetMin + budgetStep*i;

				Console.WriteLine("More critical/alacrity budget [{0}]", budget);
				int alacrity = budgetCorrections[i].AlacrityPoints/2;
				int critical = budgetCorrections[i].CriticalPoints/2;

				profile.Configuration.BaseMasteryPoints = (int) budget;
				profile.Configuration.AccuracyPoints = budgetCorrections[i].AccuracyPoints;
				profile.Configuration.AlacrityPoints = alacrity*3;
				profile.Configuration.CriticalPoints = critical*3;
				profile.Configuration.AugmentMasteryPoints = budgetCorrections[i].MasteryPoints - (alacrity + critical) / 2;
				profile.Configuration.PowerPoints = budgetCorrections[i].PowerPoints - (alacrity + critical) / 2;
				if (profile.Configuration.AugmentMasteryPoints < 0)
				{
					profile.Configuration.PowerPoints += profile.Configuration.AugmentMasteryPoints;
					profile.Configuration.AugmentMasteryPoints = 0;
				}
				if (profile.Configuration.PowerPoints < 0)
				{
					profile.Configuration.AugmentMasteryPoints += profile.Configuration.PowerPoints;
					profile.Configuration.PowerPoints = 0;
				}

				var correction = new ConfigurationCorrection
				{
					Dps = DpsUtils.CalculateDps(profile),
					AccuracyPoints = profile.Configuration.AccuracyPoints,
					PowerPoints = profile.Configuration.PowerPoints,
					AlacrityPoints = profile.Configuration.AlacrityPoints,
					CriticalPoints = profile.Configuration.CriticalPoints,
					MasteryPoints = profile.Configuration.AugmentMasteryPoints
				};
				badBudgetCorrections.Add(correction);
			}
			WriteBudget("More critical/alacrity:", badBudgetCorrections, true);
			#endregion

			#region More power
			badBudgetCorrections.Clear();
			profile = DataManager.LoadProfile(profilePath);
			for (int i = 0; i <= 30; i ++)
			{
				var budget = budgetMin + budgetStep*i;

				Console.WriteLine("More power budget [{0}]", budget);
				int alacrity = budgetCorrections[i].AlacrityPoints/2;
				int critical = budgetCorrections[i].CriticalPoints/2;
				int mastery = budgetCorrections[i].MasteryPoints;

				profile.Configuration.BaseMasteryPoints = (int) budget;
				profile.Configuration.AccuracyPoints = budgetCorrections[i].AccuracyPoints;
				profile.Configuration.AlacrityPoints = alacrity;
				profile.Configuration.CriticalPoints = critical;
				profile.Configuration.PowerPoints = budgetCorrections[i].PowerPoints + alacrity + critical;
				profile.Configuration.AugmentMasteryPoints = mastery;

				var correction = new ConfigurationCorrection
				{
					Dps = DpsUtils.CalculateDps(profile),
					AccuracyPoints = profile.Configuration.AccuracyPoints,
					PowerPoints = profile.Configuration.PowerPoints,
					AlacrityPoints = profile.Configuration.AlacrityPoints,
					CriticalPoints = profile.Configuration.CriticalPoints,
					MasteryPoints = profile.Configuration.AugmentMasteryPoints
				};
				badBudgetCorrections.Add(correction);
			}
			WriteBudget("More power:", badBudgetCorrections, true);
			#endregion

			Console.WriteLine("Done.");
			Console.ReadLine();
		}
Beispiel #3
0
		private static ConfigurationCorrection FindHighestDpsCorrection(Session session, Configuration configuration, ConfigurationCorrection correction, int budget, int step, int lastStep)
		{
			// ncalc is not thread-safe, we need lock here since we're using static instance of formulas
			lock (Lock)
			{
				correction.Dps = 0;
				var range = (lastStep + 1) * 2 + 1;
				var al = Math.Max(correction.AlacrityPoints - lastStep - 1, 0);
				var pw = Math.Max(correction.PowerPoints - lastStep - 1, 0);
				var cr = Math.Max(correction.CriticalPoints - lastStep - 1, 0);
				var ac = Math.Max(correction.AccuracyPoints - lastStep - 1, 0);

				for 
				(
					configuration.PowerPoints = pw;
					configuration.PowerPoints <= Math.Min(budget, pw + range);
					configuration.PowerPoints += step
				)
				{
					for 
					(
						configuration.CriticalPoints = cr;
						configuration.CriticalPoints <= Math.Min(budget - configuration.PowerPoints, cr + range);
						configuration.CriticalPoints += step
					)
					{
						for 
						(
							configuration.AlacrityPoints = al;
							configuration.AlacrityPoints <= Math.Min(budget - configuration.PowerPoints - configuration.CriticalPoints, al + range);
							configuration.AlacrityPoints += step
						)
						{
							for 
							(
								configuration.AccuracyPoints = ac;
								configuration.AccuracyPoints <= Math.Min(budget - configuration.PowerPoints - configuration.CriticalPoints - configuration.AlacrityPoints, ac + range);
								configuration.AccuracyPoints += step
							)
							{
								configuration.AugmentMasteryPoints = budget - configuration.PowerPoints - configuration.CriticalPoints - configuration.AlacrityPoints - configuration.AccuracyPoints;
								var dps = CalculateDps(session, configuration);

								if (correction.Dps < dps)
								{
									correction.Dps = dps;
									correction.AccuracyPoints = configuration.AccuracyPoints;
									correction.CriticalPoints = configuration.CriticalPoints;
									correction.MasteryPoints = configuration.AugmentMasteryPoints;
									correction.AlacrityPoints = configuration.AlacrityPoints;
									correction.PowerPoints = configuration.PowerPoints;
								}
							}
						}
					}
				}
				if (step == 1)
					return correction;

				return FindHighestDpsCorrection(session, configuration, correction, budget, Math.Max(step / 2, 1), step);
			}
		}