mirror of
https://github.com/ppy/osu-tools.git
synced 2025-06-11 02:13:33 +09:00
Improve output readability
This commit is contained in:
parent
ee8bb3f258
commit
eab6185780
2 changed files with 22 additions and 11 deletions
|
@ -85,15 +85,14 @@ namespace PerformanceCalculator.Difficulty
|
||||||
foreach (var group in resultSet.Results.GroupBy(r => r.RulesetId))
|
foreach (var group in resultSet.Results.GroupBy(r => r.RulesetId))
|
||||||
{
|
{
|
||||||
var ruleset = LegacyHelper.GetRulesetFromLegacyID(group.First().RulesetId);
|
var ruleset = LegacyHelper.GetRulesetFromLegacyID(group.First().RulesetId);
|
||||||
document.Children.Add(new Span($"Ruleset: {ruleset.ShortName}"), "\n");
|
document.Children.Add(new Span($"ruleset: {ruleset.ShortName}"), "\n");
|
||||||
|
|
||||||
Grid grid = new Grid();
|
Grid grid = new Grid();
|
||||||
bool firstResult = true;
|
bool firstResult = true;
|
||||||
|
|
||||||
foreach (var result in group)
|
foreach (var result in group)
|
||||||
{
|
{
|
||||||
var attributeValues = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(result.Attributes))
|
var attributeValues = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(result.Attributes)) ?? new Dictionary<string, object>();
|
||||||
?? new Dictionary<string, object>();
|
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
if (firstResult)
|
if (firstResult)
|
||||||
|
|
|
@ -8,6 +8,7 @@ using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Alba.CsConsoleFormat;
|
using Alba.CsConsoleFormat;
|
||||||
|
using Humanizer;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using McMaster.Extensions.CommandLineUtils;
|
using McMaster.Extensions.CommandLineUtils;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -119,20 +120,31 @@ namespace PerformanceCalculator.Simulate
|
||||||
|
|
||||||
// Basic score info.
|
// Basic score info.
|
||||||
document.Children.Add(
|
document.Children.Add(
|
||||||
FormatDocumentLine("Beatmap", $"{result.Score.BeatmapId} - {result.Score.Beatmap}"),
|
FormatDocumentLine("beatmap", $"{result.Score.BeatmapId} - {result.Score.Beatmap}"),
|
||||||
FormatDocumentLine("Score", result.Score.Score.ToString(CultureInfo.InvariantCulture)),
|
FormatDocumentLine("score", result.Score.Score.ToString(CultureInfo.InvariantCulture)),
|
||||||
FormatDocumentLine("Accuracy", result.Score.Accuracy.ToString("N2", CultureInfo.InvariantCulture)),
|
FormatDocumentLine("accuracy", result.Score.Accuracy.ToString("N2", CultureInfo.InvariantCulture)),
|
||||||
FormatDocumentLine("Combo", result.Score.Combo.ToString(CultureInfo.InvariantCulture)),
|
FormatDocumentLine("combo", result.Score.Combo.ToString(CultureInfo.InvariantCulture)),
|
||||||
FormatDocumentLine("Mods", result.Score.Mods.Count > 0 ? result.Score.Mods.Select(m => m.ToString()).Aggregate((c, n) => $"{c}, {n}") : "None")
|
FormatDocumentLine("mods", result.Score.Mods.Count > 0 ? result.Score.Mods.Select(m => m.ToString()).Aggregate((c, n) => $"{c}, {n}") : "None")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
document.Children.Add("---\n");
|
||||||
|
|
||||||
// Hit statistics
|
// Hit statistics
|
||||||
foreach (var stat in result.Score.Statistics)
|
foreach (var stat in result.Score.Statistics)
|
||||||
document.Children.Add(FormatDocumentLine(stat.Key.ToString(), stat.Value.ToString(CultureInfo.InvariantCulture)));
|
document.Children.Add(FormatDocumentLine(stat.Key.ToString().ToLowerInvariant(), stat.Value.ToString(CultureInfo.InvariantCulture)));
|
||||||
|
|
||||||
// Finally, pp.
|
document.Children.Add("---\n");
|
||||||
|
|
||||||
|
// pp.
|
||||||
document.Children.Add(FormatDocumentLine("pp", result.Pp.ToString("N2", CultureInfo.InvariantCulture)));
|
document.Children.Add(FormatDocumentLine("pp", result.Pp.ToString("N2", CultureInfo.InvariantCulture)));
|
||||||
|
|
||||||
|
document.Children.Add("---\n");
|
||||||
|
|
||||||
|
// Difficulty attributes
|
||||||
|
var attributeValues = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(result.Attributes)) ?? new Dictionary<string, object>();
|
||||||
|
foreach (var attrib in attributeValues)
|
||||||
|
document.Children.Add(FormatDocumentLine(attrib.Key.Humanize(), $"{attrib.Value:N2}"));
|
||||||
|
|
||||||
OutputDocument(document);
|
OutputDocument(document);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +175,7 @@ namespace PerformanceCalculator.Simulate
|
||||||
|
|
||||||
protected virtual double GetAccuracy(Dictionary<HitResult, int> statistics) => 0;
|
protected virtual double GetAccuracy(Dictionary<HitResult, int> statistics) => 0;
|
||||||
|
|
||||||
protected string FormatDocumentLine(string name, string value) => $"{name.PadRight(15)}: {value}\n";
|
protected string FormatDocumentLine(string name, string value) => $"{name.PadRight(20)}: {value}\n";
|
||||||
|
|
||||||
private class Result
|
private class Result
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue