-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
343 lines (323 loc) · 11.5 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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spin & Win: AI-Enhanced Image Slots</title>
<!-- Add this line to reference your favicon -->
<link rel="icon" type="image/png" sizes="32x32" href="/path/to/slot.png">
<link rel="icon" type="image/png" sizes="16x16" href="path/to/slot.png">
<link rel="apple-touch-icon" sizes="180x180" href="path/to/slot.png">
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background-color: #2f3640;
color: #ffffff;
padding: 20px;
box-sizing: border-box;
}
#slot-machine {
text-align: center;
width: 100%;
max-width: 800px;
}
h1 {
font-size: 2rem;
margin-bottom: 1rem;
color: #39ff14;
text-shadow: 0 0 10px #39ff14, 0 0 20px #39ff14, 0 0 30px #39ff14;
font-weight: bold;
}
#reels {
display: flex;
justify-content: center;
margin-bottom: 1rem;
flex-wrap: wrap;
}
.reel {
width: 150px;
height: 150px;
border: 2px solid #dcdde1;
margin: 0.5rem;
display: flex;
justify-content: center;
align-items: center;
background-color: #353b48;
border-radius: 10px;
}
#result {
font-size: 1.2rem;
margin-bottom: 1rem;
min-height: 3em;
display: flex;
align-items: center;
justify-content: center;
}
.win-message {
color: #ff3af2;
font-weight: bold;
}
.reel img {
max-width: 90%;
max-height: 90%;
object-fit: contain;
}
button {
background-color: #0097e6;
color: white;
border: none;
padding: 0.8rem 1.5rem;
font-size: 1rem;
cursor: pointer;
margin: 0.5rem;
border-radius: 5px;
transition: background-color 0.3s, transform 0.1s;
}
button:hover {
background-color: #00a8ff;
}
button:active {
transform: scale(0.95);
background-color: #0084c8;
}
.button-clicked {
animation: clickEffect 0.3s;
}
@keyframes clickEffect {
0% { transform: scale(1); }
50% { transform: scale(0.95); }
100% { transform: scale(1); }
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #353b48;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 90%;
max-width: 300px;
border-radius: 10px;
text-align: center;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
cursor: pointer;
}
.close:hover,
.close:focus {
color: #fff;
text-decoration: none;
cursor: pointer;
}
.wallet-option {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 50px;
margin: 10px 0;
background-color: transparent;
border: none;
border-radius: 5px;
cursor: pointer;
transition: transform 0.3s;
}
.wallet-option:hover {
transform: scale(1.05);
}
.wallet-logo {
max-width: 80%;
max-height: 80%;
object-fit: contain;
}
.rabby-logo {
max-width: 90%;
max-height: 90%;
}
@media (max-width: 600px) {
h1 {
font-size: 1.5rem;
}
.reel {
width: 100px;
height: 100px;
}
button {
padding: 0.6rem 1.2rem;
font-size: 0.9rem;
}
}
#spin-counter {
font-size: 1rem;
margin-top: 1rem;
color: #dcdde1;
}
#win-counter {
font-size: 1rem;
margin-top: 0.5rem;
color: #39ff14; /* Using the same green as the title for emphasis */
}
</style>
</head>
<body>
<div id="slot-machine">
<h1>Spin & Win: AI-Enhanced Image Slots</h1>
<div id="reels">
<div class="reel" id="reel1"></div>
<div class="reel" id="reel2"></div>
<div class="reel" id="reel3"></div>
</div>
<div id="result"></div>
<button id="spin-button">Spin</button>
<button id="connect-wallet">Connect Wallet</button>
<div id="spin-counter">Spins: 0</div>
<div id="win-counter">Winning: 0</div>
</div>
<!-- Updated modal HTML -->
<div id="connectModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<h2>Connect Wallet</h2>
<button class="wallet-option" id="keplrWallet">
<img src="/path/to/Keplr_logo_ver.1.3_2 White.png" alt="Keplr Logo" class="wallet-logo">
</button>
<button class="wallet-option" id="rabbyWallet">
<img src="/path/to/rabby-logo.png" alt="Rabby Logo" class="wallet-logo rabby-logo">
</button>
</div>
</div>
<!-- Replace the external script with an inline script -->
<script>
const reels = document.querySelectorAll('.reel');
const spinButton = document.getElementById('spin-button');
const resultDisplay = document.getElementById('result');
const connectWalletButton = document.getElementById('connect-wallet');
const spinCounterDisplay = document.getElementById('spin-counter');
const winCounterDisplay = document.getElementById('win-counter');
let spinCount = 0;
let winCount = 0;
// Update the image paths to match the correct naming convention
const images = Array.from({length: 29}, (_, i) => `/path/to/Super_Agents/img${i + 1}.png`);
function loadImage(src) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = () => reject(new Error(`Failed to load image: ${src}`));
img.src = src;
});
}
async function spin() {
spinCount++;
spinCounterDisplay.textContent = `Spins: ${spinCount}`;
const winProbability = 0.1; // 10% chance of winning
const isWin = Math.random() < winProbability;
const firstImageIndex = Math.floor(Math.random() * images.length);
for (const reel of reels) {
const imageIndex = isWin ? firstImageIndex : Math.floor(Math.random() * images.length);
const imageSrc = images[imageIndex];
try {
const img = await loadImage(imageSrc);
img.style.maxWidth = '100%';
img.style.maxHeight = '100%';
img.style.objectFit = 'contain';
reel.innerHTML = '';
reel.appendChild(img);
} catch (error) {
console.error(error);
reel.textContent = 'Error';
}
}
checkWin();
}
function checkWin() {
const results = Array.from(reels).map(reel => reel.querySelector('img')?.src);
if (results.every(src => src && src === results[0])) {
resultDisplay.textContent = 'Congratulations! You win!';
resultDisplay.classList.add('win-message');
winCount++;
winCounterDisplay.textContent = `Winning: ${winCount}`;
} else {
const loseMessages = [
"Almost there! Give it another spin!",
"So close! Try your luck again!",
"Not quite, but don't give up!",
"Keep spinning, your lucky spin is coming!",
"No win this time, but the next spin could be the one!",
"Don't lose heart, try again!",
"You're building up to a big win, keep going!",
"That was practice, now for the real deal!",
"The slots are warming up, spin again!",
"No match, but your persistence will pay off!"
];
const randomMessage = loseMessages[Math.floor(Math.random() * loseMessages.length)];
resultDisplay.textContent = randomMessage;
resultDisplay.classList.remove('win-message');
}
}
// Updated event listener for the spin button
spinButton.addEventListener('click', () => {
console.log('Spin button clicked'); // Add this line for debugging
fetch('/spin', { method: 'POST' })
.then(response => response.json())
.then(data => {
console.log('Current clicks:', data.clickCount);
// Update the spin count with the server's response
spinCount = data.clickCount;
spinCounterDisplay.textContent = `Spins: ${spinCount}`;
// Call the spin function to update the UI
spin();
})
.catch(error => {
console.error('Error:', error);
// If there's an error with the API, still allow the UI to update
spin();
});
});
connectWalletButton.addEventListener('click', () => {
console.log('Connecting wallet...');
});
// Initialize reels with placeholder or default image
async function initializeReels() {
const defaultImageSrc = images[0]; // Use the first image as default
for (const reel of reels) {
try {
const img = await loadImage(defaultImageSrc);
img.style.maxWidth = '100%';
img.style.maxHeight = '100%';
img.style.objectFit = 'contain';
reel.innerHTML = '';
reel.appendChild(img);
} catch (error) {
console.error(error);
reel.textContent = 'Error';
}
}
}
// Call initializeReels when the page loads
initializeReels();
// Initialize spin counter display
spinCounterDisplay.textContent = `Spins: ${spinCount}`;
winCounterDisplay.textContent = `Winning: ${winCount}`;
// Add this line at the end of the script for debugging
console.log('Script loaded, spin button:', spinButton);
</script>
</body>
</html>