Back to index

extremetuxracer  0.5beta
Public Member Functions | Public Attributes | Private Attributes
PlayerEventData Class Reference

#include <player.h>

Collaboration diagram for PlayerEventData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PlayerEventData ()
bool isCupWon (std::string cup)
bool getCupCourseData (std::string cup, std::string course, PlayerCourseData &data)
bool updateCupCourseData (std::string cup, std::string course, double time, int herring, int score, bool won)
void setCupComplete (std::string cup)
void clearCupData (std::string cup)
void saveData (std::ofstream &sfile)
void loadData (std::ifstream &sfile)

Public Attributes

bool won
bool loaded

Private Attributes

std::map< std::string,
PlayerCupData
cups

Detailed Description

Definition at line 70 of file player.h.


Constructor & Destructor Documentation

Definition at line 47 of file player.cpp.

 : won(false), loaded(false)
{      
}

Member Function Documentation

void PlayerEventData::clearCupData ( std::string  cup)

Definition at line 94 of file player.cpp.

{
       std::map<std::string,PlayerCupData>::iterator it;
       if( (it=cups.find( cup ))!=cups.end() ){
              cups.erase(it);
       }      
}
bool PlayerEventData::getCupCourseData ( std::string  cup,
std::string  course,
PlayerCourseData data 
)

Definition at line 65 of file player.cpp.

{
       std::map<std::string,PlayerCupData>::iterator it;
       if( (it=cups.find(cup))!=cups.end() ){
              return (*it).second.getCupCourseData(course,data);
       }
       return false; 
}
bool PlayerEventData::isCupWon ( std::string  cup)

Definition at line 53 of file player.cpp.

{
       std::map<std::string,PlayerCupData>::iterator it;
       
       if((it=cups.find(cup))!=cups.end()){
              return (*it).second.won;
       }else{
              return false; 
       }      
}
void PlayerEventData::loadData ( std::ifstream &  sfile)

Definition at line 117 of file player.cpp.

{
       char buff[256];
       int numcups;
       
       sfile >> won;
       sfile >> numcups;
       for(int i=0; i<numcups; i++){      
              sfile.get();
              sfile.getline(buff,256);
              cups[buff].loadData(sfile);
       }
       loaded=true;
}
void PlayerEventData::saveData ( std::ofstream &  sfile)

Definition at line 103 of file player.cpp.

{
              sfile << won << std::endl;
              sfile << cups.size() << std::endl;
              if(cups.size()>0){   
                     std::map<std::string,PlayerCupData>::iterator it;
                     for(it=cups.begin(); it!=cups.end(); it++){
                            sfile << (*it).first << std::endl;
                            (*it).second.saveData(sfile);      
                     }
              }
}
void PlayerEventData::setCupComplete ( std::string  cup)

Definition at line 88 of file player.cpp.

{
       cups[cup].won=true;  
}
bool PlayerEventData::updateCupCourseData ( std::string  cup,
std::string  course,
double  time,
int  herring,
int  score,
bool  won 
)

Definition at line 77 of file player.cpp.

{
       return cups[cup].updateCupCourseData(course,time,herring,score,won);
}

Member Data Documentation

std::map<std::string,PlayerCupData> PlayerEventData::cups [private]

Definition at line 72 of file player.h.

Definition at line 92 of file player.h.

Definition at line 76 of file player.h.


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