Add client-side + interface implementation

This commit is contained in:
Dan Balasescu
2021-12-09 02:12:33 +09:00
parent ce081c4acc
commit c34c580ad4
6 changed files with 266 additions and 0 deletions

View File

@ -339,6 +339,36 @@ namespace osu.Game.Tests.Visual.Multiplayer
public override Task AddPlaylistItem(MultiplayerPlaylistItem item) => AddUserPlaylistItem(api.LocalUser.Value.OnlineID, item);
public async Task RemoveUserPlaylistItem(int userId, long playlistItemId)
{
Debug.Assert(Room != null);
Debug.Assert(APIRoom != null);
if (Room.Settings.QueueMode == QueueMode.HostOnly)
throw new InvalidOperationException("Items cannot be removed in host-only mode.");
if (Room.Playlist.Count == 1)
throw new InvalidOperationException("The singular item in the room cannot be removed.");
var item = serverSidePlaylist.Find(i => i.ID == playlistItemId);
if (item == null)
throw new InvalidOperationException("Item does not exist in the room.");
if (item == currentItem)
throw new InvalidOperationException("The room's current item cannot be removed.");
if (item.OwnerID != userId)
throw new InvalidOperationException("Attempted to remove an item which is not owned by the user.");
serverSidePlaylist.Remove(item);
await ((IMultiplayerClient)this).PlaylistItemRemoved(playlistItemId).ConfigureAwait(false);
await updateCurrentItem(Room).ConfigureAwait(false);
}
public override Task RemovePlaylistItem(long playlistItemId) => RemoveUserPlaylistItem(api.LocalUser.Value.OnlineID, playlistItemId);
protected override Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default)
{
IBeatmapSetInfo? set = roomManager.ServerSideRooms.SelectMany(r => r.Playlist)