Skip to content

Commit

Permalink
Merge pull request #611 from LumpBloom7/MaimaiDX-Acc
Browse files Browse the repository at this point in the history
Add approximated maimaiDX accuracy in detailed statistics screen
  • Loading branch information
LumpBloom7 authored Aug 22, 2024
2 parents cc6f35b + 9c465c2 commit 34b0244
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions osu.Game.Rulesets.Sentakki/SentakkiRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public override StatisticItem[] CreateStatisticsForScore(ScoreInfo score, IBeatm

new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
{
new MaimaiDXAccuracy(score.HitEvents),
new UnstableRate(score.HitEvents)
}), true)
};
Expand Down
67 changes: 67 additions & 0 deletions osu.Game.Rulesets.Sentakki/Statistics/MaimaiDXAccuracy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System.Collections.Generic;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking.Statistics;

namespace osu.Game.Rulesets.Sentakki.Statistics;

public partial class MaimaiDXAccuracy : SimpleStatisticItem<double>
{
public MaimaiDXAccuracy(IEnumerable<HitEvent> hitEvents) : base("MaimaiDX accuracy (approximated)")
{
Value = calculateDXAcc(hitEvents);
}

private static double calculateDXAcc(IEnumerable<HitEvent> hitEvents)
{
double maximum = 0;
double actual = 0;

int maxBonus = 0;
int actualBonuses = 0;

foreach (HitEvent hitEvent in hitEvents)
{
switch (hitEvent.HitObject.Judgement.MaxResult)
{
case HitResult.Great:
maximum += 1;
break;

case HitResult.LargeBonus:
maxBonus += 1;
break;
}

switch (hitEvent.Result)
{
case HitResult.Great:
actual += 1;
break;

case HitResult.Good:
actual += 0.8;
break;

case HitResult.Ok:
actual += 0.5;
break;

case HitResult.LargeBonus:
actualBonuses += 1;
break;
}
}

// If there are no regular notes, then a perfect play is vacuosly true
if (maximum == 0)
actual = maximum = 1;

// If there are no break notes, then the player vacuosly hit all the breaks perfectly
if (maxBonus == 0)
actualBonuses = maxBonus = 1;

return ((actual / maximum) * 100) + (actualBonuses / (float)maxBonus);
}

protected override string DisplayValue(double value) => $"{value:N4}%";
}

0 comments on commit 34b0244

Please sign in to comment.