-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProperty.cpp
145 lines (119 loc) · 3.26 KB
/
Property.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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//
// Created by mfbut on 1/20/2018.
//
#include <iostream>
#include <cmath>
#include <string>
#include "Property.h"
#include "Player.h"
Monopoly::Property::Property(CSVReader& boardFile) : owner(nullptr) {
setId = boardFile.get_next_field_as_int();
intraSetId = boardFile.get_next_field_as_int();
name = boardFile.get_next_field();
cost = boardFile.get_next_field_as_int();
house_cost = boardFile.get_next_field_as_int();
hotel_cost = boardFile.get_next_field_as_int();
rent = boardFile.get_next_field_as_int();
rent_with_house = boardFile.get_next_field_as_int();
rent_with_hotel = boardFile.get_next_field_as_int();
numHouses = 0;
numHotels = 0;
buildingTally = "";
}
int Monopoly::Property::getSetId() const {
return setId;
}
int Monopoly::Property::getIntraSetId() const {
return intraSetId;
}
const std::string& Monopoly::Property::getName() const {
return name;
}
int Monopoly::Property::getCost() const {
return cost;
}
int Monopoly::Property::getHouse_cost() const {
return house_cost;
}
int Monopoly::Property::getHotel_cost() const {
return hotel_cost;
}
int Monopoly::Property::getRent() const {
return rent;
}
int Monopoly::Property::getRent_with_house() const {
return rent_with_house;
}
int Monopoly::Property::getRent_with_hotel() const {
return rent_with_hotel;
}
Monopoly::Player* Monopoly::Property::getOwner() const {
return owner;
}
int Monopoly::Property::getLanding_multiplier() const {
return landing_multiplier;
}
void Monopoly::Property::setLanding_multiplier(int landing_multiplier) {
this->landing_multiplier = landing_multiplier;
}
void Monopoly::Property::display() const {
std::cout << name << " | ";
if (owner == nullptr) {
std::cout << "None | ";
} else {
std::cout << owner->getName() << " | ";
}
}
std::string Monopoly::Property::getOwnerName() const {
if (owner != nullptr) {
return owner->getName();
} else {
return "None";
}
}
std::string& Monopoly::Property::addh() {
return buildingTally += 'h';
}
std::string& Monopoly::Property::minush() {
buildingTally.pop_back();
return buildingTally;
}
/*std::string& Monopoly::Property::minush() {
buildingTally.pop_back();
return buildingTally;
}*/
std::string& Monopoly::Property::gethouseString() {
//std::cout << "hello " << this->buildingTally << std::endl;
return buildingTally;
}
void Monopoly::Property::setOwner(Monopoly::Player* owner) {
Property::owner = owner;
}
int Monopoly::Property::calculateRent(const Rules& rules) const { //changed calculate rent with stipulation
if(numHouses > 0 || numHotels > 0) {
return rent_with_house * std::pow(2, numHouses - 1);
}
else{
return rent * (owner->ownsAllPropertiesInSet(setId) ? rules.getProperty_set_multiplier() : 1); //change this
}
}
int Monopoly::Property::getNumHouses() const {
return numHouses;
}
int Monopoly::Property::getNumHotels() const {
return numHotels;
}
int Monopoly::Property::incNumHouses() {
return numHouses++;
}
int Monopoly::Property::incNumHotels() { //not returning numHouses
numHouses = 0;
return numHotels++;
}
int Monopoly::Property::decNumHouses() {
return numHouses--;
}
int Monopoly::Property::decNumHotels(const Rules& rules) { //not returning numHouses
numHouses = rules.getNum_houses_before_hotel();
return numHotels--;
}