Back to index

supertuxkart  0.5+dfsg1
Public Member Functions
PenguinPlaygroundGP Class Reference

#include <penguin_playground_gp.hpp>

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

List of all members.

Public Member Functions

 PenguinPlaygroundGP ()
virtual bool grandPrixFinished ()
virtual void setRace () const
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 ()

Detailed Description

Definition at line 25 of file penguin_playground_gp.hpp.


Constructor & Destructor Documentation

Definition at line 25 of file penguin_playground_gp.cpp.

                                         : Challenge("penguinplaygroundgp", _("Win Penguin Playground Grand\nPrix"))
{
    setChallengeDescription(_("Win Penguin Playground Grand\nPrix with 3 'Racer' Level AI karts."));
    addUnlockModeReward("followleader", _("Follow the Leader"));
    // The energymathclass challenge must be done, otherwise GP can't be selected
}

Here is the call graph for this function:


Member Function Documentation

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

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 
) [inherited]

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) [inherited]

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 
) [inherited]

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) [inherited]

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, inherited]

Definition at line 71 of file challenge.hpp.

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

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, inherited]

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, inherited]

Definition at line 58 of file challenge.hpp.

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

Definition at line 78 of file challenge.hpp.

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

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:

Reimplemented from Challenge.

Definition at line 43 of file penguin_playground_gp.cpp.

{
    if (race_manager->getRaceMode()  != RaceManager::RM_GRAND_PRIX  ||
        race_manager->getGrandPrix()->getName() != _("Penguin Playground") ||
        race_manager->getDifficulty()!= RaceManager::RD_HARD        ||
        race_manager->getNumKarts()   < 4                           ||
        race_manager->getNumPlayers() > 1) return false;
    // Check if the player was in top 3:
    for(int i=0; i<(int)race_manager->getNumKarts(); i++)
    {
        const Kart* k=world->getKart(i);
        if(k->isPlayerKart() && !k->isEliminated()) return  k->getPosition()==1;
    }
    return false;
    
}   // grandPrixFinished

Here is the call graph for this function:

bool Challenge::isActive ( ) const [inline, inherited]

Definition at line 74 of file challenge.hpp.

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

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) [inherited]

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, inherited]

Definition at line 84 of file challenge.hpp.

{};

Here is the caller graph for this function:

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

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) [inherited]

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, inherited]

Definition at line 85 of file challenge.hpp.

{};

Here is the caller graph for this function:

void Challenge::setActive ( ) [inline, inherited]

Definition at line 76 of file challenge.hpp.

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

Definition at line 68 of file challenge.hpp.

Here is the caller graph for this function:

void PenguinPlaygroundGP::setRace ( ) const [virtual]

Implements Challenge.

Definition at line 33 of file penguin_playground_gp.cpp.

Here is the call graph for this function:

void Challenge::setSolved ( ) [inline, inherited]

Definition at line 75 of file challenge.hpp.

Here is the caller graph for this function:


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