// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; namespace osu.Game.Beatmaps { public class BeatmapDifficulty { /// /// The default value used for all difficulty settings except and . /// public const float DEFAULT_DIFFICULTY = 5; [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [JsonIgnore] public int ID { get; set; } public float DrainRate { get; set; } = DEFAULT_DIFFICULTY; public float CircleSize { get; set; } = DEFAULT_DIFFICULTY; public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY; public float ApproachRate { get; set; } = DEFAULT_DIFFICULTY; public float SliderMultiplier { get; set; } = 1; public float SliderTickRate { get; set; } = 1; /// /// 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; } /// /// Maps a difficulty value [0, 10] to a two-piece linear range of values. /// /// The difficulty value to be mapped. /// The values that define the two linear ranges. /// 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 od0, double od5, double od10) range) => DifficultyRange(difficulty, range.od0, range.od5, range.od10); } }