From bfc55afb14c86080d154445469d32119733be437 Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Mon, 29 Apr 2024 15:32:13 +0200 Subject: [PATCH] Fixed bug, where the popup window opened twice. --- game/gameloop.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/game/gameloop.go b/game/gameloop.go index db35669..f31438b 100644 --- a/game/gameloop.go +++ b/game/gameloop.go @@ -82,10 +82,14 @@ func Gameloop(row, col int, Window fyne.Window) { // checking if the game has been won by the human player if gameControl.PlayerHasWon(board, PLAYER_X) { dialog.ShowInformation(gameOverText, "X has won!", Window) + DisableAllButtons(gridContainer) + return } // checking if the game is a draw if gameControl.BoardisFull(board) { dialog.ShowInformation(gameOverText, "It's a draw!", Window) + DisableAllButtons(gridContainer) + return } // AI opponent makes a move bestMove := opponent.Minimax(board, 0, true, PLAYER_O) @@ -97,11 +101,13 @@ func Gameloop(row, col int, Window fyne.Window) { if gameControl.PlayerHasWon(board, PLAYER_O) { dialog.ShowInformation(gameOverText, "O has won!", Window) DisableAllButtons(gridContainer) + return } // checking if the game is a draw if gameControl.BoardisFull(board) { dialog.ShowInformation(gameOverText, "It's a draw!", Window) DisableAllButtons(gridContainer) + return } }