mirror of
https://github.com/ppy/osu.git
synced 2026-05-13 19:54:15 +08:00
53f945b7ac
The "Key Count" metric in mania is very useless since you are already expected to play maps with a specific Key Count when you are queueing. This PR inserts the proportion of LNs (Long Notes) in the place of that metric since it is one of the ways players can gudge their skillsets (This idea comes from reddit) Also improved the test suite for other skillsets by making the architecture more minor ruleset friendly Addresses https://github.com/ppy/osu/discussions/37568. --------- Co-authored-by: Dan Balasescu <smoogipoo@smgi.me> Co-authored-by: Dean Herbert <pe@ppy.sh>
97 lines
3.5 KiB
C#
97 lines
3.5 KiB
C#
// 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.
|
|
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
using osu.Game.Online.API;
|
|
using osu.Game.Online.API.Requests;
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
|
|
using osu.Game.Online.Rooms;
|
|
using osu.Game.Rulesets;
|
|
using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay;
|
|
using osu.Game.Tests.Resources;
|
|
using osu.Game.Tests.Visual.Multiplayer;
|
|
|
|
namespace osu.Game.Tests.Visual.RankedPlay
|
|
{
|
|
public abstract partial class RankedPlayTestScene : MultiplayerTestScene
|
|
{
|
|
/// <summary>
|
|
/// Returns 5 sample of the chosen ruleset <see cref="APIBeatmap"/>s.
|
|
/// </summary>
|
|
protected static APIBeatmap[] GetSampleBeatmaps(RulesetInfo ruleset)
|
|
{
|
|
switch (ruleset.OnlineID)
|
|
{
|
|
case 3:
|
|
{
|
|
using var resourceStream = TestResources.OpenResource("Requests/api-beatmaps-rankedplay-mania4k.json");
|
|
using var reader = new StreamReader(resourceStream);
|
|
return JsonConvert.DeserializeObject<APIBeatmap[]>(reader.ReadToEnd())!;
|
|
}
|
|
|
|
default:
|
|
{
|
|
using var resourceStream = TestResources.OpenResource("Requests/api-beatmaps-rankedplay.json");
|
|
using var reader = new StreamReader(resourceStream);
|
|
return JsonConvert.DeserializeObject<APIBeatmap[]>(reader.ReadToEnd())!;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// A request handler that will resolve api requests to any beatmaps provided by <see cref="GetSampleBeatmaps"/>.
|
|
/// </summary>
|
|
public class BeatmapRequestHandler
|
|
{
|
|
public APIBeatmap[] Beatmaps;
|
|
|
|
public BeatmapRequestHandler(RulesetInfo ruleset)
|
|
{
|
|
Beatmaps = GetSampleBeatmaps(ruleset);
|
|
}
|
|
|
|
public bool HandleRequest(APIRequest request)
|
|
{
|
|
switch (request)
|
|
{
|
|
case GetBeatmapRequest beatmapRequest:
|
|
var beatmap = Beatmaps.FirstOrDefault(it => it.OnlineID == beatmapRequest.OnlineID);
|
|
|
|
if (beatmap != null)
|
|
{
|
|
beatmapRequest.TriggerSuccess(beatmap);
|
|
return true;
|
|
}
|
|
|
|
break;
|
|
|
|
case GetBeatmapsRequest beatmapsRequest:
|
|
beatmapsRequest.TriggerSuccess(new GetBeatmapsResponse
|
|
{
|
|
Beatmaps = beatmapsRequest
|
|
.BeatmapIds
|
|
.Select(id => Beatmaps.FirstOrDefault(it => it.OnlineID == id))
|
|
.ToList()
|
|
});
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public class RevealedRankedPlayCardWithPlaylistItem : RankedPlayCardWithPlaylistItem
|
|
{
|
|
public RevealedRankedPlayCardWithPlaylistItem(APIBeatmap beatmap, RankedPlayCardItem? card = null)
|
|
: base(card ?? new RankedPlayCardItem())
|
|
{
|
|
PlaylistItem.Value = new MultiplayerPlaylistItem(new PlaylistItem(beatmap));
|
|
}
|
|
}
|
|
}
|
|
}
|