biquadris / scoreboard.h
scoreboard.h
Raw
/*
    Scoreboard class module
    
	  stores score(s), hiscores, and basic functionality
*/

#ifndef _SCOREBOARD_H_
#define _SCOREBOARD_H_

#include <vector>
#include "subject.h"
#include "observer.h"
#include "subscriptions.h"

class Block;
class Board;

class Scoreboard: public Subject, public Observer {
    int highScore = 0;
    int players;
    std::vector<int> scores;
    void updateHighScore(); // update high score based on current score
    void updateByClearedLine(Board *b);
    void updateByDestroyedBlock(Block *b);
  public:
    Scoreboard(int players);

    std::vector<SubscriptionType> subType() override;
    void notify(Subject *whoNotified, SubscriptionType t) override;
    
    void addScore(int player, int score); // add score to player
    void resetScore(int player); // set player's score to 0
    int getPlayerCount(); // gets the players count
    int getScore(int player); // get the player's score
    int getHighScore(); // gets the highscore of all the score of players
    void setHighScore(int score);
};

#endif