SuperTuxKart
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Achievement Class Reference

Public Member Functions

 Achievement (AchievementInfo *info)
 Constructur, initialises this object with the data from the corresponding AchievementInfo.
 
virtual void loadProgress (const XMLNode *node)
 Loads the value from an XML node. More...
 
virtual void saveProgress (UTFWriter &out)
 Saves the achievement status to a file. More...
 
virtual irr::core::stringw getProgressAsString ()
 Returns how much of an achievement has been achieved in the form n/m. More...
 
virtual irr::core::stringw getGoalProgressAsString ()
 Returns how many goals of an achievement have been achieved, in the form n/m.
 
uint32_t getID () const
 
AchievementInfogetInfo ()
 
int getFullfiledGoals ()
 Returns how many goals of an achievement have been achieved.
 
int getProgress ()
 Returns how many goals of an achievement have been achieved.
 
void setAchieved ()
 
bool isAchieved () const
 
void setGoalValue (std::string &goal_string, int value)
 Set any leaf of the progress goal tree whose type matches the goal_string to the value passed as parameter. More...
 

Protected Member Functions

int computeFullfiledGoals (AchievementInfo::goalTree &progress, AchievementInfo::goalTree &reference)
 
int computeGoalProgress (AchievementInfo::goalTree &progress, AchievementInfo::goalTree &reference, bool same_tree=false)
 Should ONLY be called if the achievement has one goal (a sum counts as one goal). More...
 

Protected Attributes

AchievementInfo::goalTree m_progress_goal_tree
 The tree of goals. More...
 
AchievementInfom_achievement_info
 A pointer to the corresponding AchievementInfo instance. More...
 

Private Member Functions

void onCompletion ()
 Manages what needs to happen once the achievement is completed, like displaying the completion message to the player or synching with the server.
 
bool recursiveSetGoalValue (AchievementInfo::goalTree &tree, const std::string &goal_string, int value, bool and_or, bool sum_andatonce)
 
bool recursiveCompletionCheck (AchievementInfo::goalTree &progress, AchievementInfo::goalTree &reference)
 Checks if this achievement has been achieved.
 

Private Attributes

bool m_achieved
 True if this achievement has been achieved. More...
 
int m_id
 

Friends

class AchievementProgressDialog
 

Member Function Documentation

◆ computeGoalProgress()

int Achievement::computeGoalProgress ( AchievementInfo::goalTree progress,
AchievementInfo::goalTree reference,
bool  same_tree = false 
)
protected

Should ONLY be called if the achievement has one goal (a sum counts as one goal).

Returning an error code with a number is not full-proof because a sum goal can legitimately be negative (a counter can be chosen to count against the achievement's fullfilment).

◆ getProgressAsString()

irr::core::stringw Achievement::getProgressAsString ( )
virtual

Returns how much of an achievement has been achieved in the form n/m.

ONLY applicable for single goal achievements. Returns a string with a single space if there are multiple goals.

◆ loadProgress()

void Achievement::loadProgress ( const XMLNode node)
virtual

Loads the value from an XML node.

Parameters
input

◆ saveProgress()

void Achievement::saveProgress ( UTFWriter out)
virtual

Saves the achievement status to a file.

Parameters
Outputstream.

◆ setGoalValue()

void Achievement::setGoalValue ( std::string &  goal_string,
int  value 
)

Set any leaf of the progress goal tree whose type matches the goal_string to the value passed as parameter.

The goal string can contain a logical prefix. If it is LOGC- ; the update is for the current value of a resetable counter. It is applied if the parent node is of type SUM or AND-AT-ONCE, ignored otherwise. If it is LOGM- ; the update is for the highest achieved value of a resetable counter. It is appliedif the parent node is of type AND or OR, ignored otherwise. If there is no logical prefix, the new value is set in all cases.

If the leaf has an operator defined, this will trigger an update of the relevant values. If the leaf's new value match or exceed its target goal value, a check for the achievement's completions is triggered.

Member Data Documentation

◆ m_achieved

bool Achievement::m_achieved
private

True if this achievement has been achieved.

◆ m_achievement_info

AchievementInfo* Achievement::m_achievement_info
protected

A pointer to the corresponding AchievementInfo instance.

◆ m_progress_goal_tree

AchievementInfo::goalTree Achievement::m_progress_goal_tree
protected

The tree of goals.

It is identical to the goal tree of the matching AchievementInfo, except that the stored values represent the achieved values instead of the values to meet.


The documentation for this class was generated from the following files: