mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 02:57:25 +08:00
Move online metrics out of BeatmapInfo
model
This commit is contained in:
parent
045dd94a6e
commit
20baae9094
@ -92,17 +92,17 @@ namespace osu.Game.Tests.Visual.Online
|
||||
OverallDifficulty = 4.5f,
|
||||
ApproachRate = 6,
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
CircleCount = 111,
|
||||
SliderCount = 12,
|
||||
PlayCount = 222,
|
||||
PassCount = 21,
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -170,17 +170,17 @@ namespace osu.Game.Tests.Visual.Online
|
||||
OverallDifficulty = 7,
|
||||
ApproachRate = 6,
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
CircleCount = 123,
|
||||
SliderCount = 45,
|
||||
PlayCount = 567,
|
||||
PassCount = 89,
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -204,12 +204,14 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Version = ruleset.Name,
|
||||
Ruleset = ruleset,
|
||||
BaseDifficulty = new BeatmapDifficulty(),
|
||||
OnlineInfo = new BeatmapOnlineInfo(),
|
||||
Metrics = new BeatmapMetrics
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -288,12 +290,14 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
OverallDifficulty = 3.5f,
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo(),
|
||||
Metrics = new BeatmapMetrics
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,14 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
Metrics = new BeatmapMetrics
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.BeatmapSet;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
@ -66,10 +67,13 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
static BeatmapInfo createBeatmap() => new BeatmapInfo
|
||||
{
|
||||
Metrics = new BeatmapMetrics
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -79,13 +83,16 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metrics = new BeatmapMetrics
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).ToArray(),
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).ToArray(),
|
||||
}
|
||||
}
|
||||
});
|
||||
AddAssert("graph max values correct",
|
||||
() => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 100));
|
||||
|
||||
AddAssert("graph max values correct", () => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 100));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -93,11 +100,13 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metrics = new BeatmapMetrics()
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Metrics = new BeatmapMetrics(),
|
||||
}
|
||||
});
|
||||
|
||||
AddAssert("graph max values correct",
|
||||
() => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 0));
|
||||
AddAssert("graph max values correct", () => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 0));
|
||||
}
|
||||
|
||||
private class GraphExposingSuccessRate : SuccessRate
|
||||
|
@ -54,11 +54,14 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
ApproachRate = 3.5f,
|
||||
},
|
||||
StarDifficulty = 5.3f,
|
||||
Metrics = new BeatmapMetrics
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -87,11 +90,14 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
ApproachRate = 3.5f,
|
||||
},
|
||||
StarDifficulty = 5.3f,
|
||||
Metrics = new BeatmapMetrics
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -143,11 +149,14 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
ApproachRate = 7,
|
||||
},
|
||||
StarDifficulty = 2.91f,
|
||||
Metrics = new BeatmapMetrics
|
||||
OnlineInfo = new APIBeatmap
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -47,10 +47,7 @@ namespace osu.Game.Beatmaps
|
||||
public BeatmapDifficulty BaseDifficulty { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public BeatmapMetrics Metrics { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public BeatmapOnlineInfo OnlineInfo { get; set; }
|
||||
public IBeatmapOnlineInfo OnlineInfo { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public int? MaxCombo { get; set; }
|
||||
@ -192,5 +189,24 @@ namespace osu.Game.Beatmaps
|
||||
double IBeatmapInfo.StarRating => StarDifficulty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation of IBeatmapOnlineInfo
|
||||
|
||||
[JsonIgnore]
|
||||
public int CircleCount => OnlineInfo.CircleCount;
|
||||
|
||||
[JsonIgnore]
|
||||
public int SliderCount => OnlineInfo.SliderCount;
|
||||
|
||||
[JsonIgnore]
|
||||
public int PlayCount => OnlineInfo.PlayCount;
|
||||
|
||||
[JsonIgnore]
|
||||
public int PassCount => OnlineInfo.PassCount;
|
||||
|
||||
[JsonIgnore]
|
||||
public BeatmapMetrics Metrics => OnlineInfo.Metrics;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// Beatmap info retrieved for previewing locally without having the beatmap downloaded.
|
||||
/// </summary>
|
||||
public class BeatmapOnlineInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of circles in this beatmap.
|
||||
/// </summary>
|
||||
public int CircleCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of sliders in this beatmap.
|
||||
/// </summary>
|
||||
public int SliderCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of plays this beatmap has.
|
||||
/// </summary>
|
||||
public int PlayCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of passes this beatmap has.
|
||||
/// </summary>
|
||||
public int PassCount { get; set; }
|
||||
}
|
||||
}
|
@ -10,8 +10,31 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
public interface IBeatmapOnlineInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The max combo of this beatmap.
|
||||
/// </summary>
|
||||
int? MaxCombo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of circles in this beatmap.
|
||||
/// </summary>
|
||||
public int CircleCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of sliders in this beatmap.
|
||||
/// </summary>
|
||||
public int SliderCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of plays this beatmap has.
|
||||
/// </summary>
|
||||
public int PlayCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of passes this beatmap has.
|
||||
/// </summary>
|
||||
public int PassCount { get; }
|
||||
|
||||
BeatmapMetrics? Metrics { get; }
|
||||
}
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
public APIBeatmapSet? BeatmapSet { get; set; }
|
||||
|
||||
[JsonProperty(@"playcount")]
|
||||
private int playCount { get; set; }
|
||||
public int PlayCount { get; set; }
|
||||
|
||||
[JsonProperty(@"passcount")]
|
||||
private int passCount { get; set; }
|
||||
public int PassCount { get; set; }
|
||||
|
||||
[JsonProperty(@"mode_int")]
|
||||
public int RulesetID { get; set; }
|
||||
@ -60,10 +60,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
private double lengthInSeconds { get; set; }
|
||||
|
||||
[JsonProperty(@"count_circles")]
|
||||
private int circleCount { get; set; }
|
||||
public int CircleCount { get; set; }
|
||||
|
||||
[JsonProperty(@"count_sliders")]
|
||||
private int sliderCount { get; set; }
|
||||
public int SliderCount { get; set; }
|
||||
|
||||
[JsonProperty(@"version")]
|
||||
public string DifficultyName { get; set; } = string.Empty;
|
||||
@ -90,7 +90,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
Status = Status,
|
||||
MD5Hash = Checksum,
|
||||
BeatmapSet = set,
|
||||
Metrics = Metrics,
|
||||
MaxCombo = MaxCombo,
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
@ -99,13 +98,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
ApproachRate = approachRate,
|
||||
OverallDifficulty = overallDifficulty,
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo
|
||||
{
|
||||
PlayCount = playCount,
|
||||
PassCount = passCount,
|
||||
CircleCount = circleCount,
|
||||
SliderCount = sliderCount,
|
||||
},
|
||||
OnlineInfo = this,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -55,8 +55,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
beatmapInfo = value;
|
||||
|
||||
metrics = beatmapInfo?.Metrics;
|
||||
ratings = beatmapInfo?.BeatmapSet.Ratings;
|
||||
metrics = beatmapInfo?.OnlineInfo?.Metrics;
|
||||
ratings = beatmapInfo?.BeatmapSet?.Ratings;
|
||||
|
||||
Scheduler.AddOnce(updateStatistics);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
|
||||
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
|
||||
BeatmapInfo.Length = 75000;
|
||||
BeatmapInfo.OnlineInfo = new BeatmapOnlineInfo();
|
||||
BeatmapInfo.OnlineInfo = new APIBeatmap();
|
||||
BeatmapInfo.BeatmapSet.OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Status = BeatmapSetOnlineStatus.Ranked,
|
||||
|
Loading…
x
Reference in New Issue
Block a user