From 3e4827768ddfe27fbacc1f0f1cec3bd8c891e001 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 21 Dec 2018 09:04:26 +0000 Subject: Added option to show cards on quit. --- README | 2 +- csol.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README b/README index e3c6877..992f5e3 100644 --- a/README +++ b/README @@ -26,6 +26,6 @@ On starting a game of Klondike, the following applies * Press '1', '2', '3' or '4' to move the top card from the hearts, diamonds, spades or clubs suit pile respectively back onto the board. - * Press 'Q' to quit. + * Press 'Q' to quit. You'll be asked if you want to see the cards. The '?' key can be used to get help at anytime. diff --git a/csol.c b/csol.c index e16c979..d305c13 100644 --- a/csol.c +++ b/csol.c @@ -492,7 +492,7 @@ static void KlondikeHelp(void) "Press '1', '2', '3' or '4' to move the top card from the hearts, ", "diamonds, spades or clubs suit pile respectively back onto the board.", "", - "Press 'Q' to quit.", + "Press 'Q' to quit. You'll be asked if you want to see the cards.", "", "", "Press SPACE to continue.", @@ -530,6 +530,7 @@ static void Klondike(int draw) int i; int won = FALSE; int quit = FALSE; + int show = FALSE; int pos_x = 0; int pos_y = 0; int move_pos_x = -1; @@ -674,8 +675,16 @@ static void Klondike(int draw) case 'Q': case 'q': + { + int k; + quit = TRUE; + Centre(LINES-1, "Show cards?"); + refresh(); + k = getch(); + show = (k == 'y' || k == 'Y'); break; + } case 10: if (move_pos_x == -1) @@ -808,6 +817,27 @@ static void Klondike(int draw) } } + if (show) + { + for(f = 0; f < 7; f++) + { + for(n = 0; n < column_down[f].no; n++) + { + DrawCard(2 + n, 1 + f * 5, FALSE, column_down[f].card[n]); + } + + for(n = 0; n < column_up[f].no; n++) + { + DrawCard(2 + column_down[f].no + n, 1 + f * 5, + FALSE, column_up[f].card[n]); + } + } + + Centre(LINES - 1, "Press any key"); + refresh(); + getch(); + } + if (won) { WinScreen(); -- cgit v1.2.3