1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 14:12:54 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/StaminaCheeseDetector.cs

92 lines
2.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.Collections.Generic;
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
{
public class StaminaCheeseDetector
{
private const int roll_min_repetitions = 12;
private const int tl_min_repetitions = 16;
private List<TaikoDifficultyHitObject> hitObjects;
public void FindCheese(List<TaikoDifficultyHitObject> difficultyHitObjects)
{
2020-06-08 15:30:26 +08:00
hitObjects = difficultyHitObjects;
2020-05-11 13:50:02 +08:00
findRolls(3);
findRolls(4);
2020-06-08 15:30:26 +08:00
findTlTap(0, true);
findTlTap(1, true);
findTlTap(0, false);
findTlTap(1, false);
2020-05-11 13:50:02 +08:00
}
private void findRolls(int patternLength)
{
List<TaikoDifficultyHitObject> history = new List<TaikoDifficultyHitObject>();
2020-06-08 15:30:26 +08:00
int repetitionStart = 0;
2020-05-11 13:50:02 +08:00
for (int i = 0; i < hitObjects.Count; i++)
{
history.Add(hitObjects[i]);
if (history.Count < 2 * patternLength) continue;
2020-06-08 15:30:26 +08:00
2020-05-11 13:50:02 +08:00
if (history.Count > 2 * patternLength) history.RemoveAt(0);
bool isRepeat = true;
2020-05-11 13:53:42 +08:00
2020-05-11 13:50:02 +08:00
for (int j = 0; j < patternLength; j++)
{
if (history[j].IsKat != history[j + patternLength].IsKat)
{
isRepeat = false;
}
}
if (!isRepeat)
{
2020-06-08 15:30:26 +08:00
repetitionStart = i - 2 * patternLength;
2020-05-11 13:50:02 +08:00
}
2020-06-08 15:30:26 +08:00
int repeatedLength = i - repetitionStart;
2020-05-11 13:50:02 +08:00
if (repeatedLength >= roll_min_repetitions)
{
2020-06-08 15:30:26 +08:00
for (int j = repetitionStart; j < i; j++)
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
hitObjects[i].StaminaCheese = true;
2020-05-11 13:50:02 +08:00
}
}
}
}
2020-06-08 15:30:26 +08:00
private void findTlTap(int parity, bool kat)
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
int tlLength = -2;
2020-05-11 13:53:42 +08:00
2020-05-11 13:50:02 +08:00
for (int i = parity; i < hitObjects.Count; i += 2)
{
if (kat == hitObjects[i].IsKat)
{
2020-06-08 15:30:26 +08:00
tlLength += 2;
2020-05-11 13:50:02 +08:00
}
else
{
2020-06-08 15:30:26 +08:00
tlLength = -2;
2020-05-11 13:50:02 +08:00
}
2020-06-08 15:30:26 +08:00
if (tlLength >= tl_min_repetitions)
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
for (int j = i - tlLength; j < i; j++)
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
hitObjects[i].StaminaCheese = true;
2020-05-11 13:50:02 +08:00
}
}
}
}
}
}