public void TestStartMatchWhileSpectating()
        {
            AddStep("set playlist", () =>
            {
                SelectedRoom.Value.Playlist.Add(new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
                {
                    RulesetID = new OsuRuleset().RulesetInfo.OnlineID
                });
            });

            ClickButtonWhenEnabled <MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();

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

            AddStep("join other user (ready)", () =>
            {
                MultiplayerClient.AddUser(new APIUser {
                    Id = PLAYER_1_ID
                });
                MultiplayerClient.ChangeUserState(PLAYER_1_ID, MultiplayerUserState.Ready);
            });

            ClickButtonWhenEnabled <MultiplayerSpectateButton>();

            AddUntilStep("wait for spectating user state", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Spectating);

            ClickButtonWhenEnabled <MultiplayerReadyButton>();

            AddUntilStep("match started", () => MultiplayerClient.Room?.State == MultiplayerRoomState.WaitingForLoad);
        }
        public void TestModOverlap()
        {
            AddStep("add dummy mods", () =>
            {
                MultiplayerClient.ChangeUserMods(new Mod[]
                {
                    new OsuModNoFail(),
                    new OsuModDoubleTime()
                });
            });

            AddStep("add user with mods", () =>
            {
                MultiplayerClient.AddUser(new APIUser
                {
                    Id                 = 0,
                    Username           = "******",
                    RulesetsStatistics = new Dictionary <string, UserStatistics>
                    {
                        {
                            Ruleset.Value.ShortName,
                            new UserStatistics {
                                GlobalRank = RNG.Next(1, 100000),
                            }
                        }
                    },
                    CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
                });
                MultiplayerClient.ChangeUserMods(0, new Mod[]
                {
                    new OsuModHardRock(),
                    new OsuModDoubleTime()
                });
            });

            AddStep("set 0 ready", () => MultiplayerClient.ChangeState(MultiplayerUserState.Ready));

            AddStep("set 1 spectate", () => MultiplayerClient.ChangeUserState(0, MultiplayerUserState.Spectating));

            // Have to set back to idle due to status priority.
            AddStep("set 0 no map, 1 ready", () =>
            {
                MultiplayerClient.ChangeState(MultiplayerUserState.Idle);
                MultiplayerClient.ChangeBeatmapAvailability(BeatmapAvailability.NotDownloaded());
                MultiplayerClient.ChangeUserState(0, MultiplayerUserState.Ready);
            });

            AddStep("set 0 downloading", () => MultiplayerClient.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(0)));

            AddStep("set 0 spectate", () => MultiplayerClient.ChangeUserState(0, MultiplayerUserState.Spectating));

            AddStep("make both default", () =>
            {
                MultiplayerClient.ChangeBeatmapAvailability(BeatmapAvailability.LocallyAvailable());
                MultiplayerClient.ChangeUserState(0, MultiplayerUserState.Idle);
                MultiplayerClient.ChangeState(MultiplayerUserState.Idle);
            });
        }
Exemple #3
0
 private void changeState(int userCount, MultiplayerUserState state)
 => AddStep($"{"user".ToQuantity(userCount)} in {state}", () =>
 {
     for (int i = 0; i < userCount; ++i)
     {
         int userId = MultiplayerClient.Room?.Users[i].UserID ?? throw new AssertionException("Room cannot be null!");
         MultiplayerClient.ChangeUserState(userId, state);
     }
 });
Exemple #4
0
        public void TestReadyButtonEnabledWhenHostAndUsersReady()
        {
            AddStep("add user", () => MultiplayerClient.AddUser(new APIUser {
                Id = PLAYER_1_ID
            }));
            AddStep("set user ready", () => MultiplayerClient.ChangeUserState(PLAYER_1_ID, MultiplayerUserState.Ready));

            ClickButtonWhenEnabled <MultiplayerSpectateButton>();
            assertReadyButtonEnablement(true);
        }
Exemple #5
0
        public void TestManyUsers()
        {
            const int users_count = 20;

            AddStep("add many users", () =>
            {
                for (int i = 0; i < users_count; i++)
                {
                    MultiplayerClient.AddUser(new APIUser
                    {
                        Id                 = i,
                        Username           = $"User {i}",
                        RulesetsStatistics = new Dictionary <string, UserStatistics>
                        {
                            {
                                Ruleset.Value.ShortName,
                                new UserStatistics {
                                    GlobalRank = RNG.Next(1, 100000),
                                }
                            }
                        },
                        CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
                    });

                    MultiplayerClient.ChangeUserState(i, (MultiplayerUserState)RNG.Next(0, (int)MultiplayerUserState.Results + 1));

                    if (RNG.NextBool())
                    {
                        var beatmapState = (DownloadState)RNG.Next(0, (int)DownloadState.LocallyAvailable + 1);

                        switch (beatmapState)
                        {
                        case DownloadState.NotDownloaded:
                            MultiplayerClient.ChangeUserBeatmapAvailability(i, BeatmapAvailability.NotDownloaded());
                            break;

                        case DownloadState.Downloading:
                            MultiplayerClient.ChangeUserBeatmapAvailability(i, BeatmapAvailability.Downloading(RNG.NextSingle()));
                            break;

                        case DownloadState.Importing:
                            MultiplayerClient.ChangeUserBeatmapAvailability(i, BeatmapAvailability.Importing());
                            break;
                        }
                    }
                }
            });

            AddRepeatStep("switch hosts", () => MultiplayerClient.TransferHost(RNG.Next(0, users_count)), 10);
            AddStep("give host back", () => MultiplayerClient.TransferHost(API.LocalUser.Value.Id));
        }
        private void verifyGameplayStartFlow()
        {
            AddUntilStep("user is ready", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Ready);
            ClickButtonWhenEnabled <MultiplayerReadyButton>();
            AddUntilStep("user waiting for load", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.WaitingForLoad);

            AddStep("finish gameplay", () =>
            {
                MultiplayerClient.ChangeUserState(MultiplayerClient.Room?.Users[0].UserID ?? 0, MultiplayerUserState.Loaded);
                MultiplayerClient.ChangeUserState(MultiplayerClient.Room?.Users[0].UserID ?? 0, MultiplayerUserState.FinishedPlay);
            });

            AddUntilStep("ready button enabled", () => control.ChildrenOfType <OsuButton>().Single().Enabled.Value);
        }
Exemple #7
0
        public void TestReadyButtonDisabledWhenNotHostAndUsersReady()
        {
            AddStep("add user and transfer host", () =>
            {
                MultiplayerClient.AddUser(new APIUser {
                    Id = PLAYER_1_ID
                });
                MultiplayerClient.TransferHost(PLAYER_1_ID);
            });

            AddStep("set user ready", () => MultiplayerClient.ChangeUserState(PLAYER_1_ID, MultiplayerUserState.Ready));

            ClickButtonWhenEnabled <MultiplayerSpectateButton>();
            assertReadyButtonEnablement(false);
        }
        public void TestCountdownWhileSpectating()
        {
            AddStep("set spectating", () => MultiplayerClient.ChangeUserState(API.LocalUser.Value.OnlineID, MultiplayerUserState.Spectating));
            AddUntilStep("local user is spectating", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Spectating);

            AddAssert("countdown button is visible", () => this.ChildrenOfType <MultiplayerCountdownButton>().Single().IsPresent);
            AddAssert("countdown button enabled", () => this.ChildrenOfType <MultiplayerCountdownButton>().Single().Enabled.Value);

            AddStep("add second user", () => MultiplayerClient.AddUser(new APIUser {
                Id = 2, Username = "******"
            }));
            AddAssert("countdown button enabled", () => this.ChildrenOfType <MultiplayerCountdownButton>().Single().Enabled.Value);

            AddStep("set second user ready", () => MultiplayerClient.ChangeUserState(2, MultiplayerUserState.Ready));
            AddAssert("countdown button enabled", () => this.ChildrenOfType <MultiplayerCountdownButton>().Single().Enabled.Value);
        }
        public void TestUserWithMods()
        {
            AddStep("add user", () =>
            {
                MultiplayerClient.AddUser(new APIUser
                {
                    Id                 = 0,
                    Username           = "******",
                    RulesetsStatistics = new Dictionary <string, UserStatistics>
                    {
                        {
                            Ruleset.Value.ShortName,
                            new UserStatistics {
                                GlobalRank = RNG.Next(1, 100000),
                            }
                        }
                    },
                    CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
                });

                MultiplayerClient.ChangeUserMods(0, new Mod[]
                {
                    new OsuModHardRock(),
                    new OsuModDifficultyAdjust {
                        ApproachRate = { Value = 1 }
                    }
                });
            });

            for (var i = MultiplayerUserState.Idle; i < MultiplayerUserState.Results; i++)
            {
                var state = i;
                AddStep($"set state: {state}", () => MultiplayerClient.ChangeUserState(0, state));
            }

            AddStep("set state: downloading", () => MultiplayerClient.ChangeUserBeatmapAvailability(0, BeatmapAvailability.Downloading(0)));

            AddStep("set state: locally available", () => MultiplayerClient.ChangeUserBeatmapAvailability(0, BeatmapAvailability.LocallyAvailable()));
        }
        public void TestManyUsersChangingState(bool isHost)
        {
            const int users = 10;

            AddStep("setup", () =>
            {
                MultiplayerClient.TransferHost(MultiplayerClient.Room?.Users[0].UserID ?? 0);
                for (int i = 0; i < users; i++)
                {
                    MultiplayerClient.AddUser(new APIUser {
                        Id = i, Username = "******"
                    });
                }
            });

            if (!isHost)
            {
                AddStep("transfer host", () => MultiplayerClient.TransferHost(2));
            }

            ClickButtonWhenEnabled <MultiplayerReadyButton>();

            AddRepeatStep("change user ready state", () =>
            {
                MultiplayerClient.ChangeUserState(RNG.Next(0, users), RNG.NextBool() ? MultiplayerUserState.Ready : MultiplayerUserState.Idle);
            }, 20);

            AddRepeatStep("ready all users", () =>
            {
                var nextUnready = MultiplayerClient.Room?.Users.FirstOrDefault(c => c.State == MultiplayerUserState.Idle);
                if (nextUnready != null)
                {
                    MultiplayerClient.ChangeUserState(nextUnready.UserID, MultiplayerUserState.Ready);
                }
            }, users);
        }