diff options
Diffstat (limited to '')
-rw-r--r-- | stack.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/stack.h b/stack.h index 3d3a43b..c315729 100644 --- a/stack.h +++ b/stack.h @@ -33,7 +33,7 @@ typedef Sint8 Card; -static inline int cardSuit(Card card) { +static inline int suit(Card card) { card = abs(card); if (card > Cards_Spade) { return Cards_Spade; @@ -46,12 +46,12 @@ static inline int cardSuit(Card card) { } } -static inline int cardColor(Card card) { - return cardSuit(card) == Cards_Diamond || cardSuit(card) == Cards_Heart; +static inline int color(Card card) { + return suit(card) == Cards_Diamond || suit(card) == Cards_Heart; } -static inline int cardRank(Card card) { - return abs(card) - cardSuit(card); +static inline int rank(Card card) { + return abs(card) - suit(card); } struct Stack { @@ -69,36 +69,36 @@ static const struct Stack Deck = { }, }; -static inline void stackClear(struct Stack *stack) { +static inline void clear(struct Stack *stack) { stack->len = 0; } -static inline void stackPush(struct Stack *stack, Card card) { +static inline void push(struct Stack *stack, Card card) { assert(stack->len < STACK_CAP); stack->cards[stack->len++] = card; } -static inline Card stackPop(struct Stack *stack) { +static inline Card pop(struct Stack *stack) { if (!stack->len) return 0; return stack->cards[--stack->len]; } -static inline Card stackTop(const struct Stack *stack) { +static inline Card peek(const 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) { +static inline void flipTo(struct Stack *dst, struct Stack *src, Uint8 n) { if (n > src->len) n = src->len; for (Uint8 i = 0; i < n; ++i) { - stackPush(dst, -stackPop(src)); + push(dst, -pop(src)); } } -static inline void stackMoveTo(struct Stack *dst, struct Stack *src, Uint8 n) { +static inline void moveTo(struct Stack *dst, struct Stack *src, Uint8 n) { if (n > src->len) n = src->len; for (Uint8 i = 0; i < n; ++i) { - stackPush(dst, src->cards[src->len - n + i]); + push(dst, src->cards[src->len - n + i]); } src->len -= n; } @@ -110,7 +110,7 @@ static inline int randUniform(int bound) { } } -static inline void stackShuffle(struct Stack *stack) { +static inline void shuffle(struct Stack *stack) { for (Uint8 i = stack->len - 1; i > 0; --i) { Uint8 j = randUniform(i + 1); Card x = stack->cards[i]; |