1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Apply review suggestions

This commit is contained in:
Endrik Tombak 2020-12-03 19:38:45 +02:00
parent cbbcf36eaa
commit 48dad61a46
3 changed files with 10 additions and 6 deletions

View File

@ -23,8 +23,6 @@ namespace osu.Game.Tests.Visual.SongSelect
{
public class TestSceneBeatmapRecommendations : OsuGameTestScene
{
protected override bool UseOnlineAPI => false;
[Resolved]
private DifficultyRecommender recommender { get; set; }

View File

@ -5,6 +5,8 @@ namespace osu.Game.Rulesets
{
public interface ILegacyRuleset
{
const int MAX_LEGACY_RULESET_ID = 3;
/// <summary>
/// Identifies the server-side ID of a legacy ruleset.
/// </summary>

View File

@ -26,6 +26,8 @@ namespace osu.Game.Screens.Select
[Resolved]
private Bindable<RulesetInfo> ruleset { get; set; }
private int storedUserId;
private readonly Dictionary<RulesetInfo, double> recommendedStarDifficulty = new Dictionary<RulesetInfo, double>();
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
@ -69,13 +71,15 @@ namespace osu.Game.Screens.Select
return beatmap;
}
private void calculateRecommendedDifficulties(bool onlyIfNoPreviousValues = false)
private void calculateRecommendedDifficulties()
{
if (recommendedStarDifficulty.Any() && onlyIfNoPreviousValues)
if (recommendedStarDifficulty.Any() && api.LocalUser.Value.Id == storedUserId)
return;
storedUserId = api.LocalUser.Value.Id;
// only query API for built-in rulesets
rulesets.AvailableRulesets.Where(ruleset => ruleset.ID <= 3).ForEach(rulesetInfo =>
rulesets.AvailableRulesets.Where(ruleset => ruleset.ID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID).ForEach(rulesetInfo =>
{
var req = new GetUserRequest(api.LocalUser.Value.Id, rulesetInfo);
@ -117,7 +121,7 @@ namespace osu.Game.Screens.Select
switch (state.NewValue)
{
case APIState.Online:
calculateRecommendedDifficulties(true);
calculateRecommendedDifficulties();
break;
}
});