From e0764762993f012852bb3082dde4bf2b1f45247f Mon Sep 17 00:00:00 2001 From: David Moeller Date: Wed, 7 Feb 2024 09:27:34 +0100 Subject: [PATCH] refactoring: changed magic number 48 to define --- src/main/c/Minesweeper/minesweeper_start.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/c/Minesweeper/minesweeper_start.c b/src/main/c/Minesweeper/minesweeper_start.c index fedb818..924e5e7 100644 --- a/src/main/c/Minesweeper/minesweeper_start.c +++ b/src/main/c/Minesweeper/minesweeper_start.c @@ -14,6 +14,7 @@ #define EASY 7 #define NORMAL 5 #define HARD 3 +#define OFFSET_NUM_CHARS 48 #pragma endregion #pragma region Funktion_heads @@ -94,7 +95,7 @@ void game_minesweeper(){ int bombs = open_tile(&board, x); if(bombs == -1){printf("You Lose!"); getchar(); break;} else if(bombs == 0){open_empty_space(&board, x, 0);} - else{board.tiles[x] = bombs + 48;} + else{board.tiles[x] = bombs + OFFSET_NUM_CHARS;} } if(t == 1){board.tiles[x] = board.tiles[x] == FLAG ? BLOCK : board.tiles[x] == BLOCK ? FLAG : board.tiles[x];} } @@ -242,7 +243,7 @@ void open_empty_space(Minesweeper_Board *board, int tile, int index){ int check_tile = is_Valid_tile(board, tile, i); if(check_tile == -1){continue;} int sum = open_tile(board, check_tile); - if(sum != 0){board->tiles[check_tile] = sum + 48;} + if(sum != 0){board->tiles[check_tile] = sum + OFFSET_NUM_CHARS;} else if(!array_contains_value(board->marked, check_tile, board->height * board->width)){open_empty_space(board, check_tile, index + 1);} } }