45#define COOKIE_NAME "ELPIELOJUEGO"
46#define COOKIE_FILE_NAME "sessions.tmp"
47#define GAME_FILE_NAME "games.tmp"
251 inFile.open(COOKIE_FILE_NAME);
256 inFile.open(COOKIE_FILE_NAME);
268 if (
s.find (
pName)!= string::npos)
271 s.replace(0,
pName.size(),
"");
292 inFile.open(GAME_FILE_NAME);
297 inFile.open(GAME_FILE_NAME);
308 if (
s.find (
pName)!= string::npos)
334 if (
vGame.compare(
"")==0)
353 bool isPlaying=
false;
370 for (
unsigned int i=0;
i<
vGame.size();
i++)
401 isPlaying=(
word.compare(
"1")==0)?
true:
false;
421 cardsList->push_back(
word);
429 vPlay->identifiant=identifiant;
430 vPlay->points=points;
431 vPlay->isPlaying=isPlaying;
432 vPlay->cardsList=cardsList;
433 vPlay->actualCard=actualCard;
539 inFile.open(GAME_FILE_NAME,ios::in);
548 inFile.open(GAME_FILE_NAME,ios::in);
562 if (
s.find (
pName)!= string::npos)
609 for(
unsigned int i=0;
i<
pGame->playersList->size();
i++)
629 for (
unsigned int i=0;
i<
pGame->playedCards->size();
i++)
641 for (
unsigned int i=0;
i<
pGame->piocheCards->size();
i++)
684 inFile.open(GAME_FILE_NAME);
791 if (
pCard.compare(
"TA")==0)
return 10;
792 if (
pCard.compare(
"TZ")==0)
return 14;
793 if (
pCard.compare(
"T2")==0)
return 2;
794 if (
pCard.compare(
"T3")==0)
return 3;
795 if (
pCard.compare(
"T4")==0)
return 4;
796 if (
pCard.compare(
"T5")==0)
return 5;
797 if (
pCard.compare(
"T6")==0)
return 6;
798 if (
pCard.compare(
"T7")==0)
return 7;
799 if (
pCard.compare(
"T8")==0)
return 8;
800 if (
pCard.compare(
"T9")==0)
return 9;
801 if (
pCard.compare(
"TD")==0)
return 12;
802 if (
pCard.compare(
"TR")==0)
return 13;
803 if (
pCard.compare(
"TB")==0)
return 11;
804 if (
pCard.compare(
"CA")==0)
return 10;
805 if (
pCard.compare(
"CZ")==0)
return 14;
806 if (
pCard.compare(
"C2")==0)
return 2;
807 if (
pCard.compare(
"C3")==0)
return 3;
808 if (
pCard.compare(
"C4")==0)
return 4;
809 if (
pCard.compare(
"C5")==0)
return 5;
810 if (
pCard.compare(
"C6")==0)
return 6;
811 if (
pCard.compare(
"C7")==0)
return 7;
812 if (
pCard.compare(
"C8")==0)
return 8;
813 if (
pCard.compare(
"C9")==0)
return 9;
814 if (
pCard.compare(
"CD")==0)
return 12;
815 if (
pCard.compare(
"CR")==0)
return 13;
816 if (
pCard.compare(
"CB")==0)
return 11;
817 if (
pCard.compare(
"PA")==0)
return 10;
818 if (
pCard.compare(
"PZ")==0)
return 14;
819 if (
pCard.compare(
"P2")==0)
return 2;
820 if (
pCard.compare(
"P3")==0)
return 3;
821 if (
pCard.compare(
"P4")==0)
return 4;
822 if (
pCard.compare(
"P5")==0)
return 5;
823 if (
pCard.compare(
"P6")==0)
return 6;
824 if (
pCard.compare(
"P7")==0)
return 7;
825 if (
pCard.compare(
"P8")==0)
return 8;
826 if (
pCard.compare(
"P9")==0)
return 9;
827 if (
pCard.compare(
"PD")==0)
return 12;
828 if (
pCard.compare(
"PR")==0)
return 13;
829 if (
pCard.compare(
"PB")==0)
return 11;
830 if (
pCard.compare(
"HA")==0)
return 10;
831 if (
pCard.compare(
"HZ")==0)
return 14;
832 if (
pCard.compare(
"H2")==0)
return 2;
833 if (
pCard.compare(
"H3")==0)
return 3;
834 if (
pCard.compare(
"H4")==0)
return 4;
835 if (
pCard.compare(
"H5")==0)
return 5;
836 if (
pCard.compare(
"H6")==0)
return 6;
837 if (
pCard.compare(
"H7")==0)
return 7;
838 if (
pCard.compare(
"H8")==0)
return 8;
839 if (
pCard.compare(
"H9")==0)
return 9;
840 if (
pCard.compare(
"HD")==0)
return 12;
841 if (
pCard.compare(
"HR")==0)
return 13;
842 if (
pCard.compare(
"HB")==0)
return 11;
866 p2->identifiant=
"FREE1";
870 p3->identifiant=
"FREE2";
874 p4->identifiant=
"FREE3";
891 for (
unsigned int i=0;
i<
myGame->playersList->size();
i++)
898 myGame->playersList->at(
i)->cardsList->push_back(
myGame->piocheCards->front());
899 myGame->piocheCards->erase(
myGame->piocheCards->begin());
920 cout <<
"<div style=\"position:absolute;top:50;left:"<<
i*150+150<<
"\" >";
921 cout <<
"<img border=\"0\" width=\"100\" src=\"images/"<<
cardList->at(
i)<<
".png\" alt=\"Carte ["<<
i<<
"]="<<
cardList->at(
i)<<
"\" />"<<
endl;
940 for (
unsigned int i=0;
i<
pGame->playersList->size();
i++)
942 if (
vPlayer->identifiant.compare(
pGame->playersList->at(
i)->identifiant)==0)
953 cout <<
"<div style=\"position:absolute;top:50;left:"<<150<<
"\" >";
977 cout <<
"<div style=\"position:absolute;width:140;top:50;left:"<<0<<
"\" >";
978 cout <<
"The latest Played Cards ";
980 cout <<
"<div style=\"width:140;position:absolute;top:180;left:"<<0<<
"\" >";
981 cout <<
"Actual Cards in the Game<br>You are the player :"<<
vPlayer->identifiant;
983 cout <<
"<div style=\"width:140;position:absolute;top:375;left:"<<0<<
"\" >";
984 cout <<
"Your Cards, you can choose one card.";
999 for (
unsigned int i=0;
i<
pGame->playersList->size();
i++)
1002 if (
vFirst==
false&&
pGame->playersList->at(
i)->actualCard.compare(
"")!=0)
1007 cout <<
"<div style=\"outline-color:"<<((
afficheFirst==
false)?
"black":
"red")<<
";outline-style:solid;outline-width:"<<((
afficheFirst==
false)?
"1":
"2")<<
"px;position:absolute;top:180;left:"<<
i*200+150<<
"\" >";
1008 cout <<
"Name :"<<
pGame->playersList->at(
i)->identifiant<<
"<br>";
1009 cout <<
"Score :"<<
pGame->playersList->at(
i)->points<<
"<br>";
1011 cout <<
"<img border=\"0\" width=\"100\" src=\"images/"<<
pGame->playersList->at(
i)->actualCard<<
".png\" alt=\" \" />"<<
endl;
1014 cout <<
"<br>The color to play";
1032 for (
unsigned int i=0;
i<
pGame->playedCards->size();
i++)
1034 cout <<
"<div style=\"position:absolute;top:100;left:"<<
i*110<<
"\" >";
1035 cout <<
"<img border=\"0\" width=\"100\" src=\"images/"<<
pGame->playedCards->at(
i)<<
".png\" alt=\"Carte ["<<
i<<
"]="<<
pGame->playedCards->at(
i)<<
"\" />"<<
endl;
1050 std::sort (
vPlayer->cardsList->begin(),
vPlayer->cardsList->end());
1051 cout <<
"<form name=\"cards\">";
1052 cout <<
"<input type=\"hidden\" name=\"actionner\" value=\"\">";
1053 cout <<
"<input type=\"hidden\" name=\"card\" value=\"\">";
1055 for (
unsigned int i=0;
i<
vPlayer->cardsList->size();
i++)
1057 cout <<
"<div style=\"position:absolute;top:375;left:"<<
i*20+150<<
"\" >";
1060 cout <<
"<a href=\"javascript:document.forms.cards.actionner.value='playcard';document.forms.cards.card.value='"<<
vPlayer->cardsList->at(
i)<<
"';document.forms.cards.submit();\">";
1062 cout <<
"<img border=\"0\" width=\"100\" src=\"images/"<<
vPlayer->cardsList->at(
i)<<
".png\" alt=\"Carte ["<<
i<<
"]="<<
vPlayer->cardsList->at(
i)<<
"\" />"<<
endl;
1088 for (
unsigned int i=0;
i<
readedGame->playersList->size();
i++)
1097 for (
unsigned int j=0;
j<
readedGame->playersList->at(
i)->cardsList->size();
j++)
1138 for (
unsigned int i=0;
i<
readedGame->playersList->size();
i++)
1179 if (
color.compare(
card->substr(0,1))==0)
1187 for (
unsigned int i=0;
i<
readedGame->playersList->size();
i++)
1193 for (
unsigned int j=0;
j<
readedGame->playersList->at(
i)->cardsList->size();
j++)
1195 if (
color.compare(
readedGame->playersList->at(
i)->cardsList->at(
j).substr(0,1))==0)
1241 for (
unsigned int i=0;
i<
readedGame->playersList->at(
pId)->cardsList->size();
i++)
1293 cout <<
"THE PLAY TABLES ARE FULL!"<<
endl;
1303 for (
unsigned int i=0;
i<
readedGame->playersList->size();
i++)
1332 cout <<
"<div style=\"position:absolute;top:50;left:"<<150<<
"\" >";
1333 cout <<
"<b>You can not Play this card!</b><br>\n";
1344 for (
unsigned int i=0;
i<
readedGame->playersList->size();
i++)
1361 if (
readedGame->playersList->at(
i)->isPlaying==
true)
1427 for (
unsigned int i=0;
i<
readedGame->playersList->size();
i++)
1437 if (
readedGame->playersList->at(
i)->isPlaying==
true)
1465 catch(std::exception &
error)
1467 cout <<
"Erreur:"<<
error.what()<<
"<br>\n";
1543 cout <<
"<H1>Card Game</H1>";
1544 cout <<
"<div style=\"position:absolute;top:5;left:"<<250<<
"\"><form name=\"start\"><input type=\"hidden\" name=\"actionner\" value=\"start\"><a href=\"javascript:document.forms.start.submit();\">Start a new Game</a></form></div>";
1568 if (
action.compare(
"start")==0)
Platform and operating system specific macro definitions.
The main header file for the GNU cgicc library.
The header file containing HTML output classes.
int main(int argc, char **argv)
The main function.
The main class of the GNU cgicc library.
Template for concrete atomic HTMLElement subclasses.
virtual const char * getName() const
Get the name of this element.
The namespace containing the cgicc library.
std::vector< FormEntry >::const_iterator const_form_iterator
A vector of const FormEntry objects.
A data model for the games.
vector< datasplayer * > * playersList
The players List.
vector< string > * piocheCards
The rest of the cards.
vector< string > * playedCards
The actual cards in the game.
A data model for the player.
string actualCard
The actual played card.
string identifiant
the identifiant of the player
vector< string > * cardsList
A list of the cards.
int points
the score of the player
bool isPlaying
If the player is playing the value is at true.