-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.cpp
73 lines (60 loc) · 1.1 KB
/
player.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "player.h"
// overloaded constructors for instances of Player
Player::Player(void)
{
this->setName(UNNAMED_PLAYER);
this->setLeftTokens(22);
}
Player::Player(string name, enum Team team)
{
this->setName(name);
this->setTeam(team);
}
// setter for player's name
void Player::setName(string name)
{
!name.empty() ? this->name=name : this->name = UNNAMED_PLAYER;
}
// setter for player's team
void Player::setTeam(enum Team team)
{
this->team = team;
}
// setter for player's amount of left tokens
void Player::setLeftTokens(int tokensLeft)
{
this->tokensLeft = tokensLeft;
}
// getter for player's name
string Player::getName(void)
{
return this->name;
}
enum Team Player::getTeam(void)
{
return this->team;
}
// get player's token // TODO: needed?
char Player::getToken(void)
{
char token;
switch (this->team)
{
case WHITE: token = TOKEN_WHITE; break;
case BLACK: token = TOKEN_BLACK; break;
// default: break;
}
return token;
}
bool Player::getIsHuman()
{
return isHuman;
}
void Player::setIsHuman(bool human){
if(human == true)
{
isHuman = true;
} else {
isHuman = false;
}
}