2020-05-11 05:50:02 +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.
|
|
|
|
|
|
2020-08-18 13:18:52 +00:00
|
|
|
|
using System;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-08-12 16:35:56 +00:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
|
|
|
|
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 07:30:26 +00:00
|
|
|
|
hitObjects = difficultyHitObjects;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
findRolls(3);
|
|
|
|
|
findRolls(4);
|
2020-08-12 16:35:56 +00:00
|
|
|
|
findTlTap(0, HitType.Rim);
|
|
|
|
|
findTlTap(1, HitType.Rim);
|
|
|
|
|
findTlTap(0, HitType.Centre);
|
|
|
|
|
findTlTap(1, HitType.Centre);
|
2020-05-11 05:50:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void findRolls(int patternLength)
|
|
|
|
|
{
|
|
|
|
|
List<TaikoDifficultyHitObject> history = new List<TaikoDifficultyHitObject>();
|
|
|
|
|
|
2020-06-08 07:30:26 +00:00
|
|
|
|
int repetitionStart = 0;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < hitObjects.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
history.Add(hitObjects[i]);
|
|
|
|
|
if (history.Count < 2 * patternLength) continue;
|
2020-06-08 07:30:26 +00:00
|
|
|
|
|
2020-05-11 05:50:02 +00:00
|
|
|
|
if (history.Count > 2 * patternLength) history.RemoveAt(0);
|
|
|
|
|
|
|
|
|
|
bool isRepeat = true;
|
2020-05-11 05:53:42 +00:00
|
|
|
|
|
2020-05-11 05:50:02 +00:00
|
|
|
|
for (int j = 0; j < patternLength; j++)
|
|
|
|
|
{
|
2020-08-12 16:35:56 +00:00
|
|
|
|
if (history[j].HitType != history[j + patternLength].HitType)
|
2020-05-11 05:50:02 +00:00
|
|
|
|
{
|
|
|
|
|
isRepeat = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isRepeat)
|
|
|
|
|
{
|
2020-06-08 07:30:26 +00:00
|
|
|
|
repetitionStart = i - 2 * patternLength;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 07:30:26 +00:00
|
|
|
|
int repeatedLength = i - repetitionStart;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
|
|
|
|
if (repeatedLength >= roll_min_repetitions)
|
|
|
|
|
{
|
2020-06-08 07:30:26 +00:00
|
|
|
|
for (int j = repetitionStart; j < i; j++)
|
2020-05-11 05:50:02 +00:00
|
|
|
|
{
|
2020-08-18 13:18:52 +00:00
|
|
|
|
hitObjects[j].StaminaCheese = true;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-12 16:35:56 +00:00
|
|
|
|
private void findTlTap(int parity, HitType type)
|
2020-05-11 05:50:02 +00:00
|
|
|
|
{
|
2020-06-08 07:30:26 +00:00
|
|
|
|
int tlLength = -2;
|
2020-05-11 05:53:42 +00:00
|
|
|
|
|
2020-05-11 05:50:02 +00:00
|
|
|
|
for (int i = parity; i < hitObjects.Count; i += 2)
|
|
|
|
|
{
|
2020-08-12 16:35:56 +00:00
|
|
|
|
if (hitObjects[i].HitType == type)
|
2020-05-11 05:50:02 +00:00
|
|
|
|
{
|
2020-06-08 07:30:26 +00:00
|
|
|
|
tlLength += 2;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-06-08 07:30:26 +00:00
|
|
|
|
tlLength = -2;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 07:30:26 +00:00
|
|
|
|
if (tlLength >= tl_min_repetitions)
|
2020-05-11 05:50:02 +00:00
|
|
|
|
{
|
2020-08-18 13:18:52 +00:00
|
|
|
|
for (int j = Math.Max(0, i - tlLength); j < i; j++)
|
2020-05-11 05:50:02 +00:00
|
|
|
|
{
|
2020-08-18 13:18:52 +00:00
|
|
|
|
hitObjects[j].StaminaCheese = true;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|