diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-29 15:34:18 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-29 15:34:18 +0100 |
| commit | 947669f063f3df9fc93a4afb2d7c9e6d3d13813a (patch) | |
| tree | 602170db40454cdd3ba5c526825f273b2af3380f /src/hand.c | |
| parent | 8e8a8a44fb85addc8a235d763ad71825cf2d90de (diff) | |
added documentation
Diffstat (limited to 'src/hand.c')
| -rw-r--r-- | src/hand.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -3,6 +3,9 @@ #include <assert.h> #include "card.h" +/** + * Compares two hands; used for sorting them in hand_sort + */ static int hand_comparator(const void *a, const void *b) { card c1 = *(card *)a; @@ -11,6 +14,10 @@ static int hand_comparator(const void *a, const void *b) return c1 - c2; } +/** + * Sord the cards in a hand + * @param[inout] h Pointer to hand that should be sorted + */ void hand_sort(hand_t *h) { assert(h != NULL); @@ -18,6 +25,11 @@ void hand_sort(hand_t *h) qsort(h->cards, MAX_HAND_CARDS, sizeof(card), hand_comparator); } +/** + * Removes a card from a hand by setting it to invalid value 0 + * @param[inout] h Hand to remove card from + * @param[in] card_index Index of card to remove + */ void hand_remove_card(hand_t *h, const uint8_t card_index) { assert(h != NULL); @@ -25,6 +37,11 @@ void hand_remove_card(hand_t *h, const uint8_t card_index) h->cards[card_index] = 0; } +/** + * Count number of valid cards in hand + * @param[in] h Hand to count + * @return Number of valid cards in hand + */ const uint8_t hand_count_cards(const hand_t* h) { uint8_t count = 0; |
