CruceGame  v0.4.0
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
round.h
Go to the documentation of this file.
1 
6 #ifndef ROUND_H
7 #define ROUND_H
8 
9 #include "platform.h"
10 #include "deck.h"
11 #include "team.h"
12 #include "constants.h"
13 #include "errors.h"
14 
27 struct Hand{
30 };
31 
51 struct Round{
52  enum Suit trump;
53  struct Hand *hands[MAX_HANDS];
57 };
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
70 EXPORT struct Player *round_getBidWinner(const struct Round *round);
71 
81 EXPORT int round_placeBid(const struct Player *player, const int bid,
82  struct Round *round);
83 
92 EXPORT int round_addPlayer(struct Player* player, struct Round *round);
93 
102 EXPORT int round_findPlayerIndexRound(const struct Player *player,
103  const struct Round *round);
104 
113 EXPORT int round_addPlayerHand(struct Player *player, struct Hand *hand);
114 
127 EXPORT int round_putCard(struct Player *player, const int cardId,
128  const int handId, struct Round *round);
129 
135 EXPORT struct Round *round_createRound();
136 
144 EXPORT int round_deleteRound(struct Round **round);
145 
151 EXPORT struct Hand *round_createHand();
152 
160 EXPORT int round_deleteHand(struct Hand **hand);
161 
170 EXPORT int round_removePlayer(const struct Player *player, struct Round *round);
171 
180 EXPORT int round_removePlayerHand(const struct Player *player,
181  struct Hand *hand);
182 
191 EXPORT struct Player *round_handWinner(const struct Hand *hand,
192  struct Round *round);
193 
202 EXPORT int round_distributeCard(struct Deck *deck, const struct Round *round);
203 
212 EXPORT int round_distributeDeck(struct Deck *deck, const struct Round *round);
213 
222 EXPORT int round_arrangePlayersHand(struct Round *round, int i);
223 
232 EXPORT int round_computePoints(const struct Team *team,
233  const struct Round *round);
234 
242 EXPORT int round_getMaximumBid(struct Round *round);
243 
252 EXPORT int round_findNextAllowedBid(struct Round *round, int currentBid);
253 
262 EXPORT int round_findPreviousAllowedBid(struct Round *round, int currentBid);
263 
264 #ifdef __cplusplus
265 }
266 #endif
267 
268 #endif
269 
Player and Team structures, with helper functions.
#define MAX_GAME_PLAYERS
Maximum number of players in a game.
Definition: constants.h:42
This file contains definitions of the symbolic constants that represents error codes, as wel the declarations of the functions that belongs to the error module.
EXPORT int round_findPlayerIndexRound(const struct Player *player, const struct Round *round)
Helper to find player in a round.
Definition: round.c:93
EXPORT int round_removePlayer(const struct Player *player, struct Round *round)
Removes a player from a round.
Definition: round.c:184
EXPORT int round_deleteHand(struct Hand **hand)
Frees the memory of a hand. Makes pointer NULL.
Definition: round.c:65
Hand structure.
Definition: round.h:27
EXPORT int round_removePlayerHand(const struct Player *player, struct Hand *hand)
Removes a player from a hand.
Definition: round.c:201
struct Card * cards[MAX_GAME_PLAYERS]
Definition: round.h:28
EXPORT int round_distributeDeck(struct Deck *deck, const struct Round *round)
Distributes cards to players.
Definition: round.c:355
#define MAX_HANDS
Maximum number of hands in a round.
Definition: constants.h:37
EXPORT int round_putCard(struct Player *player, const int cardId, const int handId, struct Round *round)
Places a card from a player to a hand and offers the player 20 points if has 3 and 4 of same suit or ...
Definition: round.c:217
Contains definitions of various symbolic constants.
struct Player * players[MAX_GAME_PLAYERS]
Definition: round.h:29
Contains platform specific definitions.
struct Card * hand[MAX_CARDS]
Definition: team.h:29
Player structure.
Definition: team.h:27
int bids[MAX_GAME_PLAYERS]
Definition: round.h:54
EXPORT struct Player * round_getBidWinner(const struct Round *round)
Finds the winner of a bid in a round.
Definition: round.c:78
Suit
Constants for suit.
Definition: constants.h:54
Card structure, to keep suit and value.
Definition: deck.h:24
EXPORT int round_findNextAllowedBid(struct Round *round, int currentBid)
Function to find the next allowed bid after currentBid.
Definition: round.c:495
EXPORT int round_arrangePlayersHand(struct Round *round, int i)
The function arranges the players in a hand.
Definition: round.c:381
EXPORT int round_addPlayer(struct Player *player, struct Round *round)
Add a player to a round.
Definition: round.c:138
EXPORT int round_computePoints(const struct Team *team, const struct Round *round)
Compute round points of a team.
Definition: round.c:405
A 28 card deck used in this game.
Definition: deck.h:38
struct Player * players[MAX_GAME_PLAYERS]
Definition: round.h:55
EXPORT int round_placeBid(const struct Player *player, const int bid, struct Round *round)
Places the bid of a player.
Definition: round.c:111
Round structure.
Definition: round.h:51
struct Hand * hands[MAX_HANDS]
Definition: round.h:53
EXPORT struct Round * round_createRound()
Allocates memory for and initializes a round.
Definition: round.c:15
EXPORT int round_distributeCard(struct Deck *deck, const struct Round *round)
Distributes one card to every player.
Definition: round.c:319
EXPORT int round_deleteRound(struct Round **round)
Frees the memory of a round. Makes NULL pointer.
Definition: round.c:38
EXPORT struct Hand * round_createHand()
Allocates memory for and initializes a hand.
Definition: round.c:51
int pointsNumber[MAX_GAME_PLAYERS]
Definition: round.h:56
enum Suit trump
Definition: round.h:52
EXPORT int round_findPreviousAllowedBid(struct Round *round, int currentBid)
Function to find the previous allowed bid before currentBid.
Definition: round.c:500
In this file are located the definitions of Card and Deck structures, as well as helper functions...
EXPORT int round_addPlayerHand(struct Player *player, struct Hand *hand)
Adds a player to a hand.
Definition: round.c:161
EXPORT struct Player * round_handWinner(const struct Hand *hand, struct Round *round)
Determines the winner of a hand.
Definition: round.c:280
EXPORT int round_getMaximumBid(struct Round *round)
The function search the maximum bid.
Definition: round.c:429
Team structure.
Definition: team.h:46