VoltAir
|
Representation of a Google Play Games Services achievement. More...
Public Types | |
enum | AchievementType { UNKNOWN = 0, REGULAR, INCREMENTAL } |
Category of achievement. More... | |
Public Member Functions | |
Achievement (const QString &name) | |
Constructs an achievement with the specified resource name. More... | |
Achievement (const QJsonObject &json) | |
Constructs an achievement from serialized JSON data. More... | |
void | merge (const Achievement &achievement) |
Merges this with another set of achievement data. More... | |
const QString & | getName () const |
Returns the name of the Achievement. More... | |
AchievementType | getAchievementType () const |
Returns the type of the Achievement. More... | |
bool | hasBeenRevealed () const |
Returns whether or not the Achievement has been revealed through reveal(). More... | |
bool | hasBeenUnlocked () const |
Returns whether or not the Achievement has been unlocked through unlock(). More... | |
int | getMinStepsSet () const |
Returns the number of progress steps minimally set for the incremental Achievement through setSteps(). More... | |
int | getStepsIncremented () const |
Returns the number of progress steps incremented for the incremental Achievement through increment(). More... | |
QJsonObject | toJsonObject () const |
Returns the Achievement serialized as a JSON object. More... | |
void | unlock (bool immediately) |
Unlocks the achievement. More... | |
void | reveal (bool immediately) |
Reveals the achievement. More... | |
void | increment (int numSteps, bool immediately) |
Increments the incremental achievement. More... | |
void | setSteps (int numSteps, bool immediately) |
Sets the incremental achievement to minimally have numSteps . More... | |
bool | saveToCloud () |
Saves any buffered achievement actions (i.e. state changed for which immediately was false ) to the cloud. More... | |
Representation of a Google Play Games Services achievement.
This class represents the current state of an application-defined achievement and provides mechanisms for altering this state (e.g. unlocking, revealing, incrementing, etc.). Additionally, this class provides ways of storing this achievement state locally and syncing that state to the cloud on Android devices.
Category of achievement.
Achievements become bound to an AchievementType through actions performed on the achievement. Once an achievement has been bound to a certain AchievementType, future actions on the achievement are limited, with certain actions becoming undefined operations. For example, an achievement becomes AchievementType::INCREMENTAL after a call to increment(), at which time actions reserved for AchievementType::REGULAR achievements (e.g. unlock()) are no longer defined or allowed.
Enumerator | |
---|---|
UNKNOWN |
No actions (i.e. increment()) have been performed on the achievement allowing its type to be distinguished. |
REGULAR |
Standard achievement that has binary state (i.e. "locked" vs. "unlocked"). |
INCREMENTAL |
Achievement whose progress advances incrementally and becomes "unlocked" after a certain number of pre-defined steps. |
Achievement::Achievement | ( | const QString & | name | ) |
Constructs an achievement with the specified resource name.
name | Android resource name that can be used to locate the achievement id |
Achievement::Achievement | ( | const QJsonObject & | json | ) |
Constructs an achievement from serialized JSON data.
json | Serialized JSON representation of an achievement to load |
AchievementType Achievement::getAchievementType | ( | ) | const |
Returns the type of the Achievement.
|
inline |
Returns the number of progress steps minimally set for the incremental Achievement through setSteps().
|
inline |
Returns the name of the Achievement.
|
inline |
Returns the number of progress steps incremented for the incremental Achievement through increment().
|
inline |
Returns whether or not the Achievement has been revealed through reveal().
false
does not guarantee the achievement in question is a "hidden" achievement – merely that there was no action actively made to reveal it with reveal().
|
inline |
Returns whether or not the Achievement has been unlocked through unlock().
void Achievement::increment | ( | int | numSteps, |
bool | immediately | ||
) |
Increments the incremental achievement.
numSteps | Number of steps to increment the achievement |
immediately | Whether or not the achievement will be incremented directly in the cloud |
void Achievement::merge | ( | const Achievement & | achievement | ) |
Merges this
with another set of achievement data.
achievement | Achievement whose state to merge |
void Achievement::reveal | ( | bool | immediately | ) |
Reveals the achievement.
immediately | Whether or not the achievement will be revealed directly in the cloud |
bool Achievement::saveToCloud | ( | ) |
Saves any buffered achievement actions (i.e. state changed for which immediately
was false
) to the cloud.
void Achievement::setSteps | ( | int | numSteps, |
bool | immediately | ||
) |
Sets the incremental achievement to minimally have numSteps
.
numSteps | Minimum number of steps to set the progress of the achievement to |
immediately | Whether or not the achievement steps will be set directly in the cloud |
QJsonObject Achievement::toJsonObject | ( | ) | const |
Returns the Achievement serialized as a JSON object.
void Achievement::unlock | ( | bool | immediately | ) |
Unlocks the achievement.
immediately | Whether or not the achievement will be unlocked directly in the cloud |