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. More... | |
| datasplayer * | convertStringToStuct (string pPlayer) |
| Generate a datasgame struct from a single line More... | |
| string | getNUMCookie (std::vector< HTTPCookie > pCookieVector) |
| Get the cookie of the game from the list of the cookies More... | |
| string | getValue (string pName) |
| Get all personnal information from the cookie's Id. More... | |
| string | getFileGame (string pName) |
| Get all game information from the name of the player. More... | |
| datasgame * | getGame (string pName) |
| Convert the data to the datasgame struct. More... | |
| void | writeValue (string pName, string pValue) |
| Write data in the cookie file. More... | |
| void | writeFileGame (string pName, string pValue) |
| Write data in the game file. More... | |
| void | writeGame (datasplayer *pPlayer, datasgame *pGame) |
| Write datasgame struct in the game file. More... | |
| string | generateUnicCookie () |
| generate an unique id More... | |
| int | countGame () |
| Read the game file and count the number of games. More... | |
| vector< string > * | loadAndMixCards () |
| Generate a mixed cards list. More... | |
| int | calculateCard (string pCard) |
| Return the value of the card. More... | |
| datasgame * | createGame (datasplayer *vPlayer) |
| Create a game from the data of the player. More... | |
| void | drawCards (vector< string > *cardList) |
| Draw the cards list. More... | |
| void | writeWinner (datasplayer *vPlayer, datasgame *pGame) |
| Draw the winner informations. More... | |
| void | drawInfos (datasplayer *vPlayer) |
| Draw player informations. More... | |
| void | drawPlayers (datasgame *pGame) |
| Draw players game informations. More... | |
| void | drawCardInPlay (datasgame *pGame) |
| Draw the cards in the table. More... | |
| void | drawPlayerCards (datasplayer *vPlayer) |
| Draw the cards of the player. More... | |
| void | playACard (datasplayer *vPlayer, datasgame *readedGame, string *card) |
| The algorithm when a card is played. More... | |
| void | turnPlayers (datasplayer *vPlayer, datasgame *readedGame) |
| Change the hand in the game. More... | |
| bool | testCard (datasplayer *vPlayer, datasgame *readedGame, string *card) |
| Test if the card is playable. More... | |
| void | IAPlay (datasgame *readedGame, int pId) |
| AI algorithme for one AI player. More... | |
| void | gameRules (datasplayer *vPlayer, string *action, string *card) |
| The rules Algorithm. More... | |
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.
| 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.
| 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.
| 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().
| 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.
| 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.
| 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.
| 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.
| 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 countGame(), getGame(), and datasplayer::identifiant.
| 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().
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(), and cgicc::FormEntry::operator*().
| 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().
| 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 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.
| 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 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 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().
| 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.
| 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.