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

Merge branch 'master' into freestyle-mods

This commit is contained in:
Dean Herbert 2025-05-30 21:54:52 +09:00
commit 8aa6173b90
No known key found for this signature in database
8 changed files with 190 additions and 48 deletions

View file

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Alba.CsConsoleFormat;
using JetBrains.Annotations;
using McMaster.Extensions.CommandLineUtils;
@ -27,6 +28,9 @@ namespace PerformanceCalculator.Profile
[AllowedValues("0", "1", "2", "3")]
public int? Ruleset { get; }
private const int max_api_scores = 200;
private const int max_api_scores_in_one_query = 100;
public override void Execute()
{
var displayPlays = new List<UserPlayInfo>();
@ -39,22 +43,28 @@ namespace PerformanceCalculator.Profile
Console.WriteLine("Getting user top scores...");
foreach (var play in GetJsonFromApi<List<SoloScoreInfo>>($"users/{userData.Id}/scores/best?mode={rulesetApiName}&limit=100"))
var apiScores = new List<SoloScoreInfo>();
for (int i = 0; i < max_api_scores; i += max_api_scores_in_one_query)
{
apiScores.AddRange(GetJsonFromApi<List<SoloScoreInfo>>($"users/{userData.Id}/scores/best?mode={rulesetApiName}&limit={max_api_scores_in_one_query}&offset={i}"));
Thread.Sleep(200);
}
foreach (var play in apiScores)
{
var working = ProcessorWorkingBeatmap.FromFileOrId(play.BeatmapID.ToString());
Mod[] mods = play.Mods.Select(x => x.ToMod(ruleset)).ToArray();
var scoreInfo = play.ToScoreInfo(mods);
var scoreInfo = play.ToScoreInfo(mods, working.BeatmapInfo);
scoreInfo.Ruleset = ruleset.RulesetInfo;
var score = new ProcessorScoreDecoder(working).Parse(scoreInfo);
var difficultyCalculator = ruleset.CreateDifficultyCalculator(working);
var difficultyAttributes = difficultyCalculator.Calculate(scoreInfo.Mods);
var performanceCalculator = ruleset.CreatePerformanceCalculator();
var ppAttributes = performanceCalculator?.Calculate(score.ScoreInfo, difficultyAttributes);
var ppAttributes = performanceCalculator?.Calculate(scoreInfo, difficultyAttributes);
var thisPlay = new UserPlayInfo
{
Beatmap = working.BeatmapInfo,

View file

@ -40,6 +40,10 @@ namespace PerformanceCalculator.Simulate
[Option(Template = "-X|--misses <misses>", Description = "Number of misses. Defaults to 0.")]
public int Misses { get; }
[UsedImplicitly]
[Option(Template = "-l|--legacy-total-score <score>", Description = "Amount of legacy total score.")]
public long? LegacyTotalScore { get; }
//
// Options implemented in the ruleset-specific commands
// -> Catch renames Mehs/Goods to (tiny-)droplets
@ -73,6 +77,7 @@ namespace PerformanceCalculator.Simulate
Accuracy = GetAccuracy(beatmap, statistics),
MaxCombo = Combo ?? (int)Math.Round(PercentCombo / 100 * beatmapMaxCombo),
Statistics = statistics,
LegacyTotalScore = LegacyTotalScore,
Mods = mods
};