summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--klondike.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/klondike.c b/klondike.c
index 153cb03..539553d 100644
--- a/klondike.c
+++ b/klondike.c
@@ -137,6 +137,7 @@ static void KlondikeHelp(void)
"",
"Use 'P' to put the current card on the suits piles.",
"If invalid it will attempt to move the card from the drawn pile.",
+ "If the cards are all shown this will automatically finish the puzzle.",
"",
"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.",
@@ -181,6 +182,7 @@ int Klondike(int draw, int thoughtful)
int won = FALSE;
int quit = FALSE;
int show = FALSE;
+ int autofill = FALSE;
int pos_x = 0;
int pos_y = 0;
int move_pos_x = -1;
@@ -254,6 +256,18 @@ int Klondike(int draw, int thoughtful)
mvaddch(2 + column_down[pos_x].no + pos_y, pos_x * 5 + 4, '<');
}
+ if (autofill)
+ {
+ for(f = 0; f < 7; f++)
+ {
+ if (PutCardOnSuitPile(&column_up[f],
+ &hearts, &diamonds, &spades, &clubs))
+ {
+ RevealCard(&column_down[pos_x], &column_up[pos_x]);
+ }
+ }
+ }
+
if (hearts.no == 13 && diamonds.no == 13 &&
spades.no == 13 && clubs.no == 13)
{
@@ -262,7 +276,7 @@ int Klondike(int draw, int thoughtful)
refresh();
- if (!won)
+ if (!won && !autofill)
{
key = getch();
}
@@ -321,6 +335,20 @@ int Klondike(int draw, int thoughtful)
PutCardOnSuitPile(&turned, &hearts, &diamonds,
&spades, &clubs);
}
+
+ if (pile.no == 0 && turned.no == 0)
+ {
+ autofill = TRUE;
+
+ for(f = 0; f < 7; f++)
+ {
+ if (column_down[f].no)
+ {
+ autofill = FALSE;
+ }
+ }
+ }
+
break;
case 'Q':