From 947669f063f3df9fc93a4afb2d7c9e6d3d13813a Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sat, 29 Jan 2011 15:34:18 +0100 Subject: added documentation --- src/hand.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/hand.c') diff --git a/src/hand.c b/src/hand.c index 359ed08..24e9a9d 100644 --- a/src/hand.c +++ b/src/hand.c @@ -3,6 +3,9 @@ #include #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; -- cgit v1.2.3