-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaxSquare.cpp
More file actions
65 lines (64 loc) · 1.84 KB
/
taxSquare.cpp
File metadata and controls
65 lines (64 loc) · 1.84 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
#include <iostream>
#include <vector>
#include "player.h"
#include "taxSquare.h"
using namespace std;
//taxSquare constructor sets position, name, and tax amount
taxSquare::taxSquare(int position, string tileName, int taxAmount) : boardTile(position, tileName)
{
this->taxAmount = taxAmount;
}
//Getters and setters
int taxSquare::getTaxAmount()
{
return taxAmount;
}
void taxSquare::setTaxAmount(int amount)
{
this->taxAmount = amount;
}
//Gets actions at taxSquare
vector<string> taxSquare::getActions(player& player)
{
vector<string> actionsVector;
this->required(player);
if (player.getPlayerProperty().size() > 0) {
actionsVector.push_back("Buy Houses / Hotels");
actionsVector.push_back("Trade Property");
}
actionsVector.push_back("End Turn");
return actionsVector;
}
//Required actions at taxSquare
void taxSquare::required(player& player)
{
cout << "You paid " << this->getTaxAmount() << " in tax" << endl;
player.setPlayerMoney(player.getPlayerMoney() - this->getTaxAmount());
}
//Gets player selection from actions vector
int taxSquare::getPlayerSelection(vector<string> actions) {
int playerSelection = 0;
for (string action : actions) {
cout << "\t" << playerSelection << ": " << action << endl;
playerSelection++;
}
cout << "Please select an action: ";
cin >> playerSelection;
if (playerSelection > actions.size() - 1) {
cout << "Invalid Selection\n";
return getPlayerSelection(actions);
}
return playerSelection;
}
//Responds to player selection
void taxSquare::replyToPlayerSelection(vector<string>& actions, int selection, player& player) {
if (actions[selection] == "Buy Houses / Hotels") {
cout << "Buy Houses / Hotels" << endl;
}
else if (actions[selection] == "End Turn") {
cout << "Ending Turn" << endl;
}
else {
cout << "Invalid Selection" << endl;
}
}