about 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;
140590d05785277a577c4&follow=1'>Update status line after scrolling and term eventsJune McEnroe 2019-02-22Reorganize input.cJune McEnroe 2019-02-22Fix name of <raw> window in man pageJune McEnroe 2019-02-22Rename global tags with angle bracketsJune McEnroe 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe 2019-02-21Replace "view" with "window"June McEnroe 2019-02-21Remove ROT13June McEnroe 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroeain, add formattingJune McEnroe 2018-08-06Fix allocation size in vaswprintfJune McEnroe 2018-08-06Implement word wrappingJune McEnroe 2018-08-06Use wchar_t strings for all of UIJune McEnroe 2018-08-06Rename line editing functionsJune McEnroe 2018-08-05Initialize all possible color pairsJune McEnroe 2018-08-05Refactor color initializationJune McEnroe 2018-08-05Add ^L redrawJune McEnroe 2018-08-05Use 16 colors if availableJune McEnroe 2018-08-05Limit parsed colors to number of mIRC colorsJune McEnroe 2018-08-04Show source link on exitJune McEnroe 2018-08-04Implement line editing, scrollingJune McEnroe 2018-08-04Handle /topicJune McEnroe