Back to index

supertuxkart  0.5+dfsg1
moon_and_back_gp.cpp
Go to the documentation of this file.
00001 //  $Id$
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 "translation.hpp"
00021 #include "challenges/moon_and_back_gp.hpp"
00022 #include "race_manager.hpp"
00023 #include "world.hpp"
00024 
00025 MoonAndBackGP::MoonAndBackGP() : Challenge("moonandbackgp",_("Win To the Moon and Back\nGrand Prix"))
00026 {
00027     setChallengeDescription(_("Win the To the Moon and Back\nGrand Prix with 3 'Racer'\nLevel AI karts."));
00028     addUnlockGPReward("Snag Drive");
00029     // The energyshiftingsands challenge must be done, otherwise gp2 can't be selected
00030     // Thejunglefollow challenge must be done, to get city for gp3
00031     addDependency("energyshiftingsands");
00032     addDependency("junglefollow");
00033 }
00034 
00035 //-----------------------------------------------------------------------------
00036 void MoonAndBackGP::setRace() const {
00037     race_manager->setRaceMode(RaceManager::RM_GRAND_PRIX);
00038     CupData cup("gp2.cup");
00039     race_manager->setGrandPrix(cup);
00040     race_manager->setDifficulty(RaceManager::RD_HARD);
00041     race_manager->setNumKarts(4);
00042     race_manager->setNumPlayers(1);
00043 }   // setRace
00044 
00045 //-----------------------------------------------------------------------------
00046 bool MoonAndBackGP::grandPrixFinished()
00047 {
00048     if (race_manager->getRaceMode()  != RaceManager::RM_GRAND_PRIX  ||
00049         race_manager->getGrandPrix()->getName() != _("To the Moon and Back") ||
00050         race_manager->getDifficulty()!= RaceManager::RD_HARD        ||
00051         race_manager->getNumKarts()   < 4                           ||
00052         race_manager->getNumPlayers() > 1) return false;
00053     // Check if the player was in top 3:
00054     for(int i=0; i<(int)race_manager->getNumKarts(); i++)
00055     {
00056         const Kart* k=world->getKart(i);
00057         if(k->isPlayerKart() && !k->isEliminated()) return  k->getPosition()==1;
00058     }
00059     return false;
00060     
00061 }   // grandPrixFinished
00062 //-----------------------------------------------------------------------------