updated gamefinished screen and added points condition to change rack
parent
30623929e0
commit
6432393147
|
@ -112,6 +112,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
Label ErrorLabel = new Label();
|
||||
|
||||
HBox rackImage;
|
||||
static Label nameWinner = new Label();
|
||||
|
||||
int confirmBtnClickedCount;
|
||||
|
||||
|
@ -148,6 +149,9 @@ public class LaticeApplicationWindow extends Application {
|
|||
root.translateYProperty().set(stage.getHeight());
|
||||
System.out.println(parentStackPane);
|
||||
System.out.println(parentStackPaneStock);
|
||||
if (parentStackPane.getChildren().contains(root)) {
|
||||
parentStackPane.getChildren().remove(root);
|
||||
}
|
||||
parentStackPane.getChildren().add(root);
|
||||
|
||||
|
||||
|
@ -354,10 +358,12 @@ public class LaticeApplicationWindow extends Application {
|
|||
if (confirmBtnClickedCount>=20) {
|
||||
Parent loader = FXMLLoader.load(getClass().getResource("../view/GameFinishedScreen.fxml"));
|
||||
Scene gameFinishedScreenScene = new Scene(loader, 1280, 720);
|
||||
if (confirmBtnClickedCount%2 == 0) {
|
||||
GameFinishedScreenController.nameWinner.setText(player1.getName());
|
||||
if (player1.getNumberOfTilesRemaining() < player2.getNumberOfTilesRemaining()) {
|
||||
// if player 1 has less tiles then he wins
|
||||
GameFinishedScreenController.staticNameWinner.setText(player1.getName());
|
||||
}else {
|
||||
GameFinishedScreenController.nameWinner.setText(player2.getName());
|
||||
//if player 2 has less tiles then he wins
|
||||
GameFinishedScreenController.staticNameWinner.setText(player2.getName());
|
||||
}
|
||||
stage.setScene(gameFinishedScreenScene);
|
||||
|
||||
|
@ -391,7 +397,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
public void handle(MouseEvent arg0) {
|
||||
|
||||
|
||||
System.out.println("Changing Rack");
|
||||
|
||||
//player.getRack().changeRack();
|
||||
|
||||
//HBox newRackImage = rack2.createTileImage();
|
||||
|
@ -401,16 +407,19 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
|
||||
////// for the actual player //////
|
||||
if (player.getScore() > 1) {
|
||||
System.out.println("Changing Rack");
|
||||
confirmBtnClickedCount++;
|
||||
player.getRack().changeRack();
|
||||
player.getRack().updateRack();
|
||||
|
||||
////// changing player //////
|
||||
confirmBtnClickedCount++;
|
||||
if (confirmBtnClickedCount%2 == 0) {
|
||||
playerFX.setFillName(Constant.realColor.BLACK);
|
||||
player = player1;
|
||||
playerFX = player1FX;
|
||||
playerFX.setFillName(Constant.realColor.RED);
|
||||
|
||||
}else {
|
||||
playerFX.setFillName(Constant.realColor.BLACK);
|
||||
player = player2;
|
||||
|
@ -418,6 +427,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
playerFX.setFillName(Constant.realColor.RED);
|
||||
}
|
||||
|
||||
|
||||
////// for the next player //////
|
||||
freeOrPayableTile = true;
|
||||
rackImage = player.getRack().createTileImage();
|
||||
|
@ -429,6 +439,9 @@ public class LaticeApplicationWindow extends Application {
|
|||
setDragnDropOnRectangles(rect, board, referee, player);
|
||||
borderPane.setBottom(rackImage);
|
||||
|
||||
}else {
|
||||
System.out.println("Not enough points to change the rack");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -701,7 +714,9 @@ public class LaticeApplicationWindow extends Application {
|
|||
return rootLayout;
|
||||
}
|
||||
|
||||
|
||||
public static String getNameWinner() {
|
||||
return nameWinner.getText();
|
||||
}
|
||||
|
||||
//getter to get the index of the mouse clicked tile
|
||||
public static int getIndexTileClicked() {
|
||||
|
|
|
@ -1,27 +1,47 @@
|
|||
package latice.controller;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import latice.application.LaticeApplicationWindow;
|
||||
|
||||
public class GameFinishedScreenController {
|
||||
public class GameFinishedScreenController implements Initializable{
|
||||
@FXML
|
||||
private Button replayBtn;
|
||||
@FXML
|
||||
private Button quitBtn;
|
||||
@FXML
|
||||
public static Label nameWinner = new Label();
|
||||
private Button testBtn;
|
||||
@FXML
|
||||
private Label nameWinner;
|
||||
|
||||
public static Label staticNameWinner;
|
||||
|
||||
// Event Listener on Button[#replayBtn].onMouseClicked
|
||||
@FXML
|
||||
public void replayBtnClicked(MouseEvent event) {
|
||||
MainScreenController MSC = new MainScreenController();
|
||||
MSC.startGameInstruction();
|
||||
System.out.println("replayBtnClicked");
|
||||
}
|
||||
// Event Listener on Button[#quitBtn].onMouseClicked
|
||||
@FXML
|
||||
public void quitBtnClicked(MouseEvent event) {
|
||||
System.out.println("quitBtnClicked");
|
||||
Platform.exit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
staticNameWinner = nameWinner;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,22 +4,20 @@
|
|||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<BorderPane prefHeight="720.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="latice.controller.GameFinishedScreenController">
|
||||
<center>
|
||||
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<Pane xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="latice.controller.GameFinishedScreenController">
|
||||
<children>
|
||||
<Button fx:id="quitBtn" layoutX="750.0" layoutY="555.0" mnemonicParsing="false" onMouseClicked="#quitBtnClicked" prefHeight="140.0" prefWidth="380.0" textFill="TRANSPARENT" />
|
||||
<Button fx:id="replayBtn" layoutX="175.0" layoutY="555.0" mnemonicParsing="false" onMouseClicked="#replayBtnClicked" prefHeight="140.0" prefWidth="380.0" textFill="TRANSPARENT" />
|
||||
<ImageView fitHeight="720.0" fitWidth="1280.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@/gameFinishedImage.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<Label fx:id="nameWinner" alignment="CENTER_RIGHT" layoutX="450.0" layoutY="250.0" prefHeight="22.0" prefWidth="300.0" textAlignment="CENTER" />
|
||||
</image></ImageView>
|
||||
<Label fx:id="nameWinner" alignment="CENTER_RIGHT" layoutX="453.0" layoutY="247.0" prefHeight="22.0" prefWidth="300.0" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font name="Bell MT" size="40.0" />
|
||||
</font></Label>
|
||||
<Button fx:id="quitBtn" layoutX="753.0" layoutY="555.0" mnemonicParsing="false" onMouseClicked="#quitBtnClicked" prefHeight="140.0" prefWidth="380.0" style="-fx-background-color: transparent;" textFill="TRANSPARENT" />
|
||||
<Button fx:id="replayBtn" layoutX="175.0" layoutY="555.0" mnemonicParsing="false" onMouseClicked="#replayBtnClicked" prefHeight="140.0" prefWidth="380.0" style="-fx-background-color: transparent;" textFill="TRANSPARENT" />
|
||||
</children>
|
||||
</Pane>
|
||||
</center>
|
||||
</BorderPane>
|
||||
</Pane>
|
||||
|
|
Loading…
Reference in New Issue