summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2018-12-21 13:17:12 +0000
committerIan C <ianc@noddybox.co.uk>2018-12-21 13:17:12 +0000
commitf9b0bb07c97392e0086a7a7fce52e255d4d2df5d (patch)
tree270041d1865945c9d3b614410355f530036418f3
parent1169992d50ce930143efe2851d02e7dfa0304e29 (diff)
Added thoughtful mode.
-rw-r--r--README3
-rw-r--r--csol.c22
-rw-r--r--klondike.c19
-rw-r--r--klondike.h2
4 files changed, 32 insertions, 14 deletions
diff --git a/README b/README
index 992f5e3..c4921e6 100644
--- a/README
+++ b/README
@@ -26,6 +26,7 @@ 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. You'll be asked if you want to see the cards.
+ * Press 'Q' to quit. You'll be asked if you want to see the cards if
+ you're not playing a thoughtful game.
The '?' key can be used to get help at anytime.
diff --git a/csol.c b/csol.c
index 1abfcc9..e417b39 100644
--- a/csol.c
+++ b/csol.c
@@ -48,12 +48,16 @@ int main(int argc, char *argv[])
while(!quit)
{
+ int row = 3;
+
erase();
Centre(1, "CURSES solitaire");
- Centre(3, "1 .. Klondike (draw three)");
- Centre(4, "2 .. Klondike (draw one)");
- Centre(5, "Q .. Quit");
+ Centre(row++, "1 ............. Klondike (draw three)");
+ Centre(row++, "2 ............... Klondike (draw one)");
+ Centre(row++, "3 .. Thoughtful Klondike (draw three)");
+ Centre(row++, "4 .... Thoughtful Klondike (draw one)");
+ Centre(row++, "Q .............................. Quit");
key = getch();
@@ -61,11 +65,19 @@ int main(int argc, char *argv[])
{
case '1':
erase();
- Klondike(3);
+ Klondike(3, FALSE);
break;
case '2':
erase();
- Klondike(1);
+ Klondike(1, FALSE);
+ break;
+ case '3':
+ erase();
+ Klondike(3, TRUE);
+ break;
+ case '4':
+ erase();
+ Klondike(1, TRUE);
break;
case 'q':
case 'Q':
diff --git a/klondike.c b/klondike.c
index 0a5b760..aac2c33 100644
--- a/klondike.c
+++ b/klondike.c
@@ -141,7 +141,8 @@ 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. You'll be asked if you want to see the cards.",
+ "Press 'Q' to quit. You'll be asked if you want to see the cards",
+ "if not playing a thoughtful game.",
"",
"",
"Press SPACE to continue.",
@@ -163,7 +164,7 @@ static void KlondikeHelp(void)
while(getch() != ' ');
}
-void Klondike(int draw)
+void Klondike(int draw, int thoughtful)
{
Deck deck;
Pile pile = {0};
@@ -224,7 +225,7 @@ void Klondike(int draw)
{
for(n = 0; n < column_down[f].no; n++)
{
- DrawCard(2 + n, 1 + f * 5, TRUE, column_down[f].card[n]);
+ DrawCard(2 + n, 1 + f * 5, !thoughtful, column_down[f].card[n]);
}
for(n = 0; n < column_up[f].no; n++)
@@ -328,10 +329,14 @@ void Klondike(int draw)
int k;
quit = TRUE;
- Centre(LINES-1, "Show cards?");
- refresh();
- k = getch();
- show = (k == 'y' || k == 'Y');
+
+ if (!thoughtful)
+ {
+ Centre(LINES-1, "Show cards?");
+ refresh();
+ k = getch();
+ show = (k == 'y' || k == 'Y');
+ }
break;
}
diff --git a/klondike.h b/klondike.h
index 84d424c..933af48 100644
--- a/klondike.h
+++ b/klondike.h
@@ -27,7 +27,7 @@
#define CSOL_KLONDIKE_H
-void Klondike(int draw);
+void Klondike(int draw, int thoughtful);
#endif