-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.cpp
More file actions
125 lines (120 loc) · 2.91 KB
/
Copy pathPlayer.cpp
File metadata and controls
125 lines (120 loc) · 2.91 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "Player.h"
#include"Utilities.h"
using namespace std;
Player::Player(std::string n, int c, int spot, bool jail, bool railroad, bool computerControlled)
:name{ n }, cash{ c }, currentSpot{ spot }, defense{ 0 }, inJail{ jail },
onRailroad{ railroad }, hp{ 100 }, bidding{ true }, alwaysOneTwo{ false },
AI{ computerControlled }, roll{ 0 }, doRoll{ true }, bankrupt{ false },
jailAttempts{ 0 }, doublesRolled{ 0 }, alwaysDoubles{ false } {}
Player::Player()
: name{ "NONE" }, cash{ 0 }, currentSpot{ 0 }, inJail{ false }, onRailroad{ false }, AI{ false } {}
int Player::getCurrentSpot() {
return this->currentSpot;
}
void Player::setCurrentSpot(int newSpot) {
this->currentSpot = newSpot;
}
int Player::getRoll() {
return this->roll;
}
void Player::setRoll(int newRoll) {
this->roll = newRoll;
}
std::string Player::getName() {
return this->name;
}
int Player::getCash() {
return this->cash;
}
std::vector<Card> Player::getCards() {
return this->cards;
}
void Player::setCash(int newCash) {
this->cash = newCash;
}
void Player::setCards(std::vector<Card> newCards) {
this->cards = newCards;
}
void Player::addCash(int amt) {
this->cash += amt;
}
void Player::deductCash(int amt) {
this->cash = (this->cash - amt < 0) ? 0 : this->cash - amt;
}
bool Player::canDeduct(int amt) {
return (this->cash - amt > 0) ? true : false;
}
void Player::setBankruptcy(bool newBankruptcy) {
this->bankrupt = newBankruptcy;
if (bankrupt) {
this->setCurrentSpot(41);
//set them out of bounds so they can't end up battling other players even though they're bankrupt
}
}
bool Player::isBankrupt() {
return this->bankrupt;
}
bool Player::isAI() {
return this->AI;
}
int Player::getDoublesRolled() {
return this->doublesRolled;
}
void Player::setDoublesRolled(int newRoll) {
this->doublesRolled = newRoll;
}
int Player::getJailAttempts() {
return this->jailAttempts;
}
void Player::addJailAttempt() {
++this->jailAttempts;
}
bool Player::canRoll() {
return this->doRoll;
}
void Player::setRolling(bool newRolling) {
this->doRoll = newRolling;
}
bool Player::isInJail() {
return this->inJail;
}
void Player::setJail(bool newJail) {
this->inJail = newJail;
}
int Player::getDefense() {
return this->defense;
}
void Player::setDefense(int newDefense) {
this->defense = newDefense;
}
int Player::getHP() {
return this->hp;
}
void Player::setHP(int newHP) {
this->hp = (newHP <= 0) ? 0 : newHP;
}
bool Player::isBidding() {
return this->bidding;
}
void Player::setBidding(bool newBidding) {
this->bidding = newBidding;
}
void Player::setOneTwo(bool newOneTwo) {
this->alwaysOneTwo = newOneTwo;
}
void Player::setAlwaysDoubles(bool newDoubles) {
this->alwaysDoubles = newDoubles;
}
bool Player::getAlwaysDoubles() {
return this->alwaysDoubles;
}
bool Player::getOneTwo() {
return this->alwaysOneTwo;
}
bool Player::canDoubleRoll() {
return this->doubleRoll;
}
void Player::setDoubleRoll(bool newDoubleRoll) {
this->doubleRoll = newDoubleRoll;
}
;