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

Revert "Revert "Implemented qwewqa's suggestions. Got rid of the temporary file, removed category Attributes, and in doing so made the stream constructor of the working beatmap class public. Also fixed some readmes""

This reverts commit 02a0f673f7.
This commit is contained in:
girantinas 2019-01-05 23:51:13 -05:00
parent 02a0f673f7
commit 4628ed9514
5 changed files with 19 additions and 37 deletions

View file

@ -29,7 +29,11 @@ namespace PerformanceCalculator
{
}
private ProcessorWorkingBeatmap(Stream stream)
/// <summary>
/// Constructs a new <see cref="ProcessorWorkingBeatmap"/> from a stream.
/// </summary>
/// <param name="stream">The stream.</param>
public ProcessorWorkingBeatmap(Stream stream)
: this(new StreamReader(stream))
{
stream.Dispose();

View file

@ -20,14 +20,8 @@ namespace PerformanceCalculator.Profile
[Argument(1, Name = "api key", Description = "Required. API Key, which you can get from here: https://osu.ppy.sh/p/api")]
public string Key { get; }
[UsedImplicitly]
[Required]
[Argument(2, Name = "path", Description = "Required. Path to an open directory. Will create a txt file in that directory called ProfileCalculator.txt that will take up a few KB.")]
public string Path { get; }
[UsedImplicitly]
[Option(Template = "-b|--bonus <number>", Description = "Optional. Whether or not Bonus PP should be included. 1 is included, 0 is not included. Default is 0.")]
public int? Bonus { get; }
[Option(Template = "-b|--bonus", Description = "Optional. Include the argument if (approxiamate) Bonus PP should be included.")]
public bool Bonus { get; }
protected override IProcessor CreateProcessor() => new ProfileProcessor(this);
}

View file

@ -29,11 +29,9 @@ namespace PerformanceCalculator.Profile
{
//initializing information-holding sorted list
var sortedPP = new SortedDictionary<double,PPInfo>();
//initialize path to download beatmap files
string path = command.Path + @"\ProfileCalculator.txt";
//get data for all 100 top plays
var getPlayData = (HttpWebRequest) WebRequest.Create("https://osu.ppy.sh/api/get_user_best?k="+command.Key+"&u="+command.ProfileName+"&limit=100&type=username");
var getPlayData = (HttpWebRequest) WebRequest.Create("https://osu.ppy.sh/api/get_user_best?k=" + command.Key+ "&u=" + command.ProfileName+"&limit=100&type=username");
HttpWebResponse response = (HttpWebResponse)getPlayData.GetResponse();
var receiveStream = response.GetResponseStream();
var readStream = new StreamReader(receiveStream);
@ -43,27 +41,15 @@ namespace PerformanceCalculator.Profile
receiveStream.Close();
readStream.Close();
//create the file if it doesnt exist
if(!File.Exists(path))
{
File.Create(path).Dispose();
}
for(int i=0; i<100; i++)
{
//for each beatmap, download it
using (var client = new WebClient()) {
try
{
client.DownloadFile("https://osu.ppy.sh/osu/" + playData[i].beatmap_id, path);
}
catch
{
Console.WriteLine("Error in Downloading Beatmaps");
}
}
var workingBeatmap = new ProcessorWorkingBeatmap(path);
var getBeatmap = (HttpWebRequest) WebRequest.Create("https://osu.ppy.sh/osu/" + playData[i].beatmap_id);
HttpWebResponse beatmapResponse = (HttpWebResponse)getBeatmap.GetResponse();
var beatmapStream = beatmapResponse.GetResponseStream();
var workingBeatmap = new ProcessorWorkingBeatmap(beatmapStream);
beatmapResponse.Close();
beatmapStream.Close();
//Stats Calculation
var ruleset = new OsuRuleset();
@ -125,8 +111,7 @@ namespace PerformanceCalculator.Profile
workingBeatmap.Mods.Value = finalMods;
var categoryAttribs = new Dictionary<string, double>();
double pp = ruleset.CreatePerformanceCalculator(workingBeatmap, scoreInfo).Calculate(categoryAttribs);
double pp = ruleset.CreatePerformanceCalculator(workingBeatmap, scoreInfo).Calculate();
var outputInfo = new PPInfo
{
OldPP = (double)playData[i].pp,
@ -152,7 +137,7 @@ namespace PerformanceCalculator.Profile
w++;
}
if(command.Bonus == 1)
if(command.Bonus == true)
{
//get user data (used for bonus pp calculation)
var getUserData = (HttpWebRequest) WebRequest.Create("https://osu.ppy.sh/api/get_user?k="+command.Key+"&u="+command.ProfileName+"&type=username");
@ -200,4 +185,4 @@ namespace PerformanceCalculator.Profile
SpunOut = 4096,
}
}
}
}

View file

@ -94,11 +94,10 @@ Usage: dotnet PerformanceCalculator.dll profile [arguments] [options]
Arguments:
profile name Required. Username of the osu account to be checked (not user id)
api key Required. API Key, which you can get from here: https://osu.ppy.sh/p/api
path Required. Path to an open directory. Will create a txt file in that directory called ProfileCalculator.txt that will take up a few KB.
Options:
-?|-h|--help Show help information
-b|--bonus <number> Optional. Whether or not Bonus PP should be included. 1 is included, 0 is not included. Default is 0.
-b|--bonus <number> Optional. Include the argument if (approxiamate)Bonus PP should be included.
```
Computes the performance of a user profile's performance. Takes 100 top plays of a user on Bancho and recalculates and reorders them in order of the performance calculator's calculated performance.

View file

@ -4,7 +4,7 @@ Tools for [osu!](https://osu.ppy.sh).
For more detailed information see per-tool READMEs.
- [PerformanceCalculator](https://github.com/girantinas/osu-tools/blob/master/PerformanceCalculator/README.md) - A CLI tool for calculating the difficulty of beatmaps and the performance of replays.
- [PerformanceCalculator](https://github.com/ppy/osu-tools/blob/master/PerformanceCalculator/README.md) - A CLI tool for calculating the difficulty of beatmaps and the performance of replays.
# Requirements