00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef JEU_H
00022 #define JEU_H
00023
00024 #include<string>
00025 #include<iostream>
00026 #include<unistd.h>
00027 #include <cstdlib>
00028 #include <sstream>
00029
00030
00031 #include "Singleton.h"
00032 #include "Mutex.h"
00033
00034
00038 struct Point{
00039 int x;
00040 int y;
00041 };
00042
00048 class Jeu : public Singleton<Jeu> {
00049 friend class Singleton<Jeu>;
00050 private:
00051 Jeu();
00052 ~Jeu();
00053 public:
00058 bool GameOver();
00059
00060
00064 void KillGame(){ mPacmanVivant=false; }
00065
00072 bool DeplacerPersonnage(unsigned int codePerso, char sens);
00073
00080 void SetJoueur(unsigned int id, string login){
00081 if(id==3) {
00082 mJoueurPacman=true;
00083 mLoginPacman=login;
00084 } else {
00085 mJoueurF[id]=true;
00086 mLoginF[id]=login;
00087 }
00088 }
00089
00094 void UnSetJoueur(unsigned int id){
00095 if(id==3) mJoueurPacman=false;
00096 else mJoueurF[id]=false;
00097 }
00098
00099 unsigned int GetScorePacman(){ return mScorePacman; }
00100 unsigned int GetScoreF(unsigned int noFantome){ return mScoreF[noFantome];}
00101 string GetLoginPacman(){ return mLoginPacman; }
00102 string GetLoginF(unsigned int noFantome){ return mLoginF[noFantome];}
00103
00104 bool GetPacmanConnecte(){ return mJoueurPacman; }
00105 bool GetFConnecte(unsigned int noFantome){ return mJoueurF[noFantome]; }
00106
00107 void SetNbFantomeAuto(unsigned int nb){ mNbFantomeAuto=nb; }
00108 unsigned int GetNbFantomeAuto(){ return mNbFantomeAuto;}
00109
00114 string JoueurConnectes() const;
00115
00120 string toString();
00121
00126 string EtatPartie();
00127
00132 bool JeuPret() const;
00133 unsigned int UintAleat(unsigned int min, unsigned int max);
00134 private:
00135
00143 void ConstruireMur(unsigned int x, unsigned int y, unsigned int l, char sens);
00144
00151 void SetPoint(unsigned int x, unsigned int y, char c);
00152
00159 int PointLibre(unsigned int x, unsigned int y);
00160
00161 bool DeplacerPacman(char sens);
00162 bool DeplacerFantome(unsigned int noFantome, char sens);
00163
00164 bool GetPacmanVivant(){ return mPacmanVivant; }
00165 void Afficher() const;
00166
00170 char mGrille[20][20];
00171
00175 int mNbFantomeAuto;
00176
00177
00181 Point mCoordPacman;
00182
00186 unsigned int mScorePacman;
00187
00191 bool mPacmanVivant;
00192
00196 bool mJoueurPacman;
00197
00201 string mLoginPacman;
00202
00203
00207 Point mCoordF[3];
00208
00212 unsigned int mScoreF[3];
00213
00217 bool mJoueurF[3];
00218
00222 string mLoginF[3];
00223
00224
00228 Point mCoordP[3];
00229
00233 unsigned int mNBPomme;
00234
00238 Mutex mVerrou;
00239 };
00240
00241 #endif