Skip to content

Commit

Permalink
osu!mania: Shared beat overall difficulty
Browse files Browse the repository at this point in the history
Fixes: ppy#4010
Notes sharing the same start time will now have the same overall
difficulty.
  • Loading branch information
nbayt committed Jan 10, 2019
1 parent e4ff36a commit af504d1
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions osu.Game.Rulesets.Mania/Objects/ManiaHitObjectDifficulty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ internal class ManiaHitObjectDifficulty
private readonly double endTime;
private readonly double[] heldUntil;

/// <summary>
/// Stores the last seen note in each column.
/// </summary>
private ManiaHitObjectDifficulty[] prior_notes;

/// <summary>
/// Measures jacks or more generally: repeated presses of the same button
/// </summary>
Expand All @@ -48,6 +53,11 @@ internal double IndividualStrain
/// </summary>
internal double OverallStrain = 1;

/// <summary>
/// Used to compute shared max strain for all notes of StartTime.
/// </summary>
internal double sharedMaxOverallStrain = 0;

public ManiaHitObjectDifficulty(ManiaHitObject baseHitObject, int columnCount)
{
BaseHitObject = baseHitObject;
Expand All @@ -57,12 +67,22 @@ public ManiaHitObjectDifficulty(ManiaHitObject baseHitObject, int columnCount)
beatmapColumnCount = columnCount;
heldUntil = new double[beatmapColumnCount];
individualStrains = new double[beatmapColumnCount];
prior_notes = new ManiaHitObjectDifficulty[beatmapColumnCount];

for (int i = 0; i < beatmapColumnCount; ++i)
{
individualStrains[i] = 0;
heldUntil[i] = 0;
prior_notes[i] = null;
}

// This is done to make sure the first note seen gets 2 individual strain.
// TODO: Breaks note order invariance
IndividualStrain = 2;

// These will get overridden if not the first note.
prior_notes[BaseHitObject.Column] = this;
heldUntil[BaseHitObject.Column] = endTime;
}

internal void CalculateStrains(ManiaHitObjectDifficulty previousHitObject, double timeRate)
Expand All @@ -78,6 +98,7 @@ internal void CalculateStrains(ManiaHitObjectDifficulty previousHitObject, doubl
// Fill up the heldUntil array
for (int i = 0; i < beatmapColumnCount; ++i)
{
prior_notes[i] = previousHitObject.prior_notes[i];
heldUntil[i] = previousHitObject.heldUntil[i];

// If there is at least one other overlapping end or note, then we get an addition, buuuuuut...
Expand All @@ -102,12 +123,31 @@ internal void CalculateStrains(ManiaHitObjectDifficulty previousHitObject, doubl
individualStrains[i] = previousHitObject.individualStrains[i] * individualDecay;
}

// TODO: Rework holds to account for tail shields and reduce individual decay during the hold.

heldUntil[BaseHitObject.Column] = endTime;

// TODO: Look at prior hold note tails to affect overall difficulty.

// Increase individual strain in own column
IndividualStrain += 2.0 * holdFactor;

OverallStrain = previousHitObject.OverallStrain * overallDecay + (1.0 + holdAddition) * holdFactor;

// Computes shared overall strain for notes of same StartTime.
sharedMaxOverallStrain = OverallStrain;
if(previousHitObject.BaseHitObject.StartTime == BaseHitObject.StartTime)
{
sharedMaxOverallStrain = Math.Max(sharedMaxOverallStrain, previousHitObject.sharedMaxOverallStrain);
for(int i = 0; i < beatmapColumnCount; i++)
{
if(prior_notes[i] != null && prior_notes[i].BaseHitObject.StartTime == BaseHitObject.StartTime)
{
prior_notes[i].OverallStrain = sharedMaxOverallStrain;
}
}
}
prior_notes[BaseHitObject.Column] = this;
}
}
}

0 comments on commit af504d1

Please sign in to comment.