SuperTuxKart
Loading...
Searching...
No Matches
challenge_data.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2008-2015 Joerg Henrichs
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_CHALLENGE_DATA_HPP
20#define HEADER_CHALLENGE_DATA_HPP
21
22#include <string>
23#include <vector>
24#include <stdio.h>
25#include <stdexcept>
26
27
28#include "race/race_manager.hpp"
29
35{
36public:
40 {
41 UNLOCK_TRACK,
42 UNLOCK_GP,
43 UNLOCK_MODE,
44 UNLOCK_KART,
45 UNLOCK_DIFFICULTY
46 };
47
51 {
52 GP_NONE,
53 GP_EASY,
54 GP_MEDIUM,
55 GP_HARD,
56 GP_BEST
57 };
58 // ------------------------------------------------------------------------
60 {
61 public:
62
63 std::string m_name; // internal name
64 irr::core::stringw m_user_name; // not all types of feature have one
65 RewardType m_type;
66
67 const irr::core::stringw getUnlockedMessage() const;
68 }; // UnlockableFeature
69 // ------------------------------------------------------------------------
70
81 {
82 CM_GRAND_PRIX,
83 CM_SINGLE_RACE,
84 CM_ANY
85 };
86
89 {
90 SPECIAL_NONE,
91 SPECIAL_MAX_REQ_IN_LOWER_DIFF
92 };
93
94
95private:
96
99
102
103 int m_num_laps;
104 bool m_reverse;
105 int m_position[RaceManager::DIFFICULTY_COUNT];
106 int m_default_num_karts[RaceManager::DIFFICULTY_COUNT];
107 std::string m_ai_kart_ident[RaceManager::DIFFICULTY_COUNT];
108 std::string m_replay_files[RaceManager::DIFFICULTY_COUNT];
109 float m_time[RaceManager::DIFFICULTY_COUNT];
110 int m_energy[RaceManager::DIFFICULTY_COUNT];
111 RaceManager::AISuperPower m_ai_superpower[RaceManager::DIFFICULTY_COUNT];
112 std::string m_gp_id;
113 std::string m_track_id;
114 std::string m_filename;
117 bool m_is_unlock_list;
118 bool m_is_ghost_replay;
119
120 void setUnlocks(const std::string &id,
122 void error(const char *id) const;
123
125 std::string m_id;
126
128 std::vector<UnlockableFeature> m_feature;
129
135
138 int m_unlock_special_value;
139
140public:
141 ChallengeData(const std::string& filename);
142
143 virtual ~ChallengeData() {}
144
146 void setRace(RaceManager::Difficulty d) const;
147
148 virtual void check() const;
149 virtual bool isChallengeFulfilled(bool check_best=false) const;
150 virtual GPLevel isGPFulfilled() const;
151 void addUnlockTrackReward(const std::string &track_name);
152 void addUnlockModeReward(const std::string &internal_mode_name,
153 const irr::core::stringw &user_mode_name);
154 void addUnlockGPReward(const std::string &gp_name);
155 void addUnlockDifficultyReward(const std::string &internal_name,
156 const irr::core::stringw &user_name);
157 void addUnlockKartReward(const std::string &internal_name,
158 const irr::core::stringw &user_name);
159
160 // ------------------------------------------------------------------------
162 int getVersion() const { return m_version; }
163
164 // ------------------------------------------------------------------------
167 const std::vector<UnlockableFeature>&
168 getFeatures() const { return m_feature; }
169
170 // ------------------------------------------------------------------------
172 const std::string &getChallengeId() const { return m_id; }
173
174 // ------------------------------------------------------------------------
176 void setChallengeId(const std::string& s) { m_id = s; }
177
178 // ------------------------------------------------------------------------
180 const std::string& getTrackId() const
181 {
182 assert(m_mode==CM_SINGLE_RACE);
183 return m_track_id;
184 } // getTrackId
185
186 // ------------------------------------------------------------------------
188 const std::string& getGPId() const
189 {
190 assert(m_mode==CM_GRAND_PRIX);
191 return m_gp_id;
192 } // getGPId
193
194 // ------------------------------------------------------------------------
196 int getNumLaps() const
197 {
198 assert(m_mode==CM_SINGLE_RACE);
199 return m_num_laps;
200 } // getNumLaps
201
202 // ------------------------------------------------------------------------
204 bool getReverse() const { return m_reverse; }
205 // ------------------------------------------------------------------------
207 int getNumTrophies() const { return m_num_trophies; }
208 // ------------------------------------------------------------------------
211 // ------------------------------------------------------------------------
213 bool isGrandPrix() const { return m_mode == CM_GRAND_PRIX; }
214 // ------------------------------------------------------------------------
216 bool isSingleRace() const { return m_mode == CM_SINGLE_RACE; }
217 // ------------------------------------------------------------------------
219 bool isGhostReplay() const { return m_is_ghost_replay; }
220 // ------------------------------------------------------------------------
222 bool isUnlockList() const { return m_is_unlock_list; }
223 // ------------------------------------------------------------------------
226 // ------------------------------------------------------------------------
228 int getSpecialValue() const { return m_unlock_special_value; }
229 // ------------------------------------------------------------------------
231 ChallengeModeType getMode() const { return m_mode; }
232 // ------------------------------------------------------------------------
235 // ------------------------------------------------------------------------
238 const irr::core::stringw getChallengeDescription() const;
239
240 // ------------------------------------------------------------------------
244 {
245 return m_position[difficulty];
246 } // getPosition
247
248 // ------------------------------------------------------------------------
252 {
253 return m_default_num_karts[difficulty];
254 } // getNumKarts
255 // ------------------------------------------------------------------------
259 {
260 return m_time[difficulty];
261 } // getTimeRequirement
262 // ------------------------------------------------------------------------
265 int getEnergy(RaceManager::Difficulty difficulty) const
266 {
267 return m_energy[difficulty];
268 } // getEnergy
269 // ------------------------------------------------------------------------
272 const std::string& getAIKartIdent(RaceManager::Difficulty difficulty) const
273 {
274 return m_ai_kart_ident[difficulty];
275 }
276
277}; // ChallengeData
278
279#endif // HEADER_CHALLENGE_DATA_HPP
Definition: challenge_data.hpp:60
the description of one challenge
Definition: challenge_data.hpp:35
float getTimeRequirement(RaceManager::Difficulty difficulty) const
Returns the maximum time in which the kart must finish.
Definition: challenge_data.hpp:258
int getVersion() const
Returns the version number of this challenge.
Definition: challenge_data.hpp:162
void setChallengeId(const std::string &s)
Sets the id of this challenge.
Definition: challenge_data.hpp:176
bool getReverse() const
Return reverse mode.
Definition: challenge_data.hpp:204
RaceManager::MinorRaceModeType m_minor
The minor type, used when m_mode is CM_GP or CM_RACE only.
Definition: challenge_data.hpp:101
const std::string & getTrackId() const
Returns the track associated with this challenge.
Definition: challenge_data.hpp:180
int getNumTrophies() const
Get number of required trophies to start this challenge.
Definition: challenge_data.hpp:207
SpecialUnlockType getSpecialType() const
Returns the special unlock list value.
Definition: challenge_data.hpp:225
ChallengeModeType m_mode
The challenge mode of this challenge.
Definition: challenge_data.hpp:98
bool isUnlockList() const
Returns if this challenge is an unlock list.
Definition: challenge_data.hpp:222
const irr::core::stringw getChallengeDescription() const
Returns the description of this challenge.
Definition: challenge_data.cpp:293
void setUnlocks(const std::string &id, ChallengeData::RewardType reward)
Adds all rewards for fulfilling this challenge.
Definition: challenge_data.cpp:380
std::vector< UnlockableFeature > m_feature
Features to unlock.
Definition: challenge_data.hpp:128
std::string m_id
Short, internal name for this challenge.
Definition: challenge_data.hpp:125
int m_version
Version number of the challenge.
Definition: challenge_data.hpp:116
int getEnergy(RaceManager::Difficulty difficulty) const
Return the energy that a kart must at least have at the end of a race.
Definition: challenge_data.hpp:265
virtual void check() const
Checks if this challenge is valid, i.e.
Definition: challenge_data.cpp:346
int getMaxPosition(RaceManager::Difficulty difficulty) const
Returns the maximum position the player must have in order to win.
Definition: challenge_data.hpp:243
int getNumKarts(RaceManager::Difficulty difficulty) const
Returns the number of karts to use.
Definition: challenge_data.hpp:251
RewardType
The type of reward you get when fulfilling this challenge.
Definition: challenge_data.hpp:40
const std::vector< UnlockableFeature > & getFeatures() const
Returns the list of unlockable features for this challenge.
Definition: challenge_data.hpp:168
int m_num_completed_challenges
Number of completed challenges required to access this challenge (esp.
Definition: challenge_data.hpp:134
bool isSingleRace() const
Returns if this challenge is a grand prix.
Definition: challenge_data.hpp:216
SpecialUnlockType m_unlock_special_type
Variables only used by unlock lists.
Definition: challenge_data.hpp:137
RaceManager::MinorRaceModeType getMinorMode() const
Returns the minor mode of this challenge.
Definition: challenge_data.hpp:234
int getNumLaps() const
Return number of laps.
Definition: challenge_data.hpp:196
const std::string & getAIKartIdent(RaceManager::Difficulty difficulty) const
Returns the name of the AI to use (used for boss challenge).
Definition: challenge_data.hpp:272
int m_num_trophies
Number of trophies required to access this challenge.
Definition: challenge_data.hpp:131
virtual GPLevel isGPFulfilled() const
Returns true if this GP challenge is fulfilled.
Definition: challenge_data.cpp:557
void addUnlockTrackReward(const std::string &track_name)
Sets that the given track will be unlocked if this challenge is unlocked.
Definition: challenge_data.cpp:642
GPLevel
The level of completion of a GP challenge.
Definition: challenge_data.hpp:51
int getSpecialValue() const
Returns the special unlock list value.
Definition: challenge_data.hpp:228
ChallengeModeType getMode() const
Returns the challenge mode of this challenge.
Definition: challenge_data.hpp:231
bool isGhostReplay() const
Returns if this challenge is using ghost replay.
Definition: challenge_data.hpp:219
virtual bool isChallengeFulfilled(bool check_best=false) const
Returns true if this (non-GP) challenge is fulfilled.
Definition: challenge_data.cpp:490
ChallengeModeType
The various types of challenges that we support, which esp.
Definition: challenge_data.hpp:81
int getNumChallenges() const
Get number of required completed challenges to start this challenge.
Definition: challenge_data.hpp:210
const std::string & getGPId() const
Returns the id of the grand prix associated with this challenge.
Definition: challenge_data.hpp:188
SpecialUnlockType
The type of value stored by m_unlock_special_value.
Definition: challenge_data.hpp:89
void setRace(RaceManager::Difficulty d) const
sets the right parameters in RaceManager to try this challenge
Definition: challenge_data.cpp:422
const std::string & getChallengeId() const
Returns the id of the challenge.
Definition: challenge_data.hpp:172
bool isGrandPrix() const
Returns if this challenge is a grand prix.
Definition: challenge_data.hpp:213
MinorRaceModeType
Minor variants to the major types of race.
Definition: race_manager.hpp:110
AISuperPower
True if the AI should have additional abbilities, e.g.
Definition: race_manager.hpp:134
Difficulty
Game difficulty.
Definition: race_manager.hpp:230