-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add server-side models for ranked play #36498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
40e55ec
Add type to matchmaking pools
smoogipoo c1fc1ed
Add type parameter to pool retrieval method
smoogipoo 70321e2
Add ranked play models
smoogipoo fa5a278
Add ranked play match type
smoogipoo 8202ad1
Add comments
smoogipoo 6d54d20
Apply default value changes from review
smoogipoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayCardItem.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } | ||
| } |
65 changes: 65 additions & 0 deletions
65
osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayRoomState.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]; | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayStage.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayUserInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.