This repository was archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTempBoard.java
More file actions
552 lines (504 loc) · 21 KB
/
TempBoard.java
File metadata and controls
552 lines (504 loc) · 21 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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
public class TempBoard extends JFrame{
private gameBoardP gameBoard;
private JSplitPane split;
private JLayeredPane lp;
private static JTextArea outputArea;
private JScrollPane outputPane;
private JPanel bottomButtonsP;
private JPanel bottomInfoP;
private JButton rollB;
private JButton endTurnB;
private JButton buyB;
private JButton propListB;
private JButton sellB;
private JButton mortgageB;
GridBagConstraints c = new GridBagConstraints();
private static JLabel p1MoneyL; private static JLabel p2MoneyL;
private static JLabel p1PosL; private static JLabel p2PosL;
private static String p1Name; private static String p2Name;
private JLabel dice1L; private JLabel dice2L;
private static int dice1; private static int dice2; private boolean doubleDice;
public TempBoard(String p1Name, String p2Name) {
this.p1Name = p1Name;
this.p2Name = p2Name;
createButtons();
//Frame
setSize(1300, 1250);
setTitle("Monopoly");
setLayout(new BorderLayout());
add(split, BorderLayout.CENTER);
add(bottomButtonsP, BorderLayout.SOUTH);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gameBoard.setMinimumSize(new Dimension(1000, 1000));
outputPane.setMinimumSize(new Dimension(150, 1000));
bottomButtonsP.setPreferredSize(new Dimension(1000, 150));
c.insets = new Insets(5,5,5,5);
c.gridx = 0; c.gridy = 0;
bottomButtonsP.add(p1PosL, c);
c.gridx = 0; c.gridy = -1;
bottomButtonsP.add(p1MoneyL,c);
c.gridx = 7; c.gridy = 0;
bottomButtonsP.add(p2PosL, c);
c.gridx = 7; c.gridy = -1;
bottomButtonsP.add(p2MoneyL,c);
c.gridx = 1; c.gridy = 1; //ROLL BUTTON
bottomButtonsP.add(rollB,c);
rollB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dice1 = Monopoly.rollDice();
dice2 = Monopoly.rollDice();
int steps = dice1 + dice2;
if (Monopoly.hasRolled() == true) {
output(Monopoly.getCurrentPlayer().getName() + " has already rolled!");
}
else {
output("Dice 1: " + dice1);
output("Dice 2: " + dice2);
if (dice1 == dice2) {
doubleDice = true;
output(Monopoly.getCurrentPlayer().getName() + " has rolled a double!");
}
Monopoly.movePlayer(steps);
}
Monopoly.playerRolled(true);
}
});
//END TURN BUTTON
c.gridx = 6; c.gridy = 1; bottomButtonsP.add(endTurnB,c);
endTurnB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Monopoly.endTurn(doubleDice);
doubleDice = false;
}
});
//BUY PROPERTIES BUTTON
c.gridx = 2; c.gridy = 1; bottomButtonsP.add(buyB, c);
buyB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int currPos = Monopoly.getCurrentPlayer().getPos();
GridBagConstraints s = new GridBagConstraints();
JFrame buyWindow = new JFrame();
buyWindow.setSize(500, 250);
buyWindow.setVisible(true);
buyWindow.setTitle("Purchase Properties/Houses/Hotels");
JPanel buyPanel = new JPanel(new GridBagLayout());
buyPanel.setBackground(new Color(0xcce4d2));
JLabel options = new JLabel("Please select an option for Player " + Monopoly.getCurrentPlayer().getName());
JButton buyCurrentTile = new JButton("Purchase current tile");
JButton buyHouses = new JButton("Purchase houses");
JButton cancel = new JButton("Cancel");
s.insets = new Insets(5, 5, 5, 5);
s.gridx = 0; s.gridy = 1; buyPanel.add(buyCurrentTile, s);
s.gridx = 1; s.gridy = 0; buyPanel.add(options, s);
s.gridx = 1; s.gridy = 1; buyPanel.add(buyHouses, s);
s.gridx = 2; s.gridy = 1;buyPanel.add(cancel, s);
buyWindow.add(buyPanel);
JFrame buyWindow2 = new JFrame();
buyWindow2.setSize(800, 250);
buyWindow2.setVisible(false);
JPanel buyPanel2 = new JPanel(new GridBagLayout()); buyPanel2.setBackground(new Color(0xcce4d2));
buyPanel2.setMinimumSize(new Dimension(500, 250));
JLabel buyLabel = new JLabel("Enter tile # of property you wish to buy houses for: ");
JTextField buyInput = new JTextField(2);
JButton confirmBuy = new JButton("Ok");
JLabel errorMSG = new JLabel("");
errorMSG.setVisible(false);
s.gridx = 0; s.gridy = 0; buyPanel2.add(buyLabel, s);
s.gridx = 0; s.gridy = 1; buyPanel2.add(buyInput, s);
s.gridx = 1; s.gridy = 1; buyPanel2.add(confirmBuy, s);
s.gridx = 0; s.gridy = 2; buyPanel2.add(errorMSG, s);
JTextArea buyOutputArea = new JTextArea(Monopoly.getCurrentPlayer().getName() + "'s Properties:\n");
buyOutputArea.setEditable(false);
buyOutputArea.setLineWrap(true);
JScrollPane buyOutputPane = new JScrollPane(buyOutputArea);
JSplitPane splitSell = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, buyPanel2, buyOutputPane);
buyWindow2.add(splitSell);
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
buyWindow.setVisible(false);
}
});
buyCurrentTile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
buyWindow.setVisible(false);
int owner = Squares.getOwner(currPos);
Monopoly.buyProperty(currPos);
}
});
buyHouses.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
buyWindow.setVisible(false);
buyWindow2.setTitle("Buying houses/hotels");
buyWindow2.setVisible(true);
JButton cancel1 = new JButton("Cancel");
for (String propName : Monopoly.getCurrentPlayer().getPropertiesList()) {
buyOutputArea.append(propName + "\n");
}
int tileNum = Integer.parseInt(buyInput.getText());
int owner = Squares.getOwner(tileNum);
Monopoly.buyHouses(tileNum);
}
catch (NumberFormatException x){
errorMSG.setText("Please enter TILE NUMBER of property you wish to purchase a house for.");
errorMSG.setVisible(true);
}
}
});
}
});
//SELL BUTTON
c.gridx = 4;
c.gridy = 1;
bottomButtonsP.add(sellB,c);
sellB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
GridBagConstraints s = new GridBagConstraints();
JFrame sellWindow = new JFrame();
sellWindow.setSize(500, 250);
sellWindow.setVisible(true);
sellWindow.setTitle("Selling Properties");
JPanel sellPanel = new JPanel(new GridBagLayout());
sellPanel.setBackground(new Color(0xcce4d2));
JLabel options = new JLabel("Please select an option for Player " + Monopoly.getCurrentPlayer().getName());
JButton sellToBank = new JButton("Sell to Bank");
JButton sellToPlayer = new JButton("Sell to Other Player");
JButton cancel = new JButton("Cancel");
s.insets = new Insets(5, 5, 5, 5);
s.gridx = 0; s.gridy = 1; sellPanel.add(sellToBank, s);
s.gridx = 1; s.gridy = 0; sellPanel.add(options, s);
s.gridx = 1; s.gridy = 1; sellPanel.add(sellToPlayer, s);
s.gridx = 2; s.gridy = 1;sellPanel.add(cancel, s);
sellWindow.add(sellPanel);
JFrame sellWindow2 = new JFrame();
sellWindow2.setSize(800, 250);
sellWindow2.setVisible(false);
JPanel sellPanel2 = new JPanel(new GridBagLayout()); sellPanel2.setBackground(new Color(0xcce4d2));
sellPanel2.setMinimumSize(new Dimension(500, 250));
JLabel sellLabel = new JLabel("Enter tile # of property you wish to sell: ");
JTextField sellInput = new JTextField(2);
JButton confirmSell = new JButton("Ok");
JLabel errorMSG = new JLabel("SLATT");
errorMSG.setVisible(false);
s.gridx = 0; s.gridy = 0; sellPanel2.add(sellLabel, s);
s.gridx = 0; s.gridy = 1; sellPanel2.add(sellInput, s);
s.gridx = 1; s.gridy = 1; sellPanel2.add(confirmSell, s);
s.gridx = 0; s.gridy = 2; sellPanel2.add(errorMSG, s);
JTextArea sellOutputArea = new JTextArea(Monopoly.getCurrentPlayer().getName() + "'s Properties:\n");
sellOutputArea.setEditable(false);
sellOutputArea.setLineWrap(true);
JScrollPane sellOutputPane = new JScrollPane(sellOutputArea);
JSplitPane splitSell = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sellPanel2, sellOutputPane);
sellWindow2.add(splitSell);
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sellWindow.setVisible(false);
}
});
sellToBank.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sellWindow.setVisible(false);
sellWindow2.setTitle("Selling to Bank");
sellWindow2.setVisible(true);
JButton cancel1 = new JButton("Cancel");
for (String propName : Monopoly.getCurrentPlayer().getPropertiesList()) {
sellOutputArea.append(propName + "\n");
}
confirmSell.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
int input = Integer.parseInt(sellInput.getText());
if (Squares.getOwner(input) != Monopoly.getCurrentPlayer().getPlayerNum()) {
errorMSG.setVisible(true);
if (Squares.getOwner(input) == Monopoly.getOtherPlayer().getPlayerNum())
errorMSG.setText(Squares.getName(input) + " belongs to " + Monopoly.getOtherPlayer().getName());
else
errorMSG.setText(Squares.getName(input) + " is unowned or cannot be sold!");
}
else {
output(Monopoly.getCurrentPlayer().getName() + " has sold " + Squares.getName(input) + " to the bank for "
+ "$" + Squares.getTilePrice(input)/2);
Squares.setOwner(0, input);
Monopoly.getCurrentPlayer().addMoney(Squares.getTilePrice(input)/2);
updateMoney();
sellWindow2.setVisible(false);
}
}
catch (NumberFormatException err) {
errorMSG.setVisible(true);
errorMSG.setText("Please enter TILE NUMBER of property you want to sell!");
}
}
});
cancel1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sellWindow2.setVisible(false);
}
});
}
});
sellToPlayer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sellWindow.setVisible(false);
sellWindow2.setTitle("Selling to Player");
sellWindow2.setVisible(true);
for (String propName : Monopoly.getCurrentPlayer().getPropertiesList()) {
sellOutputArea.append(propName + "\n");
}
JTextField sellInput2 = new JTextField(3);
JLabel sellLabel2 = new JLabel("Enter listing price: ");
s.gridx = 0; s.gridy = 0; sellPanel2.add(sellLabel, s);
s.gridx = 1; s.gridy = 0; sellPanel2.add(sellLabel2, s);
s.gridx = 0; s.gridy = 1; sellPanel2.add(sellInput, s);
s.gridx = 1; s.gridy = 1; sellPanel2.add(sellInput2, s);
s.gridx = 2; s.gridy = 1; sellPanel2.add(confirmSell, s);
s.gridx = 0; s.gridy = 2; sellPanel2.add(errorMSG, s);
JFrame sellWindow3 = new JFrame(); sellWindow3.setTitle("Confirm"); sellWindow3.setSize(500, 250);
JPanel sellPanel3 = new JPanel(new GridBagLayout()); sellPanel3.setBackground(new Color(0xcce4d2));
JLabel confirmSellLabel = new JLabel();
JButton acceptButton = new JButton("Accept Offer");
JButton declineButton = new JButton("Decline Offer");
s.gridx = 0; s.gridy = 0; sellPanel3.add(confirmSellLabel, s);
s.gridx = 0; s.gridy = 1; sellPanel3.add(acceptButton, s);
s.gridx = 1; s.gridy = 1; sellPanel3.add(declineButton, s);
sellWindow3.add(sellPanel3);
confirmSell.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sellWindow2.setVisible(false);
try {
int input = Integer.parseInt(sellInput.getText());
int inputPrice = Integer.parseInt(sellInput2.getText());
if (Squares.getOwner(input) != Monopoly.getCurrentPlayer().getPlayerNum()) {
errorMSG.setVisible(true);
if (Squares.getOwner(input) == Monopoly.getOtherPlayer().getPlayerNum())
errorMSG.setText(Squares.getName(input) + " belongs to " + Monopoly.getOtherPlayer().getName());
else
errorMSG.setText(Squares.getName(input) + " is unowned or cannot be sold!");
}
else {
confirmSellLabel.setText(Monopoly.getCurrentPlayer().getName() + " wants to sell " + Squares.getName(input) +
" for $" + inputPrice);
sellWindow3.setVisible(true);
acceptButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sellWindow3.setVisible(false);
output(Monopoly.getCurrentPlayer().getName() + " has sold " + Squares.getName(input) + " to " +
Monopoly.getOtherPlayer().getName() + " for $" + inputPrice);
Monopoly.getCurrentPlayer().addMoney(inputPrice);
Monopoly.getOtherPlayer().subtractMoney(inputPrice);
Squares.setOwner(Monopoly.getOtherPlayer().getPlayerNum(), input);
Monopoly.getOtherPlayer().addProperty(input);
Monopoly.getCurrentPlayer().removeProperty(input);
updateMoney();
}
});
declineButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sellWindow3.setVisible(false);
output(Monopoly.getOtherPlayer().getName() + " has declined " + Monopoly.getCurrentPlayer().getName() +
"'s offer of " + Squares.getName(input) + " for $" + inputPrice);
}
});
}
}
catch (NumberFormatException err) {
errorMSG.setVisible(true);
errorMSG.setText("Please enter the NUMBER of the tile you want to sell!");
}
}
});
}
});
}
});
//MORTGAGE BUTTON
c.gridx = 3;
c.gridy = 1;
bottomButtonsP.add(mortgageB,c);
mortgageB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
GridBagConstraints m = new GridBagConstraints();
JFrame mortgageWindow = new JFrame();
mortgageWindow.setSize(800, 250);
mortgageWindow.setVisible(true);
JPanel mortgagePanel = new JPanel(new GridBagLayout());
mortgagePanel.setBackground(new Color(0xcce4d2));
mortgagePanel.setMinimumSize(new Dimension(500, 250));
JLabel mortgageLabel = new JLabel("Enter tile # of property you wish to mortgage: ");
JTextField mortgageInput = new JTextField(2);
JButton confirmMortgage = new JButton("Ok");
JButton cancelButton = new JButton("Cancel");
JLabel errorMSG = new JLabel("null");
errorMSG.setVisible(false);
m.gridx = 0;
m.gridy = 0;
mortgagePanel.add(mortgageLabel, m);
m.gridx = 0;
m.gridy = 1;
mortgagePanel.add(mortgageInput, m);
m.gridx = 1;
m.gridy = 1;
mortgagePanel.add(confirmMortgage, m);
m.gridx = 2;
m.gridy = 1;
mortgagePanel.add(cancelButton, m);
m.gridx = 0;
m.gridy = 0;
mortgagePanel.add(errorMSG, m);
JTextArea mortgageOutputArea = new JTextArea(Monopoly.getCurrentPlayer().getName() + "'s Properties:\n");
mortgageOutputArea.setEditable(false);
mortgageOutputArea.setLineWrap(true);
JScrollPane mortgageOutputPane = new JScrollPane(mortgageOutputArea);
JSplitPane splitmortgage = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mortgagePanel, mortgageOutputPane);
mortgageWindow.add(splitmortgage);
for (String propName : Monopoly.getCurrentPlayer().getPropertiesList()) {
mortgageOutputArea.append(propName + "\n");
}
confirmMortgage.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
mortgageWindow.setVisible(false);
int input = Integer.parseInt(mortgageInput.getText());
if (Squares.getTileProp(input, 5) == -1) {
output("Cannot mortgage this tile!");
}
else if (Squares.getTileProp(input, 5) == 1) {
output(Squares.getName(input) + " is already mortgaged!");
}
else {
output(Monopoly.getCurrentPlayer().getName() + " has mortgaged " + Squares.getName(input) + " and has received "
+ "$" + Squares.getTilePrice(input)/2);
Squares.mortgage(input);
Monopoly.getCurrentPlayer().addMoney(Squares.getTilePrice(input)/2);
updateMoney();
}
}
catch (NumberFormatException err){
errorMSG.setText("Please enter TILE NUMBER of property to mortgage!");
errorMSG.setVisible(true);
}
}
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mortgageWindow.setVisible(false);
}
});
}
});
//VIEW PROPERTIES BUTTON
c.gridx = 5; c.gridy = 1; bottomButtonsP.add(propListB, c);
propListB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
output(Monopoly.getCurrentPlayer().getName() + "'s owned properties: ");
for (String propName : Monopoly.getCurrentPlayer().getPropertiesList()) {
output(propName);
}
output("");
}
});
}
private void createButtons() {
gameBoard = new gameBoardP("MonopolyBoard.gif");
bottomButtonsP = new JPanel(new GridBagLayout());
lp = getLayeredPane();
outputArea = new JTextArea("Monopoly Semester Project\nCreated by David Nguyen, Period 1\n\n");
outputArea.setEditable(false);
outputArea.setLineWrap(true);
outputPane = new JScrollPane(outputArea);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameBoard, outputPane);
rollB = new JButton("Roll Dice");
endTurnB = new JButton("End Turn");
buyB = new JButton("Purchase Property");
propListB = new JButton("View Owned Properties");
sellB = new JButton("Sell Property");
mortgageB = new JButton("Mortgage Property");
p1MoneyL = new JLabel(p1Name + " $: 1500");
p1PosL = new JLabel(p1Name + " is at \"Go\".");
p2MoneyL = new JLabel(p2Name + " $: 1500");
p2PosL = new JLabel(p2Name + " is at \"Go\".");
}
public void updateMoney() {
p1MoneyL.setText(p1Name + "$: " + Monopoly.getPlayer1().getMoney());
p2MoneyL.setText(p2Name + "$: " + Monopoly.getPlayer2().getMoney());
}
public void updatePos() {
p1PosL.setText(p1Name + " is at " + Squares.getName(Monopoly.getPlayer1().getPos()));
p2PosL.setText(p2Name + " is at " + Squares.getName(Monopoly.getPlayer2().getPos()));
}
public void jailGUI() {
GridBagConstraints j = new GridBagConstraints();
JFrame jailWindow = new JFrame();
jailWindow.setSize(500, 250);
jailWindow.setVisible(true);
jailWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jailWindow.setTitle(Monopoly.getCurrentPlayer().getName() + " is currently in jail.");
JPanel jailPanel = new JPanel(new GridBagLayout());
JTextField jailInput = new JTextField(30);
JLabel options = new JLabel("Select an option: (Enter 1 or 2)");
JLabel option1 = new JLabel("1: Pay a $50 fine to get out of jail");
JLabel option2 = new JLabel("2: Roll dice (If a double is rolled, player is released from jail)");
JButton enter = new JButton("Enter");
JLabel error = new JLabel("Please enter 1 or 2!");
j.gridx = 0; j.gridy = 0; jailPanel.add(options, j);
j.gridx = 0; j.gridy = 1; jailPanel.add(option1, j);
j.gridx = 0; j.gridy = 2; jailPanel.add(option2,j);
j.gridx = 0; j.gridy = 3; jailPanel.add(jailInput, j);
j.gridx = 1; j.gridy = 3; jailPanel.add(enter, j);
j.gridx = 0; j.gridy = 4; jailPanel.add(error, j);
jailWindow.add(jailPanel);
enter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
int input = Integer.parseInt(jailInput.getText());
if (input != 2 && input != 1) {
jailGUI();
}
else {
if (input == 1) {
output(Monopoly.getCurrentPlayer().getName() + " has paid a $50 fine to get out of jail.");
Monopoly.getCurrentPlayer().subtractMoney(50);
Monopoly.getCurrentPlayer().changeJailStatus(false);
p1MoneyL.setText(p1Name + "$: " + Monopoly.getPlayer1().getMoney());
p2MoneyL.setText(p2Name + "$: " + Monopoly.getPlayer2().getMoney());
}
else if (input == 2) {
dice1 = Monopoly.rollDice();
dice2 = Monopoly.rollDice();
output("Dice 1: " + dice1);
output("Dice 2: " + dice2);
Monopoly.playerRolled(true);
if (dice1 == dice2) {
output(Monopoly.getCurrentPlayer().getName() + " has rolled a double and is free from jail!");
Monopoly.getCurrentPlayer().changeJailStatus(false);
Monopoly.movePlayer(dice1 + dice2);
}
else
output(Monopoly.getCurrentPlayer().getName() + " failed to roll a double and stays in jail.");
}
}
jailWindow.setVisible(false);
}
catch (NumberFormatException err) {}
}
});
}
public void output(String txt) {
outputArea.append(txt + "\n");
}
class gameBoardP extends JPanel {
private Image image;
public gameBoardP(String img) {
image = new ImageIcon(img).getImage();
}
public void paintComponent(Graphics g) {
g.drawImage(image, 0, 0, null);
}
}
}