Skip to content

Commit 3ab4689

Browse files
committed
added phaseLabel, fixed tribute, show game message alwaysOnTop
1 parent d8dbc55 commit 3ab4689

File tree

5 files changed

+99
-55
lines changed

5 files changed

+99
-55
lines changed

src/main/java/controller/GameController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,4 +677,8 @@ public int getPlayerDeckSize() {
677677
public int getOpponentDeckSize() {
678678
return game.getOpponentGameBoard().getOwner().getUserDeck().getActiveDeck().getMainDeck().size();
679679
}
680+
681+
public String getGamePhase() {
682+
return game.getPhase();
683+
}
680684
}

src/main/java/view/gui/DuelMenuGui.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class DuelMenuGui extends MenuGui {
7272
public Text playerNickNameText;
7373
@FXML
7474
public Text playerUserNameText;
75+
@FXML
76+
public Label phaseLabel;
7577

7678
static {
7779
duelMenuMethods = DuelMenuGui.class.getDeclaredMethods();
@@ -200,6 +202,7 @@ public void updateGameBoard() {
200202
updatePlayerLifePoint();
201203
updateOpponentLifePoint();
202204
updateDecks();
205+
updatePhase();
203206
}
204207

205208
private void updateFields(ArrayList<String> cardData, String fieldName) {
@@ -319,6 +322,11 @@ private void updateDecks() {
319322
fieldPane.getChildren().addAll(playerDeckStackPane, opponentDeckStackPane);
320323
}
321324

325+
private void updatePhase() {
326+
String phase = gameController.getGamePhase();
327+
phaseLabel.setText(phase);
328+
}
329+
322330
private boolean getVisibility(String fieldName, String cardName) {
323331
boolean isVisible = true;
324332
if (fieldName.equals(CARD_FIELDS[3])) {
@@ -645,8 +653,9 @@ public ArrayList<Integer> getCardsForTribute(int i) {
645653
"Leave field empty to cancel summon.");
646654
String[] numbers = input.split(" ");
647655
ArrayList<Integer> positions = new ArrayList<>();
656+
// add (position - 1) to ArrayList because zero-indexed fields:
648657
for (String num : numbers)
649-
positions.add(Integer.parseInt(num));
658+
positions.add(Integer.parseInt(num) - 1);
650659
return positions;
651660
} catch (NumberFormatException exception) {
652661
showMessage("Invalid input format. Try again!");

src/main/java/view/gui/ShowGameMessage.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public void start(Stage prevStage) throws IOException {
3737
stage.initStyle(StageStyle.UNDECORATED);
3838
stage.toFront();
3939
stage.requestFocus();
40-
stage.setAlwaysOnTop(true);
4140

4241
stage.show();
4342
}

src/main/resources/view/gui/DuelMenuGui.fxml

Lines changed: 72 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
<?import javafx.scene.shape.*?>
1111
<?import javafx.scene.text.*?>
1212

13-
<BorderPane prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.gui.DuelMenuGui">
13+
<BorderPane prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/11.0.1"
14+
xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.gui.DuelMenuGui">
1415

1516
<stylesheets>
16-
<URL value="@styles/DuelMenuGui.css" />
17+
<URL value="@styles/DuelMenuGui.css"/>
1718
</stylesheets>
1819

1920
<center>
@@ -26,194 +27,218 @@
2627
<BorderPane prefHeight="600" prefWidth="210">
2728
<top>
2829
<VBox style="-fx-background-color: #eee0b1">
29-
<ProgressBar fx:id="opponentProgressBar" minWidth="210" progress="1" style="-fx-accent: green" />
30-
<Text fx:id="opponentNickNameText" style="-fx-fill: black; -fx-font-weight: bold;" text="opponent nickname: " />
31-
<Text fx:id="opponentUserNameText" style="-fx-fill: black; -fx-font-weight: bold;" text="opponent username: " />
30+
<ProgressBar fx:id="opponentProgressBar" minWidth="210" progress="1" style="-fx-accent: green"/>
31+
<Text fx:id="opponentNickNameText" style="-fx-fill: black; -fx-font-weight: bold;"
32+
text="opponent nickname: "/>
33+
<Text fx:id="opponentUserNameText" style="-fx-fill: black; -fx-font-weight: bold;"
34+
text="opponent username: "/>
3235
</VBox>
3336
</top>
3437
<center>
3538
<VBox alignment="CENTER" style="-fx-background-color: black">
3639
<HBox alignment="CENTER">
37-
<Rectangle fx:id="selectedCard" height="307" width="210" />
40+
<Rectangle fx:id="selectedCard" height="307" width="210"/>
3841
</HBox>
3942
<HBox alignment="CENTER">
40-
<Label fx:id="selectedCardDescription" alignment="TOP_LEFT" prefHeight="193" prefWidth="210" textAlignment="JUSTIFY" wrapText="true">
43+
<Label fx:id="selectedCardDescription" alignment="TOP_LEFT" prefHeight="193" prefWidth="210"
44+
textAlignment="JUSTIFY" wrapText="true">
4145
<padding>
42-
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
46+
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0"/>
4347
</padding>
4448
</Label>
4549
</HBox>
4650
</VBox>
4751
</center>
4852
<bottom>
4953
<VBox style="-fx-background-color: #eee0b1">
50-
<ProgressBar fx:id="playerProgressBar" minWidth="210" progress="1" style="-fx-accent: green" />
51-
<Text fx:id="playerNickNameText" style="-fx-fill: black; -fx-font-weight: bold;" text="player nickname: " />
52-
<Text fx:id="playerUserNameText" style="-fx-fill: black; -fx-font-weight: bold;" text="player username: " />
54+
<ProgressBar fx:id="playerProgressBar" minWidth="210" progress="1" style="-fx-accent: green"/>
55+
<Text fx:id="playerNickNameText" style="-fx-fill: black; -fx-font-weight: bold;"
56+
text="player nickname: "/>
57+
<Text fx:id="playerUserNameText" style="-fx-fill: black; -fx-font-weight: bold;"
58+
text="player username: "/>
5359
</VBox>
5460
</bottom>
5561
</BorderPane>
5662

5763
<BorderPane fx:id="buttonPane" prefHeight="600" prefWidth="120">
5864
<top>
5965
<HBox>
60-
<Button alignment="CENTER" onMouseClicked="#pause" prefHeight="26.0" prefWidth="110.0" text="pause">
66+
<Button alignment="CENTER" onMouseClicked="#pause" prefHeight="26.0" prefWidth="110.0"
67+
text="pause">
6168
<cursor>
62-
<Cursor fx:constant="HAND" />
69+
<Cursor fx:constant="HAND"/>
6370
</cursor>
6471
<effect>
6572
<DropShadow>
6673
<color>
67-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
74+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
6875
</color>
6976
</DropShadow>
7077
</effect>
7178
<HBox.margin>
72-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
79+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
7380
</HBox.margin>
7481
</Button>
7582
</HBox>
7683
</top>
7784
<center>
7885
<VBox alignment="CENTER">
7986
<HBox>
80-
<Button alignment="CENTER" onMouseClicked="#nextPhase" prefHeight="26.0" prefWidth="110.0" text="Next Phase">
87+
<Button alignment="CENTER" onMouseClicked="#nextPhase" prefHeight="26.0" prefWidth="110.0"
88+
text="Next Phase">
8189
<cursor>
82-
<Cursor fx:constant="HAND" />
90+
<Cursor fx:constant="HAND"/>
8391
</cursor>
8492
<effect>
8593
<DropShadow>
8694
<color>
87-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
95+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
8896
</color>
8997
</DropShadow>
9098
</effect>
9199
<HBox.margin>
92-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
100+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
93101
</HBox.margin>
94102
</Button>
95103
</HBox>
96104
<HBox>
97-
<Button alignment="CENTER" onMouseClicked="#summonCard" prefHeight="26.0" prefWidth="110.0" text="Summon">
105+
<Button alignment="CENTER" onMouseClicked="#summonCard" prefHeight="26.0" prefWidth="110.0"
106+
text="Summon">
98107
<cursor>
99-
<Cursor fx:constant="HAND" />
108+
<Cursor fx:constant="HAND"/>
100109
</cursor>
101110
<effect>
102111
<DropShadow>
103112
<color>
104-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
113+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
105114
</color>
106115
</DropShadow>
107116
</effect>
108117
<HBox.margin>
109-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
118+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
110119
</HBox.margin>
111120
</Button>
112121
</HBox>
113122
<HBox>
114-
<Button alignment="CENTER" onMouseClicked="#setCard" prefHeight="26.0" prefWidth="110.0" text="Set">
123+
<Button alignment="CENTER" onMouseClicked="#setCard" prefHeight="26.0" prefWidth="110.0"
124+
text="Set">
115125
<cursor>
116-
<Cursor fx:constant="HAND" />
126+
<Cursor fx:constant="HAND"/>
117127
</cursor>
118128
<effect>
119129
<DropShadow>
120130
<color>
121-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
131+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
122132
</color>
123133
</DropShadow>
124134
</effect>
125135
<HBox.margin>
126-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
136+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
127137
</HBox.margin>
128138
</Button>
129139
</HBox>
130140
<HBox>
131-
<Button alignment="CENTER" onMouseClicked="#changePosition" prefHeight="26.0" prefWidth="110.0" text="Change Position">
141+
<Button alignment="CENTER" onMouseClicked="#changePosition" prefHeight="26.0"
142+
prefWidth="110.0" text="Change Position">
132143
<cursor>
133-
<Cursor fx:constant="HAND" />
144+
<Cursor fx:constant="HAND"/>
134145
</cursor>
135146
<effect>
136147
<DropShadow>
137148
<color>
138-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
149+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
139150
</color>
140151
</DropShadow>
141152
</effect>
142153
<HBox.margin>
143-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
154+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
144155
</HBox.margin>
145156
</Button>
146157
</HBox>
147158
<HBox>
148-
<Button alignment="CENTER" onMouseClicked="#attack" prefHeight="26.0" prefWidth="110.0" text="Attack">
159+
<Button alignment="CENTER" onMouseClicked="#attack" prefHeight="26.0" prefWidth="110.0"
160+
text="Attack">
149161
<cursor>
150-
<Cursor fx:constant="HAND" />
162+
<Cursor fx:constant="HAND"/>
151163
</cursor>
152164
<effect>
153165
<DropShadow>
154166
<color>
155-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
167+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
156168
</color>
157169
</DropShadow>
158170
</effect>
159171
<HBox.margin>
160-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
172+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
161173
</HBox.margin>
162174
</Button>
163175
</HBox>
164176
<HBox>
165-
<Button alignment="CENTER" onMouseClicked="#activateEffect" prefHeight="26.0" prefWidth="110.0" text="Activate Effect">
177+
<Button alignment="CENTER" onMouseClicked="#activateEffect" prefHeight="26.0"
178+
prefWidth="110.0" text="Activate Effect">
166179
<cursor>
167-
<Cursor fx:constant="HAND" />
180+
<Cursor fx:constant="HAND"/>
168181
</cursor>
169182
<effect>
170183
<DropShadow>
171184
<color>
172-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
185+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
173186
</color>
174187
</DropShadow>
175188
</effect>
176189
<HBox.margin>
177-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
190+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
178191
</HBox.margin>
179192
</Button>
180193
</HBox>
181194
<HBox>
182-
<Button alignment="CENTER" onMouseClicked="#showGraveyard" prefHeight="26.0" prefWidth="110.0" text="Show Graveyard">
195+
<Button alignment="CENTER" onMouseClicked="#showGraveyard" prefHeight="26.0"
196+
prefWidth="110.0" text="Show Graveyard">
183197
<cursor>
184-
<Cursor fx:constant="HAND" />
198+
<Cursor fx:constant="HAND"/>
185199
</cursor>
186200
<effect>
187201
<DropShadow>
188202
<color>
189-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
203+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
190204
</color>
191205
</DropShadow>
192206
</effect>
193207
<HBox.margin>
194-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
208+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
195209
</HBox.margin>
196210
</Button>
197211
</HBox>
198212
<HBox>
199-
<Button alignment="CENTER" onMouseClicked="#surrender" prefHeight="26.0" prefWidth="110.0" text="Surrender">
213+
<Button alignment="CENTER" onMouseClicked="#surrender" prefHeight="26.0" prefWidth="110.0"
214+
text="Surrender">
200215
<cursor>
201-
<Cursor fx:constant="HAND" />
216+
<Cursor fx:constant="HAND"/>
202217
</cursor>
203218
<effect>
204219
<DropShadow>
205220
<color>
206-
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
221+
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
207222
</color>
208223
</DropShadow>
209224
</effect>
210225
<HBox.margin>
211-
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
226+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
212227
</HBox.margin>
213228
</Button>
214229
</HBox>
215230
</VBox>
216231
</center>
232+
233+
<bottom>
234+
<HBox alignment="CENTER">
235+
<Label fx:id="phaseLabel" alignment="CENTER" prefWidth="110" prefHeight="26">
236+
<HBox.margin>
237+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
238+
</HBox.margin>
239+
</Label>
240+
</HBox>
241+
</bottom>
217242
</BorderPane>
218243
</HBox>
219244
</left>
@@ -222,5 +247,4 @@
222247
<!-- chatBox-->
223248
</right>
224249

225-
226250
</BorderPane>

src/main/resources/view/gui/styles/DuelMenuGui.css

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33
-fx-background-color: #93a1a7;
44
}
55

6+
.button {
7+
-fx-background-color: #dd0202;
8+
-fx-text-fill: white;
9+
}
10+
611
#selectedCardDescription {
712
-fx-background-color: #eee0b1;
813
-fx-font-family: Arial;
914
-fx-border-insets: 10px;
1015
-fx-border-color: #cb9a45;
1116
}
1217

13-
.button {
14-
-fx-background-color: #dd0202;
15-
-fx-text-fill: white;
16-
}
17-
1818
#buttonPane {
1919
-fx-background-color: #141414;
20+
}
21+
22+
#phaseLabel {
23+
-fx-background-color: #dd0202;
24+
-fx-text-fill: white;
25+
-fx-font-family: Arial;
26+
-fx-font-weight: bold;
27+
-fx-background-radius: 3px;
2028
}

0 commit comments

Comments
 (0)