Move ready-up operation logic again to client

To salvage ready up button tests.
This commit is contained in:
Bartłomiej Dach
2020-12-29 09:09:47 +01:00
parent db52255bbe
commit e9b0652359
5 changed files with 61 additions and 27 deletions

View File

@ -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);