SuperTuxKart
|
This class keeps tracks of all achievements of one player. More...
#include <achievements_status.hpp>
Classes | |
struct | AchievementVariable |
struct | TrackStats |
Public Member Functions | |
AchievementsStatus () | |
Constructor for an Achievement. | |
~AchievementsStatus () | |
Removes all achievements. | |
Achievement * | getAchievement (uint32_t id) |
void | load (const XMLNode *input) |
Loads the saved state of all achievements from an XML file. | |
void | save (UTFWriter &out) |
Saves the achievement status to a file. | |
void | add (Achievement *achievement) |
void | sync (const std::vector< uint32_t > &achieved_ids) |
Synchronises the achievements between local and online usage. | |
void | increaseDataVar (unsigned int achieve_data_id, int increase) |
void | resetDataVar (unsigned int achieve_data_id) |
void | onRaceEnd (bool aborted=false) |
void | onLapEnd () |
void | trackEvent (std::string track_ident, AchievementsStatus::TrackData event) |
Use the event type to increment the correct track event counter. | |
void | resetKartHits (int num_karts) |
void | addKartHit (int kart_id) |
void | updateAllAchievementsProgress () |
int | getNumTracksAboveValue (int value, std::string goal_string) |
int | getNumAchieveTracks () |
std::map< uint32_t, Achievement * > & | getAllAchievements () |
bool | isOnline () const |
bool | isValid () const |
Private Types | |
enum | UpdateType { UP_ACHIEVEMENT_DATA = 0 , UP_TRACK_DATA = 1 , UP_KART_HITS = 2 } |
Private Member Functions | |
void | setEnumToString () |
This function loads a table associating an enum identifier with the matching command in achievements.xml. | |
void | updateAchievementsProgress (UpdateType type, unsigned int enum_id) |
Private Attributes | |
std::map< uint32_t, Achievement * > | m_achievements |
const int | DATA_VERSION = 4 |
AchievementVariable | m_variables [ACHIEVE_DATA_NUM] |
std::string | m_ach_enum_to_xml [ACHIEVE_DATA_NUM] |
std::vector< TrackStats > | m_track_stats |
std::string | m_tr_enum_to_xml [2 *TR_DATA_NUM] |
std::vector< int > | m_kart_hits |
bool | m_online |
bool | m_valid |
This class keeps tracks of all achievements of one player.
One instance of this class is stored in each PlayerProfile. It stores a map of achievements ids to instances of Achievement. Each achievement in turn stores either fulfilled achievements, or the current state of an achievement (e.g. an achievement to race every track in STK needs to keep information about which tracks have already been used.)
void AchievementsStatus::load | ( | const XMLNode * | input | ) |
Loads the saved state of all achievements from an XML file.
input | The XML node to load the data from. |
void AchievementsStatus::save | ( | UTFWriter & | out | ) |
Saves the achievement status to a file.
Achievements are stored as part of the player data file players.xml.
out | File to write to. |
|
private |
This function loads a table associating an enum identifier with the matching command in achievements.xml.
counters with anassociated max version are prefixed to allow the achievement progress update to do the correct action.
void AchievementsStatus::sync | ( | const std::vector< uint32_t > & | achieved_ids | ) |
Synchronises the achievements between local and online usage.
It takes the list of online achievements, and marks them all to be achieved locally. Then it issues 'achieved' requests to the server for all local achievements that are not set online.
void AchievementsStatus::trackEvent | ( | std::string | track_ident, |
AchievementsStatus::TrackData | event | ||
) |
Use the event type to increment the correct track event counter.
track_ident | - the internal name of the track |
event | - the type of counter to increment |