Skip to content

Commit ed905b7

Browse files
authored
Add models for new tournament-related multiplayer operations (#36953)
Continuation of ppy/osu-server-spectator#406 Operations in question being: - (un)locking rooms / `!mp (un)lock` (prevents players from changing team, will also include slots when slots are implemented) - rolling / `!roll` (frequently used in coin toss type situations, will receive nice animation to go with it)
1 parent fd66d7c commit ed905b7

File tree

7 files changed

+93
-0
lines changed

7 files changed

+93
-0
lines changed

osu.Game/Online/Multiplayer/MatchServerEvent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace osu.Game.Online.Multiplayer
1919
[Union(1, typeof(CountdownStoppedEvent))]
2020
[Union(2, typeof(MatchmakingAvatarActionEvent))]
2121
[Union(3, typeof(RankedPlayCardHandReplayEvent))]
22+
[Union(4, typeof(RollEvent))]
2223
public abstract class MatchServerEvent
2324
{
2425
}

osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusRoomState.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public class TeamVersusRoomState : MatchRoomState
1212
[Key(0)]
1313
public List<MultiplayerTeam> Teams { get; set; } = new List<MultiplayerTeam>();
1414

15+
[Key(1)]
16+
public bool Locked { get; set; }
17+
1518
public static TeamVersusRoomState CreateDefault() =>
1619
new TeamVersusRoomState
1720
{

osu.Game/Online/Multiplayer/MatchUserRequest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ namespace osu.Game.Online.Multiplayer
2121
[Union(2, typeof(StopCountdownRequest))]
2222
[Union(3, typeof(MatchmakingAvatarActionRequest))]
2323
[Union(4, typeof(RankedPlayCardHandReplayRequest))]
24+
[Union(5, typeof(SetLockStateRequest))]
25+
[Union(6, typeof(RollRequest))]
2426
public abstract class MatchUserRequest
2527
{
2628
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 MessagePack;
6+
7+
namespace osu.Game.Online.Multiplayer
8+
{
9+
/// <summary>
10+
/// Communicates the result of a <see cref="RollRequest"/>.
11+
/// </summary>
12+
[Serializable]
13+
[MessagePackObject]
14+
public class RollEvent : MatchServerEvent
15+
{
16+
/// <summary>
17+
/// The ID of the user who initiated the roll.
18+
/// </summary>
19+
[Key(0)]
20+
public int UserID { get; set; }
21+
22+
/// <summary>
23+
/// Determines the maximum possible result of the roll.
24+
/// Bigger than 1.
25+
/// </summary>
26+
[Key(1)]
27+
public uint Max { get; set; }
28+
29+
/// <summary>
30+
/// The actual result of the roll.
31+
/// In the range [1, <see cref="Max"/>], inclusive both ends.
32+
/// </summary>
33+
[Key(2)]
34+
public uint Result { get; set; }
35+
}
36+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 MessagePack;
6+
7+
namespace osu.Game.Online.Multiplayer
8+
{
9+
/// <summary>
10+
/// Requests a random roll of a number from 1 to <see cref="Max"/> inclusive.
11+
/// </summary>
12+
[Serializable]
13+
[MessagePackObject]
14+
public class RollRequest : MatchUserRequest
15+
{
16+
/// <summary>
17+
/// Determines the maximum possible result of the roll.
18+
/// Must be bigger than 1.
19+
/// Defaults to 100 if not provided.
20+
/// </summary>
21+
[Key(0)]
22+
public uint? Max { get; set; }
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 MessagePack;
5+
6+
namespace osu.Game.Online.Multiplayer
7+
{
8+
[MessagePackObject]
9+
public class SetLockStateRequest : MatchUserRequest
10+
{
11+
/// <summary>
12+
/// <para>
13+
/// If <see langword="true"/>, <see cref="MultiplayerRoomUserRole.Player"/>s will not be able to change teams by themselves in the room,
14+
/// only <see cref="MultiplayerRoomUserRole.Referee"/>s will be able to change teams for the <see cref="MultiplayerRoomUserRole.Player"/>s.
15+
/// </para>
16+
/// <para>
17+
/// If <see langword="false"/>, any user can change their team in the room.
18+
/// </para>
19+
/// </summary>
20+
// TODO: mention slots as well when slots are reimplemented
21+
[Key(0)]
22+
public bool Locked { get; set; }
23+
}
24+
}

osu.Game/Online/SignalRWorkaroundTypes.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ internal static class SignalRWorkaroundTypes
2727
(typeof(ChangeTeamRequest), typeof(MatchUserRequest)),
2828
(typeof(StartMatchCountdownRequest), typeof(MatchUserRequest)),
2929
(typeof(StopCountdownRequest), typeof(MatchUserRequest)),
30+
(typeof(SetLockStateRequest), typeof(MatchUserRequest)),
31+
(typeof(RollRequest), typeof(MatchUserRequest)),
3032
(typeof(CountdownStartedEvent), typeof(MatchServerEvent)),
3133
(typeof(CountdownStoppedEvent), typeof(MatchServerEvent)),
34+
(typeof(RollEvent), typeof(MatchServerEvent)),
3235
(typeof(TeamVersusRoomState), typeof(MatchRoomState)),
3336
(typeof(TeamVersusUserState), typeof(MatchUserState)),
3437
(typeof(MatchStartCountdown), typeof(MultiplayerCountdown)),

0 commit comments

Comments
 (0)