public void TestDelayedStart()
        {
            AddStep("start players silently", () =>
            {
                OnlinePlayDependencies.MultiplayerClient.AddUser(new APIUser {
                    Id = PLAYER_1_ID
                }, true);
                OnlinePlayDependencies.MultiplayerClient.AddUser(new APIUser {
                    Id = PLAYER_2_ID
                }, true);

                playingUsers.Add(new MultiplayerRoomUser(PLAYER_1_ID));
                playingUsers.Add(new MultiplayerRoomUser(PLAYER_2_ID));
            });

            loadSpectateScreen(false);

            AddWaitStep("wait a bit", 10);
            AddStep("load player first_player_id", () => SpectatorClient.SendStartPlay(PLAYER_1_ID, importedBeatmapId));
            AddUntilStep("one player added", () => spectatorScreen.ChildrenOfType <Player>().Count() == 1);

            AddWaitStep("wait a bit", 10);
            AddStep("load player second_player_id", () => SpectatorClient.SendStartPlay(PLAYER_2_ID, importedBeatmapId));
            AddUntilStep("two players added", () => spectatorScreen.ChildrenOfType <Player>().Count() == 2);
        }
        public void TestTeamDisplay()
        {
            AddStep("start players", () =>
            {
                var player1 = OnlinePlayDependencies.MultiplayerClient.AddUser(new APIUser {
                    Id = PLAYER_1_ID
                }, true);
                player1.MatchState = new TeamVersusUserState
                {
                    TeamID = 0,
                };

                var player2 = OnlinePlayDependencies.MultiplayerClient.AddUser(new APIUser {
                    Id = PLAYER_2_ID
                }, true);
                player2.MatchState = new TeamVersusUserState
                {
                    TeamID = 1,
                };

                SpectatorClient.SendStartPlay(player1.UserID, importedBeatmapId);
                SpectatorClient.SendStartPlay(player2.UserID, importedBeatmapId);

                playingUsers.Add(player1);
                playingUsers.Add(player2);
            });

            loadSpectateScreen();

            sendFrames(PLAYER_1_ID, 1000);
            sendFrames(PLAYER_2_ID, 1000);

            AddWaitStep("wait a bit", 20);
        }
Example #3
0
        public new void SetUpSteps()
        {
            AddStep("reset", () =>
            {
                Clear();

                clocks = new Dictionary <int, ManualClock>
                {
                    { PLAYER_1_ID, new ManualClock() },
                    { PLAYER_2_ID, new ManualClock() }
                };

                foreach ((int userId, var _) in clocks)
                {
                    SpectatorClient.SendStartPlay(userId, 0);
                    OnlinePlayDependencies.MultiplayerClient.AddUser(new APIUser {
                        Id = userId
                    });
                }
            });

            AddStep("create leaderboard", () =>
            {
                Beatmap.Value      = CreateWorkingBeatmap(Ruleset.Value);
                var playable       = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
                var scoreProcessor = new OsuScoreProcessor();
                scoreProcessor.ApplyBeatmap(playable);

                LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(Ruleset.Value, scoreProcessor, clocks.Keys.Select(id => new MultiplayerRoomUser(id)).ToArray())
                {
                    Expanded = { Value = true }
                }, Add);
            });

            AddUntilStep("wait for load", () => leaderboard.IsLoaded);
            AddUntilStep("wait for user population", () => leaderboard.ChildrenOfType <GameplayLeaderboardScore>().Count() == 2);

            AddStep("add clock sources", () =>
            {
                foreach ((int userId, var clock) in clocks)
                {
                    leaderboard.AddClock(userId, clock);
                }
            });
        }
        private void start(int[] userIds, int?beatmapId = null)
        {
            AddStep("start play", () =>
            {
                foreach (int id in userIds)
                {
                    var user = new MultiplayerRoomUser(id)
                    {
                        User = new APIUser {
                            Id = id
                        },
                    };

                    OnlinePlayDependencies.MultiplayerClient.AddUser(user.User, true);
                    SpectatorClient.SendStartPlay(id, beatmapId ?? importedBeatmapId);

                    playingUsers.Add(user);
                }
            });
        }