diff --git a/presentation_no_iframe.html b/presentation_no_iframe.html index a01dd3b..c4594c6 100644 --- a/presentation_no_iframe.html +++ b/presentation_no_iframe.html @@ -526,7 +526,7 @@ -

Play on your device or scan the QR code for mobile access

+

Play on your device or scan the QR code for mobile access

@@ -1112,6 +1112,17 @@ return; } } + + // Check for stalemate (board full or no moves possible) + if (this.isBoardFull() || this.noMovesRemaining()) { + console.log('🔄 Game stalemate detected, restarting...'); + setTimeout(() => { + this.resetGame(); + if (this.playerTypes[this.currentPlayer] === 'ai') { + setTimeout(() => this.makeAIMove(), this.aiMoveDelay); + } + }, 3000); + } } checkFiveInRow(player) { @@ -1132,6 +1143,29 @@ return false; } + isBoardFull() { + for (let r = 0; r < 13; r++) { + for (let c = 0; c < 13; c++) { + if (this.isPlayable(r, c) && this.board[r][c] === null) { + return false; + } + } + } + return true; + } + + noMovesRemaining() { + // Check if both players have no pieces left to play + for (let player = 1; player <= 2; player++) { + const inventory = this.inventory[player]; + const totalPieces = inventory.fire + inventory.water + inventory.earth + inventory.air + inventory.love; + if (totalPieces > 0) { + return false; + } + } + return true; + } + checkLineFromPosition(startR, startC, direction, player, length) { let firstElement = null; @@ -1221,9 +1255,15 @@ } // Auto-restart for presentation + console.log(`🎯 Game Over! Player ${winner} won. Restarting in 4 seconds...`); setTimeout(() => { + console.log('🔄 Restarting game...'); this.resetGame(); - }, 2000); + // Ensure AI starts playing again + if (this.playerTypes[this.currentPlayer] === 'ai') { + setTimeout(() => this.makeAIMove(), this.aiMoveDelay); + } + }, 4000); } resetGame() {