1
0
Fork 0
mirror of https://github.com/ppy/osu-tools.git synced 2025-06-09 17:44:46 +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)) : this(new StreamReader(stream))
{ {
stream.Dispose(); 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")] [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; } public string Key { get; }
[UsedImplicitly] [Option(Template = "-b|--bonus", Description = "Optional. Include the argument if (approxiamate) Bonus PP should be included.")]
[Required] public bool Bonus { get; }
[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; }
protected override IProcessor CreateProcessor() => new ProfileProcessor(this); protected override IProcessor CreateProcessor() => new ProfileProcessor(this);
} }

View file

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

View file

@ -94,11 +94,10 @@ Usage: dotnet PerformanceCalculator.dll profile [arguments] [options]
Arguments: Arguments:
profile name Required. Username of the osu account to be checked (not user id) 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 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: Options:
-?|-h|--help Show help information -?|-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. 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. 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 # Requirements