You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
895 B

  1. #include "Player.h"
  2. using namespace std;
  3. Player::Player()
  4. : name{"Unknown"}, points{0}, timesPlayed{0}
  5. {}
  6. Player::Player(string _name)
  7. : name{_name}, points{0}, timesPlayed{0}
  8. {}
  9. Player::~Player()
  10. {/* No need to do something */}
  11. string Player::getName(void){
  12. return this->name;
  13. }
  14. void Player::addPoints(unsigned int _points){
  15. points += _points;
  16. }
  17. unsigned int Player::getPoints(void){
  18. return this->points;
  19. }
  20. std::pair<std::string, unsigned int> Player::play(void){
  21. //here we will implement the basic loop of the game since each player has its remote controller
  22. //and can play the game
  23. Controller controller;
  24. while (controller.wantsToQuit() == false)
  25. {
  26. controller.readInput();
  27. if (controller.act() == DEFEAT)
  28. break;
  29. }
  30. points = controller.getCurrScore();
  31. controller.resetScore();
  32. return {this->name, points};
  33. }