-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
83 lines (83 loc) · 3.08 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
let click;
let result;
let score=JSON.parse(localStorage.getItem('score'));
if(score===null){
score={
win:0,
lost:0,
draw:0
};
}
let paper='🤚';
let rock='✊';
let sci='✌️';
function randomNumber(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
function winners(click,result){
if(click==1){
if(result==1){
document.getElementById('second').innerHTML="Draw!";
score.draw++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${rock} VS ${rock}`;
}
else if(result==2){
document.getElementById('second').innerHTML="You Lost.";
score.lost++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${rock} VS ${paper}`;
}
else{
document.getElementById('second').innerHTML="You Won.";
score.win++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${rock} VS ${sci}`;
}
}
else if(click==2){
if(result==1){
document.getElementById('second').innerHTML="You Won.";
score.win++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${paper} VS ${rock}`;
}
else if(result==2){
document.getElementById('second').innerHTML="Draw!";
score.draw++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${paper} VS ${paper}`;
}
else{
document.getElementById('second').innerHTML="You Lost.";
score.lost++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${paper} VS ${sci}`;
}
}
else{
if(result==1){
document.getElementById('second').innerHTML="You Lost.";
score.lost++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${sci} VS ${rock}`;
}
else if(result==2){
document.getElementById('second').innerHTML="You Won.";
score.win++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${sci} VS ${paper}`;
}
else{
document.getElementById('second').innerHTML="Draw!";
score.draw++;
document.getElementById('tally').innerHTML=`Win:${score.win} Lost:${score.lost} Draw:${score.draw}`;
document.getElementById('choose').innerHTML=`${sci} VS ${sci}`;
}
}
localStorage.setItem('score',JSON.stringify(score));
return 0;
}