forked from cborder42/OverlakeMonopoly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlace.java
302 lines (207 loc) · 8.64 KB
/
Place.java
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
//Final Project
//Alec Zoe Felix Celina Gavin
//Overlake Monopoly
//place class creates the place objects of the game
import java.util.*;
public class Place {
private Player owner;
private int cost;
private int rent;
private String name;
private boolean isPlace;
private String isSpecial = "no";
private boolean finished = false;
private int set;
private int numHouses;
private String monopolies;
//special place constructor
public Place(String placeName, Player person, int costs, int rents, boolean place, String special) {
owner = person;
cost = costs;
rent = rents;
name = placeName;
isPlace = place;
isSpecial = special;
}
//non special constructor
public Place(String placeName, Player person, int costs, int rents, boolean place, int sets, int houses, String mono) {
owner = person;
cost = costs;
rent = rents;
name = placeName;
isPlace = place;
set = sets;
numHouses = houses;
monopolies = mono;
}
}
}
//Chance cards
if (this.isSpecial.toLowerCase().equals("card")) {
double randNum = (Math.random() * 5);
if (randNum < 1) {
System.out.println("You fail ap calc exam, Rhonda wants 50 dollars back. ");
play.take(50);
} else if (randNum < 1.25) {
System.out.println("Overlake cafeteria gave you salmonella. Hospital bills are expensive. Kim Stevens needs a raise after your projectile vomit. School sues.");
if (play.getBank() <= 1) {
play.take(1);
} else {
play.take(play.getBank() - 1);
}
} else if (randNum < 1.5) {
System.out.println("No more depression! Summer time.");
play.give(1000);
} else if (randNum < 1.6) {
System.out.println("u lost.");
play.take(play.getBank());
} else if (randNum < 3) {
System.out.println("Chris wants to give you donuts! You've been moved to Mathsci Conference Room");
play.move(23- 1 - play.getPos());
} else if (randNum < 4) {
System.out.println("You were caught cheating, and get sent to SRB.");
play.goToJail();
} else if (randNum < 5) {
//fix this and the one above
System.out.println("Your computer died, you go to the TLC tech center, but they break your computer, and you must pay $500");
play.take(500);
play.move(23- 1 - play.getPos());
}
}
//Company cards
if (this.isSpecial.toLowerCase().equals("company")) {
if (this.owner == null) {
System.out.println("Do you want to buy " + this.name + "? Cost to buy: " + cost + ". \"yes\" or \"no\"");
Scanner myObj = new Scanner(System.in);
String response = myObj.nextLine();
finished = false;
while (finished == false) {
if (response.toLowerCase().equals("yes")) {
play.take(cost);
this.owner = play;
play.addPlace(this);
finished = true;
} else if (response.toLowerCase().equals("no")) {
finished = true;
} else {
System.out.println("Not a valid response");
System.out.println("Do you want to buy " + this.name + "? Cost to buy: " + cost + ". \"yes\" or \"no\"");
response = myObj.nextLine();
}
}
} else if (this.owner == play) {
} else {
int randomRent = (int)(Math.random() * 6) + (int)(Math.random() * 6) + 2;
System.out.println("You rolled: " + randomRent + " and must pay: " + randomRent * 4);
play.take(randomRent * 4);
owner.give(randomRent * 4);
}
}
//jail
if (this.isSpecial.toLowerCase().equals("jail")) {
if (play.isJail()) {
if (play.getTimeJail() == 2) {
play.take(50);
System.out.println("You stayed in jail too long. Pay $50 bail and leave.");
play.outJail();
} else {
int roll1 = (int)(Math.random() * 6) + 1;
int roll2 = (int)(Math.random() * 6) + 1;
System.out.println(roll1);
System.out.println(roll2);
if (roll1 == roll2) {
play.outJail();
System.out.println("Lucky! You are out of jail. Make your move.");
} else {
System.out.println("Unlucky! You are still in jail.");
play.jailNextTurn();
}
}
}
}
if (this.isSpecial.toLowerCase().equals("gojail")) {
System.out.println("Your mom's going to jail. Bye bye.");
play.goToJail();
}
//Railroad Cards
if (this.isSpecial.toLowerCase().equals("railroad")) {
if (this.owner == null) {
System.out.println("Do you want to buy " + this.name + "? Cost to buy: " + cost + ". \"yes\" or \"no\"");
Scanner myObj = new Scanner(System.in);
String response = myObj.nextLine();
finished = false;
while (finished == false) {
if (response.toLowerCase().equals("yes")) {
play.take(cost);
this.owner = play;
play.addPlace(this);
finished = true;
} else if (response.toLowerCase().equals("no")) {
finished = true;
} else {
System.out.println("Not a valid response");
System.out.println("Do you want to buy " + this.name + "? Cost to buy: " + cost + ". \"yes\" or \"no\"");
response = myObj.nextLine();
}
}
} else if (this.owner == play) {
} else {
int numRailroads = 0;
for (Place a: owner.ownPlace()) {
//fix later (multiply by the number of railroads owned)
if (a.isSpecial.toLowerCase().equals("railroad")) {
numRailroads++;
}
}
System.out.println("You pay: " + (rent * Math.pow(2, numRailroads)));
owner.give(rent * (int)(Math.pow(2, numRailroads)));
play.take(rent * (int)(Math.pow(2, numRailroads)));
}
}
}
/*public void house(){
Scanner sc = new Scanner(System.in);
if(this.getIsSpecial().equals("no") && this.owner.ownPlace().size() > 1){
boolean checkAllOwned = true;
}
}
/*public void house(){
Scanner sc = new Scanner(System.in);
if(this.getIsSpecial().equals("no") && this.owner.ownPlace().size() > 1){
boolean checkAllOwned = true;
for(Place a: this.owner.ownPlace()){
if(a.getSet() == this.getSet() || a.getOwner() != owner){
checkAllOwned = false;
break;
}
}
if(checkAllOwned && numHouses < 4){
int housePrice = cost / 2;
System.out.println("Do you want to buy a house? It costs " + housePrice);
String input = sc.nextLine();
if(input.toLowerCase().equals("yes")){
owner.take(housePrice);
rent *= 3;
numHouses++;
System.out.println("Rent is now $" + rent);
System.out.println("You now have $" + this.owner.getBank());
}
}
}
}*/
public String getName() {
return this.name;
}
public String getIsSpecial() {
return this.isSpecial;
}
public int getSet() {
return this.set;
}
public Player getOwner() {
return this.owner;
}
public String getMono() {
return monopolies;
}
}