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