CruceGame  v0.4.0
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
game.h
Go to the documentation of this file.
1 
6 #ifndef GAME_H
7 #define GAME_H
8 
9 #include "platform.h"
10 #include "constants.h"
11 #include "team.h"
12 #include "deck.h"
13 #include "round.h"
14 
34 struct Game {
37  struct Round *round;
40  struct Deck *deck;
41 };
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
54 EXPORT struct Game *game_createGame(const int numberPoints);
55 
63 EXPORT int game_deleteGame(struct Game **game);
64 
73 EXPORT int game_addPlayer(struct Player *player, struct Game *game);
74 
83 EXPORT int game_removePlayer(const struct Player *player, struct Game *game);
84 
93 EXPORT int game_addTeam(struct Team *team, struct Game *game);
94 
95 
104 EXPORT int game_removeTeam(const struct Team *team, struct Game *game);
105 
113 EXPORT struct Team *game_winningTeam(struct Game *game);
114 
127 EXPORT int game_checkCard(struct Player *player, const struct Game *game,
128  struct Hand *hand, const int idCard);
129 
142 EXPORT int game_findNextAllowedCard(struct Player *player, struct Game *game,
143  struct Hand *hand, int currentCard);
144 
157 EXPORT int game_findPreviousAllowedCard(struct Player *player,
158  struct Game *game,
159  struct Hand *hand,
160  int currentCard);
161 
170 EXPORT struct Team *game_findTeam(const struct Game *game, struct Player *player);
171 
180 EXPORT int game_updateScore(const struct Game *game, struct Player *bidWinner);
181 
191 EXPORT int game_arrangePlayersRound(struct Game *game, const int i);
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif
198 
Player and Team structures, with helper functions.
#define MAX_GAME_PLAYERS
Maximum number of players in a game.
Definition: constants.h:42
EXPORT int game_arrangePlayersRound(struct Game *game, const int i)
Function to add a round to a game and to arrange players into it, according to game rules...
Definition: game.c:358
Hand structure.
Definition: round.h:27
Contains definitions of various symbolic constants.
struct Round * round
Definition: game.h:37
int pointsNumber
Definition: game.h:36
EXPORT int game_updateScore(const struct Game *game, struct Player *bidWinner)
Function to update the score of teams and players after a round.
Definition: game.c:310
Contains platform specific definitions.
Player structure.
Definition: team.h:27
struct Deck * deck
Definition: game.h:40
EXPORT int game_removeTeam(const struct Team *team, struct Game *game)
Removes a team from a game.
Definition: game.c:121
A 28 card deck used in this game.
Definition: deck.h:38
EXPORT int game_removePlayer(const struct Player *player, struct Game *game)
Removes a player from a game.
Definition: game.c:79
Round structure.
Definition: round.h:51
EXPORT struct Team * game_findTeam(const struct Game *game, struct Player *player)
Function to find the team in which a player belongs.
Definition: game.c:292
EXPORT int game_addTeam(struct Team *team, struct Game *game)
Adds a team to a game.
Definition: game.c:99
EXPORT int game_deleteGame(struct Game **game)
Frees the memory of a game and makes the pointer NULL.
Definition: game.c:40
EXPORT struct Game * game_createGame(const int numberPoints)
Allocates memory for and initializes a game.
Definition: game.c:15
EXPORT int game_findNextAllowedCard(struct Player *player, struct Game *game, struct Hand *hand, int currentCard)
Function to find the next allowed card after currentCard. Uses game_checkCard to check if a card is a...
Definition: game.c:280
int numberPlayers
Definition: game.h:35
Game structure.
Definition: game.h:34
struct Player * players[MAX_GAME_PLAYERS]
Definition: game.h:38
EXPORT int game_findPreviousAllowedCard(struct Player *player, struct Game *game, struct Hand *hand, int currentCard)
Function to find the previous allowed card before currentCard. Uses game_checkCard to check if a card...
Definition: game.c:286
In this file are located the definitions of Card and Deck structures, as well as helper functions...
#define MAX_GAME_TEAMS
Maximum number of teams in a game.
Definition: constants.h:47
Round and Hand structures, as well as helper functions.
struct Team * teams[MAX_GAME_TEAMS]
Definition: game.h:39
EXPORT int game_checkCard(struct Player *player, const struct Game *game, struct Hand *hand, const int idCard)
Function checks if the player can put a card down.
Definition: game.c:189
EXPORT int game_addPlayer(struct Player *player, struct Game *game)
Adds a player to a game.
Definition: game.c:53
EXPORT struct Team * game_winningTeam(struct Game *game)
Searches the winning team of a game.
Definition: game.c:140
Team structure.
Definition: team.h:46