SuperTuxKart
Loading...
Searching...
No Matches
story_mode_status.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 GAME_SLOT_HPP
20#define GAME_SLOT_HPP
21
22#include "challenges/challenge_data.hpp"
23#include "race/race_manager.hpp"
24
25#include <irrString.h>
26using namespace irr;
27
28#include <string>
29#include <map>
30#include <vector>
31
32class ChallengeData;
33class ChallengeStatus;
34class UTFWriter;
35class XMLNode;
36
37const int CHALLENGE_POINTS[] = { 6, 7, 8, 10 };
38const int GP_FACTOR = 3;
39
49{
50private:
52 std::map<std::string, bool> m_locked_features;
53
56 std::vector<const ChallengeData*> m_unlocked_features;
57
58 std::map<std::string, ChallengeStatus*> m_challenges_state;
59
63
64 int m_points;
65 int m_points_before; // used for unlocks
66 int m_next_unlock_points;
67
70
71 int m_easy_challenges;
72 int m_medium_challenges;
73 int m_hard_challenges;
74 int m_best_challenges;
75
76 /* Set to true after fort magma */
77 bool m_story_mode_finished;
78
79 /* Set to true after fort magma if there was a valid speedrun active
80 * This is used to know if m_speedrun_milliseconds contain valid data */
81 bool m_valid_speedrun_finished;
82
83 // It overflows at over 500 hours
84 int m_story_mode_milliseconds;
85 int m_speedrun_milliseconds;
86
87public:
88
89 StoryModeStatus(const XMLNode *node=NULL);
91
92 void computeActive (bool first_call=false);
93 bool isLocked (const std::string& feature);
94 void unlockFeatureByList();
95 void lockFeature (ChallengeStatus *challenge);
97 bool do_save=true);
98 void raceFinished ();
99 void grandPrixFinished ();
100 void save (UTFWriter &out, bool current_player=false);
101 void addStatus(ChallengeStatus *cs);
102 void setCurrentChallenge(const std::string &challenge_id);
103
104 // ----------------------------------------------------------------------------------------
107 const std::vector<const ChallengeData*>
109 // ----------------------------------------------------------------------------------------
112 // ----------------------------------------------------------------------------------------
114 int getNumCompletedChallenges () const { return (m_easy_challenges + m_medium_challenges +
115 m_hard_challenges + m_best_challenges); }
116 // ----------------------------------------------------------------------------------------
118 int getNumReqMetInLowerDiff () const;
119 // ----------------------------------------------------------------------------------------
121 int getPoints () const { return m_points; }
122 // ----------------------------------------------------------------------------------------
124 int getPointsBefore () const { return m_points_before; }
125 // ----------------------------------------------------------------------------------------
127 int getNextUnlockPoints () const { return m_next_unlock_points; }
128 // ----------------------------------------------------------------------------------------
130 int getNumEasyTrophies () const { return m_easy_challenges; }
131 // ----------------------------------------------------------------------------------------
132 /* Returns the number of fulfilled challenges at medium level. */
133 int getNumMediumTrophies() const { return m_medium_challenges; }
134 // ----------------------------------------------------------------------------------------
136 int getNumHardTrophies () const { return m_hard_challenges; }
137 // ----------------------------------------------------------------------------------------
139 int getNumBestTrophies () const { return m_best_challenges; }
140 // ----------------------------------------------------------------------------------------
142 void setFirstTime(bool ft) { m_first_time = ft; }
143 // ----------------------------------------------------------------------------------------
145 bool isFirstTime() const { return m_first_time; }
146 // ----------------------------------------------------------------------------------------
148 void setFinished() { m_story_mode_finished = true; }
149 // ----------------------------------------------------------------------------------------
151 bool isFinished() const { return m_story_mode_finished; }
152 // ----------------------------------------------------------------------------------------
154 void setSpeedrunFinished() { m_valid_speedrun_finished = true; }
155 // ----------------------------------------------------------------------------------------
157 bool isSpeedrunFinished() const { return m_valid_speedrun_finished; }
158 // ----------------------------------------------------------------------------------------
160 void setStoryModeTimer(int milliseconds) { m_story_mode_milliseconds = milliseconds; }
161 // ----------------------------------------------------------------------------------------
165 int getStoryModeTimer() { return m_story_mode_milliseconds; }
166 // ----------------------------------------------------------------------------------------
168 void setSpeedrunTimer(int milliseconds) { m_speedrun_milliseconds = milliseconds; }
169 // ----------------------------------------------------------------------------------------
173 int getSpeedrunTimer() { return m_speedrun_milliseconds; }
174 // ----------------------------------------------------------------------------------------
175 const ChallengeStatus *getCurrentChallengeStatus() const { return m_current_challenge; }
176 // ----------------------------------------------------------------------------------------
179 const ChallengeStatus* getChallengeStatus(const std::string& id) const
180 {
181 std::map<std::string, ChallengeStatus*>::const_iterator it =
182 m_challenges_state.find(id);
183 assert(it!=m_challenges_state.end());
184 return it->second;
185 } // getChallengeStatus
186}; // StoryModeStatus
187
188#endif
the description of one challenge
Definition: challenge_data.hpp:35
The state of a challenge for one player.
Definition: challenge_status.hpp:53
Difficulty
Game difficulty.
Definition: race_manager.hpp:230
This class contains the progression through challenges for the story mode.
Definition: story_mode_status.hpp:49
int getNumCompletedChallenges() const
Returns the number of completed challenges.
Definition: story_mode_status.hpp:114
void setCurrentChallenge(const std::string &challenge_id)
Set the current challenge (or NULL if no challenge is done).
Definition: story_mode_status.cpp:265
void unlockFeature(ChallengeStatus *c, RaceManager::Difficulty d, bool do_save=true)
Unlocks a feature.
Definition: story_mode_status.cpp:247
std::map< std::string, bool > m_locked_features
Contains whether each feature of the challenge is locked or unlocked.
Definition: story_mode_status.hpp:52
void grandPrixFinished()
This is called when a GP is finished.
Definition: story_mode_status.cpp:305
int getNumBestTrophies() const
Returns the number of fulfilled challenges at best level.
Definition: story_mode_status.hpp:139
void setSpeedrunTimer(int milliseconds)
Sets the story mode timer.
Definition: story_mode_status.hpp:168
int getNumEasyTrophies() const
Returns the number of fulfilled challenges at easy level.
Definition: story_mode_status.hpp:130
void setSpeedrunFinished()
Sets if the player has finished a valid speedrun.
Definition: story_mode_status.hpp:154
int getNumHardTrophies() const
Returns the number of fulfilled challenges at hard level.
Definition: story_mode_status.hpp:136
int getNumReqMetInLowerDiff() const
Returns the number of challenges with the superTux time beaten in a lower difficulty.
Definition: story_mode_status.cpp:384
bool isFirstTime() const
Returns if this is the first time the intro is shown.
Definition: story_mode_status.hpp:145
void addStatus(ChallengeStatus *cs)
Adds a ChallengeStatus with the specified id to the set of all statuses of this object.
Definition: story_mode_status.cpp:89
bool m_first_time
Set to false after the initial stuff (intro, select kart, etc.)
Definition: story_mode_status.hpp:69
int getSpeedrunTimer()
Gets the speedrun timer This is designed to be used on loading and once story mode is completed ; it ...
Definition: story_mode_status.hpp:173
const ChallengeStatus * m_current_challenge
A pointer to the current challenge, or NULL if no challenge is active.
Definition: story_mode_status.hpp:62
int getNextUnlockPoints() const
Returns the number of points needed by the next unlockable.
Definition: story_mode_status.hpp:127
std::vector< const ChallengeData * > m_unlocked_features
Recently unlocked features (they are waiting here until they are shown to the user)
Definition: story_mode_status.hpp:56
void setFirstTime(bool ft)
Sets if this is the first time the intro is shown.
Definition: story_mode_status.hpp:142
int getStoryModeTimer()
Gets the story mode timer This is designed to be used on loading and once story mode is completed ; i...
Definition: story_mode_status.hpp:165
int getPoints() const
Returns the number of points accumulated.
Definition: story_mode_status.hpp:121
void raceFinished()
This is called when a race is finished.
Definition: story_mode_status.cpp:275
const std::vector< const ChallengeData * > getRecentlyCompletedChallenges()
Returns the list of recently unlocked features (e.g.
Definition: story_mode_status.hpp:108
int getPointsBefore() const
Returns the number of points before the previous point increase.
Definition: story_mode_status.hpp:124
bool isFinished() const
Returns if the player has beaten Nolock.
Definition: story_mode_status.hpp:151
void clearUnlocked()
Clear the list of recently unlocked challenges.
Definition: story_mode_status.hpp:111
const ChallengeStatus * getChallengeStatus(const std::string &id) const
Returns a challenge given the challenge id.
Definition: story_mode_status.hpp:179
void save(UTFWriter &out, bool current_player=false)
Writes the data of this StoryModeStatus to the specified stream.
Definition: story_mode_status.cpp:344
void setFinished()
Sets if the player has beaten Nolock.
Definition: story_mode_status.hpp:148
bool isSpeedrunFinished() const
Returns if the player has finished a valid speedrun
Definition: story_mode_status.hpp:157
void setStoryModeTimer(int milliseconds)
Sets the story mode timer.
Definition: story_mode_status.hpp:160
utility class used to write wide (UTF-16 or UTF-32, depending of size of wchar_t) XML files
Definition: utf_writer.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48