From 915390cef2f5ce3ad00e970587da9e6fc6c7e1ca Mon Sep 17 00:00:00 2001 From: thunic Date: Sun, 17 Mar 2024 15:48:21 +0100 Subject: [PATCH] all bombs revealed --- Minesweeper/Core/Src/spielfeld.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Minesweeper/Core/Src/spielfeld.c b/Minesweeper/Core/Src/spielfeld.c index e1ed180..785adf9 100644 --- a/Minesweeper/Core/Src/spielfeld.c +++ b/Minesweeper/Core/Src/spielfeld.c @@ -187,10 +187,18 @@ int revealCell(int** gameBoard, int** hiddenGameBoard, int size, int row, int co if (hiddenGameBoard[pos.row][pos.col] != HIDDEN_CELL) { return 1; } - if (gameBoard[pos.row][pos.col] == FLAG_CELL){ + if (hiddenGameBoard[pos.row][pos.col] == FLAG_CELL){ return 1; } if (gameBoard[pos.row][pos.col] == BOMB_CELL) { + hiddenGameBoard[pos.row][pos.col] = gameBoard[pos.row][pos.col]; + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + if (gameBoard[i][j] == BOMB_CELL) { + hiddenGameBoard[i][j] = gameBoard[i][j]; + } + } + } handleBombExploded(); return 0; } @@ -249,6 +257,8 @@ int checkWin(int** gameBoard, int** hiddenGameBoard, int size, int numBombs, int void handleBombExploded() { char message[] = "Spiel Verloren! Du hast eine Bombe getroffen!\r\nStarte neu mit der ON Taste. \r\n"; HAL_UART_Transmit(&huart2, (uint8_t*)message, sizeof(message), 100); + + }