1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Add basic class structure for match rulesets and required state

This commit is contained in:
Dean Herbert 2021-07-21 18:59:02 +09:00
parent 985415155d
commit e8338f2711
11 changed files with 128 additions and 1 deletions

View File

@ -50,6 +50,19 @@ namespace osu.Game.Online.Multiplayer
/// <param name="state">The new state of the user.</param>
Task UserStateChanged(int userId, MultiplayerUserState state);
/// <summary>
/// Signals that the match ruleset state has changed for a user in this room.
/// </summary>
/// <param name="userId">The ID of the user performing a state change.</param>
/// <param name="state">The new state of the user.</param>
Task MatchRulesetUserStateChanged(int userId, MatchRulesetUserState state);
/// <summary>
/// Signals that the match ruleset state has changed for this room.
/// </summary>
/// <param name="state">The new state of the room.</param>
Task MatchRulesetRoomStateChanged(MatchRulesetRoomState state);
/// <summary>
/// Signals that a user in this room changed their beatmap availability state.
/// </summary>

View File

@ -0,0 +1,18 @@
// 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 MessagePack;
namespace osu.Game.Online.Multiplayer
{
/// <summary>
/// Room-wide state for the current match ruleset.
/// Can be used to contain any state which should be used before or during match gameplay.
/// </summary>
[Serializable]
[MessagePackObject]
public abstract class MatchRulesetRoomState
{
}
}

View File

@ -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.Multiplayer
{
public enum MatchRulesetType
{
HeadToHead,
TeamVs
}
}

View File

@ -0,0 +1,18 @@
// 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 MessagePack;
namespace osu.Game.Online.Multiplayer
{
/// <summary>
/// User specific state for the current match ruleset.
/// Can be used to contain any state which should be used before or during match gameplay.
/// </summary>
[Serializable]
[MessagePackObject]
public abstract class MatchRulesetUserState
{
}
}

View File

@ -0,0 +1,19 @@
// 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 MessagePack;
namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs
{
[Serializable]
[MessagePackObject]
public class MultiplayerTeam
{
[Key(0)]
public int ID { get; set; }
[Key(1)]
public string Name { get; set; }
}
}

View File

@ -0,0 +1,14 @@
// 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.Collections.Generic;
using MessagePack;
namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs
{
public class TeamVsMatchRoomState : MatchRulesetRoomState
{
[Key(0)]
public List<MultiplayerTeam> Teams { get; set; }
}
}

View File

@ -0,0 +1,13 @@
// 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 MessagePack;
namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs
{
public class TeamVsMatchUserState : MatchRulesetUserState
{
[Key(0)]
public int TeamID { get; set; }
}
}

View File

@ -420,6 +420,16 @@ namespace osu.Game.Online.Multiplayer
return Task.CompletedTask;
}
Task IMultiplayerClient.MatchRulesetUserStateChanged(int userId, MatchRulesetUserState state)
{
throw new NotImplementedException();
}
Task IMultiplayerClient.MatchRulesetRoomStateChanged(MatchRulesetRoomState state)
{
throw new NotImplementedException();
}
Task IMultiplayerClient.UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability)
{
if (Room == null)

View File

@ -47,6 +47,9 @@ namespace osu.Game.Online.Multiplayer
[Key(4)]
public MultiplayerRoomUser? Host { get; set; }
[Key(5)]
public MatchRulesetRoomState? MatchRulesetState { get; set; }
[JsonConstructor]
[SerializationConstructor]
public MultiplayerRoom(long roomId)

View File

@ -39,6 +39,9 @@ namespace osu.Game.Online.Multiplayer
[Key(7)]
public string Password { get; set; } = string.Empty;
[Key(8)]
public MatchRulesetType MatchRulesetType { get; set; }
public bool Equals(MultiplayerRoomSettings other)
=> BeatmapID == other.BeatmapID
&& BeatmapChecksum == other.BeatmapChecksum
@ -47,7 +50,8 @@ namespace osu.Game.Online.Multiplayer
&& RulesetID == other.RulesetID
&& Password.Equals(other.Password, StringComparison.Ordinal)
&& Name.Equals(other.Name, StringComparison.Ordinal)
&& PlaylistItemId == other.PlaylistItemId;
&& PlaylistItemId == other.PlaylistItemId
&& MatchRulesetType == other.MatchRulesetType;
public override string ToString() => $"Name:{Name}"
+ $" Beatmap:{BeatmapID} ({BeatmapChecksum})"
@ -55,6 +59,7 @@ namespace osu.Game.Online.Multiplayer
+ $" AllowedMods:{string.Join(',', AllowedMods)}"
+ $" Password:{(string.IsNullOrEmpty(Password) ? "no" : "yes")}"
+ $" Ruleset:{RulesetID}"
+ $" MatchRuleset:{MatchRulesetType}"
+ $" Item:{PlaylistItemId}";
}
}

View File

@ -36,6 +36,9 @@ namespace osu.Game.Online.Multiplayer
[Key(3)]
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
[Key(4)]
public MatchRulesetUserState? MatchRulesetState { get; set; }
[IgnoreMember]
public User? User { get; set; }