about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-03-26 18:21:48 -0400
committerJune McEnroe <june@causal.agency>2019-03-26 18:21:48 -0400
commit5645043c86bf5df846078f2bcacbc881e4021619 (patch)
treec3899a243523dd21b87570e435f644e588ee023c
parentRemove stackDeck (diff)
downloadcards-5645043c86bf5df846078f2bcacbc881e4021619.tar.gz
cards-5645043c86bf5df846078f2bcacbc881e4021619.zip
Make Stack capacity configurable
Allows games to use multiple decks.
-rw-r--r--stack.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/stack.h b/stack.h
index b7b018f..61c6fc2 100644
--- a/stack.h
+++ b/stack.h
@@ -23,6 +23,10 @@
 
 #include "cards.h"
 
+#ifndef STACK_CAP
+#define STACK_CAP 52
+#endif
+
 typedef Sint8 Card;
 
 static int cardSuit(Card card) {
@@ -48,7 +52,7 @@ static int cardRank(Card card) {
 
 struct Stack {
 	Uint8 len;
-	Card cards[52];
+	Card cards[STACK_CAP];
 };
 
 static inline void stackClear(struct Stack *stack) {
@@ -56,7 +60,7 @@ static inline void stackClear(struct Stack *stack) {
 }
 
 static inline void stackPush(struct Stack *stack, Card card) {
-	assert(stack->len < 52);
+	assert(stack->len < STACK_CAP);
 	stack->cards[stack->len++] = card;
 }