osu/osu.Game/Screens/Play/RoomSubmittingPlayer.cs
Dean Herbert beb3731c0b Standardise and combine base implementation of score submission requests
These share too much yet have very different constructor signatures and
property exposure. Just a clean-up pass as I begin to look at replay
submission.
2022-02-11 15:53:47 +09:00

41 lines
1.4 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.
using System.Diagnostics;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Scoring;
namespace osu.Game.Screens.Play
{
/// <summary>
/// A player instance which submits to a room backing. This is generally used by playlists and multiplayer.
/// </summary>
public abstract class RoomSubmittingPlayer : SubmittingPlayer
{
protected readonly PlaylistItem PlaylistItem;
protected readonly Room Room;
protected RoomSubmittingPlayer(Room room, PlaylistItem playlistItem, PlayerConfiguration configuration = null)
: base(configuration)
{
Room = room;
PlaylistItem = playlistItem;
}
protected override APIRequest<APIScoreToken> CreateTokenRequest()
{
if (!(Room.RoomID.Value is long roomId))
return null;
return new CreateRoomScoreRequest(roomId, PlaylistItem.ID, Game.VersionHash);
}
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
{
Debug.Assert(Room.RoomID.Value != null);
return new SubmitRoomScoreRequest(score.ScoreInfo, token, Room.RoomID.Value.Value, PlaylistItem.ID);
}
}
}