Skip to content

Commit

Permalink
added phaseLabel, fixed tribute, show game message alwaysOnTop
Browse files Browse the repository at this point in the history
  • Loading branch information
kysre committed Jul 9, 2021
1 parent d8dbc55 commit 3ab4689
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 55 deletions.
4 changes: 4 additions & 0 deletions src/main/java/controller/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,4 +677,8 @@ public int getPlayerDeckSize() {
public int getOpponentDeckSize() {
return game.getOpponentGameBoard().getOwner().getUserDeck().getActiveDeck().getMainDeck().size();
}

public String getGamePhase() {
return game.getPhase();
}
}
11 changes: 10 additions & 1 deletion src/main/java/view/gui/DuelMenuGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class DuelMenuGui extends MenuGui {
public Text playerNickNameText;
@FXML
public Text playerUserNameText;
@FXML
public Label phaseLabel;

static {
duelMenuMethods = DuelMenuGui.class.getDeclaredMethods();
Expand Down Expand Up @@ -200,6 +202,7 @@ public void updateGameBoard() {
updatePlayerLifePoint();
updateOpponentLifePoint();
updateDecks();
updatePhase();
}

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

private void updatePhase() {
String phase = gameController.getGamePhase();
phaseLabel.setText(phase);
}

private boolean getVisibility(String fieldName, String cardName) {
boolean isVisible = true;
if (fieldName.equals(CARD_FIELDS[3])) {
Expand Down Expand Up @@ -645,8 +653,9 @@ public ArrayList<Integer> getCardsForTribute(int i) {
"Leave field empty to cancel summon.");
String[] numbers = input.split(" ");
ArrayList<Integer> positions = new ArrayList<>();
// add (position - 1) to ArrayList because zero-indexed fields:
for (String num : numbers)
positions.add(Integer.parseInt(num));
positions.add(Integer.parseInt(num) - 1);
return positions;
} catch (NumberFormatException exception) {
showMessage("Invalid input format. Try again!");
Expand Down
1 change: 0 additions & 1 deletion src/main/java/view/gui/ShowGameMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void start(Stage prevStage) throws IOException {
stage.initStyle(StageStyle.UNDECORATED);
stage.toFront();
stage.requestFocus();
stage.setAlwaysOnTop(true);

stage.show();
}
Expand Down
120 changes: 72 additions & 48 deletions src/main/resources/view/gui/DuelMenuGui.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>

<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">
<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">

<stylesheets>
<URL value="@styles/DuelMenuGui.css" />
<URL value="@styles/DuelMenuGui.css"/>
</stylesheets>

<center>
Expand All @@ -26,194 +27,218 @@
<BorderPane prefHeight="600" prefWidth="210">
<top>
<VBox style="-fx-background-color: #eee0b1">
<ProgressBar fx:id="opponentProgressBar" minWidth="210" progress="1" style="-fx-accent: green" />
<Text fx:id="opponentNickNameText" style="-fx-fill: black; -fx-font-weight: bold;" text="opponent nickname: " />
<Text fx:id="opponentUserNameText" style="-fx-fill: black; -fx-font-weight: bold;" text="opponent username: " />
<ProgressBar fx:id="opponentProgressBar" minWidth="210" progress="1" style="-fx-accent: green"/>
<Text fx:id="opponentNickNameText" style="-fx-fill: black; -fx-font-weight: bold;"
text="opponent nickname: "/>
<Text fx:id="opponentUserNameText" style="-fx-fill: black; -fx-font-weight: bold;"
text="opponent username: "/>
</VBox>
</top>
<center>
<VBox alignment="CENTER" style="-fx-background-color: black">
<HBox alignment="CENTER">
<Rectangle fx:id="selectedCard" height="307" width="210" />
<Rectangle fx:id="selectedCard" height="307" width="210"/>
</HBox>
<HBox alignment="CENTER">
<Label fx:id="selectedCardDescription" alignment="TOP_LEFT" prefHeight="193" prefWidth="210" textAlignment="JUSTIFY" wrapText="true">
<Label fx:id="selectedCardDescription" alignment="TOP_LEFT" prefHeight="193" prefWidth="210"
textAlignment="JUSTIFY" wrapText="true">
<padding>
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0"/>
</padding>
</Label>
</HBox>
</VBox>
</center>
<bottom>
<VBox style="-fx-background-color: #eee0b1">
<ProgressBar fx:id="playerProgressBar" minWidth="210" progress="1" style="-fx-accent: green" />
<Text fx:id="playerNickNameText" style="-fx-fill: black; -fx-font-weight: bold;" text="player nickname: " />
<Text fx:id="playerUserNameText" style="-fx-fill: black; -fx-font-weight: bold;" text="player username: " />
<ProgressBar fx:id="playerProgressBar" minWidth="210" progress="1" style="-fx-accent: green"/>
<Text fx:id="playerNickNameText" style="-fx-fill: black; -fx-font-weight: bold;"
text="player nickname: "/>
<Text fx:id="playerUserNameText" style="-fx-fill: black; -fx-font-weight: bold;"
text="player username: "/>
</VBox>
</bottom>
</BorderPane>

<BorderPane fx:id="buttonPane" prefHeight="600" prefWidth="120">
<top>
<HBox>
<Button alignment="CENTER" onMouseClicked="#pause" prefHeight="26.0" prefWidth="110.0" text="pause">
<Button alignment="CENTER" onMouseClicked="#pause" prefHeight="26.0" prefWidth="110.0"
text="pause">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
</top>
<center>
<VBox alignment="CENTER">
<HBox>
<Button alignment="CENTER" onMouseClicked="#nextPhase" prefHeight="26.0" prefWidth="110.0" text="Next Phase">
<Button alignment="CENTER" onMouseClicked="#nextPhase" prefHeight="26.0" prefWidth="110.0"
text="Next Phase">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
<HBox>
<Button alignment="CENTER" onMouseClicked="#summonCard" prefHeight="26.0" prefWidth="110.0" text="Summon">
<Button alignment="CENTER" onMouseClicked="#summonCard" prefHeight="26.0" prefWidth="110.0"
text="Summon">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
<HBox>
<Button alignment="CENTER" onMouseClicked="#setCard" prefHeight="26.0" prefWidth="110.0" text="Set">
<Button alignment="CENTER" onMouseClicked="#setCard" prefHeight="26.0" prefWidth="110.0"
text="Set">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
<HBox>
<Button alignment="CENTER" onMouseClicked="#changePosition" prefHeight="26.0" prefWidth="110.0" text="Change Position">
<Button alignment="CENTER" onMouseClicked="#changePosition" prefHeight="26.0"
prefWidth="110.0" text="Change Position">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
<HBox>
<Button alignment="CENTER" onMouseClicked="#attack" prefHeight="26.0" prefWidth="110.0" text="Attack">
<Button alignment="CENTER" onMouseClicked="#attack" prefHeight="26.0" prefWidth="110.0"
text="Attack">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
<HBox>
<Button alignment="CENTER" onMouseClicked="#activateEffect" prefHeight="26.0" prefWidth="110.0" text="Activate Effect">
<Button alignment="CENTER" onMouseClicked="#activateEffect" prefHeight="26.0"
prefWidth="110.0" text="Activate Effect">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
<HBox>
<Button alignment="CENTER" onMouseClicked="#showGraveyard" prefHeight="26.0" prefWidth="110.0" text="Show Graveyard">
<Button alignment="CENTER" onMouseClicked="#showGraveyard" prefHeight="26.0"
prefWidth="110.0" text="Show Graveyard">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
<HBox>
<Button alignment="CENTER" onMouseClicked="#surrender" prefHeight="26.0" prefWidth="110.0" text="Surrender">
<Button alignment="CENTER" onMouseClicked="#surrender" prefHeight="26.0" prefWidth="110.0"
text="Surrender">
<cursor>
<Cursor fx:constant="HAND" />
<Cursor fx:constant="HAND"/>
</cursor>
<effect>
<DropShadow>
<color>
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15" />
<Color red="1.0" green="1.0" blue="1.0" opacity="0.15"/>
</color>
</DropShadow>
</effect>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Button>
</HBox>
</VBox>
</center>

<bottom>
<HBox alignment="CENTER">
<Label fx:id="phaseLabel" alignment="CENTER" prefWidth="110" prefHeight="26">
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</HBox.margin>
</Label>
</HBox>
</bottom>
</BorderPane>
</HBox>
</left>
Expand All @@ -222,5 +247,4 @@
<!-- chatBox-->
</right>


</BorderPane>
18 changes: 13 additions & 5 deletions src/main/resources/view/gui/styles/DuelMenuGui.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
-fx-background-color: #93a1a7;
}

.button {
-fx-background-color: #dd0202;
-fx-text-fill: white;
}

#selectedCardDescription {
-fx-background-color: #eee0b1;
-fx-font-family: Arial;
-fx-border-insets: 10px;
-fx-border-color: #cb9a45;
}

.button {
-fx-background-color: #dd0202;
-fx-text-fill: white;
}

#buttonPane {
-fx-background-color: #141414;
}

#phaseLabel {
-fx-background-color: #dd0202;
-fx-text-fill: white;
-fx-font-family: Arial;
-fx-font-weight: bold;
-fx-background-radius: 3px;
}

0 comments on commit 3ab4689

Please sign in to comment.