mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Move ready-up operation logic again to client
To salvage ready up button tests.
This commit is contained in:
@ -183,6 +183,39 @@ namespace osu.Game.Online.Multiplayer
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the <see cref="LocalUser"/>'s ready state.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if this toggle triggered a gameplay start; <c>false</c> otherwise.</returns>
|
||||
/// <exception cref="InvalidOperationException">If a toggle of ready state is not valid at this time.</exception>
|
||||
public async Task<bool> ToggleReady()
|
||||
{
|
||||
var localUser = LocalUser;
|
||||
|
||||
if (localUser == null)
|
||||
return false;
|
||||
|
||||
switch (localUser.State)
|
||||
{
|
||||
case MultiplayerUserState.Idle:
|
||||
await ChangeState(MultiplayerUserState.Ready);
|
||||
return false;
|
||||
|
||||
case MultiplayerUserState.Ready:
|
||||
if (Room?.Host?.Equals(localUser) == true)
|
||||
{
|
||||
await StartMatch();
|
||||
return true;
|
||||
}
|
||||
|
||||
await ChangeState(MultiplayerUserState.Idle);
|
||||
return false;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException($"Cannot toggle ready when in {localUser.State}");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Task TransferHost(int userId);
|
||||
|
||||
public abstract Task ChangeSettings(MultiplayerRoomSettings settings);
|
||||
|
Reference in New Issue
Block a user