-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
121 lines (112 loc) · 4.17 KB
/
index.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
let count1=0;
let count2=0;
function shake1(){
document.getElementById("boom2").style.animation="none";
document.getElementById("minus2").style.animation="none"
document.getElementById("character1").style.animation="adiyalshake 0.5s alternate-reverse infinite";
}
function shake2(){
document.getElementById("boom1").style.animation="none";
document.getElementById("minus1").style.animation="none"
document.getElementById("character2").style.animation="thadimadushake 0.5s alternate-reverse infinite";
}
function Fight(e){
if(e==1){
count1++;
document.getElementById("character1").style.animation="adiyal 1s steps(4) 1";
document.getElementById("boom2").style.animation="boom 1.3s steps(2)";
document.getElementById("minus2").style.animation="boom 1.4s steps(2)"
setTimeout(shake1,1500)
if(count1==3){
document.getElementById("dead1").style.display="block";
document.getElementById("character2").style.display="none";
document.getElementById("boom2").style.display="none";
document.getElementById("minus2").style.display="none";
document.getElementById("character1").style.animation="adiyal 0s steps(1) 1 alternate-reverse";
}
}
if(e==2){
count2++;
document.getElementById("character2").style.animation="thadimadu 1s steps(4) 1";
document.getElementById("boom1").style.animation="boom 1.3s steps(2)";
document.getElementById("minus1").style.animation="boom 1.4s steps(2)"
setTimeout(shake2,1500)
if(count2==3){
document.getElementById("dead2").style.display="block";
document.getElementById("character1").style.display="none";
document.getElementById("boom1").style.display="none";
document.getElementById("minus1").style.display="none";
document.getElementById("win").style.display="block";
document.getElementById("character2").style.animation="adiyal 0s steps(1) 1 alternate-reverse";
}
}
}
//RPS GAME
let Matchcount=0;
let winCount=0;
let looseCount=0;
let tieCount=0;
function userData(e){
Matchcount++;
let computer=Math.floor(Math.random() * (4-1) + 1);
if(e==1){
document.getElementById("u1").style.display="flex";
}
else{
document.getElementById("u1").style.display="none";
}
if(e==2){
document.getElementById("u2").style.display="flex";
}
else{
document.getElementById("u2").style.display="none";
}
if(e==3){
document.getElementById("u3").style.display="flex";
}
else{
document.getElementById("u3").style.display="none";
}
if(computer==1){
document.getElementById("c1").style.display="flex";
}
else{
document.getElementById("c1").style.display="none";
}
if(computer==2){
document.getElementById("c2").style.display="flex";
}
else{
document.getElementById("c2").style.display="none";
}
if(computer==3){
document.getElementById("c3").style.display="flex";
}
else{
document.getElementById("c3").style.display="none";
}
if(computer==1 && e==2 || computer==2 && e==3 || computer==3 && e==1){
winCount++;
setTimeout(Fight(2),1000);
document.getElementById("ans").style.display="flex";
document.getElementById("answer").innerHTML="YOU WON!!";
}
else if(computer==e){
tieCount++;
document.getElementById("ans").style.display="flex";
document.getElementById("answer").innerHTML="MATCH TIE!!";
}
else{
looseCount++;
setTimeout(Fight(1),1000);
document.getElementById("ans").style.display="flex";
document.getElementById("answer").innerHTML="YOU LOOSE!!";
}
document.getElementById("matchCount").innerHTML=Matchcount;
document.getElementById("winCount").innerHTML=winCount;
document.getElementById("looseCount").innerHTML=looseCount;
document.getElementById("tieCount").innerHTML=tieCount;
}
function reset(){
location.reload();
}