1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
#ifndef CARDS_H
#define CARDS_H
char ColorTable[4][10] = {"spade", "clubs", "heart", "diamond"} ;
char ValueTable[13][6] = { "A" , "two", "three", "four", "five", "six", "seven", "eight", "nine", "T", "J", "Q", "K" } ;
struct card
{
char value[10];
char color[8];
} ;
struct cardgame
{
struct card CardTable[52] ;
int Id;
int position;
} ;
struct player
{
char name[20];
int wage;
int bet;
struct CardLinkedListEntryPoints* hand;
};
/**
*\struct CardChainedList : Linked list of card struct
*/
struct CardLinkedList
{
struct card current;
struct CardLinkedList* next;
struct CardLinkedList* prev;
};
struct CardLinkedListEntryPoints
{
struct CardLinkedList *first;
struct CardLinkedList *last;
};
/**
*\brief initialize a doublelinked list
*\param struct CardLinkedListEntryPoints* EntryPoints ; struct containing pointers towards first and last element.
*/
void Init_CardLinkedList(struct CardLinkedListEntryPoints* EntryPoints);
/**
*\brief CardLinkedList_Set_Top_Card insert a card at the beginning of a double linked struct containing cards
*\param struct card CardToAdd The card to insert
*\param struct CardLinkedListEntryPoints* EntryPoints struct containing entry points for double linked struct containing cards
*/
void CardLinkedList_Set_Top_Card(struct card CardToAdd,struct CardLinkedListEntryPoints* EntryPoints);
/**
*\brief CardLinkedList_Set_Last_Card insert a card at the end of a double linked struct containing cards
*\param struct card CardToAdd The card to insert
*\param struct CardLinkedListEntryPoints* EntryPoints struct containing entry points for double linked struct containing cards
*/
void CardLinkedList_Set_Last_Card(struct card CardToAdd,struct CardLinkedListEntryPoints* EntryPoints);
/**
*\brief count number of cards element in d l l EntryPoints
*\param struct CardLinkedListEntryPoints* EntryPoints
*\return int count number of elements
*/
int CardLinkedList_Count_Elements(struct CardLinkedListEntryPoints* EntryPoints);
/**
*\brief Free the memory allocated for a CardLinkList struct
*\param struct CardLinkedListEntryPoints* EntryPoints EntryPoints to the double linked list to be freed.
*/
void CardLinkedList_Clear(struct CardLinkedListEntryPoints* EntryPoints);
/**
*\brief init a struct cardgame with sorted card( A, 2 ,3,etc..) struct
*\param struct cardgame newgame
*/
void Init_Sorted_CardGame(struct cardgame * newgame);
/**
*\ Permute randomly all the cards structs in cardgame struct
*\param struct cardgame ShuffledGame : game to shuffle
*\return struct cardgame ShuffledGame
*/
void Set_Shuffled_CardGame(struct cardgame * ShuffledGame);
/**
*\brief Give a card to one player ie fill player hand substructure with card from cardgame
*\param struct gamecard gamecard game to deal with
*\param struct player *player player to deal to
*\param int nb_card number of card to deal
*/
void Deal_To_Player_Cards(struct cardgame *cardgame ,struct player *player, int nb_card);
#endif |
Partager