Pacman Torben Petré
Loading...
Searching...
No Matches
logic::Score Class Referencefinal

#include <Score.h>

Inheritance diagram for logic::Score:
Collaboration diagram for logic::Score:

Public Member Functions

 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 ScoreEntrygetLastScore () 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.
Public Member Functions inherited from logic::Observer
virtual ~Observer ()=default
Public Member Functions inherited from logic::Subject
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.

Additional Inherited Members

Protected Attributes inherited from logic::Subject
std::list< std::weak_ptr< Observer > > observers

Constructor & Destructor Documentation

◆ Score()

Score::Score ( )

Creates new Score object, and loads entries from highscores.txt file.

◆ ~Score()

Score::~Score ( )
override

Overrides destructor behaviour to call Score::write;.

Member Function Documentation

◆ 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()

const ScoreEntry & Score::getLastScore ( ) const
nodiscard

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
username

◆ update()

void Score::update ( double dt)

Updates time since last coin collection and time accumulator, te determine score decay.

Parameters
dtDeltatime

◆ 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: