1
0
Fork 0
mirror of https://github.com/ppy/osu-tools.git synced 2025-06-09 17:44:46 +09:00

Make simulate download missing beatmaps

This commit is contained in:
StanR 2021-06-01 01:10:26 +03:00
parent bf1aac3e48
commit f87f0d996c
6 changed files with 63 additions and 35 deletions

View file

@ -159,13 +159,13 @@ Computes the performance of a simulated play on a beatmap. The provided output i
Computes the performance (pp) of a simulated osu! play.
Usage: dotnet PerformanceCalculator.dll simulate osu [arguments] [options]
Usage: dotnet PerformanceCalculator.dll simulate osu <beatmap> [options]
Arguments:
beatmap Required. The beatmap file (.osu).
beatmap Required. Can be either a path to beatmap file (.osu) or beatmap ID.
Options:
-?|-h|--help Show help information
-?|-h|--help Show help information.
-a|--accuracy <accuracy> Accuracy. Enter as decimal 0-100. Defaults to 100. Scales hit results as well and is rounded to the nearest possible value for the beatmap.
-c|--combo <combo> Maximum combo during play. Defaults to beatmap maximum.
-C|--percent-combo <combo> Percentage of beatmap maximum combo achieved. Alternative to combo option. Enter as decimal 0-100.
@ -173,6 +173,7 @@ Options:
-X|--misses <misses> Number of misses. Defaults to 0.
-M|--mehs <mehs> Number of mehs. Will override accuracy if used. Otherwise is automatically calculated.
-G|--goods <goods> Number of goods. Will override accuracy if used. Otherwise is automatically calculated.
-j|--json Output results as JSON.
-o|--output <file.txt> Output results to text file.
```
@ -182,36 +183,63 @@ Options:
Computes the performance (pp) of a simulated osu!taiko play.
Usage: dotnet PerformanceCalculator.dll simulate taiko [arguments] [options]
Usage: dotnet PerformanceCalculator.dll simulate taiko <beatmap> [options]
Arguments:
beatmap Required. The beatmap file (.osu).
beatmap Required. Can be either a path to beatmap file (.osu) or beatmap ID.
Options:
-?|-h|--help Show help information
-?|-h|--help Show help information.
-a|--accuracy <accuracy> Accuracy. Enter as decimal 0-100. Defaults to 100. Scales hit results as well and is rounded to the nearest possible value for the beatmap.
-c|--combo <combo> Maximum combo during play. Defaults to beatmap maximum.
-C|--percent-combo <combo> Percentage of beatmap maximum combo achieved. Alternative to combo option. Enter as decimal 0-100.
-m|--mod <mod> One for each mod. The mods to compute the performance with. Values: hr, dt, hd, fl, ez, etc...
-X|--misses <misses> Number of misses. Defaults to 0.
-G|--goods <goods> Number of goods. Will override accuracy if used. Otherwise is automatically calculated.
-j|--json Output results as JSON.
-o|--output <file.txt> Output results to text file.
```
#### osu!catch
```
> dotnet run -- simulate catch --help
Computes the performance (pp) of a simulated osu!catch play.
Usage: dotnet PerformanceCalculator.dll simulate catch <beatmap> [options]
Arguments:
beatmap Required. Can be either a path to beatmap file (.osu) or beatmap ID.
Options:
-?|-h|--help Show help information.
-a|--accuracy <accuracy> Accuracy. Enter as decimal 0-100. Defaults to 100. Scales hit results as well and is rounded to the nearest possible value for the beatmap.
-c|--combo <combo> Maximum combo during play. Defaults to beatmap maximum.
-C|--percent-combo <combo> Percentage of beatmap maximum combo achieved. Alternative to combo option. Enter as decimal 0-100.
-m|--mod <mod> One for each mod. The mods to compute the performance with. Values: hr, dt, hd, fl, ez, etc...
-X|--misses <misses> Number of misses. Defaults to 0.
-T|--tiny-droplets <tinys> Number of tiny droplets hit. Will override accuracy if used. Otherwise is automatically calculated.
-D|--droplets <droplets> Number of droplets hit. Will override accuracy if used. Otherwise is automatically calculated.
-j|--json Output results as JSON.
-o|--output <file.txt> Output results to text file.
```
#### osu!mania
```
> dotnet run -- simulate mania --help
Computes the performance (pp) of a simulated osu!mania play.
Usage: dotnet PerformanceCalculator.dll simulate mania [arguments] [options]
Usage: dotnet PerformanceCalculator.dll simulate mania <beatmap> [options]
Arguments:
beatmap Required. The beatmap file (.osu).
beatmap Required. Can be either a path to beatmap file (.osu) or beatmap ID.
Options:
-?|-h|--help Show help information
-?|-h|--help Show help information.
-s|--score <score> Score. An integer 0-1000000.
-m|--mod <mod> One for each mod. The mods to compute the performance with. Values: hr, dt, fl, 4k, 5k, etc...
-j|--json Output results as JSON.
-o|--output <file.txt> Output results to text file.
```

View file

@ -11,7 +11,6 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
@ -20,11 +19,6 @@ namespace PerformanceCalculator.Simulate
[Command(Name = "catch", Description = "Computes the performance (pp) of a simulated osu!catch play.")]
public class CatchSimulateCommand : SimulateCommand
{
[UsedImplicitly]
[Required, FileExists]
[Argument(0, Name = "beatmap", Description = "Required. The beatmap file (.osu).")]
public override string Beatmap { get; }
[UsedImplicitly]
[Option(Template = "-a|--accuracy <accuracy>", Description = "Accuracy. Enter as decimal 0-100. Defaults to 100."
+ " Scales hit results as well and is rounded to the nearest possible value for the beatmap.")]

View file

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using JetBrains.Annotations;
using McMaster.Extensions.CommandLineUtils;
@ -17,11 +16,6 @@ namespace PerformanceCalculator.Simulate
[Command(Name = "mania", Description = "Computes the performance (pp) of a simulated osu!mania play.")]
public class ManiaSimulateCommand : SimulateCommand
{
[UsedImplicitly]
[Required, FileExists]
[Argument(0, Name = "beatmap", Description = "Required. The beatmap file (.osu).")]
public override string Beatmap { get; }
[UsedImplicitly]
[Option(Template = "-s|--score <score>", Description = "Score. An integer 0-1000000.")]
public override int Score { get; } = 1000000;

View file

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using JetBrains.Annotations;
@ -20,11 +19,6 @@ namespace PerformanceCalculator.Simulate
[Command(Name = "osu", Description = "Computes the performance (pp) of a simulated osu! play.")]
public class OsuSimulateCommand : SimulateCommand
{
[UsedImplicitly]
[Required, FileExists]
[Argument(0, Name = "beatmap", Description = "Required. The beatmap file (.osu).")]
public override string Beatmap { get; }
[UsedImplicitly]
[Option(Template = "-a|--accuracy <accuracy>", Description = "Accuracy. Enter as decimal 0-100. Defaults to 100."
+ " Scales hit results as well and is rounded to the nearest possible value for the beatmap.")]

View file

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Globalization;
using System.IO;
@ -11,6 +12,7 @@ using Alba.CsConsoleFormat;
using JetBrains.Annotations;
using McMaster.Extensions.CommandLineUtils;
using Newtonsoft.Json.Linq;
using osu.Framework.IO.Network;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
@ -21,10 +23,13 @@ namespace PerformanceCalculator.Simulate
{
public abstract class SimulateCommand : ProcessorCommand
{
public abstract string Beatmap { get; }
public abstract Ruleset Ruleset { get; }
[UsedImplicitly]
[Required]
[Argument(0, Name = "beatmap", Description = "Required. Can be either a path to beatmap file (.osu) or beatmap ID.")]
public string Beatmap { get; set; }
[UsedImplicitly]
public virtual double Accuracy { get; }
@ -59,6 +64,25 @@ namespace PerformanceCalculator.Simulate
var mods = getMods(ruleset).ToArray();
if (!Beatmap.EndsWith(".osu"))
{
if (!int.TryParse(Beatmap, out _))
{
Console.WriteLine("Incorrect beatmap ID.");
return;
}
string cachePath = Path.Combine("cache", $"{Beatmap}.osu");
if (!File.Exists(cachePath))
{
Console.WriteLine($"Downloading {Beatmap}.osu...");
new FileWebRequest(cachePath, $"https://osu.ppy.sh/osu/{Beatmap}").Perform();
Beatmap = cachePath;
}
}
var workingBeatmap = new ProcessorWorkingBeatmap(Beatmap);
var beatmap = workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);

View file

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using JetBrains.Annotations;
@ -20,11 +19,6 @@ namespace PerformanceCalculator.Simulate
[Command(Name = "taiko", Description = "Computes the performance (pp) of a simulated osu!taiko play.")]
public class TaikoSimulateCommand : SimulateCommand
{
[UsedImplicitly]
[Required, FileExists]
[Argument(0, Name = "beatmap", Description = "Required. The beatmap file (.osu).")]
public override string Beatmap { get; }
[UsedImplicitly]
[Option(Template = "-a|--accuracy <accuracy>", Description = "Accuracy. Enter as decimal 0-100. Defaults to 100."
+ " Scales hit results as well and is rounded to the nearest possible value for the beatmap.")]