2019-01-24 16:43:03 +08:00
|
|
|
// 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.
|
2018-12-22 11:50:37 +08:00
|
|
|
|
|
|
|
using System.Net.Http;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using osu.Framework.IO.Network;
|
2020-07-22 17:29:50 +08:00
|
|
|
using osu.Game.Online.API;
|
2018-12-22 11:50:37 +08:00
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
2020-12-25 12:38:11 +08:00
|
|
|
namespace osu.Game.Online.Rooms
|
2018-12-22 11:50:37 +08:00
|
|
|
{
|
2020-07-22 17:37:00 +08:00
|
|
|
public class SubmitRoomScoreRequest : APIRequest<MultiplayerScore>
|
2018-12-22 11:50:37 +08:00
|
|
|
{
|
|
|
|
private readonly int scoreId;
|
|
|
|
private readonly int roomId;
|
|
|
|
private readonly int playlistItemId;
|
|
|
|
private readonly ScoreInfo scoreInfo;
|
|
|
|
|
|
|
|
public SubmitRoomScoreRequest(int scoreId, int roomId, int playlistItemId, ScoreInfo scoreInfo)
|
|
|
|
{
|
|
|
|
this.scoreId = scoreId;
|
|
|
|
this.roomId = roomId;
|
|
|
|
this.playlistItemId = playlistItemId;
|
|
|
|
this.scoreInfo = scoreInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override WebRequest CreateWebRequest()
|
|
|
|
{
|
|
|
|
var req = base.CreateWebRequest();
|
|
|
|
|
|
|
|
req.ContentType = "application/json";
|
|
|
|
req.Method = HttpMethod.Put;
|
|
|
|
|
2019-06-15 23:31:14 +08:00
|
|
|
req.AddRaw(JsonConvert.SerializeObject(scoreInfo, new JsonSerializerSettings
|
|
|
|
{
|
|
|
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
|
|
|
}));
|
2018-12-22 11:50:37 +08:00
|
|
|
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string Target => $@"rooms/{roomId}/playlist/{playlistItemId}/scores/{scoreId}";
|
|
|
|
}
|
|
|
|
}
|