|
|
@ -340,7 +340,36 @@ int minesweeper() { |
|
|
|
if ((row == -1) && (column == -1)) { |
|
|
|
break; |
|
|
|
} |
|
|
|
// Check field boundaries |
|
|
|
if (row >= height || row < 0) { |
|
|
|
printf("Row must be between 1 and %d!\n", height); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (column >= width || column < 0) { |
|
|
|
printf("Column must be between 1 and %d!\n", width); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
// Did you land on a mine? |
|
|
|
if (field_check(minefield, mines, height, width, row, column) == 0) { |
|
|
|
// Show the mines |
|
|
|
show_minefield(mines, height, width); |
|
|
|
printf("Row: %d Column: %d was unfortunately a mine!\n", row + 1, column + 1); |
|
|
|
break; |
|
|
|
} |
|
|
|
// Are you done? |
|
|
|
else if (end_check(minefield, mines, height, width)) { |
|
|
|
// Show the mines |
|
|
|
show_minefield(mines, height, width); |
|
|
|
printf("Great! Solved correctly!\n"); |
|
|
|
break; |
|
|
|
} |
|
|
|
// Show current field to continue playing |
|
|
|
else { |
|
|
|
show_minefield(mines, height, width); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
|