2021-03-23 13:44:06 +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.
|
|
|
|
|
|
|
|
using System.Net.Http;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using osu.Framework.IO.Network;
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Online.Solo
|
|
|
|
{
|
|
|
|
public class SubmitSoloScoreRequest : APIRequest<MultiplayerScore>
|
|
|
|
{
|
2022-01-06 19:57:26 +08:00
|
|
|
public readonly SubmittableScore Score;
|
|
|
|
|
2021-03-23 13:44:06 +08:00
|
|
|
private readonly long scoreId;
|
|
|
|
|
|
|
|
private readonly int beatmapId;
|
|
|
|
|
|
|
|
public SubmitSoloScoreRequest(int beatmapId, long scoreId, ScoreInfo scoreInfo)
|
|
|
|
{
|
|
|
|
this.beatmapId = beatmapId;
|
|
|
|
this.scoreId = scoreId;
|
2022-01-06 19:57:26 +08:00
|
|
|
Score = new SubmittableScore(scoreInfo);
|
2021-03-23 13:44:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override WebRequest CreateWebRequest()
|
|
|
|
{
|
|
|
|
var req = base.CreateWebRequest();
|
|
|
|
|
|
|
|
req.ContentType = "application/json";
|
|
|
|
req.Method = HttpMethod.Put;
|
2021-12-14 05:40:45 +08:00
|
|
|
req.Timeout = 30000;
|
2021-03-23 13:44:06 +08:00
|
|
|
|
2022-01-06 19:57:26 +08:00
|
|
|
req.AddRaw(JsonConvert.SerializeObject(Score, new JsonSerializerSettings
|
2021-03-23 13:44:06 +08:00
|
|
|
{
|
|
|
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
|
|
|
}));
|
|
|
|
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
2021-04-08 22:15:08 +08:00
|
|
|
protected override string Target => $@"beatmaps/{beatmapId}/solo/scores/{scoreId}";
|
2021-03-23 13:44:06 +08:00
|
|
|
}
|
|
|
|
}
|