From c8c0792bd741e2d76c3e488b3b234f70db689b58 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 29 Sep 2026 11:27:18 +0200 Subject: [PATCH] =?UTF-8?q?M=C3=A1s=20funcionalidades=20de=20host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/buscadorSala.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/js/buscadorSala.js b/js/buscadorSala.js index 857aae5..40ced89 100644 --- a/js/buscadorSala.js +++ b/js/buscadorSala.js @@ -174,10 +174,11 @@ function mostrarSala(partida, equipos, jugadores) { let accionesSalaHTML = ""; if (usuarioYaEstaEnEquipo) { + const esHost = partida.idUsuario == idUsuarioSesion; let botonIniciarHTML = ""; // Solo el host puede iniciar la partida - if (partida.idUsuario == idUsuarioSesion) { + if (esHost) { botonIniciarHTML = ` @@ -191,7 +192,8 @@ function mostrarSala(partida, equipos, jugadores) { @@ -263,12 +265,34 @@ let botonAbandonarReferencia = null; // A. Al hacer clic en el botón "Abandonar sala" de la tarjeta, abrimos el modal $(document).on("click", ".btn-abandonar-sala", function () { botonAbandonarReferencia = $(this); + + const esHost = $(this).data("es-host") === true || $(this).data("es-host") === "true"; + const titulo = $("#modalAbandonarSalaLabel"); + const mensaje = $("#modalAbandonarSalaMensaje"); + const botonConfirmar = $("#btnConfirmarAbandonar"); + + if (esHost) { + titulo.text("¿Abandonar la sala?"); + mensaje.text( + "Si abandonas la sala como anfitrión, la partida terminará para todos los jugadores.", + ); + botonConfirmar.text("Sí, abandonar"); + } else { + titulo.text("¿Abandonar la sala?"); + mensaje.text( + "Si sales de la sala, perderás tu lugar en el equipo.", + ); + botonConfirmar.text("Sí, salir"); + } + const modal = new bootstrap.Modal( document.getElementById("modalAbandonarSala"), ); + modal.show(); }); + // B. Al hacer clic en "Sí, salir" dentro del modal Kahoot $(document).on("click", "#btnConfirmarAbandonar", function () { const modalEl = document.getElementById("modalAbandonarSala");