forked from CrissUD/GameJavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (27 loc) · 1.24 KB
/
app.js
File metadata and controls
28 lines (27 loc) · 1.24 KB
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
function play(humanOption){
const result = document.querySelector('.result');
const humanImg = document.querySelector('.human-img');
const machineImg = document.querySelector('.machine-img');
const machineOption = Math.floor(Math.random() * (4 - 1)) + 1;
humanImg.src = './resources/images/option'+humanOption+'.png';
machineImg.src = './resources/images/option'+machineOption+'.png';
machineImg.classList.add('reflex');
document.querySelector('.cover').classList.add('reset');
if(
humanOption === 1 && machineOption === 3 ||
humanOption === 2 && machineOption === 1 ||
humanOption === 3 && machineOption === 2
)
result.innerHTML = "!Felicidades! Has Ganado";
else if(humanOption === machineOption)
result.innerHTML = "!Empate!";
else
result.innerHTML = "!Lo siento! La maquina ha ganado";
}
function reset(){
document.querySelector('.human-img').src = './resources/images/question.png';
document.querySelector('.machine-img').src = './resources/images/question.png';
document.querySelector('.machine-img').classList.remove('reflex');
document.querySelector('.cover').classList.remove('reset');
document.querySelector('.result').innerHTML = "Resultado";
}