Contain all the functions to the coding game. More...
Functions | |
string | convertStructToString (datasplayer *pPlayer) |
Generate a data in a single line from the data of the player. | |
datasplayer * | convertStringToStuct (string pPlayer) |
Generate a datasgame struct from a single line | |
string | getNUMCookie (std::vector< HTTPCookie > pCookieVector) |
Get the cookie of the game from the list of the cookies | |
string | getValue (string pName) |
Get all personnal information from the cookie's Id. | |
string | getFileGame (string pName) |
Get all game information from the name of the player. | |
datasgame * | getGame (string pName) |
Convert the data to the datasgame struct. | |
void | writeValue (string pName, string pValue) |
Write data in the cookie file. | |
void | writeFileGame (string pName, string pValue) |
Write data in the game file. | |
void | writeGame (datasplayer *pPlayer, datasgame *pGame) |
Write datasgame struct in the game file. | |
string | generateUnicCookie () |
generate an unique id | |
int | countGame () |
Read the game file and count the number of games. | |
vector< string > * | loadAndMixCards () |
Generate a mixed cards list. | |
int | calculateCard (string pCard) |
Return the value of the card. | |
datasgame * | createGame (datasplayer *vPlayer) |
Create a game from the data of the player. | |
void | drawCards (vector< string > *cardList) |
Draw the cards list. | |
void | writeWinner (datasplayer *vPlayer, datasgame *pGame) |
Draw the winner informations. | |
void | drawInfos (datasplayer *vPlayer) |
Draw player informations. | |
void | drawPlayers (datasgame *pGame) |
Draw players game informations. | |
void | drawCardInPlay (datasgame *pGame) |
Draw the cards in the table. | |
void | drawPlayerCards (datasplayer *vPlayer) |
Draw the cards of the player. | |
void | playACard (datasplayer *vPlayer, datasgame *readedGame, string *card) |
The algorithm when a card is played. | |
void | turnPlayers (datasplayer *vPlayer, datasgame *readedGame) |
Change the hand in the game. | |
bool | testCard (datasplayer *vPlayer, datasgame *readedGame, string *card) |
Test if the card is playable. | |
void | IAPlay (datasgame *readedGame, int pId) |
AI algorithme for one AI player. | |
void | gameRules (datasplayer *vPlayer, string *action, string *card) |
The rules Algorithm. | |
Contain all the functions to the coding game.
int CardGameTools::calculateCard | ( | string | pCard | ) |
Return the value of the card.
pCard | : The card to evaluate |
Definition at line 788 of file cardgame.cpp.
Referenced by gameRules().
datasplayer * CardGameTools::convertStringToStuct | ( | string | pPlayer | ) |
Generate a datasgame struct from a single line
The separator in the string is the double of the character ":" . The real code is "::". The double code "||" define the end of the datas.
The format is : playerId::card1::card2::...::cardn||
pPlayer | The data to convert |
Definition at line 168 of file cardgame.cpp.
References datasplayer::cardsList, and datasplayer::identifiant.
Referenced by main().
string CardGameTools::convertStructToString | ( | datasplayer * | pPlayer | ) |
Generate a data in a single line from the data of the player.
The separator in the string is the double of the character ":" . The real code is "::". The double code "||" define the end of the datas.
The format is : playerId::card1::card2::...::cardn||
*pPlayer | A pointer on the data to convert |
Definition at line 134 of file cardgame.cpp.
References datasplayer::cardsList, and datasplayer::identifiant.
Referenced by main().
int CardGameTools::countGame | ( | ) |
Read the game file and count the number of games.
Definition at line 680 of file cardgame.cpp.
Referenced by gameRules().
datasgame * CardGameTools::createGame | ( | datasplayer * | vPlayer | ) |
Create a game from the data of the player.
vPlayer | : The data of the player |
Definition at line 855 of file cardgame.cpp.
References datasplayer::actualCard, datasplayer::identifiant, datasplayer::isPlaying, loadAndMixCards(), datasgame::piocheCards, datasgame::playedCards, datasgame::playersList, datasplayer::points, and writeGame().
Referenced by gameRules().
void CardGameTools::drawCardInPlay | ( | datasgame * | pGame | ) |
Draw the cards in the table.
pGame | : All the data of the gcurrent game to display |
Definition at line 1028 of file cardgame.cpp.
References datasgame::playedCards.
void CardGameTools::drawCards | ( | vector< string > * | cardList | ) |
Draw the cards list.
cardList | : The cards to display |
Definition at line 914 of file cardgame.cpp.
Referenced by gameRules().
void CardGameTools::drawInfos | ( | datasplayer * | vPlayer | ) |
Draw player informations.
vPlayer | : The data of the current player to display |
Definition at line 975 of file cardgame.cpp.
References datasplayer::identifiant.
Referenced by gameRules().
void CardGameTools::drawPlayerCards | ( | datasplayer * | vPlayer | ) |
Draw the cards of the player.
vPlayer | : The data of the current player to display |
Definition at line 1048 of file cardgame.cpp.
References datasplayer::cardsList, and datasplayer::isPlaying.
Referenced by gameRules().
void CardGameTools::drawPlayers | ( | datasgame * | pGame | ) |
Draw players game informations.
pGame | : All the data of the gcurrent game to display |
Definition at line 995 of file cardgame.cpp.
References datasgame::playersList.
Referenced by gameRules().
void CardGameTools::gameRules | ( | datasplayer * | vPlayer, |
string * | action, | ||
string * | card | ||
) |
The rules Algorithm.
vPlayer | : The data of the current player to display |
action | : Action of the human player |
card | : the card wanted |
Definition at line 1279 of file cardgame.cpp.
References calculateCard(), datasplayer::cardsList, countGame(), createGame(), drawCards(), drawInfos(), drawPlayerCards(), drawPlayers(), getGame(), IAPlay(), datasplayer::identifiant, datasplayer::isPlaying, datasgame::piocheCards, playACard(), datasgame::playedCards, datasgame::playersList, datasplayer::points, testCard(), turnPlayers(), writeGame(), and writeWinner().
Referenced by main().
string CardGameTools::generateUnicCookie | ( | ) |
generate an unique id
Definition at line 659 of file cardgame.cpp.
Referenced by main().
string CardGameTools::getFileGame | ( | string | pName | ) |
Get all game information from the name of the player.
read he game file and find the player for take all data of the player game
pName | : the name of the player |
Definition at line 288 of file cardgame.cpp.
Referenced by getGame().
datasgame * CardGameTools::getGame | ( | string | pName | ) |
Convert the data to the datasgame struct.
pName | : the game data |
Definition at line 326 of file cardgame.cpp.
References datasplayer::actualCard, datasplayer::cardsList, getFileGame(), datasplayer::identifiant, datasplayer::isPlaying, datasgame::piocheCards, datasgame::playedCards, datasgame::playersList, and datasplayer::points.
Referenced by gameRules().
string CardGameTools::getNUMCookie | ( | std::vector< HTTPCookie > | pCookieVector | ) |
Get the cookie of the game from the list of the cookies
We select our personnal cookie in the list of cookies sended by the user.
pCookieVector | : the cookies list |
Definition at line 216 of file cardgame.cpp.
References cgicc::HTTPCookie::getName(), and cgicc::HTTPCookie::getValue().
Referenced by main().
string CardGameTools::getValue | ( | string | pName | ) |
Get all personnal information from the cookie's Id.
read he session file and find the player for take all personnal information
pName | : the id of the player |
Definition at line 247 of file cardgame.cpp.
Referenced by main().
void CardGameTools::IAPlay | ( | datasgame * | readedGame, |
int | pId | ||
) |
AI algorithme for one AI player.
Simple AI:
readedGame | : All the data of the gcurrent game to display |
pId | : the id in the players list |
Definition at line 1219 of file cardgame.cpp.
References playACard(), datasgame::playedCards, datasgame::playersList, and turnPlayers().
Referenced by gameRules().
vector< string > * CardGameTools::loadAndMixCards | ( | ) |
Generate a mixed cards list.
Definition at line 712 of file cardgame.cpp.
Referenced by createGame().
void CardGameTools::playACard | ( | datasplayer * | vPlayer, |
datasgame * | readedGame, | ||
string * | card | ||
) |
The algorithm when a card is played.
When we choose a card , we need to add the card in a specific cards list and we need to extract the card from the player cards list Work only for AI players
vPlayer | : The data of the current player to display |
readedGame | : All the data of the gcurrent game to display |
card | : the played card |
Definition at line 1084 of file cardgame.cpp.
References datasplayer::identifiant, datasgame::piocheCards, datasgame::playedCards, and datasgame::playersList.
Referenced by gameRules(), and IAPlay().
bool CardGameTools::testCard | ( | datasplayer * | vPlayer, |
datasgame * | readedGame, | ||
string * | card | ||
) |
Test if the card is playable.
vPlayer | : The data of the current player to display |
readedGame | : All the data of the gcurrent game to display |
card | : the card wanted |
Definition at line 1168 of file cardgame.cpp.
References datasplayer::identifiant, datasplayer::isPlaying, datasgame::playedCards, and datasgame::playersList.
Referenced by gameRules().
void CardGameTools::turnPlayers | ( | datasplayer * | vPlayer, |
datasgame * | readedGame | ||
) |
Change the hand in the game.
The next candidate is to the right on the play table
vPlayer | : The data of the current player to display |
readedGame | : All the data of the gcurrent game to display |
Definition at line 1133 of file cardgame.cpp.
References datasplayer::identifiant, datasplayer::isPlaying, and datasgame::playersList.
Referenced by gameRules(), and IAPlay().
void CardGameTools::writeFileGame | ( | string | pName, |
string | pValue | ||
) |
Write data in the game file.
pName | : the name of the player |
pValue | : the value with game data |
Definition at line 533 of file cardgame.cpp.
Referenced by main(), and writeGame().
void CardGameTools::writeGame | ( | datasplayer * | pPlayer, |
datasgame * | pGame | ||
) |
Write datasgame struct in the game file.
pPlayer | : the data of the player |
pGame | : the data of the game |
Definition at line 602 of file cardgame.cpp.
References datasplayer::actualCard, datasplayer::cardsList, datasplayer::identifiant, datasplayer::isPlaying, datasgame::piocheCards, datasgame::playedCards, datasgame::playersList, datasplayer::points, and writeFileGame().
Referenced by createGame(), and gameRules().
void CardGameTools::writeValue | ( | string | pName, |
string | pValue | ||
) |
Write data in the cookie file.
pName | : the id of the player |
pValue | : the value with personnal data |
Definition at line 516 of file cardgame.cpp.
Referenced by main().
void CardGameTools::writeWinner | ( | datasplayer * | vPlayer, |
datasgame * | pGame | ||
) |
Draw the winner informations.
vPlayer | : The data of the current player to display |
pGame | : All the data of the gcurrent game to display |
Definition at line 935 of file cardgame.cpp.
References datasplayer::identifiant, and datasgame::playersList.
Referenced by gameRules().