SuperTuxKart
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ChallengeData Class Reference

the description of one challenge More...

#include <challenge_data.hpp>

Classes

class  UnlockableFeature
 

Public Types

enum  RewardType {
  UNLOCK_TRACK, UNLOCK_GP, UNLOCK_MODE, UNLOCK_KART,
  UNLOCK_DIFFICULTY
}
 The type of reward you get when fulfilling this challenge.
 
enum  GPLevel {
  GP_NONE, GP_EASY, GP_MEDIUM, GP_HARD,
  GP_BEST
}
 The level of completion of a GP challenge.
 
enum  ChallengeModeType { CM_GRAND_PRIX, CM_SINGLE_RACE, CM_ANY }
 The various types of challenges that we support, which esp. More...
 
enum  SpecialUnlockType { SPECIAL_NONE, SPECIAL_MAX_REQ_IN_LOWER_DIFF }
 The type of value stored by m_unlock_special_value.
 

Public Member Functions

 ChallengeData (const std::string &filename)
 
void setRace (RaceManager::Difficulty d) const
 sets the right parameters in RaceManager to try this challenge
 
virtual void check () const
 Checks if this challenge is valid, i.e. More...
 
virtual bool isChallengeFulfilled (bool check_best=false) const
 Returns true if this (non-GP) challenge is fulfilled. More...
 
virtual GPLevel isGPFulfilled () const
 Returns true if this GP challenge is fulfilled.
 
void addUnlockTrackReward (const std::string &track_name)
 Sets that the given track will be unlocked if this challenge is unlocked. More...
 
void addUnlockModeReward (const std::string &internal_mode_name, const irr::core::stringw &user_mode_name)
 
void addUnlockGPReward (const std::string &gp_name)
 
void addUnlockDifficultyReward (const std::string &internal_name, const irr::core::stringw &user_name)
 
void addUnlockKartReward (const std::string &internal_name, const irr::core::stringw &user_name)
 
int getVersion () const
 Returns the version number of this challenge. More...
 
const std::vector< UnlockableFeature > & getFeatures () const
 Returns the list of unlockable features for this challenge.
 
const std::string & getChallengeId () const
 Returns the id of the challenge. More...
 
void setChallengeId (const std::string &s)
 Sets the id of this challenge. More...
 
const std::string & getTrackId () const
 Returns the track associated with this challenge. More...
 
const std::string & getGPId () const
 Returns the id of the grand prix associated with this challenge. More...
 
int getNumLaps () const
 Return number of laps. More...
 
bool getReverse () const
 Return reverse mode. More...
 
int getNumTrophies () const
 Get number of required trophies to start this challenge.
 
int getNumChallenges () const
 Get number of required completed challenges to start this challenge.
 
bool isGrandPrix () const
 Returns if this challenge is a grand prix. More...
 
bool isSingleRace () const
 Returns if this challenge is a grand prix. More...
 
bool isGhostReplay () const
 Returns if this challenge is using ghost replay. More...
 
bool isUnlockList () const
 Returns if this challenge is an unlock list. More...
 
SpecialUnlockType getSpecialType () const
 Returns the special unlock list value.
 
int getSpecialValue () const
 Returns the special unlock list value.
 
ChallengeModeType getMode () const
 Returns the challenge mode of this challenge. More...
 
RaceManager::MinorRaceModeType getMinorMode () const
 Returns the minor mode of this challenge. More...
 
const irr::core::stringw getChallengeDescription () const
 Returns the description of this challenge.
 
int getMaxPosition (RaceManager::Difficulty difficulty) const
 Returns the maximum position the player must have in order to win.
 
int getNumKarts (RaceManager::Difficulty difficulty) const
 Returns the number of karts to use.
 
float getTimeRequirement (RaceManager::Difficulty difficulty) const
 Returns the maximum time in which the kart must finish.
 
int getEnergy (RaceManager::Difficulty difficulty) const
 Return the energy that a kart must at least have at the end of a race.
 
const std::string & getAIKartIdent (RaceManager::Difficulty difficulty) const
 Returns the name of the AI to use (used for boss challenge).
 

Private Member Functions

void setUnlocks (const std::string &id, ChallengeData::RewardType reward)
 Adds all rewards for fulfilling this challenge. More...
 
void error (const char *id) const
 

Private Attributes

ChallengeModeType m_mode
 The challenge mode of this challenge. More...
 
RaceManager::MinorRaceModeType m_minor
 The minor type, used when m_mode is CM_GP or CM_RACE only. More...
 
int m_num_laps
 
bool m_reverse
 
int m_position [RaceManager::DIFFICULTY_COUNT]
 
int m_default_num_karts [RaceManager::DIFFICULTY_COUNT]
 
std::string m_ai_kart_ident [RaceManager::DIFFICULTY_COUNT]
 
std::string m_replay_files [RaceManager::DIFFICULTY_COUNT]
 
float m_time [RaceManager::DIFFICULTY_COUNT]
 
int m_energy [RaceManager::DIFFICULTY_COUNT]
 
RaceManager::AISuperPower m_ai_superpower [RaceManager::DIFFICULTY_COUNT]
 
std::string m_gp_id
 
std::string m_track_id
 
std::string m_filename
 
int m_version
 Version number of the challenge. More...
 
bool m_is_unlock_list
 
bool m_is_ghost_replay
 
std::string m_id
 Short, internal name for this challenge. More...
 
std::vector< UnlockableFeaturem_feature
 Features to unlock. More...
 
int m_num_trophies
 Number of trophies required to access this challenge.
 
int m_num_completed_challenges
 Number of completed challenges required to access this challenge (esp. More...
 
SpecialUnlockType m_unlock_special_type
 Variables only used by unlock lists.
 
int m_unlock_special_value
 

Detailed Description

the description of one challenge

Member Enumeration Documentation

◆ ChallengeModeType

The various types of challenges that we support, which esp.

determine when a challenge is tested if it is fulfilled. For now we have GP (a GP challenge, tested at the end of a GP), Race (tested at the end of a challenge race), and 'any', which is checked at the end of each race (maybe even non challenged once). An example for 'any' is 'are all challenges unclocked on highest level', which needs to be tested after each race (but is itself not a race mode, so it's not that you can start this challenge, which differentiates it from a race challenge).

Member Function Documentation

◆ addUnlockTrackReward()

void ChallengeData::addUnlockTrackReward ( const std::string &  track_name)

Sets that the given track will be unlocked if this challenge is unlocked.

Parameters
track_nameName of the track to unlock.

◆ check()

void ChallengeData::check ( ) const
virtual

Checks if this challenge is valid, i.e.

contains a valid track or a valid GP. If incorrect data are found, STK is aborted with an error message. (otherwise STK aborts when trying to do this challenge, which is worse).

◆ getChallengeId()

const std::string& ChallengeData::getChallengeId ( ) const
inline

Returns the id of the challenge.

◆ getGPId()

const std::string& ChallengeData::getGPId ( ) const
inline

Returns the id of the grand prix associated with this challenge.

◆ getMinorMode()

RaceManager::MinorRaceModeType ChallengeData::getMinorMode ( ) const
inline

Returns the minor mode of this challenge.

◆ getMode()

ChallengeModeType ChallengeData::getMode ( ) const
inline

Returns the challenge mode of this challenge.

◆ getNumLaps()

int ChallengeData::getNumLaps ( ) const
inline

Return number of laps.

◆ getReverse()

bool ChallengeData::getReverse ( ) const
inline

Return reverse mode.

◆ getTrackId()

const std::string& ChallengeData::getTrackId ( ) const
inline

Returns the track associated with this challenge.

◆ getVersion()

int ChallengeData::getVersion ( ) const
inline

Returns the version number of this challenge.

◆ isChallengeFulfilled()

bool ChallengeData::isChallengeFulfilled ( bool  check_best = false) const
virtual

Returns true if this (non-GP) challenge is fulfilled.

Parameters
check_best: if true, check if the requirement for the best difficulty are met at a lower one. (requires SuperTux challenges to have a time รน requirement to make sense)

◆ isGhostReplay()

bool ChallengeData::isGhostReplay ( ) const
inline

Returns if this challenge is using ghost replay.

◆ isGrandPrix()

bool ChallengeData::isGrandPrix ( ) const
inline

Returns if this challenge is a grand prix.

◆ isSingleRace()

bool ChallengeData::isSingleRace ( ) const
inline

Returns if this challenge is a grand prix.

◆ isUnlockList()

bool ChallengeData::isUnlockList ( ) const
inline

Returns if this challenge is an unlock list.

◆ setChallengeId()

void ChallengeData::setChallengeId ( const std::string &  s)
inline

Sets the id of this challenge.

◆ setUnlocks()

void ChallengeData::setUnlocks ( const std::string &  id,
ChallengeData::RewardType  reward 
)
private

Adds all rewards for fulfilling this challenge.

Parameters
idName of track or gp or kart or mode or difficulty reward.
rewardType of reward (track, gp, mode, difficulty, kart).

Member Data Documentation

◆ m_feature

std::vector<UnlockableFeature> ChallengeData::m_feature
private

Features to unlock.

◆ m_id

std::string ChallengeData::m_id
private

Short, internal name for this challenge.

◆ m_minor

RaceManager::MinorRaceModeType ChallengeData::m_minor
private

The minor type, used when m_mode is CM_GP or CM_RACE only.

◆ m_mode

ChallengeModeType ChallengeData::m_mode
private

The challenge mode of this challenge.

◆ m_num_completed_challenges

int ChallengeData::m_num_completed_challenges
private

Number of completed challenges required to access this challenge (esp.

useful for the final challenge)

◆ m_version

int ChallengeData::m_version
private

Version number of the challenge.


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