Skip to content

Commit

Permalink
game html
Browse files Browse the repository at this point in the history
  • Loading branch information
KotsiosDimis committed Jan 9, 2025
1 parent 5db7949 commit 8de5298
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions public/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ <h4>Current Player: <span id="currentPlayer" style="color: red;">Player 1</span>
<script type="module">
import { initializeGame } from './js/renderGame.js';

// Hardcode game ID for testing
const gameId = 17; // Replace this with your test game ID

// Initialize the game
// Extract lobby_id from the URL
document.addEventListener('DOMContentLoaded', () => {
if (gameId) {
initializeGame(gameId);
const urlParams = new URLSearchParams(window.location.search);
const lobbyId = urlParams.get('lobby_id');

if (lobbyId) {
console.log(`Lobby ID: ${lobbyId}`);
initializeGame(lobbyId);
} else {
document.getElementById('board').innerHTML = '<p class="text-danger">Invalid game ID.</p>';
console.error('No lobby_id found in the URL.');
document.getElementById('board').innerHTML = '<p class="text-danger">Invalid lobby ID.</p>';
}
});
</script>
Expand Down

0 comments on commit 8de5298

Please sign in to comment.