1. Added challenge for At world's end grand prix.

2. Bugfix: active challenges are now refreshed when a challenge has been 
completed.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1768 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
scifly 2008-04-28 21:26:33 +00:00
parent a640b67e00
commit feab28cdce
4 changed files with 107 additions and 2 deletions

View File

@ -103,6 +103,7 @@ supertuxkart_SOURCES = main.cpp \
challenges/moon_and_back_gp.cpp challenges/moon_and_back_gp.hpp \
challenges/city_time.cpp challenges/city_time.hpp \
challenges/island_follow.cpp challenges/island_follow.hpp \
challenges/worlds_end_gp.cpp challenges/worlds_end_gp.hpp \
lisp/lisp.cpp lisp/lisp.hpp \
lisp/lexer.cpp lisp/lexer.hpp \
lisp/parser.cpp lisp/parser.hpp \

View File

@ -0,0 +1,64 @@
// $Id$
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2008 Joerg Henrichs
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be ruseful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "worlds_end_gp.hpp"
#include "race_manager.hpp"
#include "world.hpp"
WorldsEndGP::WorldsEndGP() : Challenge("worldsendgp","Win the At World's End Grand Prix")
{
setChallengeDescription("Come first in the At World's End\nGrand Prix with 3 'Driver' Level AI karts.");
setFeatureDescription("New Grand Prix: All Track's GP\nand Bonus Preview: Skidding\nnow available");
setFeature("All tracks");
//TODO setFeature(""); Add Skidding Preview
addDependency("islandfollow");
addDependency("racetracktime");
addDependency("tollwaytime");
addDependency("junglefollow");
addDependency("citytime");
}
//-----------------------------------------------------------------------------
void WorldsEndGP::setRace() const {
race_manager->setRaceMode(RaceManager::RM_GRAND_PRIX);
CupData cup("gp4.cup");
race_manager->setGrandPrix(cup);
race_manager->setDifficulty(RaceManager::RD_HARD);
race_manager->setNumKarts(4);
race_manager->setNumPlayers(1);
} // setRace
//-----------------------------------------------------------------------------
bool WorldsEndGP::grandPrixFinished()
{
if (race_manager->getRaceMode() != RaceManager::RM_GRAND_PRIX ||
race_manager->getGrandPrix()->getName() != "At world's end" ||
race_manager->getDifficulty()!= RaceManager::RD_HARD ||
race_manager->getNumKarts() < 4 ||
race_manager->getNumPlayers() > 1) return false;
// Check if the player was first:
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
//-----------------------------------------------------------------------------

View File

@ -0,0 +1,36 @@
// $Id$
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2008 Joerg Henrichs
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef WORLDS_END_GP_H
#define WORLDS_END_GP_H
#include "challenge.hpp"
class WorldsEndGP : public Challenge
{
public:
WorldsEndGP();
virtual bool grandPrixFinished();
virtual void setRace() const;
};
#endif /*WORLDS_END_GP_H*/

View File

@ -29,6 +29,7 @@
#include "challenges/moon_and_back_gp.hpp"
#include "challenges/city_time.hpp"
#include "challenges/island_follow.hpp"
#include "challenges/worlds_end_gp.hpp"
#include "user_config.hpp"
UnlockManager* unlock_manager=0;
@ -53,13 +54,15 @@ UnlockManager::UnlockManager()
c=new MoonAndBackGP(); m_all_challenges[c->getId()]=c;
c=new CityTime(); m_all_challenges[c->getId()]=c;
c=new IslandFollow(); m_all_challenges[c->getId()]=c;
c=new WorldsEndGP(); m_all_challenges[c->getId()]=c;
computeActive();
} // UnlockManager
//-----------------------------------------------------------------------------
std::vector<const Challenge*> UnlockManager::getActiveChallenges()
{
computeActive();
std::vector<const Challenge*> all_active;
for(AllChallengesType::iterator i =m_all_challenges.begin();
i!=m_all_challenges.end(); i++)
@ -112,7 +115,8 @@ void UnlockManager::computeActive()
// The constructor calls computeActive, which actually locks
// all features, so unlock the solved ones (and don't try to
// save the state, since we are currently reading it)
unlockFeature(i->second, /*save*/ false);
if (isLocked(i->second->getFeature()))
unlockFeature(i->second, /*save*/ false);
continue;
}