#include <Score.h>
|
| | Score () |
| | Creates new Score object, and loads entries from highscores.txt file.
|
| | ~Score () override |
| | Overrides destructor behaviour to call Score::write;.
|
| std::vector< std::unique_ptr< ScoreEntry > > & | getHighscores () |
| | Returns a reference to the vector holding all known Highscore objects.
|
| int | getScore () const |
| | Returns the current score.
|
| const ScoreEntry & | getLastScore () const |
| | Returns the last achieved score as a Highscore object.
|
| void | setUser (const std::string &username) |
| | Sets the user to whom the next ScoreEntry will be attributed.
|
| void | update (double dt) |
| | Updates time since last coin collection and time accumulator, te determine score decay.
|
| void | addScoreEntry () |
| | Creates a new score entry for the current user with the current score.
|
| void | write () const |
| | Writes the ScoreEntry objects to the highscores.txt file.
|
| virtual | ~Observer ()=default |
| virtual | ~Subject ()=default |
| void | attach (const std::shared_ptr< Observer > &observer) |
| | Attaches an observer to this Subject.
|
| void | notify (Events event) |
| | Call the Observer update function with the provided event.
|
◆ Score()
Creates new Score object, and loads entries from highscores.txt file.
◆ ~Score()
◆ addScoreEntry()
| void Score::addScoreEntry |
( |
| ) |
|
Creates a new score entry for the current user with the current score.
◆ getHighscores()
| std::vector< std::unique_ptr< ScoreEntry > > & Score::getHighscores |
( |
| ) |
|
|
nodiscard |
Returns a reference to the vector holding all known Highscore objects.
- Returns
- Reference to Highscores vector
◆ getLastScore()
Returns the last achieved score as a Highscore object.
- Returns
- Last score
◆ getScore()
| int Score::getScore |
( |
| ) |
const |
|
nodiscard |
Returns the current score.
The current score is updated by World events while the World is active so the score will vary from time to time.
- Returns
- Current score
◆ setUser()
| void Score::setUser |
( |
const std::string & | username | ) |
|
Sets the user to whom the next ScoreEntry will be attributed.
- Parameters
-
◆ update()
| void Score::update |
( |
double | dt | ) |
|
Updates time since last coin collection and time accumulator, te determine score decay.
- Parameters
-
◆ write()
| void Score::write |
( |
| ) |
const |
Writes the ScoreEntry objects to the highscores.txt file.
The documentation for this class was generated from the following files: