Browse Source

add end_check

remotes/origin/Daniel
Daniel M 11 months ago
parent
commit
00eea748af
  1. BIN
      build/test/out/c/duellist-spielesammlung-projekt.o
  2. BIN
      build/test/out/test_duellist_spielesammlung_projekt.out
  3. 2
      build/test/results/test_duellist_spielesammlung_projekt.pass
  4. 26
      src/main/duellist-spielesammlung-projekt.c

BIN
build/test/out/c/duellist-spielesammlung-projekt.o

BIN
build/test/out/test_duellist_spielesammlung_projekt.out

2
build/test/results/test_duellist_spielesammlung_projekt.pass

@ -75,4 +75,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.04396939999423921
:time: 0.04520209999998315

26
src/main/duellist-spielesammlung-projekt.c

@ -293,6 +293,21 @@ int field_check(char** minefield, char** mines, int height, int width, int row,
return 1; 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 minesweeper() {
int height, width, row, column; int height, width, row, column;
printf("Enter the height of the game field:\n"); printf("Enter the height of the game field:\n");
@ -310,17 +325,6 @@ int minesweeper() {
char** minefield = create_minefield(height, width, unknown_character); char** minefield = create_minefield(height, width, unknown_character);
char** mines = create_minefield(height, width, 0); char** mines = create_minefield(height, width, 0);
distribute_mines(mines, height, width, num_mines); 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; return 1;
} }
Loading…
Cancel
Save