Round and Hand structures, as well as helper functions. More...
#include "platform.h"
#include "deck.h"
#include "team.h"
#include "constants.h"
#include "errors.h"
Go to the source code of this file.
Classes | |
struct | Hand |
Hand structure. More... | |
struct | Round |
Round structure. More... | |
Functions | |
EXPORT struct Player * | round_getBidWinner (const struct Round *round) |
Finds the winner of a bid in a round. More... | |
EXPORT int | round_placeBid (const struct Player *player, const int bid, struct Round *round) |
Places the bid of a player. More... | |
EXPORT int | round_addPlayer (struct Player *player, struct Round *round) |
Add a player to a round. More... | |
EXPORT int | round_findPlayerIndexRound (const struct Player *player, const struct Round *round) |
Helper to find player in a round. More... | |
EXPORT int | round_addPlayerHand (struct Player *player, struct Hand *hand) |
Adds a player to a hand. More... | |
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 40 points if has 3 and 4 of same suit as the trump. More... | |
EXPORT struct Round * | round_createRound () |
Allocates memory for and initializes a round. More... | |
EXPORT int | round_deleteRound (struct Round **round) |
Frees the memory of a round. Makes NULL pointer. More... | |
EXPORT struct Hand * | round_createHand () |
Allocates memory for and initializes a hand. More... | |
EXPORT int | round_deleteHand (struct Hand **hand) |
Frees the memory of a hand. Makes pointer NULL. More... | |
EXPORT int | round_removePlayer (const struct Player *player, struct Round *round) |
Removes a player from a round. More... | |
EXPORT int | round_removePlayerHand (const struct Player *player, struct Hand *hand) |
Removes a player from a hand. More... | |
EXPORT struct Player * | round_handWinner (const struct Hand *hand, struct Round *round) |
Determines the winner of a hand. More... | |
EXPORT int | round_distributeCard (struct Deck *deck, const struct Round *round) |
Distributes one card to every player. More... | |
EXPORT int | round_distributeDeck (struct Deck *deck, const struct Round *round) |
Distributes cards to players. More... | |
EXPORT int | round_arrangePlayersHand (struct Round *round, int i) |
The function arranges the players in a hand. More... | |
EXPORT int | round_computePoints (const struct Team *team, const struct Round *round) |
Compute round points of a team. More... | |
EXPORT int | round_getMaximumBid (struct Round *round) |
The function search the maximum bid. More... | |
EXPORT int | round_findNextAllowedBid (struct Round *round, int currentBid) |
Function to find the next allowed bid after currentBid. More... | |
EXPORT int | round_findPreviousAllowedBid (struct Round *round, int currentBid) |
Function to find the previous allowed bid before currentBid. More... | |
Add a player to a round.
player | Pointer to the player to be added. |
round | Pointer to the round where to add player. |
Adds a player to a hand.
player | Pointer to the player to be added. |
hand | Pointer to the hand where the player is to be added. |
EXPORT int round_arrangePlayersHand | ( | struct Round * | round, |
int | i | ||
) |
The function arranges the players in a hand.
round | Pointer to the round from which arranges it the players. |
i | The position from where begin arranging. |
Compute round points of a team.
team | The team to compute points for. |
round | The round where to compute points. |
EXPORT struct Hand* round_createHand | ( | ) |
Allocates memory for and initializes a hand.
EXPORT struct Round* round_createRound | ( | ) |
Allocates memory for and initializes a round.
EXPORT int round_deleteHand | ( | struct Hand ** | hand | ) |
Frees the memory of a hand. Makes pointer NULL.
hand | Pointer to pointer to the hand to be deleted. |
EXPORT int round_deleteRound | ( | struct Round ** | round | ) |
Frees the memory of a round. Makes NULL pointer.
round | Pointer to pointer to the round to be deleted. |
Distributes one card to every player.
deck | Pointer to the deck from where cards are distributed. |
round | Pointer to the round containing the players that receive the cards. |
Distributes cards to players.
deck | Pointer to the deck from where cards are distributed. |
round | Pointer to the round that deck is distributed to. |
EXPORT int round_findNextAllowedBid | ( | struct Round * | round, |
int | currentBid | ||
) |
Function to find the next allowed bid after currentBid.
round | The round where are bids. |
currentBid | Function finds the first allowed bid after currentBid. |
EXPORT int round_findPreviousAllowedBid | ( | struct Round * | round, |
int | currentBid | ||
) |
Function to find the previous allowed bid before currentBid.
round | The round where are bids. |
currentBid | Function finds the first allowed bid before currentBid. |
Finds the winner of a bid in a round.
round | Pointer to the round where to find the bid winner. |
EXPORT int round_getMaximumBid | ( | struct Round * | round | ) |
The function search the maximum bid.
round | Pointer to the round in which are the bids. |
Determines the winner of a hand.
hand | Pointer to the hand. |
round | Pointer to the round containing the hand that the player won. |
Places the bid of a player.
player | Pointer to the player who places the bid. |
bid | The value of the bid. |
round | Pointer to the round where to place the bid. |
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 40 points if has 3 and 4 of same suit as the trump.
player | Pointer to the player who places the card. |
cardId | Id of the card placed by the player (id from Player.cards). |
handId | Id of the hand in which the card is placed. |
round | Pointer to the round in which is hand. |
Removes a player from a round.
player | Pointer to the player to be removed. |
round | Pointer to the round from which the player is removed. |