about summary refs log tree commit diff
path: root/stack.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-03-22 15:22:10 -0400
committerJune McEnroe <june@causal.agency>2019-03-22 15:22:10 -0400
commitc4e4d7c76563216b598feba7abc6b9b72df4724b (patch)
tree85d353f26963a702c17d07f8432db814df4df001 /stack.h
parentRefactor layout code slightly (diff)
downloadcards-c4e4d7c76563216b598feba7abc6b9b72df4724b.tar.gz
cards-c4e4d7c76563216b598feba7abc6b9b72df4724b.zip
Implement the game
Diffstat (limited to 'stack.h')
-rw-r--r--stack.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/stack.h b/stack.h
index 46b9091..e85c43f 100644
--- a/stack.h
+++ b/stack.h
@@ -39,6 +39,11 @@ static inline Sint8 stackPop(struct Stack *stack) {
 	return stack->cards[--stack->len];
 }
 
+static inline Sint8 stackTop(struct Stack *stack) {
+	if (!stack->len) return 0;
+	return stack->cards[stack->len - 1];
+}
+
 static inline void stackFlipTo(struct Stack *dst, struct Stack *src, Uint8 n) {
 	if (n > src->len) n = src->len;
 	for (Uint8 i = 0; i < n; ++i) {