CruceGame  v0.4.0
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Functions
team.c File Reference

Contains implementations for the functions used for team-related operations, like creating and deleting a team. More...

#include "team.h"
#include "constants.h"
#include "errors.h"
#include "round.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

Functions

struct Playerteam_createPlayer (const char *name, const int isHuman)
 Creates a player. More...
 
struct Teamteam_createTeam ()
 Creates a team. More...
 
int team_addPlayer (struct Team *team, struct Player *player)
 Adds a player to a team. More...
 
int team_removePlayer (struct Team *team, const struct Player *player)
 Removes a player from a team. More...
 
int team_deleteTeam (struct Team **team)
 Deletes a team and sets the pointer to NULL. More...
 
int team_deletePlayer (struct Player **player)
 Deletes a player and sets the pointer to NULL. More...
 
int team_addCard (struct Player *player, struct Card *card)
 Passes a card to a player. The function doesn't check if the card has valid value and valid suit. More...
 
int team_hasCards (const struct Player *player)
 Checks if a player has any card. More...
 
int team_updatePlayersScore (struct Team *team)
 Updates all players scores, assigning team score to them. More...
 

Detailed Description

Contains implementations for the functions used for team-related operations, like creating and deleting a team.

Function Documentation

int team_addCard ( struct Player player,
struct Card card 
)

Passes a card to a player. The function doesn't check if the card has valid value and valid suit.

Parameters
playerThe player who receives the card.
cardThe card to be received.
Returns
NO_ERROR on success, other value on failure.
int team_addPlayer ( struct Team team,
struct Player player 
)

Adds a player to a team.

Parameters
teamThe team to which the player is added.
playerThe player to be added to the team.
Returns
NO_ERROR on success, other value on failure.
struct Player* team_createPlayer ( const char *  name,
const int  isHuman 
)

Creates a player.

Parameters
nameThe name of the new player.
isHumanPlayer type.
Returns
Pointer to the created player. Needs to be freed.
struct Team* team_createTeam ( )

Creates a team.

Returns
Pointer to the created team. Needs to be freed.
int team_deletePlayer ( struct Player **  player)

Deletes a player and sets the pointer to NULL.

Parameters
playerThe player to be deleted.
Returns
NO_ERROR on success, other value on failure.
int team_deleteTeam ( struct Team **  team)

Deletes a team and sets the pointer to NULL.

Parameters
teamThe team to be deleted.
Returns
NO_ERROR on success, error code otherwise.
int team_hasCards ( const struct Player player)

Checks if a player has any card.

Parameters
playerPointer to the player that is checked
Returns
1 in case of success, 0 otherwise
int team_removePlayer ( struct Team team,
const struct Player player 
)

Removes a player from a team.

Parameters
teamThe team from where the player is removed.
playerThe player that will be removed.
Returns
NO_ERROR on success, other value on failure.
int team_updatePlayersScore ( struct Team team)

Updates all players scores, assigning team score to them.

Parameters
teamThe team where to update the score.
Returns
NO_ERROR or 0 on success, other value on failure.