Back to index

supertuxkart  0.5+dfsg1
penguin_playground_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/penguin_playground_gp.hpp"
00022 #include "race_manager.hpp"
00023 #include "world.hpp"
00024 
00025 PenguinPlaygroundGP::PenguinPlaygroundGP() : Challenge("penguinplaygroundgp", _("Win Penguin Playground Grand\nPrix"))
00026 {
00027     setChallengeDescription(_("Win Penguin Playground Grand\nPrix with 3 'Racer' Level AI karts."));
00028     addUnlockModeReward("followleader", _("Follow the Leader"));
00029     // The energymathclass challenge must be done, otherwise GP can't be selected
00030 }
00031 
00032 //-----------------------------------------------------------------------------
00033 void PenguinPlaygroundGP::setRace() const {
00034     race_manager->setRaceMode(RaceManager::RM_GRAND_PRIX);
00035     CupData cup("gp1.cup");
00036     race_manager->setGrandPrix(cup);
00037     race_manager->setDifficulty(RaceManager::RD_HARD);
00038     race_manager->setNumKarts(4);
00039     race_manager->setNumPlayers(1);
00040 }   // setRace
00041 
00042 //-----------------------------------------------------------------------------
00043 bool PenguinPlaygroundGP::grandPrixFinished()
00044 {
00045     if (race_manager->getRaceMode()  != RaceManager::RM_GRAND_PRIX  ||
00046         race_manager->getGrandPrix()->getName() != _("Penguin Playground") ||
00047         race_manager->getDifficulty()!= RaceManager::RD_HARD        ||
00048         race_manager->getNumKarts()   < 4                           ||
00049         race_manager->getNumPlayers() > 1) return false;
00050     // Check if the player was in top 3:
00051     for(int i=0; i<(int)race_manager->getNumKarts(); i++)
00052     {
00053         const Kart* k=world->getKart(i);
00054         if(k->isPlayerKart() && !k->isEliminated()) return  k->getPosition()==1;
00055     }
00056     return false;
00057     
00058 }   // grandPrixFinished
00059 //-----------------------------------------------------------------------------