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-11-24 14:25:49 +08:00
|
|
|
using osu.Game.Beatmaps;
|
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-24 14:25:49 +08:00
|
|
|
int beatmapId = Beatmap.Value.BeatmapInfo.OnlineID ?? -1;
|
|
|
|
int rulesetId = Ruleset.Value.OnlineID;
|
|
|
|
|
|
|
|
if (beatmapId <= 0)
|
2021-03-23 15:41:52 +08:00
|
|
|
return null;
|
|
|
|
|
2021-11-24 14:25:49 +08:00
|
|
|
if (rulesetId < 0 || rulesetId > 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-11-24 14:25:49 +08:00
|
|
|
IBeatmapInfo beatmap = score.ScoreInfo.BeatmapInfo;
|
2021-07-02 13:24:27 +08:00
|
|
|
|
2021-11-24 14:25:49 +08:00
|
|
|
Debug.Assert(beatmap.OnlineID > 0);
|
2021-03-24 12:12:51 +08:00
|
|
|
|
2021-11-24 14:25:49 +08:00
|
|
|
return new SubmitSoloScoreRequest(beatmap.OnlineID, token, score.ScoreInfo);
|
2021-03-24 12:12:51 +08:00
|
|
|
}
|
2021-03-23 13:47:15 +08:00
|
|
|
}
|
|
|
|
}
|