17 #ifndef PLAYERPROFILE_H
18 #define PLAYERPROFILE_H
21 #include <QJsonDocument>
25 #include <QSharedPointer>
82 const QString& environmentName)
const;
203 void reset(
bool permanently);
240 void onCloudDataLoaded(
int statusCode,
const QString& data);
242 void onCurrentLevelAbandoned();
248 bool onCurrentLevelCompleted(
const QString& progressionName,
int numStars = -1);
249 void onLevelSelected(
const QString& progressionName,
const QString& levelName,
253 enum CloudLoadStatus {
255 STATUS_INTERNAL_ERROR = 0x01,
256 STATUS_CLIENT_RECONNECT_REQUIRED = 0x02,
257 STATUS_NETWORK_ERROR_STALE_DATA = 0x03,
258 STATUS_NETWORK_ERROR_NO_DATA = 0x04,
259 STATUS_NETWORK_ERROR_OPERATION_DEFERRED = 0x05,
260 STATUS_NETWORK_ERROR_OPERATION_FAILED = 0x06,
261 STATUS_DEVELOPER_ERROR = 0x07,
262 STATUS_WRITE_OUT_OF_DATE_VERSION = 0x7d0,
263 STATUS_WRITE_SIZE_EXCEEDED = 0x7d1,
264 STATUS_STATE_KEY_NOT_FOUND = 0x7d2,
265 STATUS_STATE_KEY_LIMIT_EXCEEDED = 0x7d3,
277 int getValidPlayerStarScore(
int starScore)
const;
278 bool startLoadFromCloud();
279 bool tryFinishLoadFromCloud();
280 void loadFromLocal();
285 void clearAchievements();
286 QJsonArray getAchievementsAsJsonArray()
const;
290 bool mHasCloudData =
false;
304 #endif // PLAYERPROFILE_H
bool isEnvironmentUnlocked(const QString &progressionName, const QString &environmentName) const
Returns whether or not the Environment denoted by environmentName in the LevelProgression denoted by ...
QJsonDocument toJsonDocument()
Returns the PlayerProfile serialized as a JSON document.
LevelInfo * getLastPlayedLevelInfo(const QString &progressionName) const
Returns the LevelInfo of the level the player most recently played (or was set to play) in progressio...
int getCurrentPlayerScore(int playerId=0) const
Returns the current score for playerId.
LoadState
Current status of persistent data in the player profile.
Definition: PlayerProfile.h:50
No state has been loaded.
Definition: PlayerProfile.h:54
Available state has been loaded from local and cloud, if necessary.
Definition: PlayerProfile.h:62
void incrementAchievement(const QString &name, int numSteps, bool immediately)
Increments a Google Play Games Services incremental achievement.
void saveAchievementsToCloud()
Tries to push all buffered achievement state updates to the cloud.
bool tryFinishLoad()
Attempts to complete the loading of the PlayerProfile which was asynchronously started with startLoad...
void save()
Saves the permanent state of the PlayerProfile to local storage and, if available, cloud storage.
int updatePlayerScore(int playerId, int amountChanged)
Updates the current level score for playerId by amountChanged.
Representation of a Google Play Games Services achievement.
Definition: Achievement.h:36
bool isSignedIntoCloud() const
Returns whether or not the player is signed into Google Play Games Services.
void newDataMerged()
Emitted when new data from either local or cloud storage has been merged into the PlayerProfile...
Metadata for a Level.
Definition: LevelInfo.h:31
bool isLevelUnlocked(const QString &progressionName, const QString &levelName) const
Returns whether or not the Environment denoted by levelName in the LevelProgression denoted by progre...
void unlockAchievement(const QString &name, bool immediately)
Unlocks a Google Play Games Services achievement.
void showAchievements()
Requests that the PlayerProfile launch a view of the Google Play Games Services achievements.
void init()
Initialize the game.
int getNumStars(const QString &progressionName, const QString &levelName) const
Returns the number of star achieved by the player on the level denoted by levelName in the LevelProgr...
void startLoad()
Asynchronously starts a full load of the PlayerProfile from local storage and, if available...
Grouping of related Environments together into a logical, ordered list.
Definition: LevelProgression.h:34
void reset(bool permanently)
Clears the temporary and permanent data loaded into the PlayerProfile.
The top-level Game object for VoltAir.
Definition: Game.h:35
bool hasCloudSave() const
Returns whether or not the device supports cloud save.
void signIntoCloud()
Attempts to sign the player into Google Play Games Services.
Represents a player's profile or "save game" state.
Definition: PlayerProfile.h:44
Collection of LevelProgressions.
Definition: LevelProgressionList.h:31
bool cloudSignInFailed() const
Returns whether or not a previous attempt to sign into Google Play Games Services failed...
void signOutOfCloud()
Signs the player out of Google Play Games Services.
void revealAchievement(const QString &name, bool immediately)
Reveals a Google Play Games Services achievement.
const QMap< int, int > & getCurrentPlayerScores() const
Returns the scores for all players for the current level.
Definition: PlayerProfile.h:101
void setAchievementSteps(const QString &name, int minSteps, bool immediately)
Sets a Google Play Games Services incremental achievement to have a minimum number of steps...
bool hasMinStars(const QString &progressionName, int minStars) const
Returns whether or not the player has achieved at least a minimum number of stars on each level in th...
Grouping of related LevelInfos together into an logical, ordered list.
Definition: Environment.h:37
LoadState getLoadState() const
Returns the current LoadState of the PlayerProfile.
Definition: PlayerProfile.h:68
In the process of loading state from local and/or cloud.
Definition: PlayerProfile.h:58