1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 21:57:55 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
3.2 KiB
C#
Raw Normal View History

// 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;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
2018-11-28 15:12:57 +08:00
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mania.Difficulty
{
public class ManiaPerformanceCalculator : PerformanceCalculator
{
2018-05-16 11:44:11 +08:00
private int countPerfect;
private int countGreat;
private int countGood;
private int countOk;
private int countMeh;
private int countMiss;
2022-06-17 23:38:22 +08:00
private double scoreAccuracy;
2022-03-15 11:37:39 +08:00
public ManiaPerformanceCalculator()
: base(new ManiaRuleset())
{
}
protected override PerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, DifficultyAttributes attributes)
{
var maniaAttributes = (ManiaDifficultyAttributes)attributes;
countPerfect = score.Statistics.GetValueOrDefault(HitResult.Perfect);
countGreat = score.Statistics.GetValueOrDefault(HitResult.Great);
countGood = score.Statistics.GetValueOrDefault(HitResult.Good);
countOk = score.Statistics.GetValueOrDefault(HitResult.Ok);
countMeh = score.Statistics.GetValueOrDefault(HitResult.Meh);
countMiss = score.Statistics.GetValueOrDefault(HitResult.Miss);
scoreAccuracy = calculateCustomAccuracy();
2018-05-16 00:34:07 +08:00
// Arbitrary initial value for scaling pp in order to standardize distributions across game modes.
// The specific number has no intrinsic meaning and can be adjusted as needed.
2022-06-17 23:38:22 +08:00
double multiplier = 8.0;
if (score.Mods.Any(m => m is ModNoFail))
2022-06-20 19:55:26 +08:00
multiplier *= 0.75;
if (score.Mods.Any(m => m is ModEasy))
multiplier *= 0.5;
double difficultyValue = computeDifficultyValue(maniaAttributes);
2022-06-17 23:38:22 +08:00
double totalValue = difficultyValue * multiplier;
2021-12-21 18:08:31 +08:00
return new ManiaPerformanceAttributes
{
2021-12-21 18:08:31 +08:00
Difficulty = difficultyValue,
Total = totalValue
};
}
private double computeDifficultyValue(ManiaDifficultyAttributes attributes)
{
2022-06-17 23:38:22 +08:00
double difficultyValue = Math.Pow(Math.Max(attributes.StarRating - 0.15, 0.05), 2.2) // Star rating to pp curve
2022-06-18 12:20:47 +08:00
* Math.Max(0, 5 * scoreAccuracy - 4) // From 80% accuracy, 1/20th of total pp is awarded per additional 1% accuracy
* (1 + 0.1 * Math.Min(1, totalHits / 1500)); // Length bonus, capped at 1500 notes
return difficultyValue;
}
2018-05-16 11:44:11 +08:00
private double totalHits => countPerfect + countOk + countGreat + countGood + countMeh + countMiss;
2022-06-18 12:20:47 +08:00
/// <summary>
/// Accuracy used to weight judgements independently from the score's actual accuracy.
/// </summary>
private double calculateCustomAccuracy()
2022-10-11 01:36:52 +08:00
{
2022-10-11 01:45:16 +08:00
if (totalHits == 0)
return 0;
2022-10-11 01:36:52 +08:00
return (countPerfect * 320 + countGreat * 300 + countGood * 200 + countOk * 100 + countMeh * 50) / (totalHits * 320);
2022-10-11 12:53:18 +08:00
}
}
}