![]() |
Survival Royale 1.0.0
A very simple yet funny card game.
|
Implementation of TUI functions. More...
#include "tui.h"
Go to the source code of this file.
Functions | |
void | navigatePages (PageData *pagesData, int totalPages, int maxRows, int maxColumns, int bestStartColumn, int playerIndex, Game *game) |
Navigates between pages and handles player actions during their turn. | |
void | displayPage (PageData *page, int maxRows, int maxColumns, int bestStartColumn) |
Displays a page of cards and player information. | |
void | drawPageFrame (int maxRows, int maxColumns) |
Draws the frame for a page, including borders and separators. | |
void | drawCardsForPage (PageData *page, int startX, int bestStartColumn) |
Draws all cards for the current page. | |
void | drawLine (int startingX, int startingY, int length, char direction, char borders) |
Draws a line in the terminal. | |
void | drawCard (int startingX, int startingY, int suit, int rank) |
Draws a card at a specified position. | |
int | getCardColor (int cardRank) |
Retrieves the color associated with a card rank. | |
PageData * | getPageData (int maxRows, int maxColumns, Player **players, int totalPlayers, int *totalPages, int *bestStartColumn) |
Computes the page layout for players and allocates memory for the page data. | |
void | freePageData (PageData *pages, int totalPages) |
Frees the memory allocated for page data. | |
bool | isTerminalSizeValid (int maxRows, int maxColumns) |
Checks if the terminal size meets the minimum requirements. | |
int | getPageContainingPlayer (PageData *pagesData, int totalPages, int id) |
Determines which page contains a player by their ID. |
Variables | |
const char * | CARD_RANK_STRINGS [] |
const char * | CARD_SUIT_STRINGS [] |
Implementation of TUI functions.
Definition in file tui.c.
void displayPage | ( | PageData * | page, |
int | maxRows, | ||
int | maxColumns, | ||
int | bestStartColumn ) |
void drawCard | ( | int | startingX, |
int | startingY, | ||
int | suit, | ||
int | rank ) |
void drawCardsForPage | ( | PageData * | page, |
int | startX, | ||
int | bestStartColumn ) |
void drawLine | ( | int | startingX, |
int | startingY, | ||
int | length, | ||
char | direction, | ||
char | borders ) |
Draws a line in the terminal.
startingX | The starting row position. |
startingY | The starting column position. |
length | The length of the line. |
direction | The direction of the line ('h' for horizontal, 'v' for vertical). |
borders | The type of border ('u' for upper, 'd' for lower, 'n' for none). |
void drawPageFrame | ( | int | maxRows, |
int | maxColumns ) |
void freePageData | ( | PageData * | pages, |
int | totalPages ) |
int getCardColor | ( | int | cardRank | ) |
int getPageContainingPlayer | ( | PageData * | pagesData, |
int | totalPages, | ||
int | id ) |
PageData * getPageData | ( | int | maxRows, |
int | maxColumns, | ||
Player ** | players, | ||
int | totalPlayers, | ||
int * | totalPages, | ||
int * | bestStartColumn ) |
Computes the page layout for players and allocates memory for the page data.
maxRows | The maximum number of rows in the terminal. |
maxColumns | The maximum number of columns in the terminal. |
players | An array of pointers to all players. |
totalPlayers | The total number of players in the game. |
totalPages | Pointer to store the total number of pages. |
bestStartColumn | Pointer to store the starting column for centering the cards. |
bool isTerminalSizeValid | ( | int | maxRows, |
int | maxColumns ) |
void navigatePages | ( | PageData * | pagesData, |
int | totalPages, | ||
int | maxRows, | ||
int | maxColumns, | ||
int | bestStartColumn, | ||
int | playerIndex, | ||
Game * | game ) |
Navigates between pages and handles player actions during their turn.
pagesData | The data of all pages. |
totalPages | The total number of pages. |
maxRows | The maximum number of rows in the terminal. |
maxColumns | The maximum number of columns in the terminal. |
bestStartColumn | The starting column to align content. |
playerIndex | The index of the current player. |
game | Pointer to the game state. |
const char* CARD_RANK_STRINGS[] |