-
Notifications
You must be signed in to change notification settings - Fork 0
/
casino.html
216 lines (211 loc) · 7.3 KB
/
casino.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
border:none;
margin: 0;
padding: 0;
}
body {
margin:0;
padding: 0;
font-family: arial;
background-color: rgb(26, 44, 56);
}
#playerConsole {
background: white;
width: 40%;
margin: auto;
display: block;
height: 90%;
max-height: 90%;
padding: 10px;
border:none;
border-radius: 6px;
margin-top: 3%;
}
header {
background-color: rgb(26, 44, 56);
box-shadow: rgba(110, 110, 110, 0.1) 0px 7px 29px 0px;
padding: 20px;
display: flex;
justify-content: space-around;
max-width: 100%;
overflow: hidden;
font-size: 21px;
color: white;
}
#top {
padding: 25px;
margin: auto;
display: block;
}
ul {
list-style: none;
}
ul button {
padding: 6px 12px;
background: rgb(234, 237, 246);
color: white;
display: inline-block;
text-align: center;
border-radius: 6px;
font-size: 12px;
cursor: pointer;
color: rgb(122,126,136)
}
ul button:hover {
transform: scale(1.20);
border:none;
}
#selectColor {
padding: 5px;
border: 1px solid black;
background:white;
margin-top:10px;
}
#pbtn {
background: rgb(37,80,250);
border: 2px solid rgb(37,80,250);
color:white;
padding: 18px;
border-radius: 6px;
cursor: pointer;
outline: 0;
font-size:13px;
display: inline-block;
}
#blnc {
color:lightgreen;
}
#betAmt, #selectColor {
background-color: rgb(234, 237, 246);
padding: 15px;
border: 2px solid rgb(85,112,134);
border-radius: 6px;
outline: 0;
}
#betAmt:focus, #selectColor:focus {
border-color: rgb(47, 69, 83);
}
#betAmt, #selectColor, #pbtn {
width: 90%;
display: inline-block;
box-sizing: border-box;
}
button[disabled] {
background-color: rgb(204, 207, 216);
}
#reS {
border: 3px solid rgb(37,80,250);
border-radius: 4px;
text-align: center;
padding: 10px;
height: auto;
width: 30%;
display: none;
background-color: white;
color: #000;
}
@media only screen and (max-width:500px) {
#playerConsole {
width: 90%;
}
}
</style>
</head>
<body>
<header>Casino <p style="font-size: 16px;">Balance: $<span id="blnc">0.00</span></p></header>
<div id="playerConsole">
<div id="top">
<h4>Please select a color below</h4>
<input type="text" disabled value="" id="selectColor" placeholder="Select a Color Below">
<br/><br/>
<center>
<ul>
<button onclick="g()" id="g">Green</button>
<button onclick="y()" id="y">Yellow</button>
<button onclick="r()" id="r">Red</button>
</ul>
</center>
<br/>
<input type="text" id="betAmt" placeholder="0.00">
<br/><br/>
<button id="pbtn" onclick="chngColor()">Bet</button>
<br/><br/>
<center>
<div id="reS">
<span id="result"></span></p>
<p id="wOrL"></p>
</div>
</center>
</div>
</div>
<script>
const pbtn = document.getElementById("pbtn");
const rslt = document.getElementById("result");
const sC = document.getElementById("selectColor");
const colors = ["Green", "Yellow", "Red"];
const wL = document.getElementById("wOrL");
const blnc = document.getElementById("blnc");
const reS = document.getElementById("reS");
let betAmt = document.getElementById("betAmt");
let money = 500;
blnc.textContent = money;
function chngColor(e) {
if(sC.value === "") {
reS.style.display = "block";
rslt.textContent = "Please select a color";
}
else {
let x = Math.floor(Math.random()*colors.length);
rslt.textContent = colors[x];
}
if(rslt.textContent === sC.value) {
reS.style.display = "block";
wL.innerHTML = "2.00x <br/>" + "$"+ betAmt.value*2;
money -= betAmt.value;
money += parseFloat(betAmt.value*2);
blnc.textContent = money;
}
else {
if(sC.value === "") {
wL.textContent = "";
}
else {
reS.style.display = "block";
wL.textContent = "0.00x";
money -= betAmt.value;
blnc.textContent = money;
}
}
document.getElementById("g").disabled = false;
document.getElementById("y").disabled = false;
document.getElementById("r").disabled = false;
}
function g() {
sC.value = "Green";
document.getElementById("g").disabled = true;
document.getElementById("y").disabled = true;
document.getElementById("r").disabled = true;
}
function y() {
sC.value = "Yellow";
document.getElementById("g").disabled = true;
document.getElementById("y").disabled = true;
document.getElementById("r").disabled = true;
}
function r() {
sC.value = "Red";
document.getElementById("g").disabled = true;
document.getElementById("y").disabled = true;
document.getElementById("r").disabled = true;
}
function reset() {
rslt.textContent = "";
}
</script>
</body>
</html>