summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2022-01-02 19:48:34 +0000
committerIan C <ianc@noddybox.co.uk>2022-01-02 19:48:34 +0000
commitdeb68bff30f081b18bc06257aafb23eb28da4b50 (patch)
tree179946376f144e49db021f25aa968b5dbe6e9540
parent7f895d44a2911a182597e28cf29d8583eda65b4c (diff)
Added autofill when puzzle complete.
-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':