public async Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability)
        {
            using (var userUsage = await GetOrCreateLocalUserState())
                using (var roomUsage = await getLocalUserRoom(userUsage.Item))
                {
                    var room = roomUsage.Item;

                    if (room == null)
                    {
                        throw new InvalidOperationException("Attempted to operate on a null room");
                    }

                    var user = room.Users.Find(u => u.UserID == CurrentContextUserId);

                    if (user == null)
                    {
                        throw new InvalidOperationException("Local user was not found in the expected room");
                    }

                    if (user.BeatmapAvailability.Equals(newBeatmapAvailability))
                    {
                        return;
                    }

                    user.BeatmapAvailability = newBeatmapAvailability;

                    await Clients.Group(GetGroupId(room.RoomID)).UserBeatmapAvailabilityChanged(CurrentContextUserId, newBeatmapAvailability);
                }
        }
Beispiel #2
0
        private void showBeatmapAvailability(BeatmapAvailability availability)
        {
            switch (availability.State)
            {
            default:
                this.FadeOut(fade_time);
                break;

            case DownloadState.NotDownloaded:
                text.Text   = "no map";
                icon.Icon   = FontAwesome.Solid.MinusCircle;
                icon.Colour = colours.RedLight;
                break;

            case DownloadState.Downloading:
                Debug.Assert(availability.DownloadProgress != null);

                progressBar.FadeIn(fade_time);
                progressBar.CurrentTime = availability.DownloadProgress.Value;

                text.Text   = "downloading map";
                icon.Icon   = FontAwesome.Solid.ArrowAltCircleDown;
                icon.Colour = colours.Blue;
                break;

            case DownloadState.Importing:
                text.Text   = "importing map";
                icon.Icon   = FontAwesome.Solid.ArrowAltCircleDown;
                icon.Colour = colours.Yellow;
                break;
            }
        }
Beispiel #3
0
        public async Task OnlyClientsInSameRoomReceiveAvailabilityChange()
        {
            await Hub.JoinRoom(ROOM_ID);

            SetUserContext(ContextUser2);
            await Hub.JoinRoom(ROOM_ID_2);

            var user1Availability = BeatmapAvailability.Importing();
            var user2Availability = BeatmapAvailability.Downloading(0.5f);

            SetUserContext(ContextUser);
            await Hub.ChangeBeatmapAvailability(user1Availability);

            using (var room = await Rooms.GetForUse(ROOM_ID))
                Assert.True(room.Item?.Users.Single().BeatmapAvailability.Equals(user1Availability));

            SetUserContext(ContextUser2);
            await Hub.ChangeBeatmapAvailability(user2Availability);

            using (var room2 = await Rooms.GetForUse(ROOM_ID_2))
                Assert.True(room2.Item?.Users.Single().BeatmapAvailability.Equals(user2Availability));

            Receiver.Verify(c1 => c1.UserBeatmapAvailabilityChanged(USER_ID, It.Is <BeatmapAvailability>(b => b.Equals(user1Availability))), Times.Once);
            Receiver.Verify(c1 => c1.UserBeatmapAvailabilityChanged(USER_ID_2, It.Is <BeatmapAvailability>(b => b.Equals(user2Availability))), Times.Never);
        }
Beispiel #4
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            SelectedItem.BindTo(client.CurrentMatchPlayingItem);

            BeatmapAvailability.BindValueChanged(updateBeatmapAvailability, true);
            UserMods.BindValueChanged(onUserModsChanged);

            client.LoadRequested += onLoadRequested;
            client.RoomUpdated   += onRoomUpdated;

            isConnected.BindTo(client.IsConnected);
            isConnected.BindValueChanged(connected =>
            {
                if (!connected.NewValue)
                {
                    Schedule(this.Exit);
                }
            }, true);

            currentRoom.BindValueChanged(room =>
            {
                if (room.NewValue == null)
                {
                    // the room has gone away.
                    // this could mean something happened during the join process, or an external connection issue occurred.
                    // one specific scenario is where the underlying room is created, but the signalr server returns an error during the join process. this triggers a PartRoom operation (see https://github.com/ppy/osu/blob/7654df94f6f37b8382be7dfcb4f674e03bd35427/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomManager.cs#L97)
                    Schedule(this.Exit);
                }
            }, true);
        }
Beispiel #5
0
        public async Task OnlyClientsInSameRoomReceiveAvailabilityChange()
        {
            await hub.JoinRoom(room_id);

            setUserContext(mockContextUser2);
            await hub.JoinRoom(room_id_2);

            var user1Availability = BeatmapAvailability.Importing();
            var user2Availability = BeatmapAvailability.Downloading(0.5f);

            setUserContext(mockContextUser1);
            await hub.ChangeBeatmapAvailability(user1Availability);

            using (var room = await hub.RoomStore.GetForUse(room_id))
                Assert.True(room.Item?.Users.Single().BeatmapAvailability.Equals(user1Availability));

            setUserContext(mockContextUser2);
            await hub.ChangeBeatmapAvailability(user2Availability);

            using (var room2 = await hub.RoomStore.GetForUse(room_id_2))
                Assert.True(room2.Item?.Users.Single().BeatmapAvailability.Equals(user2Availability));

            mockReceiver.Verify(c1 => c1.UserBeatmapAvailabilityChanged(user_id, It.Is <BeatmapAvailability>(b => b.Equals(user1Availability))), Times.Once);
            mockReceiver.Verify(c1 => c1.UserBeatmapAvailabilityChanged(user_id_2, It.Is <BeatmapAvailability>(b => b.Equals(user2Availability))), Times.Never);
        }
Beispiel #6
0
        public void UpdateStatus(MultiplayerUserState state, BeatmapAvailability availability)
        {
            // the only case where the progress bar is used does its own local fade in.
            // starting by fading out is a sane default.
            progressBar.FadeOut(fade_time);
            this.FadeIn(fade_time);

            switch (state)
            {
            case MultiplayerUserState.Idle:
                showBeatmapAvailability(availability);
                break;

            case MultiplayerUserState.Ready:
                text.Text   = "ready";
                icon.Icon   = FontAwesome.Solid.CheckCircle;
                icon.Colour = Color4Extensions.FromHex("#AADD00");
                break;

            case MultiplayerUserState.WaitingForLoad:
                text.Text   = "loading";
                icon.Icon   = FontAwesome.Solid.PauseCircle;
                icon.Colour = colours.Yellow;
                break;

            case MultiplayerUserState.Loaded:
            case MultiplayerUserState.ReadyForGameplay:
                text.Text   = "loaded";
                icon.Icon   = FontAwesome.Solid.DotCircle;
                icon.Colour = colours.YellowLight;
                break;

            case MultiplayerUserState.Playing:
                text.Text   = "playing";
                icon.Icon   = FontAwesome.Solid.PlayCircle;
                icon.Colour = colours.BlueLight;
                break;

            case MultiplayerUserState.FinishedPlay:
                text.Text   = "results pending";
                icon.Icon   = FontAwesome.Solid.ArrowAltCircleUp;
                icon.Colour = colours.BlueLighter;
                break;

            case MultiplayerUserState.Results:
                text.Text   = "results";
                icon.Icon   = FontAwesome.Solid.ArrowAltCircleUp;
                icon.Colour = colours.BlueLighter;
                break;

            case MultiplayerUserState.Spectating:
                text.Text   = "spectating";
                icon.Icon   = FontAwesome.Solid.Binoculars;
                icon.Colour = colours.BlueLight;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(state), state, null);
            }
        }
Beispiel #7
0
        public void TestModOverlap()
        {
            AddStep("add dummy mods", () =>
            {
                Client.ChangeUserMods(new Mod[]
                {
                    new OsuModNoFail(),
                    new OsuModDoubleTime()
                });
            });

            AddStep("add user with mods", () =>
            {
                Client.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",
                });
                Client.ChangeUserMods(0, new Mod[]
                {
                    new OsuModHardRock(),
                    new OsuModDoubleTime()
                });
            });

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

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

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

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

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

            AddStep("make both default", () =>
            {
                Client.ChangeBeatmapAvailability(BeatmapAvailability.LocallyAvailable());
                Client.ChangeUserState(0, MultiplayerUserState.Idle);
                Client.ChangeState(MultiplayerUserState.Idle);
            });
        }
Beispiel #8
0
        public override Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability)
        {
            if (!isConnected.Value)
            {
                return(Task.CompletedTask);
            }

            return(connection.InvokeAsync(nameof(IMultiplayerServer.ChangeBeatmapAvailability), newBeatmapAvailability));
        }
Beispiel #9
0
        public Task UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability)
        {
            if (userId == this.UserID)
            {
                BeatmapAvailability = beatmapAvailability;
            }

            return(Task.CompletedTask);
        }
Beispiel #10
0
        public void TestDeletedBeatmapDisableReady()
        {
            AddUntilStep("ready button enabled", () => readyButton.Enabled.Value);

            AddStep("mark beatmap not available", () => beatmapAvailability.Value = BeatmapAvailability.NotDownloaded());
            AddUntilStep("ready button disabled", () => !readyButton.Enabled.Value);

            AddStep("mark beatmap available", () => beatmapAvailability.Value = BeatmapAvailability.LocallyAvailable());
            AddUntilStep("ready button enabled back", () => readyButton.Enabled.Value);
        }
        public void TestGameStateHasPriorityOverDownloadState()
        {
            AddStep("set to downloading map", () => Client.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(0)));
            checkProgressBarVisibility(true);

            AddStep("make user ready", () => Client.ChangeState(MultiplayerUserState.Results));
            checkProgressBarVisibility(false);
            AddUntilStep("ready mark visible", () => this.ChildrenOfType <StateDisplay>().Single().IsPresent);

            AddStep("make user ready", () => Client.ChangeState(MultiplayerUserState.Idle));
            checkProgressBarVisibility(true);
        }
Beispiel #12
0
        public async Task AvailabilityChangeBroadcastedOnlyOnChange()
        {
            await Hub.JoinRoom(ROOM_ID);

            await Hub.ChangeBeatmapAvailability(BeatmapAvailability.Importing());

            Receiver.Verify(b => b.UserBeatmapAvailabilityChanged(USER_ID, It.Is <BeatmapAvailability>(b2 => b2.State == DownloadState.Importing)), Times.Once);

            // should not fire a second time.
            await Hub.ChangeBeatmapAvailability(BeatmapAvailability.Importing());

            Receiver.Verify(b => b.UserBeatmapAvailabilityChanged(USER_ID, It.Is <BeatmapAvailability>(b2 => b2.State == DownloadState.Importing)), Times.Once);
        }
Beispiel #13
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));
        }
Beispiel #14
0
        public void SetUpSteps()
        {
            AddStep("reset state", () =>
            {
                multiplayerClient.Invocations.Clear();

                beatmapAvailability.Value = BeatmapAvailability.LocallyAvailable();

                var playlistItem = new PlaylistItem(Beatmap.Value.BeatmapInfo)
                {
                    RulesetID = Beatmap.Value.BeatmapInfo.Ruleset.OnlineID
                };

                room.Value = new Room
                {
                    Playlist            = { playlistItem },
                    CurrentPlaylistItem = { Value = playlistItem }
                };

                localUser = new MultiplayerRoomUser(API.LocalUser.Value.Id)
                {
                    User = API.LocalUser.Value
                };

                multiplayerRoom = new MultiplayerRoom(0)
                {
                    Playlist =
                    {
                        new MultiplayerPlaylistItem(playlistItem),
                    },
                    Users = { localUser },
                    Host  = localUser,
                };
            });

            AddStep("create control", () =>
            {
                content.Child = control = new MatchStartControl
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Size   = new Vector2(250, 50),
                };
            });
        }
        public void TestBeatmapDownloadingFlow()
        {
            AddAssert("ensure beatmap unavailable", () => !beatmaps.IsAvailableLocally(testBeatmapSet));
            addAvailabilityCheckStep("state not downloaded", BeatmapAvailability.NotDownloaded);

            AddStep("start downloading", () => beatmaps.Download(testBeatmapSet));
            addAvailabilityCheckStep("state downloading 0%", () => BeatmapAvailability.Downloading(0.0f));

            AddStep("set progress 40%", () => ((TestDownloadRequest)beatmaps.GetExistingDownload(testBeatmapSet)).SetProgress(0.4f));
            addAvailabilityCheckStep("state downloading 40%", () => BeatmapAvailability.Downloading(0.4f));

            AddStep("finish download", () => ((TestDownloadRequest)beatmaps.GetExistingDownload(testBeatmapSet)).TriggerSuccess(testBeatmapFile));
            addAvailabilityCheckStep("state importing", BeatmapAvailability.Importing);

            AddStep("allow importing", () => beatmaps.AllowImport.SetResult(true));
            AddUntilStep("wait for import", () => beatmaps.CurrentImportTask?.IsCompleted == true);
            addAvailabilityCheckStep("state locally available", BeatmapAvailability.LocallyAvailable);
        }
Beispiel #16
0
        Task IMultiplayerClient.UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability)
        {
            Scheduler.Add(() =>
            {
                var user = Room?.Users.SingleOrDefault(u => u.UserID == userId);

                // errors here are not critical - beatmap availability state is mostly for display.
                if (user == null)
                {
                    return;
                }

                user.BeatmapAvailability = beatmapAvailability;

                RoomUpdated?.Invoke();
            }, false);

            return(Task.CompletedTask);
        }
Beispiel #17
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Playlist.BindCollectionChanged(onPlaylistChanged, true);
            BeatmapAvailability.BindValueChanged(updateBeatmapAvailability, true);
            UserMods.BindValueChanged(onUserModsChanged);

            client.LoadRequested += onLoadRequested;

            isConnected = client.IsConnected.GetBoundCopy();
            isConnected.BindValueChanged(connected =>
            {
                if (!connected.NewValue)
                {
                    Schedule(this.Exit);
                }
            }, true);
        }
Beispiel #18
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            BeatmapAvailability.BindValueChanged(updateBeatmapAvailability, true);
            UserMods.BindValueChanged(onUserModsChanged);

            client.LoadRequested += onLoadRequested;
            client.RoomUpdated   += onRoomUpdated;

            isConnected.BindTo(client.IsConnected);
            isConnected.BindValueChanged(connected =>
            {
                if (!connected.NewValue)
                {
                    handleRoomLost();
                }
            }, true);
        }
        public void TestBeatmapDownloadingStates()
        {
            AddStep("set to no map", () => Client.ChangeBeatmapAvailability(BeatmapAvailability.NotDownloaded()));
            AddStep("set to downloading map", () => Client.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(0)));

            checkProgressBarVisibility(true);

            AddRepeatStep("increment progress", () =>
            {
                var progress = this.ChildrenOfType <ParticipantPanel>().Single().User.BeatmapAvailability.DownloadProgress ?? 0;
                Client.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(progress + RNG.NextSingle(0.1f)));
            }, 25);

            AddAssert("progress bar increased", () => this.ChildrenOfType <ProgressBar>().Single().Current.Value > 0);

            AddStep("set to importing map", () => Client.ChangeBeatmapAvailability(BeatmapAvailability.Importing()));
            checkProgressBarVisibility(false);

            AddStep("set to available", () => Client.ChangeBeatmapAvailability(BeatmapAvailability.LocallyAvailable()));
        }
Beispiel #20
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            SelectedItem.BindTo(client.CurrentMatchPlayingItem);

            BeatmapAvailability.BindValueChanged(updateBeatmapAvailability, true);
            UserMods.BindValueChanged(onUserModsChanged);

            client.LoadRequested += onLoadRequested;
            client.RoomUpdated   += onRoomUpdated;

            isConnected.BindTo(client.IsConnected);
            isConnected.BindValueChanged(connected =>
            {
                if (!connected.NewValue)
                {
                    Schedule(this.Exit);
                }
            }, true);
        }
        public void TestManyUsers()
        {
            AddStep("add many users", () =>
            {
                for (int i = 0; i < 20; i++)
                {
                    Client.AddUser(new User
                    {
                        Id              = i,
                        Username        = $"User {i}",
                        CurrentModeRank = RNG.Next(1, 100000),
                        CoverUrl        = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
                    });

                    Client.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:
                            Client.ChangeUserBeatmapAvailability(i, BeatmapAvailability.NotDownloaded());
                            break;

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

                        case DownloadState.Importing:
                            Client.ChangeUserBeatmapAvailability(i, BeatmapAvailability.Importing());
                            break;
                        }
                    }
                }
            });
        }
Beispiel #22
0
        public void TestUserWithMods()
        {
            AddStep("add user", () =>
            {
                Client.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",
                });

                Client.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}", () => Client.ChangeUserState(0, state));
            }

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

            AddStep("set state: locally available", () => Client.ChangeUserBeatmapAvailability(0, BeatmapAvailability.LocallyAvailable()));
        }
Beispiel #23
0
 public abstract Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability);
Beispiel #24
0
 public override Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability)
 {
     ChangeUserBeatmapAvailability(api.LocalUser.Value.Id, newBeatmapAvailability);
     return(Task.CompletedTask);
 }
Beispiel #25
0
        public void ChangeUserBeatmapAvailability(int userId, BeatmapAvailability newBeatmapAvailability)
        {
            Debug.Assert(Room != null);

            ((IMultiplayerClient)this).UserBeatmapAvailabilityChanged(userId, newBeatmapAvailability);
        }
Beispiel #26
0
 public TestSceneBeatmapAvailability()
 {
     Add(container = new BeatmapAvailability());
 }
Beispiel #27
0
        public static async Task Main()
        {
            // ReSharper disable once CollectionNeverQueried.Local
            var clients = new List <MultiplayerClient>();

            for (int i = 1; i < 6; i++)
            {
                clients.Add(getConnectedClient(i));
            }

            while (true)
            {
                Console.WriteLine();

                foreach (var c in clients)
                {
                    Console.WriteLine($"Client {c.UserID} room: {c.Room} state: {c.State} beatmap: {c.BeatmapAvailability} mods: {string.Join(',', c.UserMods.Select(m => m.Acronym))}");
                }

                Console.WriteLine("Usage: <client_id> <command> [params]");
                Console.WriteLine("Valid commands [ JoinRoom LeaveRoom TransferHost ChangeSettings ChangeState ChangeBeatmapAvailability ChangeMods StartMatch ]");

                Console.Write(">");

                string?input = Console.ReadLine();

                try
                {
                    var pieces = input?.Split(' ');

                    if (pieces == null || pieces.Length < 2)
                    {
                        continue;
                    }

                    var args = pieces.Skip(2).ToArray();

                    MultiplayerClient targetClient = clients.First(c => c.UserID == int.Parse(pieces[0]));

                    switch (pieces[1].ToLower())
                    {
                    case "joinroom":
                        long roomId = long.Parse(args[0]);

                        if (args.Length > 1)
                        {
                            await targetClient.JoinRoomWithPassword(roomId, args[1]);
                        }
                        else
                        {
                            await targetClient.JoinRoom(roomId);
                        }
                        break;

                    case "leaveroom":
                        await targetClient.LeaveRoom();

                        break;

                    case "transferhost":
                        await targetClient.TransferHost(int.Parse(args[0]));

                        break;

                    case "changesettings":
                        await targetClient.ChangeSettings(new MultiplayerRoomSettings { BeatmapID = RNG.Next(0, 65536) });

                        break;

                    case "changestate":
                        await targetClient.ChangeState(Enum.Parse <MultiplayerUserState>(args[0], true));

                        break;

                    case "changebeatmapavailability":
                        switch (Enum.Parse <DownloadState>(args[0], true))
                        {
                        case DownloadState.NotDownloaded:
                            await targetClient.ChangeBeatmapAvailability(BeatmapAvailability.NotDownloaded());

                            break;

                        case DownloadState.Downloading:
                            await targetClient.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(float.Parse(args[1])));

                            break;

                        case DownloadState.Importing:
                            await targetClient.ChangeBeatmapAvailability(BeatmapAvailability.Importing());

                            break;

                        case DownloadState.LocallyAvailable:
                            await targetClient.ChangeBeatmapAvailability(BeatmapAvailability.LocallyAvailable());

                            break;
                        }

                        break;

                    case "changemods":
                        var mods = new List <APIMod>();

                        for (int i = 0; i < args.Length; i++)
                        {
                            mods.Add(new APIMod {
                                Acronym = args[i]
                            });
                        }

                        await targetClient.ChangeUserMods(mods);

                        break;

                    case "startmatch":
                        await targetClient.StartMatch();

                        break;

                    default:
                        Console.WriteLine("Unknown command");
                        continue;
                    }
                }
                catch (HubException e)
                {
                    Console.WriteLine($"Server returned error: {e.Message}");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error performing action: {e}");
                }

                Thread.Sleep(50);
                Console.WriteLine("Success!");
            }

            // ReSharper disable once FunctionNeverReturns
        }
Beispiel #28
0
 public Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability) =>
 connection.InvokeAsync(nameof(IMultiplayerServer.ChangeBeatmapAvailability), newBeatmapAvailability);
Beispiel #29
0
 public async Task ClientCantChangeAvailabilityWhenNotJoinedRoom()
 {
     await Assert.ThrowsAsync <NotJoinedRoomException>(() => Hub.ChangeBeatmapAvailability(BeatmapAvailability.Importing()));
 }
 public void TestCorrectInitialState()
 {
     AddStep("set to downloading map", () => Client.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(0)));
     createNewParticipantsList();
     checkProgressBarVisibility(true);
 }