2021-03-23 06:33:31 +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-08-24 05:25:29 +00:00
|
|
|
using System.Diagnostics;
|
2021-03-23 06:33:31 +00:00
|
|
|
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;
|
2021-08-24 04:22:06 +00:00
|
|
|
protected readonly Room Room;
|
2021-03-23 06:33:31 +00:00
|
|
|
|
2021-08-24 04:22:06 +00:00
|
|
|
protected RoomSubmittingPlayer(Room room, PlaylistItem playlistItem, PlayerConfiguration configuration = null)
|
2021-03-23 06:33:31 +00:00
|
|
|
: base(configuration)
|
|
|
|
{
|
2021-08-24 04:22:06 +00:00
|
|
|
Room = room;
|
2021-03-23 06:33:31 +00:00
|
|
|
PlaylistItem = playlistItem;
|
|
|
|
}
|
|
|
|
|
2021-03-24 04:23:23 +00:00
|
|
|
protected override APIRequest<APIScoreToken> CreateTokenRequest()
|
|
|
|
{
|
2021-08-24 05:25:29 +00:00
|
|
|
if (!(Room.RoomID.Value is long roomId))
|
2021-03-24 04:23:23 +00:00
|
|
|
return null;
|
|
|
|
|
|
|
|
return new CreateRoomScoreRequest(roomId, PlaylistItem.ID, Game.VersionHash);
|
|
|
|
}
|
2021-03-23 06:33:31 +00:00
|
|
|
|
2021-08-24 05:25:29 +00:00
|
|
|
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
|
|
|
|
{
|
|
|
|
Debug.Assert(Room.RoomID.Value != null);
|
|
|
|
return new SubmitRoomScoreRequest(token, Room.RoomID.Value.Value, PlaylistItem.ID, score.ScoreInfo);
|
|
|
|
}
|
2021-03-23 06:33:31 +00:00
|
|
|
}
|
|
|
|
}
|