Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Private Types | Private Attributes
Challenge Class Reference

#include <challenge.hpp>

Inheritance diagram for Challenge:
Inheritance graph
[legend]
Collaboration diagram for Challenge:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Challenge (std::string id, std::string name)
virtual ~Challenge ()
const std::string & getId () const
const std::string & getName () const
void addUnlockTrackReward (std::string track_name)
void addUnlockModeReward (std::string internal_mode_name, std::string user_mode_name)
void addUnlockGPReward (std::string gp_name)
void addUnlockDifficultyReward (std::string internal_name, std::string user_name)
const std::string getUnlockedMessage () const
const std::vector
< UnlockableFeature > & 
getFeatures () const
void setChallengeDescription (const std::string &d)
const std::string & getChallengeDescription () const
void addDependency (const std::string id)
bool isSolved () const
bool isActive () const
void setSolved ()
void setActive ()
const std::vector< std::string > & getPrerequisites () const
void load (const lisp::Lisp *config)
 Loads the state for a challenge object (esp.
void save (lisp::Writer *writer)
virtual void loadState (const lisp::Lisp *config)
virtual void saveState (lisp::Writer *writer)
virtual bool raceFinished ()
virtual bool grandPrixFinished ()
virtual void setRace () const =0

Private Types

enum  { CH_INACTIVE, CH_ACTIVE, CH_SOLVED }

Private Attributes

enum Challenge:: { ... }  m_state
std::string m_Id
std::string m_Name
std::string m_challenge_description
std::vector< UnlockableFeaturem_feature
std::vector< std::string > m_prerequisites

Detailed Description

Definition at line 44 of file challenge.hpp.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
CH_INACTIVE 
CH_ACTIVE 
CH_SOLVED 

Definition at line 46 of file challenge.hpp.

         {CH_INACTIVE,                 // challenge not yet possible
          CH_ACTIVE,                   // challenge possible, but not yet solved
          CH_SOLVED}         m_state;  // challenge was solved

Constructor & Destructor Documentation

Challenge::Challenge ( std::string  id,
std::string  name 
)

Definition at line 30 of file challenge.cpp.

                                                 : 
    m_state(CH_INACTIVE), m_Id(id), m_Name(name)
{
}   // Challenge
virtual Challenge::~Challenge ( ) [inline, virtual]

Definition at line 56 of file challenge.hpp.

{};

Member Function Documentation

void Challenge::addDependency ( const std::string  id) [inline]

Definition at line 72 of file challenge.hpp.

{m_prerequisites.push_back(id);  }

Here is the caller graph for this function:

void Challenge::addUnlockDifficultyReward ( std::string  internal_name,
std::string  user_name 
)

Definition at line 87 of file challenge.cpp.

{
    UnlockableFeature feature;
    feature.name = internal_name;
    feature.type = UNLOCK_DIFFICULTY;
    feature.user_name = user_name;
    m_feature.push_back(feature);
}

Here is the caller graph for this function:

void Challenge::addUnlockGPReward ( std::string  gp_name)

Definition at line 79 of file challenge.cpp.

{
    UnlockableFeature feature;
    feature.name = _(gp_name.c_str());
    feature.type = UNLOCK_GP;
    m_feature.push_back(feature);
}

Here is the caller graph for this function:

void Challenge::addUnlockModeReward ( std::string  internal_mode_name,
std::string  user_mode_name 
)

Definition at line 70 of file challenge.cpp.

{
    UnlockableFeature feature;
    feature.name = internal_mode_name;
    feature.type = UNLOCK_MODE;
    feature.user_name = user_mode_name;
    m_feature.push_back(feature);
}

Here is the caller graph for this function:

void Challenge::addUnlockTrackReward ( std::string  track_name)

Definition at line 62 of file challenge.cpp.

{
    UnlockableFeature feature;
    feature.name = track_name;
    feature.type = UNLOCK_TRACK;
    m_feature.push_back(feature);
}

Here is the caller graph for this function:

const std::string& Challenge::getChallengeDescription ( ) const [inline]

Definition at line 71 of file challenge.hpp.

const std::vector<UnlockableFeature>& Challenge::getFeatures ( ) const [inline]

Definition at line 67 of file challenge.hpp.

{return m_feature;               }

Here is the caller graph for this function:

const std::string& Challenge::getId ( ) const [inline]

Definition at line 57 of file challenge.hpp.

{return m_Id;                  }

Here is the caller graph for this function:

const std::string& Challenge::getName ( ) const [inline]

Definition at line 58 of file challenge.hpp.

{return m_Name;                }
const std::vector<std::string>& Challenge::getPrerequisites ( ) const [inline]

Definition at line 78 of file challenge.hpp.

{return m_prerequisites;         }
const std::string Challenge::getUnlockedMessage ( ) const

Definition at line 96 of file challenge.cpp.

{
    std::string unlocked_message;
    
    const unsigned int amount = (unsigned int)m_feature.size();
    for(unsigned int n=0; n<amount; n++)
    {
        // add line break if we are showing multiple messages
        if(n>0) unlocked_message+='\n';
        
        char message[128];
        
        // write message depending on feature type
        switch(m_feature[n].type)
        {
            case UNLOCK_TRACK:
                {
                    Track* track = track_manager->getTrack( m_feature[n].name );
                    snprintf(message, 127, _("New track '%s'\nnow available"), gettext(track->getName()) );
                    break;
                }
            case UNLOCK_MODE:
                snprintf(message, 127, _("New game mode\n'%s'\nnow available"), m_feature[n].user_name.c_str() );
                break;
            case UNLOCK_GP:
                snprintf(message, 127, _("New Grand Prix '%s'\nnow available"), m_feature[n].name.c_str() );
                break;
            case UNLOCK_DIFFICULTY:
                snprintf(message, 127, _("New difficulty\n'%s'\nnow available"), m_feature[n].user_name.c_str() );
                break;
        }
        unlocked_message += message;
    }
    
    return unlocked_message;
}

Here is the call graph for this function:

virtual bool Challenge::grandPrixFinished ( ) [inline, virtual]

Reimplemented in MoonAndBackGP, WorldsEndGP, and PenguinPlaygroundGP.

Definition at line 91 of file challenge.hpp.

{return false;}   // end of a GP
bool Challenge::isActive ( ) const [inline]

Definition at line 74 of file challenge.hpp.

{return m_state==CH_ACTIVE;      }
bool Challenge::isSolved ( ) const [inline]

Definition at line 73 of file challenge.hpp.

{return m_state==CH_SOLVED;      }

Here is the caller graph for this function:

void Challenge::load ( const lisp::Lisp config)

Loads the state for a challenge object (esp.

m_state), and calls the virtual function loadState for additional information

Definition at line 39 of file challenge.cpp.

{
    const lisp::Lisp* subnode= config->getLisp(getId());
    if(!subnode) return;
    
    // See if the challenge is solved (it's activated later from the
    // unlock_manager).
    bool finished=false;
    subnode->get("solved", finished);
    m_state = finished ? CH_SOLVED : CH_INACTIVE;
    if(!finished) loadState(subnode);
}   // load

Here is the call graph for this function:

virtual void Challenge::loadState ( const lisp::Lisp config) [inline, virtual]

Definition at line 84 of file challenge.hpp.

{};

Here is the caller graph for this function:

virtual bool Challenge::raceFinished ( ) [inline, virtual]

Reimplemented in EnergyMathClass, RaceTrackTime, TollwayTime, CityTime, EnergyShiftingSands, TollwayHead2Head, IslandFollow, and JungleFollow.

Definition at line 90 of file challenge.hpp.

{return false;}   // end of a race
void Challenge::save ( lisp::Writer writer)

Definition at line 53 of file challenge.cpp.

{
    writer->beginList(getId());
    writer->write("solved", isSolved());
    if(!isSolved()) saveState(writer);
    writer->endList(getId());
}   // save

Here is the call graph for this function:

virtual void Challenge::saveState ( lisp::Writer writer) [inline, virtual]

Definition at line 85 of file challenge.hpp.

{};

Here is the caller graph for this function:

void Challenge::setActive ( ) [inline]

Definition at line 76 of file challenge.hpp.

void Challenge::setChallengeDescription ( const std::string &  d) [inline]

Definition at line 68 of file challenge.hpp.

Here is the caller graph for this function:

virtual void Challenge::setRace ( ) const [pure virtual]
void Challenge::setSolved ( ) [inline]

Definition at line 75 of file challenge.hpp.

Here is the caller graph for this function:


Member Data Documentation

std::string Challenge::m_challenge_description [private]

Definition at line 51 of file challenge.hpp.

std::vector<UnlockableFeature> Challenge::m_feature [private]

Definition at line 52 of file challenge.hpp.

std::string Challenge::m_Id [private]

Definition at line 49 of file challenge.hpp.

std::string Challenge::m_Name [private]

Definition at line 50 of file challenge.hpp.

std::vector<std::string> Challenge::m_prerequisites [private]

Definition at line 53 of file challenge.hpp.

enum { ... } Challenge::m_state [private]

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