summaryrefslogtreecommitdiff
path: root/src/hand.c
diff options
context:
space:
mode:
authorMario Kilies <MarioKilies@GMX.net>2011-01-29 15:50:58 +0100
committerMario Kilies <MarioKilies@GMX.net>2011-01-29 15:50:58 +0100
commit4a3e066c4c9885396893afcd2a13aa599ac4bd0e (patch)
tree753ba8320b71e7031e1bc4b1f59b011669ce8114 /src/hand.c
parent4980a92f245cf4f313d99f8c31dc61218696e98c (diff)
parent947669f063f3df9fc93a4afb2d7c9e6d3d13813a (diff)
Merge branch 'master' of ssh://git@wg.reiner-h.de:22003/~git/oxen
Diffstat (limited to 'src/hand.c')
-rw-r--r--src/hand.c17
1 files changed, 17 insertions, 0 deletions
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 <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;