2021-03-23 05:47:15 +00: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.
|
|
|
|
|
2021-03-23 07:41:52 +00:00
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
2021-03-23 06:35:06 +00:00
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.Rooms;
|
2021-03-23 07:41:52 +00:00
|
|
|
using osu.Game.Online.Solo;
|
2021-03-23 06:35:06 +00:00
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
2021-03-23 05:47:15 +00:00
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
{
|
2021-03-23 06:35:06 +00:00
|
|
|
public class SoloPlayer : SubmittingPlayer
|
2021-03-23 05:47:15 +00:00
|
|
|
{
|
2021-07-01 07:55:33 +00:00
|
|
|
public SoloPlayer()
|
|
|
|
: this(null)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected SoloPlayer(PlayerConfiguration configuration = null)
|
|
|
|
: base(configuration)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-24 04:02:37 +00:00
|
|
|
protected override APIRequest<APIScoreToken> CreateTokenRequest()
|
2021-03-23 06:35:06 +00:00
|
|
|
{
|
2021-03-23 07:41:52 +00:00
|
|
|
if (!(Beatmap.Value.BeatmapInfo.OnlineBeatmapID is int beatmapId))
|
|
|
|
return null;
|
|
|
|
|
2021-04-09 06:18:02 +00:00
|
|
|
if (!(Ruleset.Value.ID is int rulesetId))
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
|
2021-03-23 06:35:06 +00:00
|
|
|
}
|
2021-03-23 07:41:52 +00:00
|
|
|
|
|
|
|
protected override bool HandleTokenRetrievalFailure(Exception exception) => false;
|
2021-03-24 04:12:51 +00:00
|
|
|
|
|
|
|
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
|
|
|
|
{
|
|
|
|
Debug.Assert(Beatmap.Value.BeatmapInfo.OnlineBeatmapID != null);
|
|
|
|
|
|
|
|
int beatmapId = Beatmap.Value.BeatmapInfo.OnlineBeatmapID.Value;
|
|
|
|
|
|
|
|
return new SubmitSoloScoreRequest(beatmapId, token, score.ScoreInfo);
|
|
|
|
}
|
2021-03-23 05:47:15 +00:00
|
|
|
}
|
|
|
|
}
|