MVC juego.php
This commit is contained in:
+14
-2
@@ -20,7 +20,18 @@ let bloqueado = false; // true mientras se envía una respuesta o se ve el feedb
|
||||
let numeroAciertos = 0; // número de aciertos del jugador
|
||||
|
||||
$(document).ready(function () {
|
||||
idPartida = parseInt($("body").data("id-partida"), 10);
|
||||
|
||||
// Obtenemos el idPartida de la URL
|
||||
// Ejemplo: juego.php?idPartida=3
|
||||
|
||||
const parametros = new URLSearchParams(window.location.search);
|
||||
|
||||
idPartida = parseInt(parametros.get("idPartida"), 10);
|
||||
|
||||
if (!idPartida || idPartida < 1) {
|
||||
mostrarError("La partida indicada no es válida.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Un solo listener para todos los botones de respuesta
|
||||
$("#respuestas").on("click", ".btn-answer", function () {
|
||||
@@ -103,6 +114,7 @@ function responder($botonPulsado) {
|
||||
if (bloqueado) {
|
||||
return;
|
||||
}
|
||||
|
||||
bloqueado = true;
|
||||
|
||||
const pregunta = preguntas[indice];
|
||||
@@ -216,4 +228,4 @@ function mostrarError(mensaje) {
|
||||
$("#feedback").html(
|
||||
'<a href="buscadorSala.php">Volver al buscador de salas</a>',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user