Jeu.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Pierre Schmitt, Ludovic Giacomello, Nhi Ly   *
00003  *      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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 //#include "DeplacementFantome.h"
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         //Fonctions privées
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         //Attributs de pacman
00181         Point mCoordPacman;
00182 
00186         unsigned int mScorePacman;
00187         
00191         bool mPacmanVivant;
00192 
00196         bool mJoueurPacman;
00197 
00201         string mLoginPacman;
00202 
00203         //Attributes des fantomes
00207         Point mCoordF[3];
00208 
00212         unsigned int mScoreF[3];
00213 
00217         bool mJoueurF[3];
00218 
00222         string mLoginF[3];
00223 
00224         //Pour replacer les pommes 
00228         Point mCoordP[3];
00229 
00233         unsigned int mNBPomme;
00234 
00238         Mutex mVerrou;
00239 };
00240 
00241 #endif

Generated on Wed Jan 2 14:01:41 2008 for Pacman by  doxygen 1.5.1