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

91 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-19 01:13:18 +08:00
using osu.Game.Rulesets.Difficulty.Utils;
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)
{
2020-08-19 01:13:18 +08:00
var history = new LimitedCapacityQueue<TaikoDifficultyHitObject>(2 * patternLength);
2020-05-11 13:50:02 +08:00
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++)
{
2020-08-19 01:13:18 +08:00
history.Enqueue(hitObjects[i]);
if (!history.Full)
continue;
2020-05-11 13:50:02 +08:00
2020-08-19 01:18:36 +08:00
if (!containsPatternRepeat(history, patternLength))
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
repetitionStart = i - 2 * patternLength;
2020-08-19 01:18:36 +08:00
continue;
2020-05-11 13:50:02 +08:00
}
2020-06-08 15:30:26 +08:00
int repeatedLength = i - repetitionStart;
2020-08-19 01:18:36 +08:00
if (repeatedLength < roll_min_repetitions)
continue;
2020-05-11 13:50:02 +08:00
2020-08-19 01:18:36 +08:00
for (int j = repetitionStart; j < i; j++)
2020-05-11 13:50:02 +08:00
{
2020-08-19 01:18:36 +08:00
hitObjects[j].StaminaCheese = true;
2020-05-11 13:50:02 +08:00
}
}
}
2020-08-19 01:18:36 +08:00
private static bool containsPatternRepeat(LimitedCapacityQueue<TaikoDifficultyHitObject> history, int patternLength)
{
for (int j = 0; j < patternLength; j++)
{
if (history[j].HitType != history[j + patternLength].HitType)
return false;
}
return true;
}
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-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-08-19 01:18:36 +08:00
if (tlLength < tl_min_repetitions)
continue;
for (int j = Math.Max(0, i - tlLength); j < i; j++)
2020-05-11 13:50:02 +08:00
{
2020-08-19 01:18:36 +08:00
hitObjects[j].StaminaCheese = true;
2020-05-11 13:50:02 +08:00
}
}
}
}
}