Back to index

extremetuxracer  0.5beta
Public Types | Public Member Functions | Public Attributes | Private Attributes
GameMgr Class Reference

#include <game_mgr.h>

Collaboration diagram for GameMgr:
Collaboration graph
[legend]

List of all members.

Public Types

enum  gametype_t { PRACTICING, EVENT }

Public Member Functions

 GameMgr ()
void setupEventAndCup (std::list< EventData >::iterator event, std::list< CupData >::iterator cup)
void setCurrentRace (std::list< CourseData >::iterator race)
EventDatagetCurrentEvent ()
CupDatagetCurrentCup ()
CourseDatagetCurrentRace ()
void reset (gametype_t type)
bool wasRaceAborted ()
void abortRace (bool abort=true)
void updatePlayersScores ()
unsigned int calculateScore (double time, int herring, int health)
bool updateCurrentRaceData ()
bool wasRaceWon ()
bool wasCupWon ()
bool wasEventWon ()
bool doesRaceHaveToBeRetried ()
void setRaceHasToBeRetried (bool)
void resetTimeStep ()
void updateTimeStep ()
double getTimeStep ()

Public Attributes

std::list< EventData >::iterator currentEvent
std::list< CupData >::iterator currentCup
difficulty_level_t difficulty
double time
double airbornetime
double timeStep
int numPlayers
gametype_t gametype

Private Attributes

std::list< CourseData >::iterator mi_currentRace
bool m_raceAborted
bool m_raceWon
bool m_cupWon
bool m_eventWon
bool m_raceHasToBeRetried
double m_lastTicks

Detailed Description

Definition at line 28 of file game_mgr.h.


Member Enumeration Documentation

Enumerator:
PRACTICING 
EVENT 

Definition at line 65 of file game_mgr.h.


Constructor & Destructor Documentation

Definition at line 29 of file game_mgr.cpp.

{
       m_lastTicks = SDL_GetTicks()/1000.0;
    m_raceHasToBeRetried = false;

}

Member Function Documentation

void GameMgr::abortRace ( bool  abort = true) [inline]

Definition at line 74 of file game_mgr.h.

{m_raceAborted=abort;};

Here is the caller graph for this function:

unsigned int GameMgr::calculateScore ( double  time,
int  herring,
int  health 
)

Definition at line 58 of file game_mgr.cpp.

{
       int timescore = MAX( 0, int(100*((*mi_currentRace).time_req[DIFFICULTY_LEVEL_EASY]-time)));
       int herringscore = 200*herring;
       
       //for future use
       int healthscore = 0*health;
       
       return timescore+herringscore+healthscore;
}

Here is the caller graph for this function:

Definition at line 148 of file game_mgr.cpp.

Here is the caller graph for this function:

Definition at line 62 of file game_mgr.h.

{return *currentCup;};

Here is the caller graph for this function:

Definition at line 61 of file game_mgr.h.

{return *currentEvent;};

Here is the caller graph for this function:

Definition at line 63 of file game_mgr.h.

{return *mi_currentRace;};

Here is the caller graph for this function:

double GameMgr::getTimeStep ( ) [inline]

Definition at line 92 of file game_mgr.h.

{return timeStep;};  

Here is the caller graph for this function:

void GameMgr::reset ( gametype_t  type)

Definition at line 52 of file game_mgr.cpp.

{
       gametype=type;
}

Here is the caller graph for this function:

Definition at line 159 of file game_mgr.cpp.

{
       m_lastTicks = SDL_GetTicks()/1000.0;
}

Here is the caller graph for this function:

void GameMgr::setCurrentRace ( std::list< CourseData >::iterator  race)

Definition at line 46 of file game_mgr.cpp.

{
       mi_currentRace = race;
}

Here is the caller graph for this function:

Definition at line 153 of file game_mgr.cpp.

Here is the caller graph for this function:

void GameMgr::setupEventAndCup ( std::list< EventData >::iterator  event,
std::list< CupData >::iterator  cup 
)

Definition at line 38 of file game_mgr.cpp.

{
       currentEvent=event;
       currentCup=cup;                                                
}

Here is the caller graph for this function:

Definition at line 81 of file game_mgr.cpp.

{
       m_eventWon=false;
       m_cupWon=false;
       
       if(    time <= (*mi_currentRace).time_req[difficulty] &&
              players[0].herring >= (*mi_currentRace).herring_req[difficulty] &&
              players[0].score >= (*mi_currentRace).score_req[difficulty] &&
              !wasRaceAborted() ) 
    {
              m_raceWon=true;             
       } else {
              m_raceWon=false;
    }  
       
       bool bestScore = players[0].updateCupCourseData(
                                   (*currentEvent).name,
                                   (*currentCup).name,
                                   (*mi_currentRace).name,
                                   time,
                                   players[0].herring,
                                   players[0].score,
                                   m_raceWon);
       
       if(m_raceWon){       
              std::list<CourseData>::iterator lastRace=(*currentCup).raceList.end();
              lastRace--;
              
              if(mi_currentRace == lastRace){
                     m_cupWon = true;
                     players[0].setCupComplete(  (*currentEvent).name,
                                                                      (*currentCup).name);
                     std::list<CupData>::iterator lastCup=(*currentEvent).cupList.end();
                     lastCup--;
                     if(currentCup == lastCup){
                            m_eventWon = true;
                            players[0].setEventComplete((*currentEvent).name);
                     }
                     if(!getparam_always_save_event_race_data()){
                            players[0].saveData();
                     }
              }
       }
       if(getparam_always_save_event_race_data()){
              players[0].saveData();
       }
       return bestScore;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 71 of file game_mgr.cpp.

{
       for (int i=0; i<numPlayers; i++){
              players[i].score=calculateScore(time,
                                                                      players[i].herring,
                                                                      players[i].health);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 165 of file game_mgr.cpp.

{
       double ticks = SDL_GetTicks()/1000.0;
       timeStep = ticks - m_lastTicks;
       timeStep = MAX(timeStep,EPS);
       m_lastTicks = ticks;
}

Here is the caller graph for this function:

Definition at line 137 of file game_mgr.cpp.

{
       return m_cupWon;     
}

Here is the caller graph for this function:

Definition at line 143 of file game_mgr.cpp.

{
       return m_eventWon;   
}

Here is the caller graph for this function:

bool GameMgr::wasRaceAborted ( ) [inline]

Definition at line 73 of file game_mgr.h.

{return m_raceAborted;};

Here is the caller graph for this function:

Definition at line 131 of file game_mgr.cpp.

{
       return m_raceWon;    
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 52 of file game_mgr.h.

std::list<CupData>::iterator GameMgr::currentCup

Definition at line 47 of file game_mgr.h.

std::list<EventData>::iterator GameMgr::currentEvent

Definition at line 46 of file game_mgr.h.

Definition at line 50 of file game_mgr.h.

Definition at line 70 of file game_mgr.h.

bool GameMgr::m_cupWon [private]

Definition at line 34 of file game_mgr.h.

bool GameMgr::m_eventWon [private]

Definition at line 35 of file game_mgr.h.

double GameMgr::m_lastTicks [private]

Definition at line 39 of file game_mgr.h.

bool GameMgr::m_raceAborted [private]

Definition at line 32 of file game_mgr.h.

Definition at line 36 of file game_mgr.h.

bool GameMgr::m_raceWon [private]

Definition at line 33 of file game_mgr.h.

std::list<CourseData>::iterator GameMgr::mi_currentRace [private]

Definition at line 30 of file game_mgr.h.

Definition at line 54 of file game_mgr.h.

double GameMgr::time

Definition at line 51 of file game_mgr.h.

Definition at line 53 of file game_mgr.h.


The documentation for this class was generated from the following files: