Space Walk board game
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.
 
 

54 lines
975 B

  1. #include <ncurses.h> // A_REVERSE
  2. #include <stdio.h>
  3. #include "player.h"
  4. #include "infowindow.h"
  5. Player::Player() :
  6. chip(CHIP_AMOUNT),
  7. name("") {
  8. }
  9. void Player::render(InfoWindow *window, int y, int x, unsigned char number) {
  10. std::string print;
  11. print += " Player ";
  12. print += std::to_string(number);
  13. print += " ";
  14. window->print(print, y, x - 1, A_REVERSE);
  15. y += 2;
  16. window->print(this->name, y, x, COLOR_PAIR(this->color));
  17. y += 2;
  18. for (unsigned char i = 0; i < this->chip; i++) {
  19. window->print("C", y, x, COLOR_PAIR(PAIR_WHITE_BLACK));
  20. x++;
  21. window->print(" ", y, x);
  22. x++;
  23. }
  24. }
  25. unsigned char Player::getChip() {
  26. return this->chip;
  27. }
  28. void Player::setChip(unsigned char chip) {
  29. this->chip = chip;
  30. }
  31. unsigned char Player::getColor() {
  32. return this->color;
  33. }
  34. void Player::setColor(unsigned char color) {
  35. this->color = color;
  36. }
  37. std::string Player::getName() {
  38. return this->name;
  39. }
  40. void Player::setName(std::string name) {
  41. this->name = name;
  42. }