SuperTuxKart
Loading...
Searching...
No Matches
saved_grand_prix.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2010-2015 SuperTuxKart-Team
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_SAVED_GRAND_PRIX_HPP
20#define HEADER_SAVED_GRAND_PRIX_HPP
21
22#include "config/user_config.hpp"
23#include "race/race_manager.hpp"
24#include "utils/ptr_vector.hpp"
25
26#include <algorithm>
27#include <string>
28
29class RaceManager;
30
31// ============================================================================
32
39{
40private:
42 {
43 friend class SavedGrandPrix;
46 IntUserConfigParam m_score, m_local_player_id, m_global_player_id;
47 FloatUserConfigParam m_overall_time;
48 public:
49 SavedGPKart(GroupUserConfigParam * group, const XMLNode* node);
51 const std::string &ident,
52 int score,
53 int local_player_id,
54 int global_player_id,
55 float overall_time);
56 }; // SavedGPKart
57
58protected:
59
65 IntUserConfigParam m_player_id;
66
69
72
75
78
81
84
87
90
93
95
96public:
97
101 SavedGrandPrix(unsigned int player_id,
102 const std::string &gp_id,
104 RaceManager::Difficulty difficulty,
105 int player_karts,
106 int last_track,
107 int reverse_type,
108 int skipped_tracks,
109 float time_target,
110 int player_total_laps,
111 const std::vector<RaceManager::KartStatus> &kart_list);
112
116 SavedGrandPrix(const XMLNode* node);
117 void setKarts(const std::vector<RaceManager::KartStatus> &kart_list);
118 void clearKarts();
119 void loadKarts(std::vector<RaceManager::KartStatus> & kart_list);
120
121 // ------------------------------------------------------------------------
123 unsigned int getPlayerID() const { return m_player_id; }
124
125 // ------------------------------------------------------------------------
127 std::string getGPID() const { return m_gp_id; }
128
129 // ------------------------------------------------------------------------
131 int getRaceType() const { return m_race_type; }
132
133 // ------------------------------------------------------------------------
135 int getDifficulty() const { return m_difficulty; }
136
137 // ------------------------------------------------------------------------
139 int getTotalKarts() const { return m_karts.size(); }
140
141 // ------------------------------------------------------------------------
143 int getPlayerKarts() const { return m_player_karts; }
144
145 // ------------------------------------------------------------------------
147 int getNextTrack() const { return m_next_track; }
148
149 // ------------------------------------------------------------------------
151 int getReverseType() const { return m_reverse_type; }
152
153 // ------------------------------------------------------------------------
155 int getSkippedTracks() const { return m_skipped_tracks; }
156
157 // ------------------------------------------------------------------------
159 float getTimeTarget() const { return m_time_target; }
160
161 // ------------------------------------------------------------------------
164
165 // ------------------------------------------------------------------------
167 void setNextTrack(int next_track) { m_next_track = next_track; }
168
169 // ------------------------------------------------------------------------
172 void remove()
173 {
175 delete this;
176 } // remove
177
178 // ------------------------------------------------------------------------
181 static SavedGrandPrix* getSavedGP(unsigned int player,
182 const std::string &gpid,
184 const unsigned int number_of_players)
185 {
186 for (unsigned int n=0; n<UserConfigParams::m_saved_grand_prix_list.size(); n++)
187 {
189 if (gp->getGPID() == gpid &&
190 gp->getRaceType() == race_type &&
191 gp->getPlayerID() == player &&
192 gp->getPlayerKarts() == (int)number_of_players)
193 return gp;
194 }
195 return NULL;
196 } // getSavedGP
197 // ------------------------------------------------------------------------
198}; // class SavedGrandPrix
199
200#endif
201
202/*EOF*/
Definition: user_config.hpp:329
Definition: user_config.hpp:85
Definition: user_config.hpp:194
Definition: ptr_vector.hpp:44
The race manager has two functions: 1) it stores information about the race the user selected (e....
Definition: race_manager.hpp:88
MinorRaceModeType
Minor variants to the major types of race.
Definition: race_manager.hpp:110
Difficulty
Game difficulty.
Definition: race_manager.hpp:230
Definition: saved_grand_prix.hpp:42
Class for managing saved Grand-Prix's A list of all possible resumable GP's is stored in the user con...
Definition: saved_grand_prix.hpp:39
IntUserConfigParam m_difficulty
Difficulty at which this GP was run.
Definition: saved_grand_prix.hpp:74
IntUserConfigParam m_player_total_laps
Total laps count, used in Lap Trial mode.
Definition: saved_grand_prix.hpp:92
int getReverseType() const
Returns the reverse Type.
Definition: saved_grand_prix.hpp:151
std::string getGPID() const
Returns the grand prix id.
Definition: saved_grand_prix.hpp:127
float getTimeTarget() const
Returns time target used in Lap Trial mode.
Definition: saved_grand_prix.hpp:159
IntUserConfigParam m_race_type
Race type at which this GP was run.
Definition: saved_grand_prix.hpp:71
IntUserConfigParam m_player_karts
Number of player karts used in this GP.
Definition: saved_grand_prix.hpp:77
IntUserConfigParam m_next_track
Index of the next to run track.
Definition: saved_grand_prix.hpp:80
int getRaceType() const
Returns the race type of this GP.
Definition: saved_grand_prix.hpp:131
IntUserConfigParam m_skipped_tracks
Count of tracks that player skipped.
Definition: saved_grand_prix.hpp:86
IntUserConfigParam m_reverse_type
GPReverseType of the GP as int.
Definition: saved_grand_prix.hpp:83
int getTotalKarts() const
Returns the total number of karts of this GP.
Definition: saved_grand_prix.hpp:139
FloatUserConfigParam m_time_target
Time target used in Lap Trial mode.
Definition: saved_grand_prix.hpp:89
int getDifficulty() const
Returns the difficulty of this GP.
Definition: saved_grand_prix.hpp:135
GroupUserConfigParam m_savedgp_group
For saving to config file.
Definition: saved_grand_prix.hpp:64
int getPlayerTotalLaps() const
Returns total laps in GP.
Definition: saved_grand_prix.hpp:163
int getSkippedTracks() const
Returns skipped tracks count.
Definition: saved_grand_prix.hpp:155
static SavedGrandPrix * getSavedGP(unsigned int player, const std::string &gpid, RaceManager::MinorRaceModeType race_type, const unsigned int number_of_players)
Finds the right SavedGrandPrix given the specified data, or NULL if no matching GP was found.
Definition: saved_grand_prix.hpp:181
unsigned int getPlayerID() const
Returns the player id for this saved GP.
Definition: saved_grand_prix.hpp:123
int getPlayerKarts() const
Returns the number of player karts in this GP.
Definition: saved_grand_prix.hpp:143
void remove()
Removed this SavedGrandPrix from the list of all SavedGrandPrix, and deletes it.
Definition: saved_grand_prix.hpp:172
void setNextTrack(int next_track)
Sets the index of the last track finished.
Definition: saved_grand_prix.hpp:167
StringUserConfigParam m_gp_id
Identifier of this GP.
Definition: saved_grand_prix.hpp:68
int getNextTrack() const
Returns the index of the last track finished when this GP was saved.
Definition: saved_grand_prix.hpp:147
Definition: user_config.hpp:256
utility class used to parse XML files
Definition: xml_node.hpp:48
PARAM_PREFIX PtrVector< SavedGrandPrix > m_saved_grand_prix_list
List of all saved GPs.
Definition: user_config.hpp:1389