2022-05-31 15:17:39 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-06 08:11:26 +00:00
|
|
|
using System;
|
2022-05-31 15:17:39 +00:00
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
|
|
|
|
{
|
|
|
|
public class StaminaEvaluator
|
|
|
|
{
|
|
|
|
/// <summary>
|
2022-10-03 06:20:01 +00:00
|
|
|
/// Applies a speed bonus dependent on the time since the last hit performed using this finger.
|
2022-05-31 15:17:39 +00:00
|
|
|
/// </summary>
|
2022-10-03 06:20:01 +00:00
|
|
|
/// <param name="interval">The interval between the current and previous note hit using the same finger.</param>
|
2022-06-22 09:17:19 +00:00
|
|
|
private static double speedBonus(double interval)
|
2022-05-31 15:17:39 +00:00
|
|
|
{
|
2022-10-02 06:08:14 +00:00
|
|
|
// Interval is capped at a very small value to prevent infinite values.
|
|
|
|
interval = Math.Max(interval, 1);
|
2022-07-14 08:29:23 +00:00
|
|
|
|
2022-07-16 11:45:35 +00:00
|
|
|
return 30 / interval;
|
2022-05-31 15:17:39 +00:00
|
|
|
}
|
|
|
|
|
2022-09-30 01:10:56 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Determines the number of fingers available to hit the current <see cref="TaikoDifficultyHitObject"/>.
|
2022-10-03 09:31:45 +00:00
|
|
|
/// Any mono notes that is more than 300ms apart from a colour change will be considered to have more than 2
|
2022-10-03 06:16:53 +00:00
|
|
|
/// fingers available, since players can hit the same key with multiple fingers.
|
2022-09-30 01:10:56 +00:00
|
|
|
/// </summary>
|
|
|
|
private static int availableFingersFor(TaikoDifficultyHitObject hitObject)
|
|
|
|
{
|
2022-09-30 03:42:48 +00:00
|
|
|
DifficultyHitObject? previousColourChange = hitObject.Colour.PreviousColourChange;
|
|
|
|
DifficultyHitObject? nextColourChange = hitObject.Colour.NextColourChange;
|
2022-09-30 01:10:56 +00:00
|
|
|
|
|
|
|
if (previousColourChange != null && hitObject.StartTime - previousColourChange.StartTime < 300)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nextColourChange != null && nextColourChange.StartTime - hitObject.StartTime < 300)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2022-10-02 05:28:39 +00:00
|
|
|
return 4;
|
2022-09-30 01:10:56 +00:00
|
|
|
}
|
|
|
|
|
2022-05-31 15:17:39 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Evaluates the minimum mechanical stamina required to play the current object. This is calculated using the
|
2022-10-03 06:20:01 +00:00
|
|
|
/// maximum possible interval between two hits using the same key, by alternating available fingers for each colour.
|
2022-05-31 15:17:39 +00:00
|
|
|
/// </summary>
|
|
|
|
public static double EvaluateDifficultyOf(DifficultyHitObject current)
|
|
|
|
{
|
2022-07-15 11:07:01 +00:00
|
|
|
if (current.BaseObject is not Hit)
|
2022-05-31 15:17:39 +00:00
|
|
|
{
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2022-10-03 06:20:01 +00:00
|
|
|
// Find the previous hit object hit by the current finger, which is n notes prior, n being the number of
|
|
|
|
// available fingers.
|
2022-05-31 15:17:39 +00:00
|
|
|
TaikoDifficultyHitObject taikoCurrent = (TaikoDifficultyHitObject)current;
|
2022-09-30 01:10:56 +00:00
|
|
|
TaikoDifficultyHitObject? keyPrevious = taikoCurrent.PreviousMono(availableFingersFor(taikoCurrent) - 1);
|
2022-06-09 09:22:55 +00:00
|
|
|
|
2022-05-31 21:20:08 +00:00
|
|
|
if (keyPrevious == null)
|
2022-05-31 15:17:39 +00:00
|
|
|
{
|
2022-10-03 06:20:01 +00:00
|
|
|
// There is no previous hit object hit by the current finger
|
2022-05-31 21:20:08 +00:00
|
|
|
return 0.0;
|
|
|
|
}
|
2022-05-31 15:17:39 +00:00
|
|
|
|
2022-07-14 08:29:23 +00:00
|
|
|
double objectStrain = 0.5; // Add a base strain to all objects
|
|
|
|
objectStrain += speedBonus(taikoCurrent.StartTime - keyPrevious.StartTime);
|
2022-05-31 15:17:39 +00:00
|
|
|
return objectStrain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|