summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--sol.c27
-rw-r--r--stack.h24
2 files changed, 27 insertions, 24 deletions
diff --git a/sol.c b/sol.c
index 0a0740c..bb73b84 100644
--- a/sol.c
+++ b/sol.c
@@ -25,27 +25,6 @@
 
 typedef unsigned uint;
 
-static Sint8 cardSuit(Sint8 card) {
-	card = abs(card);
-	if (card > Cards_Spade) {
-		return Cards_Spade;
-	} else if (card > Cards_Heart) {
-		return Cards_Heart;
-	} else if (card > Cards_Diamond) {
-		return Cards_Diamond;
-	} else {
-		return Cards_Club;
-	}
-}
-
-static Sint8 cardColor(Sint8 card) {
-	return cardSuit(card) == Cards_Diamond || cardSuit(card) == Cards_Heart;
-}
-
-static Sint8 cardRank(Sint8 card) {
-	return abs(card) - cardSuit(card);
-}
-
 enum {
 	Stock,
 	Waste1,
@@ -88,10 +67,10 @@ static void gameDeal(void) {
 static void gameDraw(void) {
 	stackMoveTo(&stacks[Waste1], &stacks[Waste3], stacks[Waste3].len);
 	if (stacks[Stock].len) {
-		if (game.draw == 1) {
-			stackFlipTo(&stacks[Waste1], &stacks[Stock], 1);
+		if (game.draw > 1) {
+			stackFlipTo(&stacks[Waste3], &stacks[Stock], game.draw);
 		} else {
-			stackFlipTo(&stacks[Waste3], &stacks[Stock], 3);
+			stackFlipTo(&stacks[Waste1], &stacks[Stock], 1);
 		}
 	} else {
 		stackFlipTo(&stacks[Stock], &stacks[Waste1], stacks[Waste1].len);
diff --git a/stack.h b/stack.h
index e85c43f..a635e8c 100644
--- a/stack.h
+++ b/stack.h
@@ -19,6 +19,30 @@
 
 #include <SDL_stdinc.h>
 #include <assert.h>
+#include <stdlib.h>
+
+#include "cards.h"
+
+static Sint8 cardSuit(Sint8 card) {
+	card = abs(card);
+	if (card > Cards_Spade) {
+		return Cards_Spade;
+	} else if (card > Cards_Heart) {
+		return Cards_Heart;
+	} else if (card > Cards_Diamond) {
+		return Cards_Diamond;
+	} else {
+		return Cards_Club;
+	}
+}
+
+static Sint8 cardColor(Sint8 card) {
+	return cardSuit(card) == Cards_Diamond || cardSuit(card) == Cards_Heart;
+}
+
+static Sint8 cardRank(Sint8 card) {
+	return abs(card) - cardSuit(card);
+}
 
 struct Stack {
 	Uint8 len;