-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGameController.java
More file actions
314 lines (233 loc) · 8.16 KB
/
Copy pathGameController.java
File metadata and controls
314 lines (233 loc) · 8.16 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
import javafx.geometry.Pos;
import javafx.geometry.Insets;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.text.*;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
public class GameController {
private Button b1, b2, b3, b4, b5, b6, b7, b8, b9;
private MenuBar menuBar;
private Menu menu;
private MenuItem menuItemRules;
private MenuItem menuItemOdds;
private MenuItem menuItemMatch;
private MenuItem menuItemExit;
private MenuItem menuItemLook;
private BorderPane layout;
private HBox centeredMenu;
private HBox spotQuestChoices;
private HBox drawQuestChoices;
private VBox components;
private Text spotQuest;
private Text drawQuest;
private static final int ROWS = 8;
private static final int COLS = 10;
private final SceneManager sceneManager;
private final KenoGame game;
private StackPane stackPane2;
public GameController(SceneManager sceneManager, KenoGame game) {
this.sceneManager = sceneManager;
this.game = game;
// Set menu options
menuBar = new MenuBar();
menu = new Menu("Menu");
menuItemRules = new MenuItem("Game Rules");
menuItemOdds = new MenuItem("Winning Odds");
menuItemMatch = new MenuItem("Play a Match");
menuItemExit = new MenuItem("Exit");
menuItemLook = new MenuItem("New Look");
menu.getItems().addAll(menuItemRules, menuItemOdds, menuItemMatch,
menuItemExit, menuItemLook);
menuBar.getMenus().add(menu);
centeredMenu = new HBox(menuBar);
centeredMenu.setAlignment(Pos.CENTER);
// Set Questions and background shape
spotQuest = new Text("How many spots do you want to play?");
spotQuest.setFont(new Font(15));
drawQuest = new Text("How many consecutive draws?");
drawQuest.setFont(new Font(15));
Rectangle rect = new Rectangle(550, 80);
rect.setFill(Color.ORANGE);
rect.setArcHeight(50);
rect.setArcWidth(50);
// Set buttons
b1 = new Button("1");
b1.setMinWidth(10);
b2 = new Button("4");
b2.setMinWidth(10);
b3 = new Button("8");
b3.setMinWidth(10);
b4 = new Button("10");
b4.setMinWidth(10);
b5 = new Button("Auto Select");
b5.setMinWidth(10);
spotQuestChoices = new HBox(10);
spotQuestChoices.getChildren().addAll(spotQuest, b1, b2, b3, b4, b5);
spotQuestChoices.setAlignment(Pos.TOP_CENTER);
b6 = new Button("1");
b6.setMinWidth(10);
b7 = new Button("2");
b7.setMinWidth(10);
b8 = new Button("3");
b8.setMinWidth(10);
b9 = new Button("4");
b9.setMinWidth(10);
drawQuestChoices = new HBox(10);
drawQuestChoices.getChildren().addAll(drawQuest, b6, b7, b8, b9);
drawQuestChoices.setAlignment(Pos.TOP_CENTER);
// Set Button Grid
GridPane grid = new GridPane();
int counter = 1;
for (int r = 0; r < ROWS; ++r) {
for (int c = 0; c < COLS; ++c) {
Button b0 = new Button("" + counter);
b0.setPrefSize(50, 50);
b0.setFont(new Font(20));
grid.add(b0, c, r);
counter++;
}
}
HBox centeredGrid = new HBox(10);
centeredGrid.getChildren().addAll(grid);
centeredGrid.setAlignment(Pos.CENTER);
// Vertically space out all components
components = new VBox(25);
components.getChildren().addAll(spotQuestChoices, drawQuestChoices, centeredGrid);
// Center all components
stackPane2 = new StackPane();
stackPane2.getChildren().addAll(rect, components);
stackPane2.setAlignment(Pos.TOP_CENTER);
// wire menu actions
menuItemRules.setOnAction(e -> onShowRules());
menuItemOdds.setOnAction(e -> onShowOdds());
menuItemMatch.setOnAction(e -> onShowMatch());
menuItemExit.setOnAction(e -> onExit());
menuItemLook.setOnAction(e -> onShowLook());
// Set layout components
layout = new BorderPane();
layout.setTop(centeredMenu);
layout.setCenter(stackPane2);
layout.setPrefSize(900, 600);
layout.setBackground(new Background (new BackgroundFill(
Color.PURPLE,
CornerRadii.EMPTY,
Insets.EMPTY
)));
}
public Parent getRoot() {
return layout;
}
// --- public methods per UML ---
public void onShowRules() {
// Header
Text RulesSign = new Text("Game Rules");
RulesSign.setFont(new Font(25));
// Description
Text DescriptRules = new Text(
"As a player, you can only select the number\n "
+ "of spots you want at the beginning of the\n"
+ "match. This also applies to the number of\n"
+ "draws you want. You will not be able to\n"
+ "make any changes once the draw begins.\n\n\n\n\n\n");
DescriptRules.setFont(new Font(15));
// Backdrop
Rectangle rectRules = new Rectangle(300, 400);
rectRules.setFill(Color.ORANGE);
rectRules.setArcHeight(50);
rectRules.setArcWidth(50);
// Align Header, Description, and Backdrop
StackPane stackPane2 = new StackPane();
stackPane2.getChildren().addAll(rectRules, RulesSign, DescriptRules);
StackPane.setAlignment(RulesSign, Pos.CENTER);
RulesSign.setTranslateY(-180);
layout.setCenter(stackPane2);
}
public void onShowOdds() {
// Header
Text RulesSign = new Text("Winning Odds");
RulesSign.setFont(new Font(25));
// Description
Text DescriptOdds = new Text(
"Winning odds increase if you choose\n"
+ "more spots on your bet card and if you\n"
+ "do more than one draw. There are 80 spots\n"
+ "on the bet card. If you are choosing to do\n"
+ "one draw, your odds of winning are shown\n"
+ "below:\n"
+ "\n"
+ " 1 spot = 0.125%\r\n"
+ " 4 spot = 0.5%\r\n"
+ " 8 spot = 1%\r\n"
+ " 10 spot = 1.25%");
DescriptOdds.setFont(new Font(15));
// Backdrop
Rectangle rectRules = new Rectangle(300, 400);
rectRules.setFill(Color.ORANGE);
rectRules.setArcHeight(50);
rectRules.setArcWidth(50);
// Align Header, Description, and Backdrop
StackPane stackPane2 = new StackPane();
stackPane2.getChildren().addAll(rectRules, RulesSign, DescriptOdds);
StackPane.setAlignment(RulesSign, Pos.CENTER);
RulesSign.setTranslateY(-180);
layout.setCenter(stackPane2);
}
public void onShowMatch() {
// swap to the game scene registered by ViewFactory
sceneManager.show("game");
}
public void onExit() {
// Set welcome text and background shape
Text welcomeText = new Text("Welcome to the Lottery Zone!");
welcomeText.setFont(new Font(40));
welcomeText.setFill(Color.ORANGE);
Rectangle rect = new Rectangle(550, 80);
rect.setFill(Color.BLACK);
rect.setArcHeight(50);
rect.setArcWidth(50);
StackPane stackPane3 = new StackPane();
stackPane3.getChildren().addAll(rect, welcomeText);
// Set layout
layout.setCenter(stackPane3);
}
public void onShowLook() {
// Set layout components
BorderPane layout2 = new BorderPane();
layout2.setPrefSize(900, 600);
layout2.setBackground(new Background (new BackgroundFill(
Color.GREEN,
CornerRadii.EMPTY,
Insets.EMPTY
)));
}
public void enableCard() {
}
public void disableCard() {
}
public void updateStatus(/*text String*/) {
}
public void populateGrid() {
}
public void selectNumber(/*n int*/) {
}
public void autoPick() {
}
public void startDrawings() {
}
public void nextDrawings() {
}
public void showResult() {
}
}