[ADD] added that when you join an empty lobby you become the host

This commit is contained in:
Sem van der Hoeven
2020-10-22 13:22:52 +02:00
parent 471247827b
commit 0b72c4dc9b
5 changed files with 22 additions and 10 deletions

View File

@@ -201,8 +201,9 @@ namespace Server.Models
return lobby.ID;
}
public void JoinLobby(User user, int id)
public void JoinLobby(User user, int id, out bool isHost)
{
isHost = false;
foreach (Lobby l in lobbies)
{
if (l.ID == id)
@@ -210,6 +211,7 @@ namespace Server.Models
if (l.Users.Count == 0)
{
user.Host = true;
isHost = true;
}
AddToLobby(l, user);
Debug.WriteLine($"{user.Username} joined lobby with id {id}");