-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTradePropertyPopUp.java
292 lines (215 loc) · 9.02 KB
/
TradePropertyPopUp.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
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/** Class to implement the trade property pop up of the GUI, containing
* description of the property and button choices
* @author Joseph
*
* Credits: http://monopoly.wikia.com/wiki/Property
*/
public class TradePropertyPopUp {
// /** Board image. */
// private Image _board;
// /** Background image. */
// private Image _background;
// /** The game GUI */
// private MonopolyGUI _gui;
// /** On button click -> paint the property */
// private boolean _paintClick;
// /** Names of the properties that was clicked on by current*/
// private Property[] _propertyListCurrent;
// /** Names of the properties thta was clicked on by offered */
// private Property[] _propertyListOffered;
// /** The current player making the trade */
// private Player _current;
// /** The offered player making the trade */
// private Player _offered;
// /** The Monopoly game */
// private Monopoly _game;
// /** The Mortgage Initialized */
// private boolean _initialized;
// /** HashMap containing all of the property locations based on the
// * X and Y coordinates from boardlocs.txt. */
// private HashMap<String, Location> _locations;
// public TradePropertyPopUp(MonopolyGUI gui, Monopoly game, Player current, Player offered) {
// super();
// _gui = gui;
// _game = game;
// _current = current;
// _current = current;
// setPropertyLocations();
// this.setOpaque(false);
// this.setLayout(null);
// InputStream in1 = getClass().getResourceAsStream(
// "resources/wood.jpg");
// try {
// _background = ImageIO.read(in1);
// } catch (IOException e) {
// System.out.println("error loading background image");
// System.exit(1);
// }
// InputStream in2 = getClass().getResourceAsStream(
// "resources/board.jpg");
// try {
// _board = ImageIO.read(in2);
// } catch (IOException e) {
// System.out.println("error loading board image.");
// System.exit(1);
// }
// }
// @Override
// protected void paintComponent(Graphics g) {
// g.drawImage(_background, 0, 0, 800, 650, null);
// drawBoard((Graphics2D) g);
// drawPropertyButtons((Graphics2D) g);
// drawButtons((Graphics2D) g);
// if (_paintClick) {
// clickDraw((Graphics2D) g);
// }
// drawPropertyMarkers((Graphics2D) g);
// }
// /** Draws the board itself. */
// private void drawBoard(Graphics2D g) {
// g.drawImage(_board, 30, 40, 425, 425, null);
// }
// /** Draws the Graphics Jbuttons for the GUI */
// private void drawButtons(Graphics2D g) {
// }
// /** Draw property markers, indicating who owns which property. */
// private void drawPropertyMarkers(Graphics2D g) {
// Player[] players = _game.players();
// for (int i = 1; i < players.length; i++) {
// Player next = players[i];
// if (next == null) {
// continue;
// }
// for (String group : next.properties().keySet()) {
// for (Property p : next.properties().get(group)) {
// g.setColor(Monopoly.COLORS[i]);
// Location loc = _locations.get(p.name());
// int x = loc.x;
// int y = loc.y;
// if (loc.side.equals("top")) {
// y -= 13;
// g.fillRoundRect(x + 3, y, SHORT - 3, 8, ARC, ARC);
// if (p.isFull()) {
// g.drawRect(loc.x, loc.y, SHORT, LONG);
// }
// if (p.isMortgaged()) {
// g.setColor(new Color(155, 0, 0));
// Font font = new Font("Arial",
// Font.BOLD, 25);
// g.setFont(font);
// g.drawString("M", loc.x + (SHORT / 4),
// loc.y + (LONG / 2) + 5);
// }
// } else if (loc.side.equals("left")) {
// x -= 13;
// g.fillRoundRect(x, y + 3, 8, SHORT - 3, ARC, ARC);
// if (p.isFull()) {
// g.drawRect(loc.x, loc.y, LONG, SHORT);
// }
// if (p.isMortgaged()) {
// g.setColor(new Color(155, 0, 0));
// Font font = new Font("Arial",
// Font.BOLD, 25);
// g.setFont(font);
// g.drawString("M", loc.x + (SHORT / 4),
// loc.y + (LONG / 2));
// }
// } else if (loc.side.equals("right")) {
// x += (LONG + 5);
// g.fillRoundRect(x, y + 3, 8, SHORT - 3, ARC, ARC);
// if (p.isFull()) {
// g.drawRect(loc.x, loc.y, LONG, SHORT);
// }
// if (p.isMortgaged()) {
// g.setColor(new Color(155, 0, 0));
// Font font = new Font("Arial",
// Font.BOLD, 25);
// g.setFont(font);
// g.drawString("M", loc.x + (SHORT / 2),
// loc.y + (LONG / 2));
// }
// } else {
// y += (LONG + 5);
// g.fillRoundRect(x + 3, y, SHORT - 3, 8, ARC, ARC);
// if (p.isFull()) {
// g.drawRect(loc.x, loc.y, SHORT, LONG);
// }
// if (p.isMortgaged()) {
// g.setColor(new Color(155, 0, 0));
// Font font = new Font("Arial",
// Font.BOLD, 25);
// g.setFont(font);
// g.drawString("M", loc.x + (SHORT / 4),
// loc.y + (LONG / 2) + 15);
// }
// }
// }
// }
// }
// }
// /** Initializes the locations variable. */
// private void setPropertyLocations() {
// _locations = new HashMap<String, Location>();
// BufferedReader input = null;
// try {
// input = new BufferedReader(new FileReader(
// "resources/boardlocs.txt"));
// String next = input.readLine();
// while (next != null) {
// String[] info = next.split(",");
// int x = Integer.parseInt(info[1]);
// int y = Integer.parseInt(info[2]);
// _locations.put(info[0], new Location(x, y, info[3]));
// next = input.readLine();
// }
// input.close();
// } catch (FileNotFoundException e) {
// System.out.println("Error: boardlocs.txt not found");
// } catch (IOException e) {
// System.out.println("Error:Invalid input in boardlocs.txt file");
// }
// }
// /** Draws the property that was clicked on */
// private void clickDraw(Graphics2D g) {
// if ()
// g.setColor(Color.BLACK);
// if (_property.position().equals("vert")) {
// g.fillRoundRect(_property.x(), _property.y(), 34, 57, 1, 1);
// } else {
// g.fillRoundRect(_property.x(), _property.y(), 57, 34, 1, 1);
// }
// }
// /** Takes care of mortgage pop up buttons */
// @Override
// public void actionPerformed(ActionEvent e) {
// String actionPerformed = e.getActionCommand();
// if (actionPerformed.equals(""))
// _paintClick = true;
// for (BoardNode curr = _game.getBoard().next();
// !(curr.piece().name().equals("Go")); curr = curr.next()) {
// if (curr.piece() instanceof Property) {
// if (curr.piece().name().equals(actionPerformed)) {
// _property = (Property) curr.piece();
// }
// }
// }
// repaint();
// }
// /** Gets the property that was clicked */
// public Property property() {
// return _property;
// }
}