// 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.

using System;
using System.Diagnostics;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Online.Solo;
using osu.Game.Rulesets;
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()
        {
            if (!(Beatmap.Value.BeatmapInfo.OnlineBeatmapID is int beatmapId))
                return null;

            if (!(Ruleset.Value.ID is int rulesetId) || Ruleset.Value.ID > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
                return null;

            return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
        }

        protected override bool HandleTokenRetrievalFailure(Exception exception) => false;

        protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
        {
            var beatmap = score.ScoreInfo.Beatmap;

            Debug.Assert(beatmap.OnlineBeatmapID != null);

            int beatmapId = beatmap.OnlineBeatmapID.Value;

            return new SubmitSoloScoreRequest(beatmapId, token, score.ScoreInfo);
        }
    }
}

// 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.

using System;
using System.Diagnostics;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Online.Solo;
using osu.Game.Rulesets;
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()
        {
            if (!(Beatmap.Value.BeatmapInfo.OnlineBeatmapID is int beatmapId))
                return null;

            if (!(Ruleset.Value.ID is int rulesetId) || Ruleset.Value.ID > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
                return null;

            return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
        }

        protected override bool HandleTokenRetrievalFailure(Exception exception) => false;

        protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
        {
            var scoreCopy = score.DeepClone();

            var beatmap = scoreCopy.ScoreInfo.Beatmap;

            Debug.Assert(beatmap.OnlineBeatmapID != null);

            int beatmapId = beatmap.OnlineBeatmapID.Value;

            return new SubmitSoloScoreRequest(beatmapId, token, scoreCopy.ScoreInfo);
        }
    }
}

Copy score during submission process to ensure it isn't modified
Copy score during submission process to ensure it isn't modified
