Skip to content

Commit a401c7d

Browse files
authored
Merge pull request #36498 from smoogipoo/ranked-play-models
Add server-side models for ranked play
2 parents 6185a81 + 6d54d20 commit a401c7d

24 files changed

Lines changed: 429 additions & 7 deletions

osu.Game/Online/Matchmaking/IMatchmakingServer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public interface IMatchmakingServer
1010
/// <summary>
1111
/// Retrieves all active matchmaking pools.
1212
/// </summary>
13-
Task<MatchmakingPool[]> GetMatchmakingPools();
13+
/// <param name="type"></param>
14+
Task<MatchmakingPool[]> GetMatchmakingPoolsOfType(MatchmakingPoolType type);
1415

1516
/// <summary>
1617
/// Joins the matchmaking lobby, allowing the local user to receive status updates.

osu.Game/Online/Matchmaking/MatchmakingPool.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class MatchmakingPool : IEquatable<MatchmakingPool>
2323
[Key(3)]
2424
public string Name { get; set; } = string.Empty;
2525

26+
[Key(4)]
27+
public MatchmakingPoolType Type { get; set; } = MatchmakingPoolType.QuickPlay;
28+
2629
public bool Equals(MatchmakingPool? other)
2730
=> other != null
2831
&& Id == other.Id
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
namespace osu.Game.Online.Matchmaking
5+
{
6+
public enum MatchmakingPoolType
7+
{
8+
QuickPlay,
9+
RankedPlay
10+
}
11+
}

osu.Game/Online/Multiplayer/MatchRoomState.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using MessagePack;
66
using osu.Game.Online.Multiplayer.MatchTypes.Matchmaking;
7+
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
78
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
89

910
namespace osu.Game.Online.Multiplayer
@@ -16,6 +17,7 @@ namespace osu.Game.Online.Multiplayer
1617
[MessagePackObject]
1718
[Union(0, typeof(TeamVersusRoomState))] // IMPORTANT: Add rules to SignalRUnionWorkaroundResolver for new derived types.
1819
[Union(1, typeof(MatchmakingRoomState))]
20+
[Union(2, typeof(RankedPlayRoomState))]
1921
public abstract class MatchRoomState
2022
{
2123
}

osu.Game/Online/Multiplayer/MatchServerEvent.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using MessagePack;
66
using osu.Game.Online.Matchmaking.Events;
77
using osu.Game.Online.Multiplayer.Countdown;
8+
using osu.Game.Online.RankedPlay;
89

910
namespace osu.Game.Online.Multiplayer
1011
{
@@ -17,6 +18,7 @@ namespace osu.Game.Online.Multiplayer
1718
[Union(0, typeof(CountdownStartedEvent))]
1819
[Union(1, typeof(CountdownStoppedEvent))]
1920
[Union(2, typeof(MatchmakingAvatarActionEvent))]
21+
[Union(3, typeof(RankedPlayCardHandReplayEvent))]
2022
public abstract class MatchServerEvent
2123
{
2224
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System;
5+
using System.Diagnostics.CodeAnalysis;
6+
using MessagePack;
7+
8+
namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay
9+
{
10+
[Serializable]
11+
[MessagePackObject]
12+
public class RankedPlayCardItem : IEquatable<RankedPlayCardItem>
13+
{
14+
/// <summary>
15+
/// A unique identifier for this card.
16+
/// </summary>
17+
[Key(0)]
18+
public Guid ID { get; set; } = Guid.NewGuid();
19+
20+
public bool Equals(RankedPlayCardItem? other)
21+
=> other != null && ID.Equals(other.ID);
22+
23+
public override bool Equals(object? obj)
24+
=> obj is RankedPlayCardItem other && Equals(other);
25+
26+
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
27+
public override int GetHashCode()
28+
{
29+
return ID.GetHashCode();
30+
}
31+
}
32+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using MessagePack;
7+
8+
namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay
9+
{
10+
[Serializable]
11+
[MessagePackObject]
12+
public class RankedPlayRoomState : MatchRoomState
13+
{
14+
/// <summary>
15+
/// The current room stage.
16+
/// </summary>
17+
[Key(0)]
18+
public RankedPlayStage Stage { get; set; }
19+
20+
/// <summary>
21+
/// The current round number (1-based).
22+
/// </summary>
23+
[Key(1)]
24+
public int CurrentRound { get; set; }
25+
26+
/// <summary>
27+
/// A multiplier applied to life point damage.
28+
/// </summary>
29+
[Key(2)]
30+
public double DamageMultiplier { get; set; } = 1;
31+
32+
/// <summary>
33+
/// A dictionary containing all users in the room.
34+
/// </summary>
35+
[Key(3)]
36+
public Dictionary<int, RankedPlayUserInfo> Users { get; set; } = [];
37+
38+
/// <summary>
39+
/// The ID of the user currently playing a card.
40+
/// </summary>
41+
[Key(4)]
42+
public int? ActiveUserId { get; set; }
43+
44+
/// <summary>
45+
/// The average star rating of all cards.
46+
/// </summary>
47+
[Key(5)]
48+
public double StarRating { get; set; }
49+
50+
/// <summary>
51+
/// The winner of the match.
52+
/// </summary>
53+
[Key(6)]
54+
public int? WinningUserId { get; set; }
55+
56+
/// <summary>
57+
/// The user currently playing a card.
58+
/// </summary>
59+
[IgnoreMember]
60+
public RankedPlayUserInfo? ActiveUser => ActiveUserId == null ? null : Users[ActiveUserId.Value];
61+
62+
[IgnoreMember]
63+
public RankedPlayUserInfo? WinningUser => WinningUserId == null ? null : Users[WinningUserId.Value];
64+
}
65+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay
5+
{
6+
public enum RankedPlayStage
7+
{
8+
/// <summary>
9+
/// Waiting for clients to join.
10+
/// </summary>
11+
WaitForJoin,
12+
13+
/// <summary>
14+
/// Period of time before the round starts.
15+
/// </summary>
16+
RoundWarmup,
17+
18+
/// <summary>
19+
/// Users are discarding cards and drawing new ones.
20+
/// </summary>
21+
CardDiscard,
22+
23+
/// <summary>
24+
/// Users have finished discarding their cards.
25+
/// </summary>
26+
FinishCardDiscard,
27+
28+
/// <summary>
29+
/// The active user is selecting a card to play.
30+
/// </summary>
31+
CardPlay,
32+
33+
/// <summary>
34+
/// The active user has made a selection, both players should now start downloading it.
35+
/// </summary>
36+
FinishCardPlay,
37+
38+
/// <summary>
39+
/// Period of time before gameplay starts.
40+
/// </summary>
41+
GameplayWarmup,
42+
43+
/// <summary>
44+
/// Gameplay is in progress.
45+
/// </summary>
46+
Gameplay,
47+
48+
/// <summary>
49+
/// Users are viewing the gameplay results
50+
/// </summary>
51+
Results,
52+
53+
/// <summary>
54+
/// The match has concluded.
55+
/// </summary>
56+
Ended
57+
}
58+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using MessagePack;
7+
8+
namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay
9+
{
10+
[Serializable]
11+
[MessagePackObject]
12+
public class RankedPlayUserInfo
13+
{
14+
/// <summary>
15+
/// This user's matchmaking rating.
16+
/// </summary>
17+
[Key(0)]
18+
public required int Rating { get; set; }
19+
20+
/// <summary>
21+
/// The current life points.
22+
/// </summary>
23+
[Key(1)]
24+
public int Life { get; set; } = 1_000_000;
25+
26+
/// <summary>
27+
/// The cards in this user's hand.
28+
/// </summary>
29+
[Key(2)]
30+
public List<RankedPlayCardItem> Hand { get; set; } = [];
31+
32+
/// <summary>
33+
/// Rating after conclusion of the match.
34+
/// </summary>
35+
[Key(3)]
36+
public int RatingAfter { get; set; }
37+
}
38+
}

osu.Game/Online/Multiplayer/MatchUserRequest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using osu.Game.Online.Matchmaking.Events;
77
using osu.Game.Online.Multiplayer.Countdown;
88
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
9+
using osu.Game.Online.RankedPlay;
910

1011
namespace osu.Game.Online.Multiplayer
1112
{
@@ -19,6 +20,7 @@ namespace osu.Game.Online.Multiplayer
1920
[Union(1, typeof(StartMatchCountdownRequest))]
2021
[Union(2, typeof(StopCountdownRequest))]
2122
[Union(3, typeof(MatchmakingAvatarActionRequest))]
23+
[Union(4, typeof(RankedPlayCardHandReplayRequest))]
2224
public abstract class MatchUserRequest
2325
{
2426
}

0 commit comments

Comments
 (0)