Spaces:
Sleeping
Sleeping
Upload 6 files
Browse files- room_game.html +0 -31
- room_game.js +1 -12
room_game.html
CHANGED
|
@@ -75,30 +75,6 @@
|
|
| 75 |
margin-bottom: 10px;
|
| 76 |
}
|
| 77 |
|
| 78 |
-
.markdown-panel {
|
| 79 |
-
flex: 0 0 300px;
|
| 80 |
-
background: #222;
|
| 81 |
-
border: 1px solid #444;
|
| 82 |
-
border-radius: 5px;
|
| 83 |
-
overflow: hidden;
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
.markdown-header {
|
| 87 |
-
background: #333;
|
| 88 |
-
padding: 10px;
|
| 89 |
-
text-align: center;
|
| 90 |
-
color: #00ccff;
|
| 91 |
-
font-weight: bold;
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
.markdown-content {
|
| 95 |
-
padding: 15px;
|
| 96 |
-
font-size: 12px;
|
| 97 |
-
line-height: 1.4;
|
| 98 |
-
max-height: 600px;
|
| 99 |
-
overflow-y: auto;
|
| 100 |
-
white-space: pre-wrap;
|
| 101 |
-
}
|
| 102 |
|
| 103 |
.game-board {
|
| 104 |
flex: 1;
|
|
@@ -283,13 +259,6 @@
|
|
| 283 |
</div>
|
| 284 |
</div>
|
| 285 |
|
| 286 |
-
<!-- Markdown Display Panel -->
|
| 287 |
-
<div class="markdown-panel">
|
| 288 |
-
<div class="markdown-header">📝 Game State (Markdown)</div>
|
| 289 |
-
<div class="markdown-content" id="markdownContent">
|
| 290 |
-
Select or create a room to see the markdown representation...
|
| 291 |
-
</div>
|
| 292 |
-
</div>
|
| 293 |
|
| 294 |
<!-- Game Board -->
|
| 295 |
<div class="game-board">
|
|
|
|
| 75 |
margin-bottom: 10px;
|
| 76 |
}
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
.game-board {
|
| 80 |
flex: 1;
|
|
|
|
| 259 |
</div>
|
| 260 |
</div>
|
| 261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
<!-- Game Board -->
|
| 264 |
<div class="game-board">
|
room_game.js
CHANGED
|
@@ -5,7 +5,6 @@ class RoomTicTacToeGame {
|
|
| 5 |
this.cells = document.querySelectorAll('.cell');
|
| 6 |
this.gameStatus = document.getElementById('gameStatus');
|
| 7 |
this.roomInfo = document.getElementById('roomInfo');
|
| 8 |
-
this.markdownContent = document.getElementById('markdownContent');
|
| 9 |
this.chatMessages = document.getElementById('chatMessages');
|
| 10 |
this.chatInput = document.getElementById('chatInput');
|
| 11 |
this.sendBtn = document.getElementById('sendBtn');
|
|
@@ -84,7 +83,6 @@ class RoomTicTacToeGame {
|
|
| 84 |
|
| 85 |
// Update display
|
| 86 |
this.updateDisplay();
|
| 87 |
-
this.updateMarkdown(data.markdown);
|
| 88 |
this.loadChatHistory();
|
| 89 |
|
| 90 |
this.gameStatus.textContent = `Joined room ${roomId}!`;
|
|
@@ -110,7 +108,6 @@ class RoomTicTacToeGame {
|
|
| 110 |
this.clearBoard();
|
| 111 |
this.gameStatus.textContent = "Create or join a room to start playing!";
|
| 112 |
this.updateRoomInfo();
|
| 113 |
-
this.markdownContent.textContent = "Select or create a room to see the markdown representation...";
|
| 114 |
|
| 115 |
// Clear chat
|
| 116 |
this.chatMessages.innerHTML = `
|
|
@@ -139,7 +136,6 @@ class RoomTicTacToeGame {
|
|
| 139 |
const data = await response.json();
|
| 140 |
this.roomData = data.room_data;
|
| 141 |
this.updateDisplay();
|
| 142 |
-
this.updateMarkdown(data.markdown);
|
| 143 |
|
| 144 |
} catch (error) {
|
| 145 |
console.error('Failed to refresh room:', error);
|
|
@@ -178,7 +174,6 @@ class RoomTicTacToeGame {
|
|
| 178 |
const data = await response.json();
|
| 179 |
this.roomData = data.room_data;
|
| 180 |
this.updateDisplay();
|
| 181 |
-
this.updateMarkdown(data.markdown);
|
| 182 |
this.loadChatHistory(); // Reload chat to get AI's move message
|
| 183 |
|
| 184 |
if (this.roomData.game_status === 'active') {
|
|
@@ -223,8 +218,7 @@ class RoomTicTacToeGame {
|
|
| 223 |
|
| 224 |
const data = await response.json();
|
| 225 |
this.roomData = data.room_data;
|
| 226 |
-
|
| 227 |
-
this.loadChatHistory();
|
| 228 |
|
| 229 |
} catch (error) {
|
| 230 |
console.error('Chat failed:', error);
|
|
@@ -280,11 +274,6 @@ class RoomTicTacToeGame {
|
|
| 280 |
`;
|
| 281 |
}
|
| 282 |
|
| 283 |
-
updateMarkdown(markdown) {
|
| 284 |
-
if (markdown) {
|
| 285 |
-
this.markdownContent.textContent = markdown;
|
| 286 |
-
}
|
| 287 |
-
}
|
| 288 |
|
| 289 |
loadChatHistory() {
|
| 290 |
if (!this.roomData || !this.roomData.chat_history) return;
|
|
|
|
| 5 |
this.cells = document.querySelectorAll('.cell');
|
| 6 |
this.gameStatus = document.getElementById('gameStatus');
|
| 7 |
this.roomInfo = document.getElementById('roomInfo');
|
|
|
|
| 8 |
this.chatMessages = document.getElementById('chatMessages');
|
| 9 |
this.chatInput = document.getElementById('chatInput');
|
| 10 |
this.sendBtn = document.getElementById('sendBtn');
|
|
|
|
| 83 |
|
| 84 |
// Update display
|
| 85 |
this.updateDisplay();
|
|
|
|
| 86 |
this.loadChatHistory();
|
| 87 |
|
| 88 |
this.gameStatus.textContent = `Joined room ${roomId}!`;
|
|
|
|
| 108 |
this.clearBoard();
|
| 109 |
this.gameStatus.textContent = "Create or join a room to start playing!";
|
| 110 |
this.updateRoomInfo();
|
|
|
|
| 111 |
|
| 112 |
// Clear chat
|
| 113 |
this.chatMessages.innerHTML = `
|
|
|
|
| 136 |
const data = await response.json();
|
| 137 |
this.roomData = data.room_data;
|
| 138 |
this.updateDisplay();
|
|
|
|
| 139 |
|
| 140 |
} catch (error) {
|
| 141 |
console.error('Failed to refresh room:', error);
|
|
|
|
| 174 |
const data = await response.json();
|
| 175 |
this.roomData = data.room_data;
|
| 176 |
this.updateDisplay();
|
|
|
|
| 177 |
this.loadChatHistory(); // Reload chat to get AI's move message
|
| 178 |
|
| 179 |
if (this.roomData.game_status === 'active') {
|
|
|
|
| 218 |
|
| 219 |
const data = await response.json();
|
| 220 |
this.roomData = data.room_data;
|
| 221 |
+
this.loadChatHistory();
|
|
|
|
| 222 |
|
| 223 |
} catch (error) {
|
| 224 |
console.error('Chat failed:', error);
|
|
|
|
| 274 |
`;
|
| 275 |
}
|
| 276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
|
| 278 |
loadChatHistory() {
|
| 279 |
if (!this.roomData || !this.roomData.chat_history) return;
|