2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 04:59:30 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-12-06 09:56:20 +00:00
|
|
|
|
|
2017-10-04 19:52:12 +00:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2017-12-05 15:37:37 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2016-10-04 15:31:10 +00:00
|
|
|
|
|
2017-07-26 04:22:46 +00:00
|
|
|
|
namespace osu.Game.Beatmaps
|
2016-10-14 03:33:58 +00:00
|
|
|
|
{
|
2017-03-16 14:18:02 +00:00
|
|
|
|
public class BeatmapDifficulty
|
2016-10-14 03:33:58 +00:00
|
|
|
|
{
|
2017-05-15 03:54:56 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The default value used for all difficulty settings except <see cref="SliderMultiplier"/> and <see cref="SliderTickRate"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const float DEFAULT_DIFFICULTY = 5;
|
|
|
|
|
|
2017-10-05 21:23:26 +00:00
|
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
2017-12-05 15:37:37 +00:00
|
|
|
|
[JsonIgnore]
|
2017-10-14 05:28:25 +00:00
|
|
|
|
public int ID { get; set; }
|
2017-10-17 09:26:28 +00:00
|
|
|
|
|
2017-05-15 03:54:56 +00:00
|
|
|
|
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
|
|
|
|
|
public float CircleSize { get; set; } = DEFAULT_DIFFICULTY;
|
|
|
|
|
public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY;
|
2018-02-13 11:23:51 +00:00
|
|
|
|
|
2018-02-09 00:55:02 +00:00
|
|
|
|
private float? approachRate;
|
2018-02-13 11:23:51 +00:00
|
|
|
|
|
2018-02-09 00:21:18 +00:00
|
|
|
|
public float ApproachRate
|
|
|
|
|
{
|
2018-02-13 11:23:51 +00:00
|
|
|
|
get => approachRate ?? OverallDifficulty;
|
|
|
|
|
set => approachRate = value;
|
2018-02-09 00:21:18 +00:00
|
|
|
|
}
|
2018-02-13 11:23:51 +00:00
|
|
|
|
|
2018-03-05 07:01:05 +00:00
|
|
|
|
public double SliderMultiplier { get; set; } = 1;
|
|
|
|
|
public double SliderTickRate { get; set; } = 1;
|
2017-03-16 14:17:27 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Maps a difficulty value [0, 10] to a two-piece linear range of values.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="difficulty">The difficulty value to be mapped.</param>
|
|
|
|
|
/// <param name="min">Minimum of the resulting range which will be achieved by a difficulty value of 0.</param>
|
|
|
|
|
/// <param name="mid">Midpoint of the resulting range which will be achieved by a difficulty value of 5.</param>
|
|
|
|
|
/// <param name="max">Maximum of the resulting range which will be achieved by a difficulty value of 10.</param>
|
|
|
|
|
/// <returns>Value to which the difficulty value maps in the specified range.</returns>
|
|
|
|
|
public static double DifficultyRange(double difficulty, double min, double mid, double max)
|
|
|
|
|
{
|
|
|
|
|
if (difficulty > 5)
|
|
|
|
|
return mid + (max - mid) * (difficulty - 5) / 5;
|
|
|
|
|
if (difficulty < 5)
|
|
|
|
|
return mid - (mid - min) * (5 - difficulty) / 5;
|
|
|
|
|
return mid;
|
|
|
|
|
}
|
2018-02-02 10:35:44 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Maps a difficulty value [0, 10] to a two-piece linear range of values.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="difficulty">The difficulty value to be mapped.</param>
|
|
|
|
|
/// <param name="range">The values that define the two linear ranges.</param>
|
2018-02-08 04:57:45 +00:00
|
|
|
|
/// <param name="range.od0">Minimum of the resulting range which will be achieved by a difficulty value of 0.</param>
|
|
|
|
|
/// <param name="range.od5">Midpoint of the resulting range which will be achieved by a difficulty value of 5.</param>
|
|
|
|
|
/// <param name="range.od10">Maximum of the resulting range which will be achieved by a difficulty value of 10.</param>
|
2018-02-02 10:35:44 +00:00
|
|
|
|
/// <returns>Value to which the difficulty value maps in the specified range.</returns>
|
2018-02-08 04:57:45 +00:00
|
|
|
|
public static double DifficultyRange(double difficulty, (double od0, double od5, double od10) range)
|
|
|
|
|
=> DifficultyRange(difficulty, range.od0, range.od5, range.od10);
|
2016-10-14 03:33:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|