diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/Rhythm/TaikoDifficultyHitObjectRhythm.cs b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/Rhythm/TaikoDifficultyHitObjectRhythm.cs index a273d7e2ea..d35004b0a4 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/Rhythm/TaikoDifficultyHitObjectRhythm.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/Rhythm/TaikoDifficultyHitObjectRhythm.cs @@ -1,24 +1,82 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Linq; +using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Rhythm.Data; + namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Rhythm { /// - /// Represents a rhythm change in a taiko map. + /// Stores rhythm data for a . /// public class TaikoDifficultyHitObjectRhythm { + /// + /// The group of hit objects with consistent rhythm that this object belongs to. + /// + public EvenHitObjects? EvenHitObjects; + + /// + /// The larger pattern of rhythm groups that this object is part of. + /// + public EvenPatterns? EvenPatterns; + + /// + /// The ratio of current + /// to previous for the rhythm change. + /// A above 1 indicates a slow-down; a below 1 indicates a speed-up. + /// + public readonly double Ratio; + /// /// The difficulty multiplier associated with this rhythm change. /// public readonly double Difficulty; /// - /// The ratio of current - /// to previous for the rhythm change. - /// A above 1 indicates a slow-down; a below 1 indicates a speed-up. + /// List of most common rhythm changes in taiko maps. This is used as a display value. /// - public readonly double Ratio; + /// + /// The general guidelines for the values are: + /// + /// rhythm changes with ratio closer to 1 (that are not 1) are harder to play, + /// speeding up is generally harder than slowing down (with exceptions of rhythm changes requiring a hand switch). + /// + /// + private static readonly TaikoDifficultyHitObjectRhythm[] common_rhythms = + { + new TaikoDifficultyHitObjectRhythm(1, 1, 0.0), + new TaikoDifficultyHitObjectRhythm(2, 1, 0.3), + new TaikoDifficultyHitObjectRhythm(1, 2, 0.5), + new TaikoDifficultyHitObjectRhythm(3, 1, 0.3), + new TaikoDifficultyHitObjectRhythm(1, 3, 0.35), + new TaikoDifficultyHitObjectRhythm(3, 2, 0.6), + new TaikoDifficultyHitObjectRhythm(2, 3, 0.4), + new TaikoDifficultyHitObjectRhythm(5, 4, 0.5), + new TaikoDifficultyHitObjectRhythm(4, 5, 0.7) + }; + + /// + /// Initialises a new instance of s, + /// calculating the closest rhythm change and its associated difficulty for the current hit object. + /// + /// The current being processed. + public TaikoDifficultyHitObjectRhythm(TaikoDifficultyHitObject current) + { + var previous = current.Previous(0); + + if (previous == null) + { + Ratio = 1; + Difficulty = 0.0; + return; + } + + TaikoDifficultyHitObjectRhythm closestRhythm = getClosestRhythm(current.DeltaTime, previous.DeltaTime); + Ratio = closestRhythm.Ratio; + Difficulty = closestRhythm.Difficulty; + } /// /// Creates an object representing a rhythm change. @@ -26,10 +84,24 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Rhythm /// The numerator for . /// The denominator for /// The difficulty multiplier associated with this rhythm change. - public TaikoDifficultyHitObjectRhythm(int numerator, int denominator, double difficulty) + private TaikoDifficultyHitObjectRhythm(int numerator, int denominator, double difficulty) { Ratio = numerator / (double)denominator; Difficulty = difficulty; } + + /// + /// Determines the closest rhythm change from that matches the timing ratio + /// between the current and previous intervals. + /// + /// The time difference between the current hit object and the previous one. + /// The time difference between the previous hit object and the one before it. + /// The closest matching rhythm from . + private TaikoDifficultyHitObjectRhythm getClosestRhythm(double currentDeltaTime, double previousDeltaTime) + { + double ratio = currentDeltaTime / previousDeltaTime; + return common_rhythms.OrderBy(x => Math.Abs(x.Ratio - ratio)).First(); + } } } +