Browse Source

refactoring: changed magic number 48 to define

remotes/origin/David
David Moeller 11 months ago
parent
commit
e076476299
  1. 5
      src/main/c/Minesweeper/minesweeper_start.c

5
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);}
}
}

Loading…
Cancel
Save