summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2011-01-29 16:20:40 +0100
committerReiner Herrmann <reiner@reiner-h.de>2011-01-29 16:20:40 +0100
commitde36871c582a4f228df71e15560c020f34d39d4a (patch)
tree07b5ee2e202b1bec7547e3b3ac8c857d7fec6540 /src/player.c
parenta85546a9a58ce313302f1be91923a14c5723375c (diff)
added more documentation
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/player.c b/src/player.c
index cf587fc..4e7d5e9 100644
--- a/src/player.c
+++ b/src/player.c
@@ -2,6 +2,12 @@
#include <stdlib.h>
#include <assert.h>
+/**
+ * Search for a player in the player list
+ * @param[in] pl Pointer to player list to search
+ * @param[in] pid Player ID of searched player
+ * @return Pointer to player_list_entry_t; NULL if none found for specified player id
+ */
player_list_entry_t *get_player_list_entry_by_player_id(player_list_t *pl, const player_id_t pid)
{
assert(pl != NULL);
@@ -16,6 +22,9 @@ player_list_entry_t *get_player_list_entry_by_player_id(player_list_t *pl, const
return NULL;
}
+/**
+ * Compare player list entries via open_card
+ */
static int ple_open_card_comparator(const void *a, const void *b)
{
player_list_entry_t ple1 = *(player_list_entry_t *)a;
@@ -24,6 +33,9 @@ static int ple_open_card_comparator(const void *a, const void *b)
return ple1.open_card - ple2.open_card;
}
+/**
+ * Compare player list entries via score
+ */
static int ple_score_comparator(const void *a, const void *b)
{
player_list_entry_t ple1 = *(player_list_entry_t *)a;
@@ -32,6 +44,11 @@ static int ple_score_comparator(const void *a, const void *b)
return ple1.score - ple2.score;
}
+/**
+ * Sort a player list in ascending order by open card values
+ * @param[in,out] pl Pointer to layer list to sort
+ * @param[in] num_entries Number of player list entries in list
+ */
void player_list_sort_by_open_card(player_list_t *pl, const uint8_t num_entries)
{
assert(pl != NULL);
@@ -39,6 +56,11 @@ void player_list_sort_by_open_card(player_list_t *pl, const uint8_t num_entries)
qsort(pl->players, num_entries, sizeof(player_list_entry_t), ple_open_card_comparator);
}
+/**
+ * Sort a player list in ascending order by scores
+ * @param[in,out] pl Pointer to layer list to sort
+ * @param[in] num_entries Number of player list entries in list
+ */
void player_list_sort_by_score(player_list_t *pl, const uint8_t num_entries)
{
assert(pl != NULL);