mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Apply review suggestions
This commit is contained in:
@ -335,11 +335,15 @@ namespace osu.Game
|
|||||||
/// The user should have already requested this interactively.
|
/// The user should have already requested this interactively.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap to select.</param>
|
/// <param name="beatmap">The beatmap to select.</param>
|
||||||
/// <param name="difficultyCriteria">
|
/// <param name="difficultyCriteria">Optional predicate used to narrow the set of difficulties to select from when presenting.</param>
|
||||||
/// Optional predicate used to filter which difficulties to select.
|
/// <remarks>
|
||||||
/// If omitted, this will try to present a recommended beatmap from the current ruleset.
|
/// Among items satisfying the predicate, the order of preference is:
|
||||||
/// In case of failure the first difficulty of the set will be presented, ignoring the predicate.
|
/// <list type="bullet">
|
||||||
/// </param>
|
/// <item>beatmap with recommended difficulty, as provided by <see cref="DifficultyRecommender"/>,</item>
|
||||||
|
/// <item>first beatmap from the current ruleset,</item>
|
||||||
|
/// <item>first beatmap from any ruleset.</item>
|
||||||
|
/// </list>
|
||||||
|
/// </remarks>
|
||||||
public void PresentBeatmap(BeatmapSetInfo beatmap, Predicate<BeatmapInfo> difficultyCriteria = null)
|
public void PresentBeatmap(BeatmapSetInfo beatmap, Predicate<BeatmapInfo> difficultyCriteria = null)
|
||||||
{
|
{
|
||||||
var databasedSet = beatmap.OnlineBeatmapSetID != null
|
var databasedSet = beatmap.OnlineBeatmapSetID != null
|
||||||
@ -373,11 +377,12 @@ namespace osu.Game
|
|||||||
|
|
||||||
// Try to select recommended beatmap
|
// Try to select recommended beatmap
|
||||||
// This should give us a beatmap from current ruleset if there are any in our matched beatmaps
|
// This should give us a beatmap from current ruleset if there are any in our matched beatmaps
|
||||||
var selection = DifficultyRecommender.GetRecommendedBeatmap(beatmaps) ?? (
|
var selection = DifficultyRecommender.GetRecommendedBeatmap(beatmaps);
|
||||||
// Fallback if a difficulty can't be recommended, maybe we are offline
|
// Fallback if a difficulty can't be recommended, maybe we are offline
|
||||||
// First try to find a beatmap in current ruleset, otherwise use first beatmap
|
// First try to find a beatmap in current ruleset
|
||||||
beatmaps.FirstOrDefault(b => b.Ruleset.Equals(Ruleset.Value)) ?? beatmaps.First()
|
selection ??= beatmaps.FirstOrDefault(b => b.Ruleset.Equals(Ruleset.Value));
|
||||||
);
|
// Otherwise use first beatmap
|
||||||
|
selection ??= beatmaps.First();
|
||||||
|
|
||||||
Ruleset.Value = selection.Ruleset;
|
Ruleset.Value = selection.Ruleset;
|
||||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection);
|
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection);
|
||||||
|
@ -81,7 +81,6 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
req.Success += result =>
|
req.Success += result =>
|
||||||
{
|
{
|
||||||
bestRulesetOrder = null;
|
|
||||||
// algorithm taken from https://github.com/ppy/osu-web/blob/e6e2825516449e3d0f3f5e1852c6bdd3428c3437/app/Models/User.php#L1505
|
// algorithm taken from https://github.com/ppy/osu-web/blob/e6e2825516449e3d0f3f5e1852c6bdd3428c3437/app/Models/User.php#L1505
|
||||||
recommendedStarDifficulty[rulesetInfo] = Math.Pow((double)(result.Statistics.PP ?? 0), 0.4) * 0.195;
|
recommendedStarDifficulty[rulesetInfo] = Math.Pow((double)(result.Statistics.PP ?? 0), 0.4) * 0.195;
|
||||||
};
|
};
|
||||||
@ -90,19 +89,12 @@ namespace osu.Game.Screens.Select
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<RulesetInfo> bestRulesetOrder;
|
|
||||||
|
|
||||||
private IEnumerable<RulesetInfo> getBestRulesetOrder()
|
private IEnumerable<RulesetInfo> getBestRulesetOrder()
|
||||||
{
|
{
|
||||||
bestRulesetOrder ??= recommendedStarDifficulty.OrderByDescending(pair => pair.Value)
|
IEnumerable<RulesetInfo> bestRulesetOrder = recommendedStarDifficulty.OrderByDescending(pair => pair.Value)
|
||||||
.Select(pair => pair.Key)
|
.Select(pair => pair.Key)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return moveCurrentRulesetToFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<RulesetInfo> moveCurrentRulesetToFirst()
|
|
||||||
{
|
|
||||||
List<RulesetInfo> orderedRulesets;
|
List<RulesetInfo> orderedRulesets;
|
||||||
|
|
||||||
if (bestRulesetOrder.Contains(ruleset.Value))
|
if (bestRulesetOrder.Contains(ruleset.Value))
|
||||||
|
Reference in New Issue
Block a user