// Copyright (c) ppy Pty Ltd . 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 ", Description = "Number of goods. Will override accuracy if used. Otherwise is automatically calculated.")] public override int? Goods { get; } [UsedImplicitly] [Option(Template = "-c|--combo ", Description = "Maximum combo during play. Defaults to beatmap maximum.")] public override int? Combo { get; } [UsedImplicitly] [Option(Template = "-C|--percent-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 GenerateHitResults(IBeatmap beatmap, Mod[] mods) => generateHitResults(Accuracy / 100, beatmap, Misses, Goods); private static Dictionary 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.Great, countGreat }, { HitResult.Ok, (int)countGood }, { HitResult.Meh, 0 }, { HitResult.Miss, countMiss } }; } protected override double GetAccuracy(IBeatmap beatmap, Dictionary 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); } } }