diff --git a/Minesweeper/Core/Inc/spielfeld.h b/Minesweeper/Core/Inc/spielfeld.h index f86119d..c786eac 100644 --- a/Minesweeper/Core/Inc/spielfeld.h +++ b/Minesweeper/Core/Inc/spielfeld.h @@ -35,8 +35,9 @@ void placeBombs(int** gameBoard, int size, int numBombs); void displayGameBoardUART(int** gameBoard, int size, int numBombs, int numFlags); void freeGameBoard(int** gameBoard, int size); int** createHiddenGameBoard(int** gameBoard, int size); -int** revealCell(int** gameBoard, int** hiddenGameBoard, int size, int row, int col); +void revealCell(int** gameBoard, int** hiddenGameBoard, int size, int row, int col); void getPositionIndices(int row, int col, Position* pos); void getNewPosition(Position* pos, int dx, int dy, Position* newPos); +void setFlag(int** hiddenGameBoard, int row, int col, int* numFlags); #endif /* INC_SPIELFELD_H_ */ diff --git a/Minesweeper/Core/Src/main.c b/Minesweeper/Core/Src/main.c index ebbc4f9..eb19cff 100644 --- a/Minesweeper/Core/Src/main.c +++ b/Minesweeper/Core/Src/main.c @@ -108,8 +108,8 @@ int main(void) hiddenGameBoard= createHiddenGameBoard(gameBoard, size); displayGameBoardUART(hiddenGameBoard, size, numBombs, numFlags); - hiddenGameBoard= revealCell(gameBoard, hiddenGameBoard, size, 3, 5); - hiddenGameBoard= setFlag(hiddenGameBoard, 6,7, numFlags); + revealCell(gameBoard, hiddenGameBoard, size, 3, 5); + setFlag(hiddenGameBoard, 6,7, &numFlags); displayGameBoardUART(hiddenGameBoard, size, numBombs, numFlags); diff --git a/Minesweeper/Core/Src/spielfeld.c b/Minesweeper/Core/Src/spielfeld.c index 08cc667..355b65f 100644 --- a/Minesweeper/Core/Src/spielfeld.c +++ b/Minesweeper/Core/Src/spielfeld.c @@ -174,7 +174,7 @@ void revealEmptyCells(int** gameBoard, int** hiddenGameBoard, int size, Position } } -int** revealCell(int** gameBoard, int** hiddenGameBoard, int size, int row, int col) { +void revealCell(int** gameBoard, int** hiddenGameBoard, int size, int row, int col) { Position pos; pos.row = row; pos.col = col; @@ -202,15 +202,19 @@ int** revealCell(int** gameBoard, int** hiddenGameBoard, int size, int row, int return hiddenGameBoard; } -void setFlag(int** hiddenGameBoard, int row, int col, int numFlags) { +void setFlag(int** hiddenGameBoard, int row, int col, int* numFlags) { if (hiddenGameBoard[row][col] == FLAG_CELL) { hiddenGameBoard[row][col] = HIDDEN_CELL; - numFlags --; + (*numFlags)--; } - else if (hiddenGameBoard[row][col] == HIDDEN_CELL){ + else if (hiddenGameBoard[row][col] == HIDDEN_CELL) + { hiddenGameBoard[row][col] = FLAG_CELL; - numFlags ++; + (*numFlags)++; } - return numFlags; +} + +void checkWin(){ + }