19 #ifndef HEADER_PLAYER_PROFILE_HPP
20 #define HEADER_PLAYER_PROFILE_HPP
22 #include "challenges/story_mode_status.hpp"
23 #include "config/favorite_status.hpp"
25 #include "utils/leak_check.hpp"
26 #include "utils/no_copy.hpp"
29 #include <irrString.h>
72 unsigned int m_magic_number;
126 PlayerProfile(
const core::stringw &name,
bool is_guest =
false);
130 void loadRemainingData(
const XMLNode *node);
131 void initRemainingData();
132 void incrementUseFrequency();
133 int getUseFrequency()
const {
return m_use_frequency; }
136 void saveSession(
int user_id,
const std::string &token);
137 void clearSession(
bool save=
true);
142 const std::string &action,
143 const std::string &url_path =
"")
const = 0;
144 virtual uint32_t getOnlineId()
const = 0;
147 virtual void requestPoll()
const = 0;
148 virtual void requestSavedSession() = 0;
149 virtual void requestSignIn(
const irr::core::stringw &username,
150 const irr::core::stringw &password) = 0;
151 virtual void signIn(
bool success,
const XMLNode * input) = 0;
152 virtual void signOut(
bool success,
const XMLNode * input,
153 const irr::core::stringw &info) = 0;
154 virtual void requestSignOut() = 0;
155 virtual bool isLoggedIn()
const {
return false; }
156 const std::string getIconFilename()
const;
162 assert(m_magic_number == 0xABCD1234);
172 assert(m_magic_number == 0xABCD1234);
182 assert(m_magic_number == 0xABCD1234);
184 return m_is_guest_account;
190 return m_last_online_name;
196 m_last_online_name = name;
205 return m_story_mode_status->isLocked(feature);
229 unsigned int getPoints()
const {
return m_story_mode_status->
getPoints(); }
231 unsigned int getPointsBefore()
const {
return m_story_mode_status->
getPointsBefore(); }
233 unsigned int getNextUnlockPoints()
const {
return m_story_mode_status->
getNextUnlockPoints(); }
235 void setFirstTime(
bool b) { m_story_mode_status->
setFirstTime(b); }
237 bool isFirstTime()
const {
return m_story_mode_status->
isFirstTime(); }
239 void setFinished() { m_story_mode_status->
setFinished(); }
241 bool isFinished()
const {
return m_story_mode_status->
isFinished(); }
251 void setSpeedrunTimer(
int ms) { m_story_mode_status->
setSpeedrunTimer(ms); }
263 return m_story_mode_status->getCurrentChallengeStatus();
271 unsigned int getNumEasyTrophies()
const
276 unsigned int getNumMediumTrophies()
const
278 return m_story_mode_status->getNumMediumTrophies();
281 unsigned int getNumHardTrophies()
const
285 unsigned int getNumBestTrophies()
const
292 return m_achievements_status;
300 FavoriteStatus* getFavoriteTrackStatus() {
return m_favorite_track_status; }
302 FavoriteStatus* getFavoriteKartStatus() {
return m_favorite_kart_status; }
304 bool isFavoriteTrack(std::string ident)
306 return m_favorite_track_status->
isFavorite(ident);
308 void addFavoriteTrack(std::string ident, std::string group =
309 FavoriteStatus::DEFAULT_FAVORITE_GROUP_NAME)
311 m_favorite_track_status->
addFavorite(ident, group);
313 void removeFavoriteTrack(std::string ident, std::string group =
314 FavoriteStatus::DEFAULT_FAVORITE_GROUP_NAME)
319 bool isFavoriteKart(std::string ident)
321 return m_favorite_kart_status->
isFavorite(ident);
323 void addFavoriteKart(std::string ident, std::string group =
324 FavoriteStatus::DEFAULT_FAVORITE_GROUP_NAME)
328 void removeFavoriteKart(std::string ident, std::string group =
329 FavoriteStatus::DEFAULT_FAVORITE_GROUP_NAME)
337 assert(m_saved_session);
338 return m_saved_user_id;
344 assert(m_saved_session);
345 return m_saved_token;
362 void setDefaultKartColor(
float c) { m_default_kart_color = c; }
364 float getDefaultKartColor()
const {
return m_default_kart_color; }
This class keeps tracks of all achievements of one player.
Definition: achievements_status.hpp:43
The state of a challenge for one player.
Definition: challenge_status.hpp:53
Class for storing the current favorites/custom groups of karts and tracks.
Definition: favorite_status.hpp:43
bool isFavorite(std::string ident)
Adds a new favorite track to this player profile and to the group of favorite tracks of the Track Man...
Definition: favorite_status.cpp:69
void addFavorite(std::string ident, std::string group=DEFAULT_FAVORITE_GROUP_NAME)
Adds a new favorite track to this player profile and to the group of favorite tracks of the Track Man...
Definition: favorite_status.cpp:79
void removeFavorite(std::string ident, std::string group=DEFAULT_FAVORITE_GROUP_NAME)
Removes a favorite track from this player profile and from the group of favorite tracks of the Track ...
Definition: favorite_status.cpp:88
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Class that represents an online profile.
Definition: online_profile.hpp:42
Class for managing player profiles (name, usage frequency, etc.).
Definition: player_profile.hpp:55
unsigned int getUniqueID() const
Returns the unique id of this player.
Definition: player_profile.hpp:200
void grandPrixFinished()
Callback when a GP is finished (to test if a challenge was fulfilled).
Definition: player_profile.hpp:225
bool hasSavedSession() const
Returns true if a session was saved for this player.
Definition: player_profile.hpp:296
bool m_saved_session
True if this user has a saved session.
Definition: player_profile.hpp:92
const core::stringw & getName() const
Returns the name of this player.
Definition: player_profile.hpp:169
AchievementsStatus * m_achievements_status
The complete achievement data.
Definition: player_profile.hpp:116
int getSavedUserId() const
If a session was saved, return the id of the saved user.
Definition: player_profile.hpp:335
void setCurrentChallenge(const std::string &name)
Sets the currently active challenge.
Definition: player_profile.hpp:218
int m_use_frequency
Counts how often this player was used (always -1 for guests).
Definition: player_profile.hpp:83
void setLastOnlineName(const core::stringw &name)
Sets the last used online name.
Definition: player_profile.hpp:194
const std::string & getSavedToken() const
If a session was saved, return the token to use.
Definition: player_profile.hpp:342
std::string m_icon_filename
Absolute path of the icon file for this player.
Definition: player_profile.hpp:89
const core::stringw & getLastOnlineName() const
Returns the last used online name.
Definition: player_profile.hpp:188
StoryModeStatus * m_story_mode_status
The complete challenge state.
Definition: player_profile.hpp:113
std::string m_saved_token
The token of the saved session.
Definition: player_profile.hpp:98
void setName(const core::stringw &name)
Sets the name of this player.
Definition: player_profile.hpp:159
void setRememberPassword(bool b)
Sets if this player was logged in last time it was used.
Definition: player_profile.hpp:360
bool m_last_was_online
True if the last time this player was used as online.
Definition: player_profile.hpp:104
FavoriteStatus * m_favorite_kart_status
The favorite karts selected by this player.
Definition: player_profile.hpp:122
core::stringw m_local_name
The name of the player (wide string, so it can be in native language).
Definition: player_profile.hpp:77
const ChallengeStatus * getCurrentChallengeStatus() const
Returns the current challenge for this player.
Definition: player_profile.hpp:261
OnlineState
The online state a player can be in.
Definition: player_profile.hpp:59
bool isLocked(const std::string &feature) const
Returnes if the feature (kart, track) is locked.
Definition: player_profile.hpp:203
bool isGuestAccount() const
Returns true if this player is a guest account.
Definition: player_profile.hpp:179
std::vector< const ChallengeData * > getRecentlyCompletedChallenges()
Returns the list of recently completed challenges.
Definition: player_profile.hpp:212
unsigned int m_unique_id
A unique number for this player, used to link it to challenges etc.
Definition: player_profile.hpp:86
bool m_is_guest_account
True if this account is a guest account.
Definition: player_profile.hpp:80
void setWasOnlineLastTime(bool b)
Sets if this player was logged in last time it was used.
Definition: player_profile.hpp:353
float m_default_kart_color
Default kart color (in hue) used in game, 0.0f to use the original.
Definition: player_profile.hpp:110
void computeActive()
Returns all active challenges.
Definition: player_profile.hpp:209
bool rememberPassword() const
Returns if the last time this player was used it was used online or offline.
Definition: player_profile.hpp:357
FavoriteStatus * m_favorite_track_status
The favorite tracks selected by this player.
Definition: player_profile.hpp:119
int m_saved_user_id
If a session was saved, this will be the online user id to use.
Definition: player_profile.hpp:95
bool wasOnlineLastTime() const
Returns if the last time this player was used it was used online or offline.
Definition: player_profile.hpp:350
virtual void setUserDetails(std::shared_ptr< Online::HTTPRequest > request, const std::string &action, const std::string &url_path="") const =0
Abstract virtual classes, to be implemented by the OnlinePlayer.
core::stringw m_last_online_name
The online user name used last (empty if not used online).
Definition: player_profile.hpp:101
bool m_remember_password
True if the login data are saved.
Definition: player_profile.hpp:107
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
const std::vector< const ChallengeData * > getRecentlyCompletedChallenges()
Returns the list of recently unlocked features (e.g.
Definition: story_mode_status.hpp:108
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
bool isFirstTime() const
Returns if this is the first time the intro is shown.
Definition: story_mode_status.hpp:145
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
int getNextUnlockPoints() const
Returns the number of points needed by the next unlockable.
Definition: story_mode_status.hpp:127
void setFirstTime(bool ft)
Sets if this is the first time the intro is shown.
Definition: story_mode_status.hpp:142
const ChallengeStatus * getChallengeStatus(const std::string &id) const
Returns a challenge given the challenge id.
Definition: story_mode_status.hpp:179
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
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
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
Declares the general types that are used by the network.