This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const botones = [superiorIzquierda, superiorDerecha, inferiorIzquierda, inferiorDerecha]; | |
botones.forEach(boton => { | |
boton.on("click", async () => { | |
if (!puedeJugar) { | |
console.log("No puedes jugar ._."); | |
return; | |
} | |
puedeJugar = false; | |
const ok = compararSecuenciaDeUsuarioConOriginal(secuencia, boton, contador); | |
if (ok) { | |
await encenderYApagarBoton(boton, milisegundosUsuario); | |
if (contador >= secuencia.length - 1) { | |
puntaje++; | |
refrescarPuntaje(puntaje); | |
await sleep(500); | |
await turnoDelCpu(); | |
} else { | |
contador++; | |
} | |
puedeJugar = true; | |
} else { | |
$btnComenzar.disabled = false; | |
Swal.fire("Perdiste", `Has perdido. Tu puntuación fue de ${puntaje}. Puedes jugar de nuevo cuando quieras`); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment