Renday commited on
Commit
40208b1
·
verified ·
1 Parent(s): 29704a2

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +161 -0
templates/index.html ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="de">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Ren-Ga Racing Internal</title>
7
+ <script src="https://cdn.socket.io/4.7.2/socket.io.min.js"></script>
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <style>
10
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;900&display=swap');
11
+ body { font-family: 'Inter', sans-serif; background: transparent; margin: 0; color: white; }
12
+
13
+ .horse-track {
14
+ background: rgba(255, 255, 255, 0.03);
15
+ border-radius: 999px;
16
+ height: 40px;
17
+ position: relative;
18
+ border: 1px solid rgba(255, 255, 255, 0.1);
19
+ overflow: hidden;
20
+ }
21
+
22
+ .horse-icon {
23
+ position: absolute;
24
+ top: 50%;
25
+ transform: translateY(-50%);
26
+ transition: left 0.1s linear;
27
+ font-size: 24px;
28
+ filter: drop-shadow(0 0 8px rgba(0,0,0,0.5));
29
+ }
30
+
31
+ .poker-card {
32
+ background: linear-gradient(145deg, #1e293b, #0f172a);
33
+ border: 1px solid rgba(255, 255, 255, 0.1);
34
+ }
35
+
36
+ #login-screen {
37
+ background: radial-gradient(circle at center, #1a1c2c 0%, #0a0a0a 100%);
38
+ }
39
+ </style>
40
+ </head>
41
+ <body class="overflow-hidden">
42
+
43
+ <div id="login-area" class="fixed inset-0 z-50 flex items-center justify-center p-6">
44
+ <div class="w-full max-w-sm text-center p-8 rounded-[2.5rem] bg-gray-900 border border-yellow-500/30 shadow-2xl">
45
+ <h1 class="text-4xl font-black text-yellow-500 mb-2 italic uppercase">Join Race</h1>
46
+ <p class="text-gray-400 text-[10px] tracking-widest uppercase mb-8">GamerJam Casino Login</p>
47
+
48
+ <input type="email" id="email" placeholder="E-Mail Adresse"
49
+ class="w-full bg-gray-800 border border-gray-700 text-white px-6 py-4 rounded-2xl mb-4 outline-none focus:border-yellow-500 text-center transition-all">
50
+
51
+ <button onclick="doLogin()" class="bg-red-600 hover:bg-red-500 w-full py-4 rounded-2xl font-black uppercase tracking-widest transition-all active:scale-95 shadow-lg">
52
+ An den Tisch
53
+ </button>
54
+ </div>
55
+ </div>
56
+
57
+ <div id="game-area" class="hidden min-h-screen p-4 flex flex-col">
58
+
59
+ <header class="flex justify-between items-center bg-black/40 p-4 rounded-3xl border border-white/5 mb-6">
60
+ <div class="flex gap-8">
61
+ <div>
62
+ <span class="block text-[8px] text-gray-500 uppercase font-black tracking-widest">Bankroll</span>
63
+ <span id="user-coins" class="text-xl font-black text-green-400">0 $</span>
64
+ </div>
65
+ <div>
66
+ <span class="block text-[8px] text-yellow-500 uppercase font-black tracking-widest">Gesamtpott</span>
67
+ <span id="display-pott" class="text-xl font-black text-white">0 $</span>
68
+ </div>
69
+ </div>
70
+ <div class="text-right">
71
+ <span class="block text-[8px] text-gray-500 uppercase font-black tracking-widest">Status</span>
72
+ <span id="status-text" class="text-[10px] font-black uppercase text-yellow-500 animate-pulse">Warten auf Einsätze...</span>
73
+ </div>
74
+ </header>
75
+
76
+ <div id="race-track-container" class="space-y-3 bg-black/20 p-6 rounded-[2rem] border border-white/5 mb-6">
77
+ </div>
78
+
79
+ <div id="betting-area" class="grid grid-cols-2 sm:grid-cols-4 gap-3">
80
+ </div>
81
+
82
+ <button id="admin-btn" onclick="startRace()" class="hidden mt-6 bg-yellow-500 hover:bg-yellow-400 text-black py-4 rounded-2xl font-black uppercase tracking-widest transition-all active:scale-95 shadow-xl">
83
+ Rennen Starten
84
+ </button>
85
+ </div>
86
+
87
+ <script>
88
+ const socket = io(); // Connects to the HF server automatically
89
+ let myEmail = "";
90
+
91
+ async function doLogin() {
92
+ myEmail = document.getElementById('email').value;
93
+ if(!myEmail.includes('@')) return alert("Gültige E-Mail erforderlich!");
94
+
95
+ const res = await fetch('/login', {
96
+ method: 'POST',
97
+ headers: {'Content-Type': 'application/json'},
98
+ body: JSON.stringify({email: myEmail})
99
+ });
100
+ const data = await res.json();
101
+
102
+ document.getElementById('login-area').classList.add('hidden');
103
+ document.getElementById('game-area').classList.remove('hidden');
104
+
105
+ if(data.stats.is_admin) {
106
+ document.getElementById('admin-btn').classList.remove('hidden');
107
+ }
108
+
109
+ socket.emit('join_game', {email: myEmail});
110
+ }
111
+
112
+ socket.on('update_table', (data) => {
113
+ // Render Race Tracks
114
+ const trackContainer = document.getElementById('race-track-container');
115
+ trackContainer.innerHTML = data.game.horses.map(h => `
116
+ <div class="horse-track">
117
+ <div id="horse-${h.id}" class="horse-icon" style="left: ${h.pos}%">🐎</div>
118
+ </div>
119
+ `).join('');
120
+
121
+ // Render Bet Buttons
122
+ const betArea = document.getElementById('betting-area');
123
+ betArea.innerHTML = data.game.horses.map(h => `
124
+ <button onclick="placeBet(${h.id})" class="p-4 rounded-2xl border border-white/10 hover:border-yellow-500 transition-all text-center bg-white/5">
125
+ <div class="w-3 h-3 rounded-full mx-auto mb-2 shadow-lg" style="background: ${h.color}"></div>
126
+ <span class="text-[9px] font-black uppercase tracking-widest">${h.name}</span>
127
+ </button>
128
+ `).join('');
129
+
130
+ // Update Stats
131
+ const me = data.players.find(p => p.email === myEmail);
132
+ if(me) {
133
+ document.getElementById('user-coins').innerText = me.coins + " $";
134
+ }
135
+ document.getElementById('display-pott').innerText = data.game.pott + " $";
136
+ });
137
+
138
+ function placeBet(horse_id) {
139
+ socket.emit('place_bet', {email: myEmail, horse_id: horse_id});
140
+ document.getElementById('status-text').innerText = "Wette platziert!";
141
+ }
142
+
143
+ function startRace() {
144
+ socket.emit('start_round', {email: myEmail});
145
+ }
146
+
147
+ socket.on('race_progress', (data) => {
148
+ document.getElementById('status-text').innerText = "RENNEN LÄUFT!";
149
+ data.horses.forEach(h => {
150
+ const el = document.getElementById(`horse-${h.id}`);
151
+ if(el) el.style.left = h.pos + "%";
152
+ });
153
+ });
154
+
155
+ socket.on('race_over', (data) => {
156
+ document.getElementById('status-text').innerText = "RENNEN BEENDET!";
157
+ alert("RUNDENENDE: " + data.winner + " hat gewonnen!");
158
+ });
159
+ </script>
160
+ </body>
161
+ </html>