19#ifndef HEADER_PLAYER_PROFILE_HPP
20#define HEADER_PLAYER_PROFILE_HPP
22#include "challenges/story_mode_status.hpp"
24#include "utils/leak_check.hpp"
25#include "utils/no_copy.hpp"
71 unsigned int m_magic_number;
118 PlayerProfile(
const core::stringw &name,
bool is_guest =
false);
128 void saveSession(
int user_id,
const std::string &token);
134 const std::string &action,
135 const std::string &url_path =
"")
const = 0;
136 virtual uint32_t getOnlineId()
const = 0;
139 virtual void requestPoll()
const = 0;
140 virtual void requestSavedSession() = 0;
141 virtual void requestSignIn(
const irr::core::stringw &username,
142 const irr::core::stringw &password) = 0;
143 virtual void signIn(
bool success,
const XMLNode * input) = 0;
144 virtual void signOut(
bool success,
const XMLNode * input,
145 const irr::core::stringw &info) = 0;
146 virtual void requestSignOut() = 0;
147 virtual bool isLoggedIn()
const {
return false; }
154 assert(m_magic_number == 0xABCD1234);
163 assert(m_magic_number == 0xABCD1234);
172 assert(m_magic_number == 0xABCD1234);
261 unsigned int getNumEasyTrophies()
const
266 unsigned int getNumMediumTrophies()
const
271 unsigned int getNumHardTrophies()
const
275 unsigned int getNumBestTrophies()
const
282 return m_achievements_status;
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
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:54
void clearSession(bool save=true)
Unsets any saved session data.
Definition: player_profile.cpp:252
const core::stringw & getLastOnlineName() const
Returns the last used online name.
Definition: player_profile.hpp:178
unsigned int getUniqueID() const
Returns the unique id of this player.
Definition: player_profile.hpp:190
void grandPrixFinished()
Callback when a GP is finished (to test if a challenge was fulfilled).
Definition: player_profile.hpp:215
bool hasSavedSession() const
Returns true if a session was saved for this player.
Definition: player_profile.hpp:286
bool m_saved_session
True if this user has a saved session.
Definition: player_profile.hpp:91
void incrementUseFrequency()
Increments how often that account was used.
Definition: player_profile.cpp:264
void saveSession(int user_id, const std::string &token)
Saves the online data, so that it will automatically re-connect next time this profile is loaded.
Definition: player_profile.cpp:242
void addIcon()
Creates an icon for a player if non exist so far.
Definition: player_profile.cpp:155
const ChallengeStatus * getCurrentChallengeStatus() const
Returns the current challenge for this player.
Definition: player_profile.hpp:251
int getSavedUserId() const
If a session was saved, return the id of the saved user.
Definition: player_profile.hpp:291
void setCurrentChallenge(const std::string &name)
Sets the currently active challenge.
Definition: player_profile.hpp:208
int m_use_frequency
Counts how often this player was used (always -1 for guests).
Definition: player_profile.hpp:82
void setLastOnlineName(const core::stringw &name)
Sets the last used online name.
Definition: player_profile.hpp:184
std::string m_icon_filename
Absolute path of the icon file for this player.
Definition: player_profile.hpp:88
StoryModeStatus * m_story_mode_status
The complete challenge state.
Definition: player_profile.hpp:112
const std::string getIconFilename() const
Returns the name of the icon file for this player.
Definition: player_profile.cpp:186
std::string m_saved_token
The token of the saved session.
Definition: player_profile.hpp:97
void setName(const core::stringw &name)
Sets the name of this player.
Definition: player_profile.hpp:151
void setRememberPassword(bool b)
Sets if this player was logged in last time it was used.
Definition: player_profile.hpp:316
const core::stringw & getName() const
Returns the name of this player.
Definition: player_profile.hpp:161
const std::string & getSavedToken() const
If a session was saved, return the token to use.
Definition: player_profile.hpp:298
void loadRemainingData(const XMLNode *node)
This function loads the achievement and story mode data.
Definition: player_profile.cpp:118
bool m_last_was_online
True if the last time this player was used as online.
Definition: player_profile.hpp:103
bool operator<(const PlayerProfile &other)
Comparison used to sort players.
Definition: player_profile.cpp:282
core::stringw m_local_name
The name of the player (wide string, so it can be in native language).
Definition: player_profile.hpp:76
void raceFinished()
Notification of a finished race, which can trigger fulfilling challenges.
Definition: player_profile.cpp:273
OnlineState
The online state a player can be in.
Definition: player_profile.hpp:58
bool isLocked(const std::string &feature) const
Returnes if the feature (kart, track) is locked.
Definition: player_profile.hpp:193
bool isGuestAccount() const
Returns true if this player is a guest account.
Definition: player_profile.hpp:169
unsigned int m_unique_id
A unique number for this player, used to link it to challenges etc.
Definition: player_profile.hpp:85
bool m_is_guest_account
True if this account is a guest account.
Definition: player_profile.hpp:79
std::vector< const ChallengeData * > getRecentlyCompletedChallenges()
Returns the list of recently completed challenges.
Definition: player_profile.hpp:202
void setWasOnlineLastTime(bool b)
Sets if this player was logged in last time it was used.
Definition: player_profile.hpp:309
float m_default_kart_color
Default kart color (in hue) used in game, 0.0f to use the original.
Definition: player_profile.hpp:109
void computeActive()
Returns all active challenges.
Definition: player_profile.hpp:199
bool rememberPassword() const
Returns if the last time this player was used it was used online or offline.
Definition: player_profile.hpp:313
void save(UTFWriter &out)
Writes the data for this player to the specified UTFWriter.
Definition: player_profile.cpp:202
void initRemainingData()
Initialises the story- and achievement data structure in case of the first start of STK.
Definition: player_profile.cpp:134
int m_saved_user_id
If a session was saved, this will be the online user id to use.
Definition: player_profile.hpp:94
bool wasOnlineLastTime() const
Returns if the last time this player was used it was used online or offline.
Definition: player_profile.hpp:306
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:100
bool m_remember_password
True if the login data are saved.
Definition: player_profile.hpp:106
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 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
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
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 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.