Skip to content

Commit

Permalink
comments, minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
panki27 committed Oct 9, 2022
1 parent c5d9360 commit d1bcb7d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions minesweeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ static bool game_won(Minesweeper* minesweeper_state) {
dialog_message_set_header(message, header_text, 64, 3, AlignCenter, AlignTop);
dialog_message_set_text(message, furi_string_get_cstr(tempStr), 64, 32, AlignCenter, AlignCenter);
dialog_message_set_buttons(message, NULL, "Play again", NULL);
// TODO: create icon
dialog_message_set_icon(message, NULL, 72, 17);

DialogMessageButton choice = dialog_message_show(dialogs, message);
Expand All @@ -317,7 +316,6 @@ static bool game_won(Minesweeper* minesweeper_state) {

// returns false if the move loses the game - otherwise true
static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y) {
TileType tile = minesweeper_state->playfield[cursor_x][cursor_y]
if (minesweeper_state->playfield[cursor_x][cursor_y] == TileTypeFlag) {
// we're on a flagged field, do nothing
return true;
Expand Down Expand Up @@ -363,16 +361,13 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
}
}
}
}
}
// we're done without hitting a mine - so return
return true;
}
}
//if (minesweeper_state->playfield[cursor_x][cursor_y] != TileTypeUncleared) {
// // we're on an already uncovered field
// return true;
//}
// get number of surrounding mines.

// calculate number of surrounding mines.
int hint = 0;
for (int y = cursor_y-1; y <= cursor_y+1; y++) {
for (int x = cursor_x-1; x <= cursor_x+1; x++) {
Expand All @@ -393,6 +388,7 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
minesweeper_state->fields_cleared++;
FURI_LOG_D("Minesweeper", "Setting %d,%d to %d", cursor_x, cursor_y, hint);
if (hint == 0) {
// the field is "empty"
// auto open surrounding fields.
for (int auto_y = cursor_y-1; auto_y <= cursor_y+1; auto_y++) {
for (int auto_x = cursor_x-1; auto_x <= cursor_x+1; auto_x++) {
Expand Down

0 comments on commit d1bcb7d

Please sign in to comment.