mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
634b6cdbbe
Right now, the client does nothing to ensure a beatmap is in a valid state before requesting to submit a score. There is further work to be done client-side so it is more aware of this state (already handled for playlists, but not for the solo gameplay loop), but the solution I have in mind for that is a bit more involved. This is not used server-side yet, but I want to get this sending so we can start using it for some very basic validation. Will resolve the basic portion of #11922 after implemented server-side.
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
// 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.
|
|
|
|
#nullable disable
|
|
|
|
using System;
|
|
using System.Diagnostics;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Extensions;
|
|
using osu.Game.Online.API;
|
|
using osu.Game.Online.Rooms;
|
|
using osu.Game.Online.Solo;
|
|
using osu.Game.Scoring;
|
|
|
|
namespace osu.Game.Screens.Play
|
|
{
|
|
public class SoloPlayer : SubmittingPlayer
|
|
{
|
|
public SoloPlayer()
|
|
: this(null)
|
|
{
|
|
}
|
|
|
|
protected SoloPlayer(PlayerConfiguration configuration = null)
|
|
: base(configuration)
|
|
{
|
|
}
|
|
|
|
protected override APIRequest<APIScoreToken> CreateTokenRequest()
|
|
{
|
|
int beatmapId = Beatmap.Value.BeatmapInfo.OnlineID;
|
|
int rulesetId = Ruleset.Value.OnlineID;
|
|
|
|
if (beatmapId <= 0)
|
|
return null;
|
|
|
|
if (!Ruleset.Value.IsLegacyRuleset())
|
|
return null;
|
|
|
|
return new CreateSoloScoreRequest(Beatmap.Value.BeatmapInfo, rulesetId, Game.VersionHash);
|
|
}
|
|
|
|
protected override bool HandleTokenRetrievalFailure(Exception exception) => false;
|
|
|
|
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
|
|
{
|
|
IBeatmapInfo beatmap = score.ScoreInfo.BeatmapInfo;
|
|
|
|
Debug.Assert(beatmap.OnlineID > 0);
|
|
|
|
return new SubmitSoloScoreRequest(score.ScoreInfo, token, beatmap.OnlineID);
|
|
}
|
|
}
|
|
}
|