|
|
@ -293,6 +293,21 @@ int field_check(char** minefield, char** mines, int height, int width, int row, |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
int end_check(char** minefield, char** mines, int height, int width) { |
|
|
|
int i, j; |
|
|
|
|
|
|
|
for (i = 0; i < height; i++) { |
|
|
|
for (j = 0; j < width; j++) { |
|
|
|
// If a field is not uncovered and does not contain a mine, the game is not over |
|
|
|
if ((mines[i][j] == 0) && (minefield[i][j] == unknown_character)) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
int minesweeper() { |
|
|
|
int height, width, row, column; |
|
|
|
printf("Enter the height of the game field:\n"); |
|
|
@ -310,17 +325,6 @@ int minesweeper() { |
|
|
|
char** minefield = create_minefield(height, width, unknown_character); |
|
|
|
char** mines = create_minefield(height, width, 0); |
|
|
|
distribute_mines(mines, height, width, num_mines); |
|
|
|
while (1) { |
|
|
|
|
|
|
|
printf("Enter 'row column' to uncover (to quit enter '0 0'):\n"); |
|
|
|
if (scanf("%d %d", &row, &column) != 2) { |
|
|
|
printf("Incorrect input!\n"); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
row--; |
|
|
|
column--; |
|
|
|
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
|