mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:42:54 +08:00
Add testing setup to get a better visual idea of how scoreboard will work
fixup! Add method to ScoreProcessor to calculate score and accuracy from statistics
This commit is contained in:
parent
d009a0be51
commit
09d0ceb766
@ -2,14 +2,18 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Database;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
|
using osu.Game.Replays.Legacy;
|
||||||
using osu.Game.Rulesets.Osu.Scoring;
|
using osu.Game.Rulesets.Osu.Scoring;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
@ -17,7 +21,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public class TestSceneSpectatorDrivenLeaderboard : OsuTestScene
|
public class TestSceneSpectatorDrivenLeaderboard : OsuTestScene
|
||||||
{
|
{
|
||||||
[Cached(typeof(SpectatorStreamingClient))]
|
[Cached(typeof(SpectatorStreamingClient))]
|
||||||
private TestSceneSpectator.TestSpectatorStreamingClient testSpectatorStreamingClient = new TestSceneSpectator.TestSpectatorStreamingClient();
|
private TestMultiplayerStreaming streamingClient = new TestMultiplayerStreaming(16);
|
||||||
|
|
||||||
// used just to show beatmap card for the time being.
|
// used just to show beatmap card for the time being.
|
||||||
protected override bool UseOnlineAPI => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
@ -27,7 +31,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
OsuScoreProcessor scoreProcessor;
|
OsuScoreProcessor scoreProcessor;
|
||||||
|
|
||||||
testSpectatorStreamingClient.StartPlay(55);
|
streamingClient.Start(Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -38,37 +42,90 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
|
||||||
|
|
||||||
|
var playable = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
|
||||||
|
|
||||||
|
scoreProcessor.ApplyBeatmap(playable);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
public class MultiplayerGameplayLeaderboard : GameplayLeaderboard
|
[Test]
|
||||||
{
|
public void TestScoreUpdates()
|
||||||
private readonly OsuScoreProcessor scoreProcessor;
|
|
||||||
|
|
||||||
public MultiplayerGameplayLeaderboard(OsuScoreProcessor scoreProcessor)
|
|
||||||
{
|
{
|
||||||
this.scoreProcessor = scoreProcessor;
|
AddRepeatStep("update state", () => streamingClient.RandomlyUpdateState(), 100);
|
||||||
|
|
||||||
AddPlayer(new BindableDouble(), new GuestUser());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
public class TestMultiplayerStreaming : SpectatorStreamingClient
|
||||||
private SpectatorStreamingClient streamingClient { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private UserLookupCache userLookupCache { get; set; }
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("got here");
|
public new BindableList<int> PlayingUsers => (BindableList<int>)base.PlayingUsers;
|
||||||
|
|
||||||
foreach (var user in streamingClient.PlayingUsers)
|
private readonly int totalUsers;
|
||||||
|
|
||||||
|
public TestMultiplayerStreaming(int totalUsers)
|
||||||
{
|
{
|
||||||
streamingClient.WatchUser(user);
|
this.totalUsers = totalUsers;
|
||||||
var resolvedUser = userLookupCache.GetUserAsync(user).Result;
|
|
||||||
AddPlayer(new BindableDouble(), resolvedUser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Start(int beatmapId)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < totalUsers; i++)
|
||||||
|
{
|
||||||
|
((ISpectatorClient)this).UserBeganPlaying(i, new SpectatorState
|
||||||
|
{
|
||||||
|
BeatmapID = beatmapId,
|
||||||
|
RulesetID = 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Dictionary<int, FrameHeader> lastHeaders = new Dictionary<int, FrameHeader>();
|
||||||
|
|
||||||
|
public void RandomlyUpdateState()
|
||||||
|
{
|
||||||
|
foreach (var userId in PlayingUsers)
|
||||||
|
{
|
||||||
|
if (RNG.Next(0, 1) == 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!lastHeaders.TryGetValue(userId, out var header))
|
||||||
|
{
|
||||||
|
lastHeaders[userId] = header = new FrameHeader(new ScoreInfo
|
||||||
|
{
|
||||||
|
Statistics = new Dictionary<HitResult, int>(new[]
|
||||||
|
{
|
||||||
|
new KeyValuePair<HitResult, int>(HitResult.Miss, 0),
|
||||||
|
new KeyValuePair<HitResult, int>(HitResult.Meh, 0),
|
||||||
|
new KeyValuePair<HitResult, int>(HitResult.Great, 0)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (RNG.Next(0, 3))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
header.Combo = 0;
|
||||||
|
header.Statistics[HitResult.Miss]++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
header.Combo++;
|
||||||
|
header.MaxCombo = Math.Max(header.MaxCombo, header.Combo);
|
||||||
|
header.Statistics[HitResult.Meh]++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
header.Combo++;
|
||||||
|
header.MaxCombo = Math.Max(header.MaxCombo, header.Combo);
|
||||||
|
header.Statistics[HitResult.Great]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
((ISpectatorClient)this).UserSentFrames(userId, new FrameDataBundle(header, Array.Empty<LegacyReplayFrame>()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Task Connect() => Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -90,7 +89,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
if (LastHeader == null)
|
if (LastHeader == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(Score.Value, Accuracy.Value) = processor.GetScoreAndAccuracy(mode, LastHeader.MaxCombo, LastHeader.Statistics.ToDictionary(s => s.Result, s => s.Count));
|
(Score.Value, Accuracy.Value) = processor.GetScoreAndAccuracy(mode, LastHeader.MaxCombo, LastHeader.Statistics);
|
||||||
|
|
||||||
CurrentCombo.Value = LastHeader.Combo;
|
CurrentCombo.Value = LastHeader.Combo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user