-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
97 lines (88 loc) · 2.16 KB
/
player.cpp
File metadata and controls
97 lines (88 loc) · 2.16 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "player.h"
Player::Player()
{
participantIdx = uniqueID++;
createHand();
}
void Player::displayHand(Hand *hand, const bool& isStateDealing) const
{
if (canPlay)
{
if (noOfHands > 1 && !hand->getisHandBust()) {
cout << "Player " << participantIdx << ", hand " << hand->handIdx + 1 << ":" << endl << endl;
}
else if (!hand->getisHandBust()) {
cout << "Player " << participantIdx << "'s cards are:" << endl << endl;
}
hand->displayHand(isStateDealing);
}
}
bool Player::isDealer()
{
return false;
}
bool Player::getisWinner() const {
return isWinner;
}
bool Player::getcanPlay() const
{
return canPlay;
}
int Player::getParticipantIdx() const
{
return participantIdx;
}
vector<Hand*> Player::getHands() const {
return hands;
}
int Player::getnoOfHands() const {
return noOfHands;
}
Hand* Player::getHandByIdx(const int& handIdx) const {
return hands[handIdx];
}
Hand* Player::getLastHand() const{
return hands.back();
}
bool Player::gethasRefusedSplit() const {
return hasRefusedSplit;
}
void Player::setcanPlay(const bool& status) {
canPlay = status;
}
void Player::setisWinner(const bool& status) {
isWinner = status;
}
void Player::sethasRefusedSplit(const bool& status) {
hasRefusedSplit = status;
}
void Player::setisHandBust(const int& handIdx, const bool& status) {
hands[handIdx]->setisHandBust(status);
}
void Player::setnoOfHands(const int& _noOfHands) {
noOfHands = _noOfHands;
}
void Player::sethandIdx(const int& _handIdx) {
handIdx = _handIdx;
}
void Player::recalculateScore(Hand* hand) {
hand->recalculateScore();
}
void Player::createHand() {
Hand* hand = new Hand(participantIdx, handIdx);
hands.emplace_back(hand);
handIdx++;
noOfHands++;
}
void Player::addCard(Hand* hand, Card* card)
{
hand->addCard(card);
}
void Player::collectPrevRoundCards()
{
for (int handIdx = 0; handIdx < hands.size(); handIdx++) {
hands[handIdx]->clearHand();
hands.resize(1);
}
}
int Player::uniqueID = 1;