nsnake
Classic snake game for the terminal
|
Stores points the player made on the game. More...
#include <ScoreFile.hpp>
Public Member Functions | |
ScoreFile (std::string levelName) | |
Creates a new score handler for the level #levelName. | |
void | load () |
Loads all high score entries based on a level name. | |
void | save () |
Saves all the current scores on the file. | |
bool | handle (ScoreEntry *score) |
Checks if #score is the highest score and make it so. | |
Static Public Member Functions | |
static void | eraseAll () |
Erases all high score files. | |
Public Attributes | |
ScoreEntry * | highScore |
Maximum high score obtained for the current game. | |
Static Public Attributes | |
static std::string | directory = "" |
Default directory where we store the game score files. | |
static std::string | extension = "nsnakescores" |
Default extension to save the score files. | |
Stores points the player made on the game.
There's different high scores for different game settings.
Each time the user runs the game with a different configuration of the tweaks above, a new high score is generated.
It always starts with 0 and if the player surpasses it, will be the new maximum.
Definition at line 87 of file ScoreFile.hpp.
ScoreFile::ScoreFile | ( | std::string | levelName | ) |
Creates a new score handler for the level #levelName.
Definition at line 91 of file ScoreFile.cpp.
|
static |
Erases all high score files.
By "all" I mean every single score file from the arcade mode to all levels.
Definition at line 71 of file ScoreFile.cpp.
bool ScoreFile::handle | ( | ScoreEntry * | score | ) |
Checks if #score is the highest score and make it so.
Call this when you finished the game.
Definition at line 263 of file ScoreFile.cpp.
void ScoreFile::load | ( | ) |
Loads all high score entries based on a level name.
The file where we save the high scores will be based on the level name.
levelName
is empty, will fall back to the default score file (see Globals). Definition at line 96 of file ScoreFile.cpp.
void ScoreFile::save | ( | ) |
Saves all the current scores on the file.
Definition at line 202 of file ScoreFile.cpp.
|
static |
Default directory where we store the game score files.
By default is the same directory as the level files (see BoardParser).
So the default behavior is to create a score file with the same name as the level and a custom extension.
Definition at line 97 of file ScoreFile.hpp.
|
static |
Default extension to save the score files.
It's all the part that comes after the dot on a file name.
Definition at line 105 of file ScoreFile.hpp.
ScoreEntry* ScoreFile::highScore |
Maximum high score obtained for the current game.
It will point to an element within entries that has the highest score for this game settings.
Definition at line 148 of file ScoreFile.hpp.