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-11-24 06:25:49 +00:00
|
|
|
using osu.Game.Beatmaps;
|
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-07-11 00:34:57 +00:00
|
|
|
using osu.Game.Rulesets;
|
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-11-24 03:16:08 +00:00
|
|
|
int beatmapId = Beatmap.Value.BeatmapInfo.OnlineID;
|
2021-11-24 06:25:49 +00:00
|
|
|
int rulesetId = Ruleset.Value.OnlineID;
|
|
|
|
|
|
|
|
if (beatmapId <= 0)
|
2021-03-23 07:41:52 +00:00
|
|
|
return null;
|
|
|
|
|
2021-11-24 06:25:49 +00:00
|
|
|
if (rulesetId < 0 || rulesetId > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
|
2021-04-09 06:18:02 +00:00
|
|
|
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)
|
|
|
|
{
|
2021-11-24 06:25:49 +00:00
|
|
|
IBeatmapInfo beatmap = score.ScoreInfo.BeatmapInfo;
|
2021-07-02 05:24:27 +00:00
|
|
|
|
2021-11-24 06:25:49 +00:00
|
|
|
Debug.Assert(beatmap.OnlineID > 0);
|
2021-03-24 04:12:51 +00:00
|
|
|
|
2021-11-24 06:25:49 +00:00
|
|
|
return new SubmitSoloScoreRequest(beatmap.OnlineID, token, score.ScoreInfo);
|
2021-03-24 04:12:51 +00:00
|
|
|
}
|
2021-03-23 05:47:15 +00:00
|
|
|
}
|
|
|
|
}
|