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