1
0
Fork 0
mirror of https://github.com/ppy/osu-tools.git synced 2025-06-08 07:17:01 +09:00
osu-tools/PerformanceCalculator/Simulate/TaikoSimulateCommand.cs
2025-02-21 21:50:38 +01:00

73 lines
2.9 KiB
C#

// 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 JetBrains.Annotations;
using McMaster.Extensions.CommandLineUtils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko;
namespace PerformanceCalculator.Simulate
{
[Command(Name = "taiko", Description = "Computes the performance (pp) of a simulated osu!taiko play.")]
public class TaikoSimulateCommand : SimulateCommand
{
[UsedImplicitly]
[Option(Template = "-G|--goods <goods>", Description = "Number of goods. Will override accuracy if used. Otherwise is automatically calculated.")]
public override int? Goods { get; }
[UsedImplicitly]
[Option(Template = "-c|--combo <combo>", Description = "Maximum combo during play. Defaults to beatmap maximum.")]
public override int? Combo { get; }
[UsedImplicitly]
[Option(Template = "-C|--percent-combo <combo>", Description = "Percentage of beatmap maximum combo achieved. Alternative to combo option. Enter as decimal 0-100.")]
public override double PercentCombo { get; } = 100;
public override Ruleset Ruleset => new TaikoRuleset();
protected override Dictionary<HitResult, int> GenerateHitResults(IBeatmap beatmap, Mod[] mods) => generateHitResults(Accuracy / 100, beatmap, Misses, Goods);
private static Dictionary<HitResult, int> generateHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countGood)
{
int totalResultCount = beatmap.GetMaxCombo();
int countGreat;
if (countGood != null)
{
countGreat = (int)(totalResultCount - countGood - countMiss);
}
else
{
// Let Great=2, Good=1, Miss=0. The total should be this.
int targetTotal = (int)Math.Round(accuracy * totalResultCount * 2);
countGreat = targetTotal - (totalResultCount - countMiss);
countGood = totalResultCount - countGreat - countMiss;
}
return new Dictionary<HitResult, int>
{
{ HitResult.Great, countGreat },
{ HitResult.Ok, (int)countGood },
{ HitResult.Meh, 0 },
{ HitResult.Miss, countMiss }
};
}
protected override double GetAccuracy(IBeatmap beatmap, Dictionary<HitResult, int> statistics, Mod[] mods)
{
int countGreat = statistics[HitResult.Great];
int countGood = statistics[HitResult.Ok];
int countMiss = statistics[HitResult.Miss];
int total = countGreat + countGood + countMiss;
return (double)((2 * countGreat) + countGood) / (2 * total);
}
}
}