Fixed bug, where the popup window opened twice.
This commit is contained in:
parent
d208a51419
commit
bfc55afb14
|
@ -82,10 +82,14 @@ func Gameloop(row, col int, Window fyne.Window) {
|
||||||
// checking if the game has been won by the human player
|
// checking if the game has been won by the human player
|
||||||
if gameControl.PlayerHasWon(board, PLAYER_X) {
|
if gameControl.PlayerHasWon(board, PLAYER_X) {
|
||||||
dialog.ShowInformation(gameOverText, "X has won!", Window)
|
dialog.ShowInformation(gameOverText, "X has won!", Window)
|
||||||
|
DisableAllButtons(gridContainer)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// checking if the game is a draw
|
// checking if the game is a draw
|
||||||
if gameControl.BoardisFull(board) {
|
if gameControl.BoardisFull(board) {
|
||||||
dialog.ShowInformation(gameOverText, "It's a draw!", Window)
|
dialog.ShowInformation(gameOverText, "It's a draw!", Window)
|
||||||
|
DisableAllButtons(gridContainer)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// AI opponent makes a move
|
// AI opponent makes a move
|
||||||
bestMove := opponent.Minimax(board, 0, true, PLAYER_O)
|
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) {
|
if gameControl.PlayerHasWon(board, PLAYER_O) {
|
||||||
dialog.ShowInformation(gameOverText, "O has won!", Window)
|
dialog.ShowInformation(gameOverText, "O has won!", Window)
|
||||||
DisableAllButtons(gridContainer)
|
DisableAllButtons(gridContainer)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// checking if the game is a draw
|
// checking if the game is a draw
|
||||||
if gameControl.BoardisFull(board) {
|
if gameControl.BoardisFull(board) {
|
||||||
dialog.ShowInformation(gameOverText, "It's a draw!", Window)
|
dialog.ShowInformation(gameOverText, "It's a draw!", Window)
|
||||||
DisableAllButtons(gridContainer)
|
DisableAllButtons(gridContainer)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue