Spaces:
Running
Running
Upload 7 files
Browse files- game_logic.js +25 -32
- index.html +7 -3
game_logic.js
CHANGED
@@ -176,39 +176,32 @@ async function submitAdvice(adviceText) {
|
|
176 |
}
|
177 |
|
178 |
function fetchGameState() {
|
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 |
-
.catch(err => {
|
206 |
-
console.error(err);
|
207 |
-
statusEl.textContent = "Error fetching game state.";
|
208 |
-
addStreamMessage("Error fetching game state", 'system');
|
209 |
-
});
|
210 |
-
}
|
211 |
|
|
|
|
|
212 |
// Event listeners
|
213 |
let isProcessing = false;
|
214 |
|
|
|
176 |
}
|
177 |
|
178 |
function fetchGameState() {
|
179 |
+
const formData = new FormData();
|
180 |
+
formData.append('player_name', playerName);
|
181 |
+
|
182 |
+
fetch('https://lemot.online/player/play/', {
|
183 |
+
method: 'POST',
|
184 |
+
body: formData
|
185 |
+
})
|
186 |
+
.then(res => res.json())
|
187 |
+
.then(data => {
|
188 |
+
if (data.error) {
|
189 |
+
statusEl.textContent = data.message;
|
190 |
+
statusEl.classList.add('text-red-600');
|
191 |
+
addStreamMessage(data.message, 'system');
|
192 |
+
} else {
|
193 |
+
statusEl.classList.remove('text-red-600');
|
194 |
+
updateGameState(data);
|
195 |
+
}
|
196 |
+
})
|
197 |
+
.catch(err => {
|
198 |
+
console.error(err);
|
199 |
+
statusEl.textContent = "Error fetching game state.";
|
200 |
+
addStreamMessage("Error fetching game state", 'system');
|
201 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
+
}
|
204 |
+
|
205 |
// Event listeners
|
206 |
let isProcessing = false;
|
207 |
|
index.html
CHANGED
@@ -114,12 +114,16 @@
|
|
114 |
|
115 |
<script>
|
116 |
const toggleBtn = document.createElement('button');
|
117 |
-
toggleBtn.innerHTML = '
|
118 |
toggleBtn.style.cssText = 'position: fixed; bottom: 16px; left: 16px; background: #1f2937; border: none; border-radius: 50%; padding: 8px; cursor: pointer; color: white;';
|
119 |
|
120 |
-
let isVisible =
|
|
|
|
|
|
|
|
|
|
|
121 |
toggleBtn.onclick = () => {
|
122 |
-
const debugEl = document.getElementById('dev_dbug');
|
123 |
if (debugEl) {
|
124 |
isVisible = !isVisible;
|
125 |
debugEl.style.opacity = isVisible ? '1' : '0';
|
|
|
114 |
|
115 |
<script>
|
116 |
const toggleBtn = document.createElement('button');
|
117 |
+
toggleBtn.innerHTML = '👁️🗨️';
|
118 |
toggleBtn.style.cssText = 'position: fixed; bottom: 16px; left: 16px; background: #1f2937; border: none; border-radius: 50%; padding: 8px; cursor: pointer; color: white;';
|
119 |
|
120 |
+
let isVisible = false;
|
121 |
+
const debugEl = document.getElementById('dev_dbug');
|
122 |
+
if (debugEl) {
|
123 |
+
debugEl.style.opacity = '0';
|
124 |
+
}
|
125 |
+
|
126 |
toggleBtn.onclick = () => {
|
|
|
127 |
if (debugEl) {
|
128 |
isVisible = !isVisible;
|
129 |
debugEl.style.opacity = isVisible ? '1' : '0';
|