mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 16:12:54 +08:00
Add DailyChallengeButton
for intro played flag reset logic
This commit is contained in:
parent
f5e195a7ee
commit
b54487031a
@ -2,7 +2,6 @@
|
||||
// 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.Game.Configuration;
|
||||
@ -10,11 +9,14 @@ using osu.Game.Online.API;
|
||||
using osu.Game.Online.Metadata;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.OnlinePlay.DailyChallenge;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Tests.Visual.Metadata;
|
||||
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
|
||||
@ -32,23 +34,27 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
base.Content.Add(notificationOverlay);
|
||||
base.Content.Add(metadataClient);
|
||||
Add(notificationOverlay);
|
||||
Add(metadataClient);
|
||||
|
||||
// add button to observe for daily challenge changes and perform its logic.
|
||||
Add(new DailyChallengeButton(@"button-default-select", new Color4(102, 68, 204, 255), _ => { }, 0, Key.D));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDailyChallenge()
|
||||
{
|
||||
startChallenge();
|
||||
startChallenge(1234);
|
||||
AddStep("push screen", () => LoadScreen(new DailyChallengeIntro(room)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPlayIntroOnceFlag()
|
||||
{
|
||||
startChallenge(1234);
|
||||
AddStep("set intro played flag", () => Dependencies.Get<SessionStatics>().SetValue(Static.DailyChallengeIntroPlayed, true));
|
||||
|
||||
startChallenge();
|
||||
startChallenge(1235);
|
||||
|
||||
AddAssert("intro played flag reset", () => Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed), () => Is.False);
|
||||
|
||||
@ -56,25 +62,28 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
AddUntilStep("intro played flag set", () => Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed), () => Is.True);
|
||||
}
|
||||
|
||||
private void startChallenge()
|
||||
private void startChallenge(int roomId)
|
||||
{
|
||||
room = new Room
|
||||
AddStep("add room", () =>
|
||||
{
|
||||
RoomID = { Value = 1234 },
|
||||
Name = { Value = "Daily Challenge: June 4, 2024" },
|
||||
Playlist =
|
||||
API.Perform(new CreateRoomRequest(room = new Room
|
||||
{
|
||||
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
|
||||
RoomID = { Value = roomId },
|
||||
Name = { Value = "Daily Challenge: June 4, 2024" },
|
||||
Playlist =
|
||||
{
|
||||
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)));
|
||||
new PlaylistItem(CreateAPIBeatmap(new OsuRuleset().RulesetInfo))
|
||||
{
|
||||
RequiredMods = [new APIMod(new OsuModTraceable())],
|
||||
AllowedMods = [new APIMod(new OsuModDoubleTime())]
|
||||
}
|
||||
},
|
||||
StartDate = { Value = DateTimeOffset.Now },
|
||||
EndDate = { Value = DateTimeOffset.Now.AddHours(24) },
|
||||
Category = { Value = RoomCategory.DailyChallenge }
|
||||
}));
|
||||
});
|
||||
AddStep("signal client", () => metadataClient.DailyChallengeUpdated(new DailyChallengeInfo { RoomID = roomId }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Tests.Visual.OnlinePlay
|
||||
{
|
||||
@ -277,11 +278,18 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
||||
var result = JsonConvert.DeserializeObject<Room>(JsonConvert.SerializeObject(source));
|
||||
Debug.Assert(result != null);
|
||||
|
||||
// Playlist item IDs aren't serialised.
|
||||
// Playlist item IDs and beatmaps aren't serialised.
|
||||
if (source.CurrentPlaylistItem.Value != null)
|
||||
{
|
||||
result.CurrentPlaylistItem.Value = result.CurrentPlaylistItem.Value.With(new Optional<IBeatmapInfo>(source.CurrentPlaylistItem.Value.Beatmap));
|
||||
result.CurrentPlaylistItem.Value.ID = source.CurrentPlaylistItem.Value.ID;
|
||||
}
|
||||
|
||||
for (int i = 0; i < source.Playlist.Count; i++)
|
||||
{
|
||||
result.Playlist[i] = result.Playlist[i].With(new Optional<IBeatmapInfo>(source.Playlist[i].Beatmap));
|
||||
result.Playlist[i].ID = source.Playlist[i].ID;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Utils
|
||||
/// </remarks>
|
||||
public readonly bool HasValue;
|
||||
|
||||
private Optional(T value)
|
||||
public Optional(T value)
|
||||
{
|
||||
Value = value;
|
||||
HasValue = true;
|
||||
|
Loading…
Reference in New Issue
Block a user