FYP  1.0.0
Final Year Project -- Alexander Meuer
PlayerProfile Class Reference

Record of how far a player has progressed through the game. Used to save/load to/from file. More...

#include <PlayerProfile.hpp>

Collaboration diagram for PlayerProfile:
Collaboration graph

Public Member Functions

 PlayerProfile (std::string const &xmlPath)
 Constructs a PlayerProfile from an xml file. If the file does not exist, a new one will be created.
 
bool hasUnlockedLevel (std::string const &levelPath)
 Find out if the player has unlocked a level. More...
 
void unlockLevel (std::string const &levelPath)
 Unlocks a level for this profile. More...
 
std::string const & getName () const
 Returns the name of the player.
 
bool save () const
 Saves the profile to its file. More...
 

Static Private Member Functions

static void createProfileFile (std::string const &path)
 Creates a new profile file with the first level unlocked. zparam path Path to where the file should be created, including file name and extension.
 
static void printError (std::string const &preMsg, errno_t error)
 

Private Attributes

std::set< std::string > mUnlockedLevelPaths
 Every level path contained in the set is considered unlocked for this profile.
 
std::string mName
 Name of the player.
 
const std::string mPath
 

Detailed Description

Record of how far a player has progressed through the game. Used to save/load to/from file.

Member Function Documentation

bool PlayerProfile::hasUnlockedLevel ( std::string const &  levelPath)

Find out if the player has unlocked a level.

Parameters
levelPathPath to level xml definition. (Not opened, just used as a key)
Returns
True if the player has unlocked the level, false otherwise.
bool PlayerProfile::save ( ) const

Saves the profile to its file.

Returns
True if saving was successful.
void PlayerProfile::unlockLevel ( std::string const &  levelPath)

Unlocks a level for this profile.

Parameters
levelPathPath to level xml definition. (Not opened, just used as a key)

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