2019-01-24 16:43:03 +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.
|
2018-05-16 00:24:53 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-05-16 00:24:53 +08:00
|
|
|
|
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;
|
2018-05-16 00:24:53 +08:00
|
|
|
|
|
|
|
|
|
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;
|
2018-05-16 00:24:53 +08:00
|
|
|
|
private int countMiss;
|
2022-06-17 23:38:22 +08:00
|
|
|
|
private double scoreAccuracy;
|
2018-05-16 00:24:53 +08:00
|
|
|
|
|
2022-03-15 11:37:39 +08:00
|
|
|
|
public ManiaPerformanceCalculator()
|
|
|
|
|
: base(new ManiaRuleset())
|
2018-05-16 00:24:53 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 13:25:26 +08:00
|
|
|
|
protected override PerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, DifficultyAttributes attributes)
|
2018-05-16 00:24:53 +08:00
|
|
|
|
{
|
2022-03-14 13:25:26 +08:00
|
|
|
|
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);
|
2022-06-17 23:38:22 +08:00
|
|
|
|
scoreAccuracy = customAccuracy;
|
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;
|
2018-05-16 00:24:53 +08:00
|
|
|
|
|
2022-03-14 13:25:26 +08:00
|
|
|
|
if (score.Mods.Any(m => m is ModNoFail))
|
2018-05-16 00:24:53 +08:00
|
|
|
|
multiplier *= 0.9;
|
2022-03-14 13:25:26 +08:00
|
|
|
|
if (score.Mods.Any(m => m is ModEasy))
|
2018-05-16 00:24:53 +08:00
|
|
|
|
multiplier *= 0.5;
|
|
|
|
|
|
2022-03-14 13:25:26 +08:00
|
|
|
|
double difficultyValue = computeDifficultyValue(maniaAttributes);
|
2022-06-17 23:38:22 +08:00
|
|
|
|
double totalValue = difficultyValue * multiplier;
|
2018-05-16 00:24:53 +08:00
|
|
|
|
|
2021-12-21 18:08:31 +08:00
|
|
|
|
return new ManiaPerformanceAttributes
|
2018-05-16 00:24:53 +08:00
|
|
|
|
{
|
2021-12-21 18:08:31 +08:00
|
|
|
|
Difficulty = difficultyValue,
|
|
|
|
|
Total = totalValue
|
|
|
|
|
};
|
2018-05-16 00:24:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 13:25:26 +08:00
|
|
|
|
private double computeDifficultyValue(ManiaDifficultyAttributes attributes)
|
2018-05-16 00:24:53 +08:00
|
|
|
|
{
|
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
|
|
|
|
|
* Math.Max(0, 5 * scoreAccuracy - 4) // Accuracy curve
|
|
|
|
|
* (1 + 0.1 * Math.Min(1, totalHits / 1500)); // Length bonus
|
2018-05-16 00:24:53 +08:00
|
|
|
|
|
2021-12-18 04:39:03 +08:00
|
|
|
|
return difficultyValue;
|
2018-05-16 00:24:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 11:44:11 +08:00
|
|
|
|
private double totalHits => countPerfect + countOk + countGreat + countGood + countMeh + countMiss;
|
2022-06-17 23:38:22 +08:00
|
|
|
|
private double customAccuracy => (countPerfect * 320 + countGreat * 300 + countGood * 200 + countOk * 100 + countMeh * 50) / (totalHits * 320);
|
2018-05-16 00:24:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|