1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 17:42:54 +08:00
osu-lazer/osu.Game/Online/Multiplayer/GetRoomsRequest.cs
2020-07-22 18:34:04 +09:00

39 lines
1.2 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using Humanizer;
using osu.Framework.IO.Network;
using osu.Game.Online.API;
using osu.Game.Screens.Multi.Lounge.Components;
namespace osu.Game.Online.Multiplayer
{
public class GetRoomsRequest : APIRequest<List<Room>>
{
private readonly RoomStatusFilter statusFilter;
private readonly RoomCategoryFilter categoryFilter;
public GetRoomsRequest(RoomStatusFilter statusFilter, RoomCategoryFilter categoryFilter)
{
this.statusFilter = statusFilter;
this.categoryFilter = categoryFilter;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
if (statusFilter != RoomStatusFilter.Open)
req.AddParameter("mode", statusFilter.ToString().Underscore().ToLowerInvariant());
if (categoryFilter != RoomCategoryFilter.Any)
req.AddParameter("category", categoryFilter.ToString().Underscore().ToLowerInvariant());
return req;
}
protected override string Target => "rooms";
}
}