From 847ed8b7df324125953856e7692d79e19542bb8a Mon Sep 17 00:00:00 2001 From: girst Date: Wed, 24 Oct 2018 16:07:32 +0200 Subject: [PATCH] on win: show all flags the original minesweeper sets all mines to flags when won. this also helps distinguishing wins from losses (that previously only differed in emoticon) --- mines.c | 11 ++++++++--- mines.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mines.c b/mines.c index d4f0b68..c0edcbb 100644 --- a/mines.c +++ b/mines.c @@ -101,7 +101,8 @@ newgame: } timer_setup(0); /* stop timer */ - show_minefield (SHOWMINES); + int show_how = g.o==GAME_WON?SHOWFLAGS:SHOWMINES; + show_minefield (show_how); for(;;) { switch(getch_wrapper()) { case WRAPPER_EMOTICON: @@ -109,7 +110,7 @@ newgame: case 'q': goto quit; case CTRL_'L': //TODO: updates the timer (fix in show_minefield()) screen_setup(1); - show_minefield (SHOWMINES); + show_minefield (show_how); break; case CTRL_'R': interactive_resize(); @@ -472,7 +473,11 @@ char* cell2schema (int l, int c, int mode) { cell.m == DEATH_MINE ? op.scheme->mine_death: cell.o == CLOSED ? op.scheme->field_closed: /*.......................*/ op.scheme->number[f.c[l][c].n]); - else return ( + else if (mode == SHOWFLAGS) return ( + /* on win (everything opened, only correct flags left) */ + cell.m == STD_MINE ? op.scheme->field_flagged: + /*.......................*/ op.scheme->number[f.c[l][c].n]); + else return ( cell.f == FLAG ? op.scheme->field_flagged: cell.f == QUESM ? op.scheme->field_question: cell.o == CLOSED ? op.scheme->field_closed: diff --git a/mines.h b/mines.h index 60a31c0..95506c9 100644 --- a/mines.h +++ b/mines.h @@ -110,6 +110,7 @@ enum modes { NORMAL, REDUCED, SHOWMINES, + SHOWFLAGS, HIGHLIGHT, RESIZEMODE, }; -- 2.39.3