|
|
|
@ -187,10 +187,18 @@ int revealCell(int** gameBoard, int** hiddenGameBoard, int size, int row, int co
|
|
|
|
if (hiddenGameBoard[pos.row][pos.col] != HIDDEN_CELL) {
|
|
|
|
if (hiddenGameBoard[pos.row][pos.col] != HIDDEN_CELL) {
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gameBoard[pos.row][pos.col] == FLAG_CELL){
|
|
|
|
if (hiddenGameBoard[pos.row][pos.col] == FLAG_CELL){
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gameBoard[pos.row][pos.col] == BOMB_CELL) {
|
|
|
|
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();
|
|
|
|
handleBombExploded();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -249,6 +257,8 @@ int checkWin(int** gameBoard, int** hiddenGameBoard, int size, int numBombs, int
|
|
|
|
void handleBombExploded() {
|
|
|
|
void handleBombExploded() {
|
|
|
|
char message[] = "Spiel Verloren! Du hast eine Bombe getroffen!\r\nStarte neu mit der ON Taste. \r\n";
|
|
|
|
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);
|
|
|
|
HAL_UART_Transmit(&huart2, (uint8_t*)message, sizeof(message), 100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|