-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.cpp
77 lines (63 loc) · 1.29 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
74
75
76
77
#include "player.h"
Player::Player(int num, string col) : number(num) {
points = 0;
color = colorMap()[col];
barrels = 0;
barley = 0;
spools = 0;
}
Player::~Player() {
for (int i = 0; i < followers.size(); ++i) {
delete followers.at(i);
}
}
void Player::addPoints(int p) {
points += p;
}
void Player::addMerchandise(int b, int g, int s) {
barrels += b;
barley += g;
spools += s;
}
int Player::getWine() {
return barrels;
}
int Player::getGrain() {
return barley;
}
int Player::getCloth() {
return spools;
}
int Player::getPoints() {
return points;
}
int Player::getPlayerNumber() {
return number;
}
PlayerColor Player::getColor() {
return color;
}
void Player::addFollower(FollowerType t, OccupationMapper *om, int amount = 1) {
for (int i = 0; i < amount; ++i) {
followers.push_back(new Follower(this, t, om)); // Deleted in destructor
}
}
Follower* Player::getFollower(FollowerType t) {
for (int i = 0; i < followers.size(); ++i) {
if (followers.at(i)->getType() == t && followers.at(i)->isPlayable()) {
return followers.at(i);
}
}
return NULL;
}
vector<Follower*> Player::getAllFollowers() {
return followers;
}
bool Player::hasPlayableFollowers() {
for (int i = 0; i < followers.size(); ++i) {
if (followers.at(i)->isPlayable()) {
return true;
}
}
return false;
}