-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
259 lines (233 loc) · 7.13 KB
/
index.html
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!DOCTYPE html>
<html lang="en">
<head>
<title>- MCricket -</title>
<link rel="icon" href="./cckt.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Orbitron&family=Oswald:wght@600&display=swap" rel="stylesheet">
<style>
* {
text-transform: uppercase;
font-family: "Orbitron";
letter-spacing: 1.5px;
}
#header {
background-color: #b539ee2c;
border-radius: 15px;
color: rgb(40, 233, 223);
text-shadow: 4px 4px 5px rgb(0, 0, 0);
font-weight: normal;
padding: 10px;
margin: 0px 15px;
}
#ans {
letter-spacing: 2px;
text-shadow: 4px 4px 8px rgb(221, 120, 26);
}
body {
background-image: url(./ground.jpg);
background-repeat: no-repeat;
background-size: cover;
text-align: center;
}
button {
font-size: 1.3em;
border: none;
background-color: rgba(0, 0, 0, 0.349);
border-radius: 15px;
padding: 10px 30px;
margin: 30px 20px;
color: white;
box-shadow: 2px 2px 80px rgb(255, 255, 255);
text-transform: uppercase;
}
button:hover {
background-color: rgba(255, 255, 255, 0.349);
color: rgb(0, 0, 0);
text-shadow: 4px 4px 8px rgb(255, 255, 255);
cursor: pointer;
transform: scale(1.05);
transition: all 0.2s ease-in-out;
}
table {
text-shadow: 8px 8px 10px rgb(0, 0, 0);
border: solid 2px yellow;
margin: 20px auto;
color: rgb(234, 238, 28);
font-weight: bolder;
background-color: #ffffff67;
padding: 30px;
box-shadow: 2px 2px 80px rgb(245, 248, 82);
}
#lost {
color: rgb(255, 20, 20);
font-weight: 800;
text-shadow: 5px 5px 12px rgb(255, 20, 20);
border-radius: 50%;
}
#win {
color: rgb(35, 241, 35);
text-shadow: 5px 5px 12px rgb(35, 241, 35);
font-weight: 800;
}
#tie {
color: rgb(255, 255, 255);
font-weight: 600;
text-shadow: 5px 5px 12px rgb(255, 255, 255);
border-radius: 50%;
}
#sc {
font-family: 'Oswald';
text-shadow: none;
font-weight: 900;
text-decoration: underline rgb(137, 241, 255);
font-size: 30px;
background: linear-gradient(to right, #fff01e,
#ffdf89, #ff9e2e, #ffe600);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
}
.main {
backdrop-filter: blur(10px);
border-radius: 50px;
padding: 30px 0px;
width: 100%;
margin-top: 50px;
box-shadow: 10px 10px 40px 20px rgba(255, 255, 255, 0.301);
font-weight: 10;
}
th {
padding: 10px;
}
</style>
</head>
<body>
<div class="main">
<h1 id="header">Bat- Ball- Stump Game</h1>
<button
onclick="
randGen();
bat();
// -- just for color --
colors();
"
>
Bat
</button>
<button
onclick="
randGen();
ball();
// -- just for color --
colors();
"
>
Ball
</button>
<button
onclick="
randGen();
stump();
// -- just for color --
colors();
"
>
Stump
</button>
<h2 id="ans"></h2>
</div>
<table>
<thead>
<tr>
<th colspan="3" id="sc">SCORE-BOARD</th>
</tr>
</thead>
<thead>
<tr>
<th class="subhead">Win</th>
<th class="subhead">Tie</th>
<th class="subhead">Lost</th>
</tr>
</thead>
<tbody>
<tr>
<td id="win">0</td>
<td id="tie">0</td>
<td id="lost">0</td>
</tr>
</tbody>
</table>
<script>
// ----------- J S Starts here ------------
let score = {
win: 0,
lost: 0,
tie: 0,
};
let randomNumber, randomChoice;
document.querySelector("#ans").innerText = "Click any button";
document.getElementById("ans").style.color = "yellow";
function randGen() {
randomNumber = Math.floor(Math.random() * 3); // need not to be redeclared these variables
if (randomNumber == 0) randomChoice = "bat";
if (randomNumber == 1) randomChoice = "ball";
if (randomNumber == 2) randomChoice = "stump";
}
function bat() {
if (randomChoice == "bat") {
document.querySelector("#ans").innerText = "Tie!";
score.tie++;
document.querySelector("#tie").innerText = score.tie;
} else if (randomChoice == "ball") {
document.querySelector("#ans").innerText = "You Won!";
score.win++;
document.querySelector("#win").innerText = score.win;
} else {
document.querySelector("#ans").innerText = "You lost";
score.lost++;
document.querySelector("#lost").innerText = score.lost;
}
}
function stump() {
if (randomChoice == "ball") {
document.querySelector("#ans").innerText = "You Lost";
score.lost++;
document.querySelector("#lost").innerText = score.lost;
} else if (randomChoice == "bat") {
document.querySelector("#ans").innerText = "You Won!";
score.win++;
document.querySelector("#win").innerText = score.win;
} else {
document.querySelector("#ans").innerText = "Tie!";
score.tie++;
document.querySelector("#tie").innerText = score.tie;
}
}
function ball() {
if (randomChoice == "ball") {
document.querySelector("#ans").innerText = "Tie!";
score.tie++;
document.querySelector("#tie").innerText = score.tie;
} else if (randomChoice == "bat") {
document.querySelector("#ans").innerText = "You Lost!";
score.lost++;
document.querySelector("#lost").innerText = score.lost;
} else {
document.querySelector("#ans").innerText = "You Won!";
score.win++;
document.querySelector("#win").innerText = score.win;
}
}
function colors() {
if (document.querySelector("#ans").innerText == "Tie!") {
document.getElementById("ans").style.color = "blue";
} else if (document.querySelector("#ans").innerText == "You Won!") {
document.getElementById("ans").style.color = "#53c020";
} else {
document.getElementById("ans").style.color = "yellow";
}
}
</script>
</body>
</html>