Back to index

extremetuxracer  0.5beta
game_mgr.h
Go to the documentation of this file.
00001 /* 
00002  * PPRacer 
00003  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (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 Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 
00021 #ifndef _GAME_MGR_H_
00022 #define _GAME_MGR_H_
00023 
00024 
00025 #include "course_mgr.h"
00026 #include "player.h"
00027 
00028 class GameMgr
00029 {
00030        std::list<CourseData>::iterator mi_currentRace;
00031        
00032        bool m_raceAborted;
00033        bool m_raceWon;
00034        bool m_cupWon;
00035        bool m_eventWon;
00036     bool m_raceHasToBeRetried;
00037 
00038        
00039        double m_lastTicks;
00040               
00041 public:
00042        GameMgr();
00043 
00044        // should be private
00045        // needs some love in event_select.cpp
00046        std::list<EventData>::iterator currentEvent;
00047        std::list<CupData>::iterator currentCup;
00048 
00049 
00050        difficulty_level_t difficulty;
00051        double time;
00052        double airbornetime;
00053        double timeStep;
00054        int numPlayers;
00055 
00056        void setupEventAndCup( std::list<EventData>::iterator event,
00057                                           std::list<CupData>::iterator cup);
00058 
00059        void setCurrentRace(std::list<CourseData>::iterator race);
00060        
00061        inline EventData& getCurrentEvent(){return *currentEvent;};
00062        inline CupData& getCurrentCup(){return *currentCup;};
00063        inline CourseData& getCurrentRace(){return *mi_currentRace;};
00064 
00065        typedef enum{
00066               PRACTICING,
00067               EVENT
00068        }gametype_t;
00069 
00070        gametype_t gametype;
00071        void reset(gametype_t type);
00072        
00073        inline bool wasRaceAborted(){return m_raceAborted;};
00074        inline void abortRace(bool abort=true){m_raceAborted=abort;};
00075        
00076        void updatePlayersScores();
00077 
00078        unsigned int calculateScore(double time,
00079                                                         int herring,
00080                                                         int health);
00081 
00082        bool updateCurrentRaceData();
00083        bool wasRaceWon();
00084        bool wasCupWon();
00085        bool wasEventWon();
00086     bool doesRaceHaveToBeRetried();
00087     void setRaceHasToBeRetried(bool);
00088 
00089        
00090        void resetTimeStep();
00091        void updateTimeStep();
00092        inline double getTimeStep(){return timeStep;};   
00093 };
00094 
00095 extern GameMgr* gameMgr;
00096 
00097 #endif // _GAME_MGR_H_