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.

50 lines
816 B

пре 5 година
  1. #ifndef _2EASY4ME_PLAYER_H_
  2. #define _2EASY4ME_PLAYER_H_
  3. #include "character.hpp"
  4. class Player : public Character
  5. {
  6. protected:
  7. int xp;
  8. int level;
  9. public:
  10. Player(char *name)
  11. : Character(name)
  12. {
  13. this->xp = 0;
  14. this->level = 1;
  15. }
  16. Player(char *name, int hp, int att, int def, int level, int xp)
  17. : Character(name, hp, att, def)
  18. {
  19. this->xp = xp;
  20. this->level = level;
  21. }
  22. bool checkLevelup()
  23. {
  24. return xp > (level * level);
  25. }
  26. bool levelUp(int stat)
  27. {
  28. switch (stat)
  29. {
  30. case 1:
  31. hp += 10;
  32. break;
  33. case 2:
  34. att += 2;
  35. break;
  36. case 3:
  37. def += 1;
  38. break;
  39. }
  40. xp -= level * level;
  41. }
  42. };
  43. #endif