Back to index

supertuxkart  0.5+dfsg1
energy_math_class.cpp
Go to the documentation of this file.
00001 //  $Id: energy_math_class.cpp 1259 2007-09-24 12:28:19Z hiker $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2008 Joerg Henrichs
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be ruseful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #include <algorithm>
00021 #include "translation.hpp"
00022 #include "challenges/energy_math_class.hpp"
00023 #include "race_manager.hpp"
00024 #include "world.hpp"
00025 
00026 EnergyMathClass::EnergyMathClass() : Challenge("energymathclass", _("Collect Coins in Math Class"))
00027 {
00028     setChallengeDescription(_("Collect at least 6 points\nworth of coins\non three laps of\nOliver's Math Class\nin under 1 minute."));
00029     addUnlockTrackReward("crescentcrossing");
00030 }   // EnergyMathClass
00031 
00032 //-----------------------------------------------------------------------------
00033 void EnergyMathClass::setRace() const {
00034     race_manager->setRaceMode(RaceManager::RM_QUICK_RACE);
00035     race_manager->setTrack("olivermath");
00036     race_manager->setDifficulty(RaceManager::RD_EASY);
00037     race_manager->setNumLaps(3);
00038     race_manager->setNumKarts(1);
00039     race_manager->setNumPlayers(1);
00040     race_manager->setCoinTarget(6);
00041 }   // setRace
00042 \
00043 //-----------------------------------------------------------------------------
00044 bool EnergyMathClass::raceFinished()
00045 {
00046     std::string track_name = world->getTrack()->getIdent();
00047     if(track_name!="olivermath") return false;    // wrong track
00048     Kart* kart=world->getPlayerKart(0);
00049     if(kart->getFinishTime()>60) return false;    // too slow
00050     if(kart->getLap()!=3       ) return false;    // wrong number of laps
00051     if(kart->getNumHerring()<6 ) return false;    // not enough herrings
00052     return true;
00053 }   // raceFinished
00054 //-----------------------------------------------------------------------------