Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.0.x"
- name: Set Xcode version
run: sudo xcode-select -s /Applications/Xcode_26.3.app

- name: Install .NET Workloads
run: dotnet workload install ios
Expand Down
10 changes: 3 additions & 7 deletions osu.Game.Tests/Visual/DailyChallenge/TestSceneDailyChallenge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void TestDailyChallenge()
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
],
StartDate = DateTimeOffset.Now.AddSeconds(-10),
EndDate = DateTimeOffset.Now.AddHours(12),
Category = RoomCategory.DailyChallenge
};
Expand All @@ -75,7 +74,6 @@ public void TestUseTheseModsUnavailableIfNoFreeMods()
AllowedMods = []
}
],
StartDate = DateTimeOffset.Now.AddSeconds(-10),
EndDate = DateTimeOffset.Now.AddHours(12),
Category = RoomCategory.DailyChallenge
};
Expand Down Expand Up @@ -108,19 +106,18 @@ public void TestNotifications()
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
],
StartDate = DateTimeOffset.Now.AddSeconds(-10),
EndDate = DateTimeOffset.Now.AddHours(12),
Category = RoomCategory.DailyChallenge
};

AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = (room.RoomID ?? 0) });
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = room.RoomID!.Value });

Screens.OnlinePlay.DailyChallenge.DailyChallenge screen = null!;
AddStep("push screen", () => LoadScreen(screen = new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));
AddUntilStep("wait for screen", () => screen.IsCurrentScreen());
AddStep("daily challenge ended", () => metadataClient.DailyChallengeInfo.Value = null);
AddUntilStep("notification posted", () => notificationOverlay.AllNotifications.OfType<SimpleNotification>().Any(n => n.Text == DailyChallengeStrings.ChallengeEndedNotification));
AddAssert("notification posted", () => notificationOverlay.AllNotifications.OfType<SimpleNotification>().Any(n => n.Text == DailyChallengeStrings.ChallengeEndedNotification));
}

[Test]
Expand All @@ -137,13 +134,12 @@ public void TestConclusionNotificationDoesNotFireOnDisconnect()
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
],
StartDate = DateTimeOffset.Now.AddSeconds(-10),
EndDate = DateTimeOffset.Now.AddHours(12),
Category = RoomCategory.DailyChallenge
};

AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = (room.RoomID ?? 0) });
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = room.RoomID!.Value });

Screens.OnlinePlay.DailyChallenge.DailyChallenge screen = null!;
AddStep("push screen", () => LoadScreen(screen = new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public void TestBasicAppearance()
CoverUrl = TestResources.COVER_IMAGE_3,
}, RNG.Next(1_000_000), RNG.Next(11, 1000));


var testScore = TestResources.CreateTestScoreInfo();
testScore.TotalScore = RNG.Next(1_000_000);

feed.AddNewScore(ev);
}, 50);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Online.API;
using osu.Game.Online.Metadata;
Expand All @@ -19,6 +17,7 @@
using osu.Game.Tests.Visual.OnlinePlay;
using osuTK.Graphics;
using osuTK.Input;
using CreateRoomRequest = osu.Game.Online.Rooms.CreateRoomRequest;

namespace osu.Game.Tests.Visual.DailyChallenge
{
Expand All @@ -30,7 +29,7 @@ public partial class TestSceneDailyChallengeIntro : OnlinePlayTestScene
[Cached(typeof(INotificationOverlay))]
private NotificationOverlay notificationOverlay = new NotificationOverlay();

private Room? room;
private Room room = null!;

[BackgroundDependencyLoader]
private void load()
Expand All @@ -45,45 +44,31 @@ private void load()
[Test]
public void TestDailyChallenge()
{
startChallenge("first");
AddUntilStep("wait for button room", () => this.ChildrenOfType<DailyChallengeButton>().FirstOrDefault()?.Room?.RoomID == room?.RoomID);
AddStep("push screen", () =>
{
if (room != null)
LoadScreen(new DailyChallengeIntro(room));
});
startChallenge();
AddStep("push screen", () => LoadScreen(new DailyChallengeIntro(room)));
}

[Test]
public void TestPlayIntroOnceFlag()
{
startChallenge("first");
AddUntilStep("wait for first button room", () => this.ChildrenOfType<DailyChallengeButton>().FirstOrDefault()?.Room?.RoomID == room?.RoomID);

startChallenge();
AddStep("set intro played flag", () => Dependencies.Get<SessionStatics>().SetValue(Static.DailyChallengeIntroPlayed, true));
AddAssert("intro played flag is true", () => Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed));

startChallenge("second");
startChallenge();

AddUntilStep("wait for button to update to second room", () => this.ChildrenOfType<DailyChallengeButton>().FirstOrDefault()?.Room?.RoomID == room?.RoomID);
AddUntilStep("intro played flag reset", () => !Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed));
AddAssert("intro played flag reset", () => Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed), () => Is.False);

AddStep("push screen", () =>
{
if (room != null)
LoadScreen(new DailyChallengeIntro(room));
});
AddStep("push screen", () => LoadScreen(new DailyChallengeIntro(room)));
AddUntilStep("intro played flag set", () => Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed), () => Is.True);
}

private void startChallenge(string suffix)
private void startChallenge()
{
AddStep($"reset info ({suffix})", () => metadataClient.DailyChallengeUpdated(null!));
AddStep($"reset room ({suffix})", () => room = null);
AddStep($"add room ({suffix})", () =>
AddStep("add room", () =>
{
var newRoom = new Room
API.Perform(new CreateRoomRequest(room = new Room
{
Name = $"Daily Challenge {suffix}",
Name = "Daily Challenge: June 4, 2024",
Playlist =
[
new PlaylistItem(CreateAPIBeatmap(new OsuRuleset().RulesetInfo))
Expand All @@ -92,20 +77,12 @@ private void startChallenge(string suffix)
AllowedMods = [new APIMod(new OsuModDoubleTime())]
}
],
StartDate = DateTimeOffset.Now.AddSeconds(-10),
StartDate = DateTimeOffset.Now,
EndDate = DateTimeOffset.Now.AddHours(24),
Category = RoomCategory.DailyChallenge
};
room = newRoom;
API.Perform(new CreateRoomRequest(newRoom));
});
AddUntilStep($"wait for room id ({suffix})", () => room?.RoomID is > 0);
AddUntilStep($"wait for playlist id ({suffix})", () => room?.Playlist.All(p => p.ID > 0) is true);
AddStep($"signal client ({suffix})", () =>
{
if (room?.RoomID is long roomId)
metadataClient.DailyChallengeUpdated(new DailyChallengeInfo { RoomID = roomId });
}));
});
AddStep("signal client", () => metadataClient.DailyChallengeUpdated(new DailyChallengeInfo { RoomID = room.RoomID!.Value }));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public void TestBasicAppearance()
CoverUrl = TestResources.COVER_IMAGE_3,
}, RNG.Next(1_000_000), RNG.Next(11, 1000));

var testScore = TestResources.CreateTestScoreInfo();
testScore.TotalScore = RNG.Next(1_000_000);

totals.AddNewScore(ev);
}
Expand Down
8 changes: 4 additions & 4 deletions osu.Game/Online/Multiplayer/MultiplayerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private set
/// <summary>
/// The <see cref="MultiplayerRoomUser"/> corresponding to the local player, if available.
/// </summary>
public virtual MultiplayerRoomUser? LocalUser => Room?.Users.FirstOrDefault(u => u.UserID == API.LocalUser.Value.Id);
public virtual MultiplayerRoomUser? LocalUser => Room?.Users.SingleOrDefault(u => u.User?.Id == API.LocalUser.Value.Id);

/// <summary>
/// Whether the <see cref="LocalUser"/> is the host in <see cref="Room"/>.
Expand Down Expand Up @@ -288,7 +288,7 @@ private async Task setupJoinedRoom(Room apiRoom, MultiplayerRoom joinedRoom, Can
// Populate users.
await PopulateUsers(joinedRoom.Users).ConfigureAwait(false);
if (joinedRoom.Host != null)
await PopulateUsers(new[] { joinedRoom.Host }).ConfigureAwait(false);
await PopulateUsers([joinedRoom.Host]).ConfigureAwait(false);

// Update the stored room (must be done on update thread for thread-safety).
await runOnUpdateThreadAsync(() =>
Expand All @@ -310,8 +310,8 @@ await runOnUpdateThreadAsync(() =>
// The server will null out the end date upon the host joining the room, but the null value is never communicated to the client.
APIRoom.EndDate = null;

var localUser = LocalUser;
if (localUser != null) addUserToAPIRoom(localUser);
Debug.Assert(LocalUser != null);
addUserToAPIRoom(LocalUser);

foreach (var user in joinedRoom.Users)
updateUserPlayingState(user.UserID, user.State);
Expand Down
7 changes: 2 additions & 5 deletions osu.Game/Screens/Menu/DailyChallengeButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ private void dailyChallengeChanged(ValueChangedEvent<DailyChallengeInfo?> _)
}
else
{
if (info.Value is not DailyChallengeInfo infoValue) return;

var roomRequest = new GetRoomRequest(infoValue.RoomID);
var roomRequest = new GetRoomRequest(info.Value.Value.RoomID);

roomRequest.Success += room =>
{
Expand All @@ -166,14 +164,13 @@ private void dailyChallengeChanged(ValueChangedEvent<DailyChallengeInfo?> _)
statics.SetValue(Static.DailyChallengeIntroPlayed, false);

// we only want to notify the user if the new challenge just went live.
if (room.StartDate != null && Math.Abs((DateTimeOffset.Now - (room.StartDate ?? DateTimeOffset.Now)).TotalSeconds) < 1800)
if (Math.Abs((DateTimeOffset.Now - room.StartDate.Value).TotalSeconds) < 1800)
notificationOverlay?.Post(new NewDailyChallengeNotification(room));
}

updateCountdown();
Scheduler.AddDelayed(updateCountdown, 1000, true);
};

api.Queue(roomRequest);
}
}
Expand Down
Loading
Loading