CardGameTools Namespace Reference

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.
datasplayerconvertStringToStuct (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.
datasgamegetGame (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.
datasgamecreateGame (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.


Detailed Description

Contain all the functions to the coding game.

Function Documentation

int CardGameTools::calculateCard ( string  pCard  ) 

Return the value of the card.

Parameters:
pCard : The card to evaluate
Returns:
the value of the card

Definition at line 784 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||

Parameters:
pPlayer The data to convert
See also:
datasplayer The data of the players

convertStructToString Do the same in the other direction

Returns:
Return the datasplayer struct conversion of the players

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||

Parameters:
*pPlayer A pointer on the data to convert
See also:
datasplayer The data of the players

convertStringToStuct Do the same in the other sense

Returns:
Return the string conversion of the players

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.

Returns:
the number of games

Definition at line 676 of file cardgame.cpp.

References GAME_FILE_NAME.

Referenced by gameRules().

datasgame* CardGameTools::createGame ( datasplayer vPlayer  ) 

Create a game from the data of the player.

See also:
datasgame

datasplayer

Parameters:
vPlayer : The data of the player
Returns:
the data game struct of the new created game

Definition at line 851 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.

See also:
datasgame
Parameters:
pGame : All the data of the gcurrent game to display

Definition at line 1024 of file cardgame.cpp.

References datasgame::playedCards.

void CardGameTools::drawCards ( vector< string > *  cardList  ) 

Draw the cards list.

Parameters:
cardList : The cards to display

Definition at line 910 of file cardgame.cpp.

Referenced by gameRules().

void CardGameTools::drawInfos ( datasplayer vPlayer  ) 

Draw player informations.

See also:
datasplayer
Parameters:
vPlayer : The data of the current player to display

Definition at line 971 of file cardgame.cpp.

References datasplayer::identifiant.

Referenced by gameRules().

void CardGameTools::drawPlayerCards ( datasplayer vPlayer  ) 

Draw the cards of the player.

See also:
datasplayer
Parameters:
vPlayer : The data of the current player to display

Definition at line 1044 of file cardgame.cpp.

References datasplayer::cardsList, and datasplayer::isPlaying.

Referenced by gameRules().

void CardGameTools::drawPlayers ( datasgame pGame  ) 

Draw players game informations.

See also:
datasgame
Parameters:
pGame : All the data of the gcurrent game to display

Definition at line 991 of file cardgame.cpp.

References datasgame::playersList.

Referenced by gameRules().

void CardGameTools::gameRules ( datasplayer vPlayer,
string *  action,
string *  card 
)

The rules Algorithm.

See also:
datasplayer
Parameters:
vPlayer : The data of the current player to display
action : Action of the human player
card : the card wanted

Definition at line 1275 of file cardgame.cpp.

References calculateCard(), datasplayer::cardsList, countGame(), createGame(), drawCards(), drawInfos(), drawPlayerCards(), drawPlayers(), getGame(), IAPlay(), datasplayer::identifiant, datasplayer::isPlaying, MAX_GAME, datasgame::piocheCards, playACard(), datasgame::playedCards, datasgame::playersList, datasplayer::points, testCard(), turnPlayers(), writeGame(), and writeWinner().

Referenced by main().

string CardGameTools::generateUnicCookie (  ) 

generate an unique id

Returns:
the id generated

Definition at line 655 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

Parameters:
pName : the name of the player
Returns:
Return the data string structure of the game

Definition at line 286 of file cardgame.cpp.

References GAME_FILE_NAME.

Referenced by getGame().

datasgame* CardGameTools::getGame ( string  pName  ) 

Convert the data to the datasgame struct.

Parameters:
pName : the game data
Returns:
Return the datasgame struct

Definition at line 324 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.

Parameters:
pCookieVector : the cookies list
See also:
HTTPCookie
Returns:
Return the id of the player

Definition at line 214 of file cardgame.cpp.

References COOKIE_NAME.

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

Parameters:
pName : the id of the player
Returns:
Return the data string structure of the player

Definition at line 245 of file cardgame.cpp.

References COOKIE_FILE_NAME.

Referenced by main(), cgicc::FormEntry::operator *(), and showForm().

void CardGameTools::IAPlay ( datasgame readedGame,
int  pId 
)

AI algorithme for one AI player.

Simple AI:

Definition at line 1215 of file cardgame.cpp.

References playACard(), datasgame::playedCards, datasgame::playersList, and turnPlayers().

Referenced by gameRules().

vector<string>* CardGameTools::loadAndMixCards (  ) 

Generate a mixed cards list.

Returns:
the cards list

Definition at line 708 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

See also:
datasplayer

datasgame

Parameters:
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 1080 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.

See also:
datasplayer

datasgame

Parameters:
vPlayer : The data of the current player to display
readedGame : All the data of the gcurrent game to display
card : the card wanted
Returns:
True if it's good to play and false for others cases

Definition at line 1164 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

See also:
datasplayer

datasgame

Parameters:
vPlayer : The data of the current player to display
readedGame : All the data of the gcurrent game to display

Definition at line 1129 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.

Parameters:
pName : the name of the player
pValue : the value with game data

Definition at line 529 of file cardgame.cpp.

References GAME_FILE_NAME.

Referenced by main(), and writeGame().

void CardGameTools::writeGame ( datasplayer pPlayer,
datasgame pGame 
)

Write datasgame struct in the game file.

Parameters:
pPlayer : the data of the player
pGame : the data of the game

Definition at line 598 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.

Parameters:
pName : the id of the player
pValue : the value with personnal data

Definition at line 512 of file cardgame.cpp.

References COOKIE_FILE_NAME.

Referenced by main().

void CardGameTools::writeWinner ( datasplayer vPlayer,
datasgame pGame 
)

Draw the winner informations.

See also:
datasplayer

datasgame

Parameters:
vPlayer : The data of the current player to display
pGame : All the data of the gcurrent game to display

Definition at line 931 of file cardgame.cpp.

References datasplayer::identifiant, and datasgame::playersList.

Referenced by gameRules().


GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996 - 2004 Stephen F. Booth
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front Cover Texts, and with no Back-Cover Texts.
Documentation generated Sat Jan 19 21:16:00 2008 for cgicc by doxygen 1.5.1