-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameDriver.cpp
276 lines (270 loc) · 12.5 KB
/
gameDriver.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#include <iostream>
#include <iomanip>
#include "Game.h"
using namespace std;
int main()
{
cout << endl << endl << endl;
cout << setw(50) << "Welcome to a Game of Monopoly!" <<endl;
cout << setw(50) << "Theme: CU Boudler" << endl;
cout << setw(50) << "Solgan: The only place in Boulder where you can get rich!" << endl;
cout << setw(50) << "Brought to you by Josh Truong & Kennedy Adams" << endl;
Game monopoly;
bool successfulRead = monopoly.readPlayers();
monopoly.readProperty();
if(!successfulRead)
{
successfulRead = monopoly.readPlayers();
}
string playerQuit;
int playerMenuOptions = 0;
int quitcounter = 0;
do
{
system("clear");
int currentTurn = monopoly.getCurrentTurn();
int numPlayers = monopoly.getNumPlayers();
int amountBankrupt = monopoly.getAmountofBankruptPlayers();
if(amountBankrupt == (numPlayers - 1))
{
quitcounter = 1;
}
else if(monopoly.getBankruptStatus(currentTurn) == false && monopoly.getNumPlayers() != 1)
{
if(monopoly.getInJail() == true && monopoly.getTurnsInJail() > 0)
{
cout << "You are in jail for " << monopoly.getTurnsInJail() << " turn." << endl;
monopoly.setTurnsInJail(monopoly.getTurnsInJail() - 1);
monopoly.endTurn();
}
else
{
if(monopoly.getDisplayStatus() == true)
{
cout << "\x1B[97m" << "[" << monopoly.getPlayerUsername_GAME(currentTurn) << "][" << monopoly.getPlayerCharacter() << "\x1B[97m" << "] TURN" << "\x1B[0m" << endl;
monopoly.roll();
monopoly.move();
monopoly.display_MapAndPlayer();
monopoly.checkOwnership(currentTurn);
}
cout << endl;
cout << "\x1B[97m" << "[" << monopoly.getPlayerUsername_GAME(currentTurn) << "][" << monopoly.getPlayerCharacter() << "\x1B[97m" << "] TURN" << "\x1B[0m" << endl;
cout << "Menu" << endl;
cout << "1. Balance" << endl;
cout << "2. List of Owned Properties" << endl;
cout << "3. Get Players Info" << endl;
cout << "4. Get Property Info" << endl;
cout << "5. Morgage" << endl;
cout << "6. Buy House" << endl;
cout << "7. Buy Back Morgaged Property" << endl;
cout << "8. Trade" << endl;
cout << "9. Display Board" << endl;
cout << "10. End Turn" << endl;
cout << "----------------------------" << endl;
cout << "11. Withdraw" << endl;
cout << "12. QUIT GAME" << endl;
cin >> playerMenuOptions;
if(cin.fail())
{
cin.clear();
cin.ignore(1000, '\n');
cout << "\x1B[91m" << "You Entered a non-digit Input" << "\x1B[0m" << endl;
}
else
{
switch(playerMenuOptions)
{
case 1: //Display Current Player Balance
{
monopoly.currentPlayerBal();
break;
}
case 2: // Display Current Player List Of Owned Properties
{
monopoly.listOfOwnedProperties();
break;
}
case 3: // Displayer Other Players Info
{
monopoly.listOfOwnedProperties_ByOtherPlayers();
break;
}
case 4: // Get Property Info from (0-39)
{
int propertyLocation;
cout << "Enter from 0-39: ";
cin >> propertyLocation;
monopoly.getPropertyInfo(propertyLocation);
break;
}
case 5: // Morgage a Property
{
monopoly.morgage();
break;
}
case 6: //Buy Houses/hotel
{
if(monopoly.listOfOwnedProperties() != 0)
{
cout << "Which Property would you like to upgrade? ";
int location;
cin >> location;
monopoly.buyHouse(location);
}
else
{
cout << "You have no properties to build your houses on." << endl;
}
break;
}
case 7: // Buy back a morgaged property
{
monopoly.buyMorgaged();
break;
}
case 8: // Trade Menu
{
int tradeMenu;
cout << "-------------Trade Menu-------------" << endl;
cout << "1. Trade with Money" << endl;
cout << "2. Trade with Property" << endl;
cin >> tradeMenu;
if(tradeMenu == 1)
{
int wantedProperty;
int moneyDeal;
cout << "Which property do you want? (Enter from 0 - 39): ";
cin >> wantedProperty;
cout << "How much money do you want to trade? $";
cin >> moneyDeal;
if(wantedProperty >= 0 && wantedProperty <= 39)
{
monopoly.tradeWithMoney(wantedProperty, moneyDeal);
}
else
{
cout << "You entered a number outside of the range." << endl;
}
}
else if(tradeMenu == 2)
{
int IwantThis;
int IGiveYouThat;
cout << "Which property do you want? (Enter from 0 - 39): ";
cin >> IwantThis;
cout << "Which Property do you want to trade for property [" << IwantThis << "]? ";
cin >> IGiveYouThat;
if(IGiveYouThat >= 0 && IGiveYouThat <= 39 && IwantThis >= 0 && IwantThis <= 39)
{
monopoly.tradeWithProperty(IwantThis, IGiveYouThat);
}
else
{
cout << "You entered in a value outside of the range." << endl;
}
}
break;
}
case 9: // Re-display board
{
monopoly.display_MapAndPlayer();
break;
}
case 10: // End Turn
{
if(monopoly.getDisplayStatus() == true)
{
cout << "\x1B[92m" << "[Mr.Monopoly]" << "\x1B[0m" << " --> " << "\x1B[97m" << "[" << monopoly.getPlayerUsername_GAME(currentTurn) << "]" << "\x1B[0m" << " You have an extra turn!"<< endl;
}
if(monopoly.getDisplayStatus() == false)
{
monopoly.setDisplayStatus(true);
monopoly.endTurn();
}
break;
}
case 11: // Individuals may withdraw from game
{
int repeater = 0;
while(repeater == 0)
{
cout << "Are you sure you want to withdraw from the game?" << endl;
cout << "NOTE* That withdrawing from this game means that you will have declared bankruptcy!" << endl;
cout << "Enter QUIT or Enter CANCEL. Ensure the letters are completely capitalized." << endl;
string entry;
cin >> entry;
if(entry == "QUIT")
{
monopoly.bankrupt();
repeater = 1;
}
else if(entry == "CANCEL")
{
cout << "The game goes on." << endl;
repeater = 1;
}
else
{
cout << "Invalid input." << endl;
}
}
break;
}
case 12: // End all game
{
int repeater = 0;
while(repeater == 0)
{
cout << "Are you sure you want to quit?" << endl;
cout << "NOTE* This command will stop the game completetly" << endl;
cout << "Enter QUIT or Enter CANCEL. Ensure the letters are completely capitalized." << endl;
string entry;
cin >> entry;
if(entry == "QUIT")
{
quitcounter = 1;
repeater = 1;
}
else if(entry == "CANCEL")
{
cout << "The game goes on." << endl;
repeater = 1;
}
else
{
cout << "Invalid input." << endl;
}
}
break;
}
case 13: //GOD MODE: buy function at any location
{
int propertyLocation;
cout << "Enter property Location: ";
cin >> propertyLocation;
int player;
cout << "Choose your player (1-4): ";
cin >> player;
monopoly.buy(propertyLocation, player);
break;
}
default:
cout << "You have entered an option that does not exits." << endl;
break;
}
}
}
}
else
{
monopoly.endTurn();
}
} while (quitcounter == 0);
monopoly.endGame();
// for(int i = 0; i <= 3492; i++)
// {
// cout << "HELP US. WE DID " << i << " lines!";
// }
// cout << endl;
return 0;
}