1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 20:47:24 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/StaminaCheeseDetector.cs

94 lines
2.7 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.
2020-08-18 21:18:52 +08:00
using System;
2020-05-11 13:50:02 +08:00
using System.Collections.Generic;
2020-08-13 00:35:56 +08:00
using osu.Game.Rulesets.Taiko.Objects;
2020-05-11 13:50:02 +08: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 15:30:26 +08:00
hitObjects = difficultyHitObjects;
2020-05-11 13:50:02 +08:00
findRolls(3);
findRolls(4);
2020-08-13 00:35:56 +08:00
findTlTap(0, HitType.Rim);
findTlTap(1, HitType.Rim);
findTlTap(0, HitType.Centre);
findTlTap(1, HitType.Centre);
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++)
{
2020-08-13 00:35:56 +08:00
if (history[j].HitType != history[j + patternLength].HitType)
2020-05-11 13:50:02 +08:00
{
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-08-18 21:18:52 +08:00
hitObjects[j].StaminaCheese = true;
2020-05-11 13:50:02 +08:00
}
}
}
}
2020-08-13 00:35:56 +08:00
private void findTlTap(int parity, HitType type)
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)
{
2020-08-13 00:35:56 +08:00
if (hitObjects[i].HitType == type)
2020-05-11 13:50:02 +08:00
{
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-08-18 21:18:52 +08:00
for (int j = Math.Max(0, i - tlLength); j < i; j++)
2020-05-11 13:50:02 +08:00
{
2020-08-18 21:18:52 +08:00
hitObjects[j].StaminaCheese = true;
2020-05-11 13:50:02 +08:00
}
}
}
}
}
}