1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 16:47:26 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/Skills/Colour.cs

111 lines
3.6 KiB
C#
Raw Normal View History

2020-05-11 13:50:02 +08: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.
using System;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
2020-08-19 01:13:18 +08:00
using osu.Game.Rulesets.Difficulty.Utils;
2020-05-11 13:50:02 +08:00
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
using osu.Game.Rulesets.Taiko.Objects;
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
{
public class Colour : Skill
{
protected override double SkillMultiplier => 1;
2020-05-22 19:50:21 +08:00
protected override double StrainDecayBase => 0.4;
2020-05-11 13:50:02 +08:00
2020-08-22 23:51:35 +08:00
private const int mono_history_max_length = 5;
2020-05-11 13:50:02 +08:00
2020-08-13 12:47:35 +08:00
/// <summary>
2020-08-22 23:51:35 +08:00
/// List of the last <see cref="mono_history_max_length"/> most recent mono patterns, with the most recent at the end of the list.
2020-08-13 12:47:35 +08:00
/// </summary>
2020-08-22 23:51:35 +08:00
private readonly LimitedCapacityQueue<int> monoHistory = new LimitedCapacityQueue<int>(mono_history_max_length);
private HitType? previousHitType;
2020-08-13 12:47:35 +08:00
/// <summary>
2020-08-22 23:51:35 +08:00
/// Length of the current mono pattern.
2020-08-13 12:47:35 +08:00
/// </summary>
2020-08-22 23:51:35 +08:00
private int currentMonoLength = 1;
2020-05-11 13:53:42 +08:00
2020-08-13 00:35:56 +08:00
protected override double StrainValueOf(DifficultyHitObject current)
2020-05-22 19:50:21 +08:00
{
2020-08-13 00:35:56 +08:00
if (!(current.LastObject is Hit && current.BaseObject is Hit && current.DeltaTime < 1000))
{
previousHitType = null;
return 0.0;
}
var taikoCurrent = (TaikoDifficultyHitObject)current;
double objectStrain = 0.0;
2020-08-19 01:39:03 +08:00
if (previousHitType != null && taikoCurrent.HitType != previousHitType)
2020-08-13 00:35:56 +08:00
{
2020-08-13 12:47:35 +08:00
// The colour has changed.
2020-08-13 00:35:56 +08:00
objectStrain = 1.0;
if (monoHistory.Count < 2)
2020-08-13 12:47:35 +08:00
{
// There needs to be at least two streaks to determine a strain.
2020-08-13 00:35:56 +08:00
objectStrain = 0.0;
2020-08-13 12:47:35 +08:00
}
2020-08-13 00:35:56 +08:00
else if ((monoHistory[^1] + currentMonoLength) % 2 == 0)
2020-08-13 12:47:35 +08:00
{
// The last streak in the history is guaranteed to be a different type to the current streak.
2020-08-22 23:15:08 +08:00
// If the total number of notes in the two streaks is even, nullify this object's strain.
objectStrain = 0.0;
2020-08-13 12:47:35 +08:00
}
2020-08-13 00:35:56 +08:00
objectStrain *= repetitionPenalties();
currentMonoLength = 1;
}
else
{
currentMonoLength += 1;
}
previousHitType = taikoCurrent.HitType;
return objectStrain;
2020-05-22 19:50:21 +08:00
}
2020-05-11 13:53:42 +08:00
2020-08-13 12:47:35 +08:00
/// <summary>
/// The penalty to apply due to the length of repetition in colour streaks.
/// </summary>
2020-06-08 15:30:26 +08:00
private double repetitionPenalties()
2020-05-11 13:50:02 +08:00
{
2020-08-18 21:24:30 +08:00
const int l = 2;
2020-06-08 15:30:26 +08:00
double penalty = 1.0;
2020-05-11 13:50:02 +08:00
2020-08-19 01:13:18 +08:00
monoHistory.Enqueue(currentMonoLength);
2020-05-11 13:50:02 +08:00
2020-08-18 21:24:30 +08:00
for (int start = monoHistory.Count - l - 1; start >= 0; start--)
2020-06-08 15:30:26 +08:00
{
if (!isSamePattern(start, l))
continue;
2020-05-22 19:50:21 +08:00
int notesSince = 0;
for (int i = start; i < monoHistory.Count; i++) notesSince += monoHistory[i];
penalty *= repetitionPenalty(notesSince);
break;
2020-06-08 15:30:26 +08:00
}
2020-05-11 13:50:02 +08:00
2020-06-08 15:30:26 +08:00
return penalty;
}
2020-05-11 13:50:02 +08:00
private bool isSamePattern(int start, int l)
{
for (int i = 0; i < l; i++)
{
if (monoHistory[start + i] != monoHistory[monoHistory.Count - l + i])
return false;
}
return true;
}
2020-08-13 12:47:35 +08:00
private double repetitionPenalty(int notesSince) => Math.Min(1.0, 0.032 * notesSince);
2020-05-11 13:50:02 +08:00
}
}