107 int randomInt(
const int min,
const int max);
218 void revealCard(
Card card,
int playerId,
bool facedUp,
bool newLine);
Definition of functions which retrieves the game configuration from the possible sources.
Preprocessor file used for including library for modules.
Definition of logger configuration structure.
void giveCards(Game *game, Card *deck)
Assigns new cards to the player. It is not guaranteed that the old cards might be reassigned to the s...
Card * prepareCardDeck()
Generates a deck with cards ordered randomly. It is guaranteed that no duplicated cards occurs in the...
bool cardAreEqual(Card card1, Card card2)
Checks if two cards are equal.
bool isGameEnded(Game *game)
Determines whether the game is ended.
void shuffleDeck(Card *deck)
Shuffles the deck using Fisher - Yates algorithm.
Card * buildDeck()
Generates a deck.
void printCardEffect(Card card, bool newLine)
Prints user-friendly the card's effect.
bool handleGamePhase(Game *game)
Handles the current game phase.
Player * buildPlayer()
Generates a player.
bool cardsWereGiven(Player **players, int playersCounter, Player player)
Checks if the cards of a given player have been already given to other players.
void freeGame(Game *game)
Frees a game structure.
Card buildCard()
Generates a card.
bool revealFacedDownCard(Card card)
Asks to the player if he wants to reveal the faced down card.
Game prepareGame(int playersCounter, Card *deck, GameConfiguration gameConfiguration, LogsConfiguration logsConfiguration)
Generates a game structure with the given players number and with the given data gave by the game con...
void freePlayer(Player *player)
Frees a player.
bool checkTerminalSize()
Checks if the terminal size is suitable for the TUI (Terminal User Interface).
void setupTerminal()
On Windows, configures that the terminal such that it supports UTF-8 encoded chars.
void revealCard(Card card, int playerId, bool facedUp, bool newLine)
Prints user-friendly the card revealed from a player.
Game buildGame(int playersCounter)
Generates a game with the given number of players.
int randomInt(const int min, const int max)
Generates a random number in the range (inclusive).
void announceWinner(Player player)
Announces the winner.
bool applyEffect(Game *game, int playerPosition, bool facedUpCard)
Applies the effect of the player at the given index in the players vector.
bool checkTerminalHost()
On Windows, it checks if the terminal's host process is supported.
void freePlayers(Player **players, int playersCounter)
Free all the players in the vector.
void checkTerminal()
Checks if the terminal size is suitable for the TUI (Terminal User Interface); if the terminal it is ...
int askPlayerNumber()
Asks the number of players to the user.
void removeDeadPlayers(Game *game)
Removes the dead players from the players vector.
void withdrawCards(Game *game)
Generates via the function buildCard new cards that are given to the players.
void tellFacedDownCard(Card card, int playerId)
Prints user-friendly the faced down card revealed of the player.
bool deckHasCard(Card *deck, Card card)
Checks if a card is present in a deck.
void announceDeadPlayers(Game *game)
Announces the dead players.
int countDeadPlayers(Game *game)
Counts how many dead players there are in the players vector.
void freeDeck(Card *deck)
Frees the cards deck.
Player * preparePlayer(int id, Card *deck, GameConfiguration configuration)
Generates a player structure with the given player id and with the given data gave by the game config...
Defines a structure for the cards.
unsigned int rank
The rank of the card.
unsigned int suit
The suit of the card.
The game configuration structure.
Defines a structure for the game.
unsigned int lifePointsOnTheField
The amount of LPs currently on the playing field.
GameConfiguration gameConfiguration
The configuration for the game.
unsigned int playersCounter
The amount of players currently alive.
Player ** players
The currently alive players vector.
LogsConfiguration logsConfiguration
The configuration for the logs, if the game has to be verbose.
The configuration for the logger.
Defines a structure for the player's info.
Card facedDownCard
The faced down card.
bool revealedFacedDownCard
Flag for recording if the faced down card has been revealed; it can be toggled even if the faced down...
unsigned int lifePoints
The current player LPs.
unsigned int id
The player ID.
Card facedUpCard
The faced up card.