From 28e006eeb9f806e8cc41653df295fef4f17ac3ac Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 16 Mar 2017 23:17:27 +0900 Subject: [PATCH] Move MapDifficultyRange into BaseDifficulty. --- osu.Game/Database/BaseDifficulty.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game/Database/BaseDifficulty.cs b/osu.Game/Database/BaseDifficulty.cs index 83f6e2fdd5..ea7511315f 100644 --- a/osu.Game/Database/BaseDifficulty.cs +++ b/osu.Game/Database/BaseDifficulty.cs @@ -15,6 +15,23 @@ namespace osu.Game.Database public float ApproachRate { get; set; } public float SliderMultiplier { get; set; } public float SliderTickRate { get; set; } + + /// + /// Maps a difficulty value [0, 10] to a two-piece linear range of values. + /// + /// The difficulty value to be mapped. + /// Minimum of the resulting range which will be achieved by a difficulty value of 0. + /// Midpoint of the resulting range which will be achieved by a difficulty value of 5. + /// Maximum of the resulting range which will be achieved by a difficulty value of 10. + /// Value to which the difficulty value maps in the specified range. + 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; + } } }