@(user: Option[model.users.User], gamelobby: logic.game.GameLobby)
@import play.api.libs.json._
<div id="lobby-app-mount"></div>

<script>
    // Initialisierung des momentanen Lobby Standes, welcher direkt gerendert werden muss.

    const initialLobbyName = '@gamelobby.name';
    const initialLobbyId = '@gamelobby.id';

    const initialIsHost = @{user.map(u => gamelobby.getUserSession(u.id)).exists(_.host)};
    const initialMaxPlayers = @{gamelobby.maxPlayers};

    const initialPlayers = JSON.parse('@Html({
        val currentUserId = user.map(_.id).getOrElse(java.util.UUID.randomUUID())

        val playerListForVue = gamelobby.getUsers.toSeq.map { u =>
            val isSelf = u.id == currentUserId
            val playerDogStatus = false

            Json.obj(
                "id" -> u.id.toString,
                "name" -> u.name,
                "self" -> isSelf,
                "dog" -> playerDogStatus
            )
        }
        Json.stringify(Json.toJson(playerListForVue))
    })');
    connectWebSocket();
    globalThis.initLobbyVueComponents(
    initialLobbyName,
    initialLobbyId,
    initialIsHost,
    initialMaxPlayers,
    initialPlayers
    );
</script>