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