Merge pull request #18623 from LittleEndu/new-me-recommender

Use new own profile statistics in difficulty recommender
This commit is contained in:
Dean Herbert
2022-06-09 11:11:21 +09:00
committed by GitHub
2 changed files with 30 additions and 75 deletions

View File

@ -5,12 +5,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Mania;
@ -23,38 +22,28 @@ namespace osu.Game.Tests.Visual.SongSelect
{
public class TestSceneBeatmapRecommendations : OsuGameTestScene
{
[Resolved]
private IRulesetStore rulesetStore { get; set; }
[SetUpSteps]
public override void SetUpSteps()
{
AddStep("register request handling", () =>
{
((DummyAPIAccess)API).HandleRequest = req =>
{
switch (req)
{
case GetUserRequest userRequest:
userRequest.TriggerSuccess(getUser(userRequest.Ruleset.OnlineID));
return true;
}
return false;
};
});
base.SetUpSteps();
APIUser getUser(int? rulesetID)
AddStep("populate ruleset statistics", () =>
{
return new APIUser
Dictionary<string, UserStatistics> rulesetStatistics = new Dictionary<string, UserStatistics>();
rulesetStore.AvailableRulesets.Where(ruleset => ruleset.IsLegacyRuleset()).ForEach(rulesetInfo =>
{
Username = @"Dummy",
Id = 1001,
Statistics = new UserStatistics
rulesetStatistics[rulesetInfo.ShortName] = new UserStatistics
{
PP = getNecessaryPP(rulesetID)
}
};
}
PP = getNecessaryPP(rulesetInfo.OnlineID)
};
});
API.LocalUser.Value.RulesetsStatistics = rulesetStatistics;
});
decimal getNecessaryPP(int? rulesetID)
{