-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
69 lines (49 loc) · 1.68 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// DECLARACION DE VARIABLES GLOBALES***********************************************************
var cartaElegida;
var carta;
var number;
// EVITAR RECARGA DE FORMULARIO*********************************************************************
function evitarRecarga(event) {
event.preventDefault();
return false;
}
// FUNCTION ELEGIR CARTA****************************************************************************
function elegirCarta(number) {
if (carta < 18) {
if (number == carta) {
document.getElementById("imgcarta" + number).src =
"images/cartaganaste.jpg";
carta = 18;
mostrarBoton();
} else {
document.getElementById("imgcarta" + number).src =
"images/cartaperdiste.jpg";
intentosCartas = intentosCartas - 1;
document.getElementById("cantdeIntentosCartas").textContent =
"LIVES:" + " ❤ ".repeat(intentosCartas);
if (intentosCartas == 0) {
document.getElementById("imgcarta" + carta).src =
"images/cartafinal.jpg";
carta = 18;
mostrarBoton();
}
}
}
}
function sortearCarta() {
intentosCartas = 5;
document.getElementById("cantdeIntentosCartas").textContent =
"LIVES:" + " ❤ ".repeat(intentosCartas);
carta = Math.floor(Math.random() * 16);
if (carta == 0) {
carta = 16;
}
document.getElementById("btncartamostrar").id = "btncarta";
//console.log(carta);
for (number = 1; number < 17; number++) {
document.getElementById("imgcarta" + number).src = "images/cartaback.jpg";
}
}
function mostrarBoton() {
document.getElementById("btncarta").id = "btncartamostrar";
}