1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 18:52:56 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/Skills/Colour.cs

115 lines
3.5 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;
2020-05-22 19:50:21 +08:00
using System.Collections.Generic;
2020-05-11 13:50:02 +08:00
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
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-06-08 15:30:26 +08:00
private NoteColour prevNoteColour = NoteColour.None;
2020-05-11 13:50:02 +08:00
2020-05-22 19:50:21 +08:00
private int currentMonoLength = 1;
2020-06-08 15:30:26 +08:00
private readonly List<int> monoHistory = new List<int>();
private const int mono_history_max_length = 5;
2020-05-11 13:53:42 +08:00
2020-05-22 19:50:21 +08:00
private double sameParityPenalty()
{
return 0.0;
}
2020-05-11 13:53:42 +08:00
2020-06-08 15:30:26 +08:00
private double repetitionPenalty(int notesSince)
2020-05-22 19:50:21 +08:00
{
2020-06-08 15:30:26 +08:00
double n = notesSince;
return Math.Min(1.0, 0.032 * n);
2020-05-22 19:50:21 +08:00
}
2020-05-11 13:50:02 +08:00
2020-06-08 15:30:26 +08:00
private double repetitionPenalties()
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
double penalty = 1.0;
2020-05-11 13:50:02 +08:00
2020-06-08 15:30:26 +08:00
monoHistory.Add(currentMonoLength);
2020-05-11 13:50:02 +08:00
2020-06-08 15:30:26 +08:00
if (monoHistory.Count > mono_history_max_length)
monoHistory.RemoveAt(0);
2020-05-11 13:50:02 +08:00
2020-06-08 15:30:26 +08:00
for (int l = 2; l <= mono_history_max_length / 2; l++)
{
for (int start = monoHistory.Count - l - 1; start >= 0; start--)
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
bool samePattern = true;
2020-05-22 19:50:21 +08:00
2020-06-08 15:30:26 +08:00
for (int i = 0; i < l; i++)
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
if (monoHistory[start + i] != monoHistory[monoHistory.Count - l + i])
{
samePattern = false;
}
2020-05-11 13:50:02 +08:00
}
2020-06-08 15:30:26 +08:00
if (samePattern) // Repetition found!
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
int notesSince = 0;
for (int i = start; i < monoHistory.Count; i++) notesSince += monoHistory[i];
penalty *= repetitionPenalty(notesSince);
break;
2020-05-11 13:50:02 +08:00
}
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
2020-06-08 15:30:26 +08:00
protected override double StrainValueOf(DifficultyHitObject current)
{
if (!(current.LastObject is Hit && current.BaseObject is Hit && current.DeltaTime < 1000))
{
prevNoteColour = NoteColour.None;
return 0.0;
}
2020-05-11 13:50:02 +08:00
2020-06-08 15:30:26 +08:00
TaikoDifficultyHitObject hitObject = (TaikoDifficultyHitObject)current;
2020-05-11 13:50:02 +08:00
2020-06-08 15:30:26 +08:00
double objectStrain = 0.0;
NoteColour noteColour = hitObject.IsKat ? NoteColour.Ka : NoteColour.Don;
if (noteColour == NoteColour.Don && prevNoteColour == NoteColour.Ka ||
noteColour == NoteColour.Ka && prevNoteColour == NoteColour.Don)
{
objectStrain = 1.0;
2020-05-11 13:50:02 +08:00
2020-06-08 15:30:26 +08:00
if (monoHistory.Count < 2)
objectStrain = 0.0;
else if ((monoHistory[^1] + currentMonoLength) % 2 == 0)
objectStrain *= sameParityPenalty();
objectStrain *= repetitionPenalties();
currentMonoLength = 1;
}
else
2020-05-11 13:50:02 +08:00
{
2020-06-08 15:30:26 +08:00
currentMonoLength += 1;
2020-05-11 13:50:02 +08:00
}
2020-06-08 15:30:26 +08:00
prevNoteColour = noteColour;
return objectStrain;
2020-05-11 13:50:02 +08:00
}
2020-06-08 15:30:26 +08:00
private enum NoteColour
{
Don,
Ka,
None
}
2020-05-11 13:50:02 +08:00
}
}