public override void Execute() { var workingBeatmap = new ProcessorWorkingBeatmap(Beatmap); var scoreParser = new ProcessorScoreDecoder(workingBeatmap); foreach (var f in Replays) { Score score; using (var stream = File.OpenRead(f)) score = scoreParser.Parse(stream); var ruleset = score.ScoreInfo.Ruleset.CreateInstance(); var difficultyCalculator = ruleset.CreateDifficultyCalculator(workingBeatmap); var difficultyAttributes = difficultyCalculator.Calculate(LegacyHelper.TrimNonDifficultyAdjustmentMods(ruleset, score.ScoreInfo.Mods).ToArray()); var performanceCalculator = score.ScoreInfo.Ruleset.CreateInstance().CreatePerformanceCalculator(difficultyAttributes, score.ScoreInfo); var categoryAttribs = new Dictionary <string, double>(); double pp = performanceCalculator.Calculate(categoryAttribs); Console.WriteLine(f); writeAttribute("Player", score.ScoreInfo.User.Username); writeAttribute("Mods", score.ScoreInfo.Mods.Length > 0 ? score.ScoreInfo.Mods.Select(m => m.Acronym).Aggregate((c, n) => $"{c}, {n}") : "None"); foreach (var kvp in categoryAttribs) { writeAttribute(kvp.Key, kvp.Value.ToString(CultureInfo.InvariantCulture)); } writeAttribute("pp", pp.ToString(CultureInfo.InvariantCulture)); Console.WriteLine(); } }
public override void Execute() { var workingBeatmap = new ProcessorWorkingBeatmap(Beatmap); var scoreParser = new ProcessorScoreDecoder(workingBeatmap); foreach (var f in Replays) { Score score; using (var stream = File.OpenRead(f)) score = scoreParser.Parse(stream); // Convert + process beatmap var categoryAttribs = new Dictionary <string, double>(); var performanceCalculator = score.ScoreInfo.Ruleset.CreateInstance().CreatePerformanceCalculator(workingBeatmap, score.ScoreInfo); Trace.Assert(performanceCalculator != null); double pp = performanceCalculator.Calculate(categoryAttribs); Console.WriteLine(f); writeAttribute("Player", score.ScoreInfo.User.Username); writeAttribute("Mods", score.ScoreInfo.Mods.Length > 0 ? score.ScoreInfo.Mods.Select(m => m.Acronym).Aggregate((c, n) => $"{c}, {n}") : "None"); foreach (var kvp in categoryAttribs) { writeAttribute(kvp.Key, kvp.Value.ToString(CultureInfo.InvariantCulture)); } writeAttribute("pp", pp.ToString(CultureInfo.InvariantCulture)); Console.WriteLine(); } }
public static async Task <double> CalculatePerformancePoints(Score score) { var beatmapMd5 = await GetBeatmap(score.FileChecksum, score.Beatmap.Id); var beatmap = new ProcessorWorkingBeatmap($"./data/beatmaps/{beatmapMd5}.osu"); var psp = new ProcessorScoreDecoder(beatmap); var parsedScore = psp.Parse(score, $"./data/osr/{score.ReplayChecksum}.osr"); var categoryAttribs = new Dictionary <string, double>(); var pp = parsedScore.ScoreInfo.Ruleset .CreateInstance() .CreatePerformanceCalculator(beatmap, parsedScore.ScoreInfo) .Calculate(categoryAttribs); return(pp); }
public override void Execute() { var workingBeatmap = ProcessorWorkingBeatmap.FromFileOrId(Beatmap); var scoreParser = new ProcessorScoreDecoder(workingBeatmap); foreach (var f in Replays) { Score score; using (var stream = File.OpenRead(f)) score = scoreParser.Parse(stream); var ruleset = score.ScoreInfo.Ruleset.CreateInstance(); var difficultyCalculator = ruleset.CreateDifficultyCalculator(workingBeatmap); Mod[] mods = score.ScoreInfo.Mods; if (score.ScoreInfo.IsLegacyScore) { mods = LegacyHelper.ConvertToLegacyDifficultyAdjustmentMods(ruleset, mods); } var difficultyAttributes = difficultyCalculator.Calculate(mods); var performanceCalculator = score.ScoreInfo.Ruleset.CreateInstance().CreatePerformanceCalculator(); var ppAttributes = performanceCalculator?.Calculate(score.ScoreInfo, difficultyAttributes); Console.WriteLine(f); writeAttribute("Player", score.ScoreInfo.User.Username); writeAttribute("Mods", score.ScoreInfo.Mods.Length > 0 ? score.ScoreInfo.Mods.Select(m => m.Acronym).Aggregate((c, n) => $"{c}, {n}") : "None"); var ppAttributeValues = JsonConvert.DeserializeObject <Dictionary <string, object> >(JsonConvert.SerializeObject(ppAttributes)) ?? new Dictionary <string, object>(); foreach (var attrib in ppAttributeValues) { writeAttribute(attrib.Key.Humanize(), FormattableString.Invariant($"{attrib.Value:N2}")); } Console.WriteLine(); } }
public static async Task <double> CalculatePerformancePoints(DbScore score) { var beatmapMd5 = await GetBeatmapByMd5(score.FileChecksum); if (beatmapMd5 == string.Empty) { return(0.0); } var workingBeatmap = new ProcessorWorkingBeatmap($"./data/beatmaps/{beatmapMd5}.osu"); var psp = new ProcessorScoreDecoder(workingBeatmap); var parsedScore = psp.Parse(score); var categoryAttribs = new Dictionary <string, double>(); var pp = parsedScore.ScoreInfo.Ruleset .CreateInstance() .CreatePerformanceCalculator(workingBeatmap, parsedScore.ScoreInfo) .Calculate(categoryAttribs); return(pp); }