|
@ -25,6 +25,7 @@ void place_bombs(Minesweeper_Board *board); |
|
|
bool bomb_in_array(int array[], int bomb, int length); |
|
|
bool bomb_in_array(int array[], int bomb, int length); |
|
|
void draw_minesweeper(Minesweeper_Board board); |
|
|
void draw_minesweeper(Minesweeper_Board board); |
|
|
int open_tile(Minesweeper_Board *board, int tile); |
|
|
int open_tile(Minesweeper_Board *board, int tile); |
|
|
|
|
|
int number_of_bombs(Minesweeper_Board *board, int tile); |
|
|
#pragma endregion |
|
|
#pragma endregion |
|
|
|
|
|
|
|
|
#pragma region Global |
|
|
#pragma region Global |
|
@ -199,5 +200,23 @@ void draw_minesweeper(Minesweeper_Board board){ |
|
|
|
|
|
|
|
|
int open_tile(Minesweeper_Board *board, int tile){ |
|
|
int open_tile(Minesweeper_Board *board, int tile){ |
|
|
if(bomb_in_array(board->bombs, tile, board->num_bombs)){return -1;} |
|
|
if(bomb_in_array(board->bombs, tile, board->num_bombs)){return -1;} |
|
|
|
|
|
int num = number_of_bombs(board, tile); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int number_of_bombs(Minesweeper_Board *board, int tile){ |
|
|
|
|
|
int sum = 0; |
|
|
|
|
|
for(int i = 0; i < 8; i++){ |
|
|
|
|
|
int check_tile = tile; |
|
|
|
|
|
if(i < 3 && tile % board->width == 0){continue;} |
|
|
|
|
|
else{check_tile - 1;} |
|
|
|
|
|
if(i > 4 && tile % board->width + 1 == board->width){continue;} |
|
|
|
|
|
else{check_tile + 1;} |
|
|
|
|
|
if(i % 3 == 0 && i != 0 && tile / board->width == 0){continue;} |
|
|
|
|
|
else{check_tile - board->width;} |
|
|
|
|
|
if(i % 3 == 1 && tile / board->width + 1 == height){continue;} |
|
|
|
|
|
else{check_tile + board->width;} |
|
|
|
|
|
if(bomb_in_array(board->bombs, check_tile, board->num_bombs)){sum++;} |
|
|
|
|
|
} |
|
|
|
|
|
return sum; |
|
|
} |
|
|
} |