|
int | main (int argc, char **argv) |
void | checkTerminal () |
| Checks if the terminal size is suitable for the TUI (Terminal User Interface); if the terminal it is too small, it exits with EXIT_TERMINAL_TOO_SMALL exit code. On Windows, it checks if the terminal's host process is supported, otherwise it exits with EXIT_WINDOWS_TERMINAL_HOST_NOT_SUPPORTED exit code.
|
void | setupTerminal () |
| On Windows, configures that the terminal such that it supports UTF-8 encoded chars.
|
bool | checkTerminalSize () |
| Checks if the terminal size is suitable for the TUI (Terminal User Interface).
|
bool | checkTerminalHost () |
| On Windows, it checks if the terminal's host process is supported.
|
int | randomInt (const int min, const int max) |
| Generates a random number in the range (inclusive).
|
GameConfiguration | askConfigurationOptionsViaTerminal () |
| Asks to the user via terminal the game configuration.
|
int | askPlayerNumber () |
| Asks the number of players to the user.
|
Card | buildCard () |
| Generates a card.
|
Card * | buildDeck () |
| Generates a deck.
|
Player * | buildPlayer () |
| Generates a player.
|
Game | buildGame (int playersCounter) |
| Generates a game with the given number of players.
|
void | freeDeck (Card *deck) |
| Frees the cards deck.
|
void | freePlayer (Player *player) |
| Frees a player.
|
void | freePlayers (Player **players, int playersCounter) |
| Free all the players in the vector.
|
void | freeGame (Game *game) |
| Frees a game structure.
|
Card * | prepareCardDeck () |
| Generates a deck with cards ordered randomly. It is guaranteed that no duplicated cards occurs in the same deck.
|
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 configuration.
|
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 configuration.
|
void | shuffleDeck (Card *deck) |
| Shuffles the deck using Fisher - Yates algorithm.
|
bool | handleGamePhase (Game *game) |
| Handles the current game phase.
|
bool | isGameEnded (Game *game) |
| Determines whether the game is ended.
|
bool | applyEffect (Game *game, int playerPosition, bool facedUpCard) |
| Applies the effect of the player at the given index in the players vector.
|
bool | revealFacedDownCard (Card card) |
| Asks to the player if he wants to reveal the faced down card.
|
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 same player.
|
void | announceDeadPlayers (Game *game) |
| Announces the dead players.
|
int | countDeadPlayers (Game *game) |
| Counts how many dead players there are in the players vector.
|
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 | announceWinner (Player player) |
| Announces the winner.
|
bool | deckHasCard (Card *deck, Card card) |
| Checks if a card is present in a deck.
|
bool | cardAreEqual (Card card1, Card card2) |
| Checks if two cards are equal.
|
bool | cardsWereGiven (Player **players, int playersCounter, Player player) |
| Checks if the cards of a given player have been already given to other players.
|
void | printCardEffect (Card card, bool newLine) |
| Prints user-friendly the card's effect.
|
void | revealCard (Card card, int playerId, bool facedUp, bool newLine) |
| Prints user-friendly the card revealed from a player.
|
void | tellFacedDownCard (Card card, int playerId) |
| Prints user-friendly the faced down card revealed of the player.
|
Implementation of game-related functions.
Definition in file main.c.