Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion osu.Game/Online/Matchmaking/IMatchmakingServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public interface IMatchmakingServer
/// <summary>
/// Retrieves all active matchmaking pools.
/// </summary>
Task<MatchmakingPool[]> GetMatchmakingPools();
/// <param name="type"></param>
Task<MatchmakingPool[]> GetMatchmakingPoolsOfType(MatchmakingPoolType type);

/// <summary>
/// Joins the matchmaking lobby, allowing the local user to receive status updates.
Expand Down
3 changes: 3 additions & 0 deletions osu.Game/Online/Matchmaking/MatchmakingPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class MatchmakingPool : IEquatable<MatchmakingPool>
[Key(3)]
public string Name { get; set; } = string.Empty;

[Key(4)]
public MatchmakingPoolType Type { get; set; } = MatchmakingPoolType.QuickPlay;

public bool Equals(MatchmakingPool? other)
=> other != null
&& Id == other.Id
Expand Down
11 changes: 11 additions & 0 deletions osu.Game/Online/Matchmaking/MatchmakingPoolType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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.

namespace osu.Game.Online.Matchmaking
{
public enum MatchmakingPoolType
{
QuickPlay,
RankedPlay
}
}
2 changes: 2 additions & 0 deletions osu.Game/Online/Multiplayer/MatchRoomState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using MessagePack;
using osu.Game.Online.Multiplayer.MatchTypes.Matchmaking;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;

namespace osu.Game.Online.Multiplayer
Expand All @@ -16,6 +17,7 @@ namespace osu.Game.Online.Multiplayer
[MessagePackObject]
[Union(0, typeof(TeamVersusRoomState))] // IMPORTANT: Add rules to SignalRUnionWorkaroundResolver for new derived types.
[Union(1, typeof(MatchmakingRoomState))]
[Union(2, typeof(RankedPlayRoomState))]
public abstract class MatchRoomState
{
}
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Online/Multiplayer/MatchServerEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using MessagePack;
using osu.Game.Online.Matchmaking.Events;
using osu.Game.Online.Multiplayer.Countdown;
using osu.Game.Online.RankedPlay;

namespace osu.Game.Online.Multiplayer
{
Expand All @@ -17,6 +18,7 @@ namespace osu.Game.Online.Multiplayer
[Union(0, typeof(CountdownStartedEvent))]
[Union(1, typeof(CountdownStoppedEvent))]
[Union(2, typeof(MatchmakingAvatarActionEvent))]
[Union(3, typeof(RankedPlayCardHandReplayEvent))]
public abstract class MatchServerEvent
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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.CodeAnalysis;
using MessagePack;

namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay
{
[Serializable]
[MessagePackObject]
public class RankedPlayCardItem : IEquatable<RankedPlayCardItem>
{
/// <summary>
/// A unique identifier for this card.
/// </summary>
[Key(0)]
public Guid ID { get; set; } = Guid.NewGuid();

public bool Equals(RankedPlayCardItem? other)
=> other != null && ID.Equals(other.ID);

public override bool Equals(object? obj)
=> obj is RankedPlayCardItem other && Equals(other);

[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
public override int GetHashCode()
{
return ID.GetHashCode();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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.Collections.Generic;
using MessagePack;

namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay
{
[Serializable]
[MessagePackObject]
public class RankedPlayRoomState : MatchRoomState
{
/// <summary>
/// The current room stage.
/// </summary>
[Key(0)]
public RankedPlayStage Stage { get; set; }

/// <summary>
/// The current round number (1-based).
/// </summary>
[Key(1)]
public int CurrentRound { get; set; }

/// <summary>
/// A multiplier applied to life point damage.
/// </summary>
[Key(2)]
public double DamageMultiplier { get; set; } = 1;

/// <summary>
/// A dictionary containing all users in the room.
/// </summary>
[Key(3)]
public Dictionary<int, RankedPlayUserInfo> Users { get; set; } = [];

/// <summary>
/// The ID of the user currently playing a card.
/// </summary>
[Key(4)]
public int? ActiveUserId { get; set; }

/// <summary>
/// The average star rating of all cards.
/// </summary>
[Key(5)]
public double StarRating { get; set; }

/// <summary>
/// The winner of the match.
/// </summary>
[Key(6)]
public int? WinningUserId { get; set; }

/// <summary>
/// The user currently playing a card.
/// </summary>
[IgnoreMember]
public RankedPlayUserInfo? ActiveUser => ActiveUserId == null ? null : Users[ActiveUserId.Value];

[IgnoreMember]
public RankedPlayUserInfo? WinningUser => WinningUserId == null ? null : Users[WinningUserId.Value];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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.

namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay
{
public enum RankedPlayStage
{
/// <summary>
/// Waiting for clients to join.
/// </summary>
WaitForJoin,

/// <summary>
/// Period of time before the round starts.
/// </summary>
RoundWarmup,

/// <summary>
/// Users are discarding cards and drawing new ones.
/// </summary>
CardDiscard,

/// <summary>
/// Users have finished discarding their cards.
/// </summary>
FinishCardDiscard,

/// <summary>
/// The active user is selecting a card to play.
/// </summary>
CardPlay,

/// <summary>
/// The active user has made a selection, both players should now start downloading it.
/// </summary>
FinishCardPlay,

/// <summary>
/// Period of time before gameplay starts.
/// </summary>
GameplayWarmup,

/// <summary>
/// Gameplay is in progress.
/// </summary>
Gameplay,

/// <summary>
/// Users are viewing the gameplay results
/// </summary>
Results,

/// <summary>
/// The match has concluded.
/// </summary>
Ended
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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.Collections.Generic;
using MessagePack;

namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay
{
[Serializable]
[MessagePackObject]
public class RankedPlayUserInfo
{
/// <summary>
/// This user's matchmaking rating.
/// </summary>
[Key(0)]
public required int Rating { get; set; }

/// <summary>
/// The current life points.
/// </summary>
[Key(1)]
public int Life { get; set; } = 1_000_000;

/// <summary>
/// The cards in this user's hand.
/// </summary>
[Key(2)]
public List<RankedPlayCardItem> Hand { get; set; } = [];

/// <summary>
/// Rating after conclusion of the match.
/// </summary>
[Key(3)]
public int RatingAfter { get; set; }
}
}
2 changes: 2 additions & 0 deletions osu.Game/Online/Multiplayer/MatchUserRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using osu.Game.Online.Matchmaking.Events;
using osu.Game.Online.Multiplayer.Countdown;
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
using osu.Game.Online.RankedPlay;

namespace osu.Game.Online.Multiplayer
{
Expand All @@ -19,6 +20,7 @@ namespace osu.Game.Online.Multiplayer
[Union(1, typeof(StartMatchCountdownRequest))]
[Union(2, typeof(StopCountdownRequest))]
[Union(3, typeof(MatchmakingAvatarActionRequest))]
[Union(4, typeof(RankedPlayCardHandReplayRequest))]
public abstract class MatchUserRequest
{
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Online/Multiplayer/MultiplayerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ Task IMatchmakingClient.MatchmakingItemDeselected(int userId, long playlistItemI
return Task.CompletedTask;
}

public abstract Task<MatchmakingPool[]> GetMatchmakingPools();
public abstract Task<MatchmakingPool[]> GetMatchmakingPoolsOfType(MatchmakingPoolType type);

public abstract Task MatchmakingJoinLobby();

Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Online/Multiplayer/MultiplayerCountdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using MessagePack;
using osu.Game.Online.Matchmaking;
using osu.Game.Online.Multiplayer.Countdown;
using osu.Game.Online.RankedPlay;

namespace osu.Game.Online.Multiplayer
{
Expand All @@ -16,6 +17,7 @@ namespace osu.Game.Online.Multiplayer
[Union(1, typeof(ForceGameplayStartCountdown))]
[Union(2, typeof(ServerShuttingDownCountdown))]
[Union(3, typeof(MatchmakingStageCountdown))]
[Union(4, typeof(RankedPlayStageCountdown))]
public abstract class MultiplayerCountdown
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,13 @@ public override Task DisconnectInternal()
return connector.Disconnect();
}

public override Task<MatchmakingPool[]> GetMatchmakingPools()
public override Task<MatchmakingPool[]> GetMatchmakingPoolsOfType(MatchmakingPoolType type)
{
if (!IsConnected.Value)
return Task.FromResult(Array.Empty<MatchmakingPool>());

Debug.Assert(connection != null);
return connection.InvokeAsync<MatchmakingPool[]>(nameof(IMatchmakingServer.GetMatchmakingPools));
return connection.InvokeAsync<MatchmakingPool[]>(nameof(IMatchmakingServer.GetMatchmakingPoolsOfType), type);
}

public override Task MatchmakingJoinLobby()
Expand Down
39 changes: 39 additions & 0 deletions osu.Game/Online/RankedPlay/IRankedPlayClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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.Threading.Tasks;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
using osu.Game.Online.Rooms;

namespace osu.Game.Online.RankedPlay
{
public interface IRankedPlayClient
{
/// <summary>
/// Indicates that a card has been added to a user's hand.
/// </summary>
/// <param name="userId">The user whose hand has changed.</param>
/// <param name="card">The card added to the user's hand.</param>
Task RankedPlayCardAdded(int userId, RankedPlayCardItem card);

/// <summary>
/// Indicates that a card has been removed from a user's hand.
/// </summary>
/// <param name="userId">The user whose hand has changed.</param>
/// <param name="card">The card removed from the user's hand.</param>
Task RankedPlayCardRemoved(int userId, RankedPlayCardItem card);

/// <summary>
/// Indicates that a card has been revealed to the local user.
/// </summary>
/// <param name="card">The card that was revealed.</param>
/// <param name="item">The playlist item the card corresponds to.</param>
Task RankedPlayCardRevealed(RankedPlayCardItem card, MultiplayerPlaylistItem item);

/// <summary>
/// Indicates a card was played.
/// </summary>
/// <param name="card">The card played.</param>
Task RankedPlayCardPlayed(RankedPlayCardItem card);
}
}
22 changes: 22 additions & 0 deletions osu.Game/Online/RankedPlay/IRankedPlayServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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.Threading.Tasks;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;

namespace osu.Game.Online.RankedPlay
{
public interface IRankedPlayServer
{
/// <summary>
/// Discards cards from the local user's hand during the <see cref="RankedPlayStage.CardDiscard"/> stage.
/// </summary>
Task DiscardCards(RankedPlayCardItem[] cards);

/// <summary>
/// Plays a card from the local user's hand during the <see cref="RankedPlayStage.CardPlay"/> stage.
/// Only usable while the local user is the <see cref="RankedPlayRoomState.ActiveUserId">active player</see>.
/// </summary>
Task PlayCard(RankedPlayCardItem card);
}
}
Loading