forked from anthonyjuan-wang/Watopoly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcTimsLine.cc
executable file
·65 lines (61 loc) · 2.45 KB
/
dcTimsLine.cc
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
#include "dcTimsLine.h"
#include "tile.h"
#include "board.h"
#include "player.h"
#include <vector>
#include <string>
#include <memory>
#include <iostream>
using namespace std;
DcTimsLine::DcTimsLine(int position, string blockName, shared_ptr<Board> board) : Tile{blockName, false, false, position, 0, board} {}
DcTimsLine::~DcTimsLine() {}
void DcTimsLine::action(shared_ptr<Player> player) {
if (player->getJailStatus() == true) {
while (true) {
// If player is in last turn
if (player->getJailCount() == 2) {
cout << "This is your last turn in jail. You must use a roll up the rim cup or pay up." << endl;
}
// If player cannot pay
if (player->getRollUpCount() == 0 && player->getMoney() < 50){
if (player->getJailCount() == 2) {
player->setAlmostBankruptStatus(true);
player->setMoneyOwed(50);
break;
} else {
cout << "Your turn is over. You cannot pay or use a roll up the rim cup." << endl;
player->setJailCount(player->getJailCount() + 1);
break;
}
}
cout << "Enter 'pay' to pay the jail fee, or 'up' to use your Roll Up cup" << endl;
string cmd;
cin >> cmd;
if (cmd == "pay") {
if (player->getMoney() < 50) {
cout << "You have less than 50$! This command is invalid. Please enter a valid command" << endl;
continue;
} else {
player->subtractMoney(50);
cout << "You pay 50$, and are now free from jail!." << endl;
player->setJailStatus(false);
player->setJailCount(0);
break;
}
} else if (cmd == "up") {
// cannot use rolluprim cup
if (player->getRollUpCount() == 0 ){
cout << "You don't have a roll up the rim cup. Please enter a valid command." << endl;
continue;
}
else {
// use up roll up the rim cup
player->useRollUpCount();
player->setJailStatus(false);
player->setJailCount(0);
break;
}
}
}
}
}