Skip to content

Commit

Permalink
Merge pull request #28440 from bdach/daily-challenge/new-screen
Browse files Browse the repository at this point in the history
Add minimal viable new screen for daily challenge feature
  • Loading branch information
peppy committed Jun 12, 2024
2 parents 9048122 + 5e002fb commit 94b7148
Show file tree
Hide file tree
Showing 13 changed files with 497 additions and 60 deletions.
40 changes: 40 additions & 0 deletions osu.Game.Tests/Visual/DailyChallenge/TestSceneDailyChallenge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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;
using System.Linq;
using NUnit.Framework;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual.OnlinePlay;

namespace osu.Game.Tests.Visual.DailyChallenge
{
public partial class TestSceneDailyChallenge : OnlinePlayTestScene
{
[Test]
public void TestDailyChallenge()
{
var room = new Room
{
RoomID = { Value = 1234 },
Name = { Value = "Daily Challenge: June 4, 2024" },
Playlist =
{
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
{
RequiredMods = [new APIMod(new OsuModTraceable())],
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
},
EndDate = { Value = DateTimeOffset.Now.AddHours(12) },
Category = { Value = RoomCategory.DailyChallenge }
};

AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
AddStep("push screen", () => LoadScreen(new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));
}
}
}
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ public void TestLeaveNavigation()
}
});

AddStep("open mod overlay", () => this.ChildrenOfType<RoomSubScreen.UserModSelectButton>().Single().TriggerClick());
AddStep("open mod overlay", () => this.ChildrenOfType<UserModSelectButton>().Single().TriggerClick());

AddStep("invoke on back button", () => multiplayerComponents.OnBackButton());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void TestFreeModSelectionHasAllowedMods()

AddUntilStep("wait for join", () => RoomJoined);

ClickButtonWhenEnabled<RoomSubScreen.UserModSelectButton>();
ClickButtonWhenEnabled<UserModSelectButton>();

AddUntilStep("mod select contents loaded",
() => this.ChildrenOfType<ModColumn>().Any() && this.ChildrenOfType<ModColumn>().All(col => col.IsLoaded && col.ItemsLoaded));
Expand Down Expand Up @@ -311,7 +311,7 @@ public void TestModSelectOverlay()

AddUntilStep("wait for join", () => RoomJoined);

ClickButtonWhenEnabled<RoomSubScreen.UserModSelectButton>();
ClickButtonWhenEnabled<UserModSelectButton>();
AddAssert("mod select shows unranked", () => screen.UserModsSelectOverlay.ChildrenOfType<RankingInformationDisplay>().Single().Ranked.Value == false);
AddAssert("score multiplier = 1.20", () => screen.UserModsSelectOverlay.ChildrenOfType<RankingInformationDisplay>().Single().ModMultiplier.Value, () => Is.EqualTo(1.2).Within(0.01));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace osu.Game.Online.Rooms
/// </summary>
public partial class OnlinePlayBeatmapAvailabilityTracker : CompositeComponent
{
public readonly IBindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();

[Resolved]
private RealmAccess realm { get; set; } = null!;
Expand Down
5 changes: 2 additions & 3 deletions osu.Game/Screens/Menu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using osu.Game.Rulesets;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit;
using osu.Game.Screens.OnlinePlay.DailyChallenge;
using osu.Game.Screens.OnlinePlay.Multiplayer;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Select;
Expand Down Expand Up @@ -149,9 +150,7 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
OnPlaylists = () => this.Push(new Playlists()),
OnDailyChallenge = room =>
{
Playlists playlistsScreen;
this.Push(playlistsScreen = new Playlists());
playlistsScreen.Join(room);
this.Push(new DailyChallenge(room));
},
OnExit = () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ protected override Task Poll()

req.Success += result =>
{
result = result.Where(r => r.Category.Value != RoomCategory.DailyChallenge).ToList();
foreach (var existing in RoomManager.Rooms.ToArray())
{
if (result.All(r => r.RoomID.Value != existing.RoomID.Value))
Expand Down
Loading

0 comments on commit 94b7148

Please sign in to comment.