Cleaned the source code
parent
2a73cfb775
commit
14a0045859
|
@ -110,7 +110,7 @@ public class LaticeApplicationConsole {
|
||||||
if (player.getScore()>=3) {
|
if (player.getScore()>=3) {
|
||||||
//Buy another action and remove 2 points from score
|
//Buy another action and remove 2 points from score
|
||||||
player.Play(play, board, 0);
|
player.Play(play, board, 0);
|
||||||
player.diffScore(2);
|
player.removePointsFromScore(2);
|
||||||
}else {
|
}else {
|
||||||
System.out.println("Il vous faut 2 points pour acheter une nouvelle action !");
|
System.out.println("Il vous faut 2 points pour acheter une nouvelle action !");
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
//lists for tiles
|
//lists for tiles
|
||||||
ArrayList<Tile> listRackTile;
|
ArrayList<Tile> listRackTile;
|
||||||
ArrayList<Image> listRackImage;
|
ArrayList<Image> listOfTilesInRack;
|
||||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
static StackPane rootLayout;
|
static StackPane rootLayout;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
Paint tileOnRect;
|
Paint tileOnRect;
|
||||||
|
|
||||||
//tile is free when it's the first tile put but tile is payable after
|
//tile is free when it's the first tile put but tile is payable after
|
||||||
Boolean freeOrPayableTile = true;
|
Boolean isFreePlacement = true;
|
||||||
|
|
||||||
public static BorderPane borderPane = new BorderPane();
|
public static BorderPane borderPane = new BorderPane();
|
||||||
|
|
||||||
|
@ -102,9 +102,9 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
Stage primaryStageCopy;
|
Stage primaryStageCopy;
|
||||||
StackPane parentStackPane = new StackPane();
|
StackPane parentStackPane = new StackPane();
|
||||||
Label ErrorLabel = new Label();
|
Label gameInfoLabel = new Label();
|
||||||
|
|
||||||
HBox rackImage;
|
HBox rackTileImage;
|
||||||
static Label nameWinner = new Label();
|
static Label nameWinner = new Label();
|
||||||
|
|
||||||
int confirmBtnClickedCount;
|
int confirmBtnClickedCount;
|
||||||
|
@ -152,7 +152,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
stage.setScene(menu);
|
stage.setScene(menu);
|
||||||
|
|
||||||
parentStackPane.getChildren().remove(root);
|
parentStackPane.getChildren().remove(root);
|
||||||
//parentStackPane.getChildren().add(root);
|
parentStackPane.getChildren().add(root);
|
||||||
parentStackPane.getChildren().remove(menuBorderPane);
|
parentStackPane.getChildren().remove(menuBorderPane);
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
|
@ -186,9 +186,9 @@ public class LaticeApplicationWindow extends Application {
|
||||||
topVbox.setAlignment(Pos.CENTER);
|
topVbox.setAlignment(Pos.CENTER);
|
||||||
|
|
||||||
//error label for displaying errors
|
//error label for displaying errors
|
||||||
ErrorLabel.setFont(new Font(20));
|
gameInfoLabel.setFont(new Font(20));
|
||||||
ErrorLabel.setTextFill(Constant.realColor.RED);
|
gameInfoLabel.setTextFill(Constant.realColor.RED);
|
||||||
topVbox.getChildren().add(ErrorLabel);
|
topVbox.getChildren().add(gameInfoLabel);
|
||||||
borderPane.setTop(topVbox);
|
borderPane.setTop(topVbox);
|
||||||
|
|
||||||
//background image
|
//background image
|
||||||
|
@ -294,14 +294,14 @@ public class LaticeApplicationWindow extends Application {
|
||||||
//RackChange Button
|
//RackChange Button
|
||||||
Image changeIconImage = new Image("changeIcon.png");
|
Image changeIconImage = new Image("changeIcon.png");
|
||||||
ImageView changeIconView = new ImageView(changeIconImage);
|
ImageView changeIconView = new ImageView(changeIconImage);
|
||||||
changeButton = new Button("Change Rack", changeIconView);
|
changeButton = new Button("Change Rack (2 points)", changeIconView);
|
||||||
changeButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
changeButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
||||||
changeButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
changeButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
||||||
|
|
||||||
//Buy another action Button
|
//Buy another action Button
|
||||||
Image buyActionImage = new Image("buyAction.png");
|
Image buyActionImage = new Image("buyAction.png");
|
||||||
ImageView buyActionView = new ImageView(buyActionImage);
|
ImageView buyActionView = new ImageView(buyActionImage);
|
||||||
buyActionButton = new Button("Buy Action", buyActionView);
|
buyActionButton = new Button("Buy Action (2 points)", buyActionView);
|
||||||
buyActionButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
buyActionButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
||||||
buyActionButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
buyActionButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
||||||
|
|
||||||
|
@ -339,13 +339,13 @@ public class LaticeApplicationWindow extends Application {
|
||||||
playerFX.setFillName(Constant.realColor.RED);
|
playerFX.setFillName(Constant.realColor.RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
freeOrPayableTile = true;
|
isFreePlacement = true;
|
||||||
|
|
||||||
rackImage = player.getRack().createTileImage();
|
rackTileImage = player.getRack().createTileImage();
|
||||||
setDragnDropOnRack(rackImage, player);
|
setDragnDropOnRack(rackTileImage, player);
|
||||||
setDragnDropOnRectangles(rect, board, referee, player);
|
setDragnDropOnRectangles(rect, board, referee, player);
|
||||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
rackTileImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||||
borderPane.setBottom(rackImage);
|
borderPane.setBottom(rackTileImage);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
//switching to game finished screen if the game finishes
|
//switching to game finished screen if the game finishes
|
||||||
System.out.println("confirmBtnClickedCount : " + confirmBtnClickedCount);
|
System.out.println("confirmBtnClickedCount : " + confirmBtnClickedCount);
|
||||||
if (confirmBtnClickedCount>=2) {
|
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, Constant.SCREEN_WIDTH, Constant.SCREEN_HEIGHT);
|
Scene gameFinishedScreenScene = new Scene(loader, Constant.SCREEN_WIDTH, Constant.SCREEN_HEIGHT);
|
||||||
if (player1.getNumberOfTilesRemaining() < player2.getNumberOfTilesRemaining()) {
|
if (player1.getNumberOfTilesRemaining() < player2.getNumberOfTilesRemaining()) {
|
||||||
|
@ -379,13 +379,13 @@ public class LaticeApplicationWindow extends Application {
|
||||||
});
|
});
|
||||||
|
|
||||||
//With Image
|
//With Image
|
||||||
rackImage = player.getRack().createTileImage();
|
rackTileImage = player.getRack().createTileImage();
|
||||||
|
|
||||||
//Adding lists to Arraylists
|
//Adding lists to Arraylists
|
||||||
listRackTile = player.getRack().getListRackTile();
|
listRackTile = player.getRack().getListRackTile();
|
||||||
System.out.println(listRackTile);
|
System.out.println(listRackTile);
|
||||||
listRackImage = player.getRack().getRackTileImage();
|
listOfTilesInRack = player.getRack().getRackTileImage();
|
||||||
System.out.println("listTileImge : " + listRackImage);
|
System.out.println("listTileImge : " + listOfTilesInRack);
|
||||||
|
|
||||||
changeButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
changeButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||||
|
|
||||||
|
@ -415,18 +415,19 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
|
|
||||||
////// for the next player //////
|
////// for the next player //////
|
||||||
freeOrPayableTile = true;
|
isFreePlacement = true;
|
||||||
rackImage = player.getRack().createTileImage();
|
rackTileImage = player.getRack().createTileImage();
|
||||||
|
|
||||||
//Setting drag n drop on tiles
|
//Setting drag n drop on tiles
|
||||||
setDragnDropOnRack(rackImage, player);
|
setDragnDropOnRack(rackTileImage, player);
|
||||||
|
|
||||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
rackTileImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||||
setDragnDropOnRectangles(rect, board, referee, player);
|
setDragnDropOnRectangles(rect, board, referee, player);
|
||||||
borderPane.setBottom(rackImage);
|
borderPane.setBottom(rackTileImage);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
System.out.println("Not enough points to change the rack");
|
System.out.println("Not enough points to change the rack");
|
||||||
|
gameInfoLabel.setText("Error !" + player.getName() + ", you haven't enough points to change your rack");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -437,22 +438,15 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(MouseEvent arg0) {
|
public void handle(MouseEvent arg0) {
|
||||||
//TODO verify score and give another play()
|
gameInfoLabel.setText(player.getName() + ", you can now play another time !");
|
||||||
/*if (player.getScore()>=3) {
|
|
||||||
//Donner une action supplémentaire et enlever 3 points au joueur
|
|
||||||
player.Play(play, board, 0);
|
|
||||||
player.diffScore(3);
|
|
||||||
}else {
|
|
||||||
System.out.println("Il vous faut 3 points pour acheter une nouvelle action !");
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
rackTileImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||||
setDragnDropOnRack(rackImage, player);
|
setDragnDropOnRack(rackTileImage, player);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
borderPane.setBottom(rackImage);
|
borderPane.setBottom(rackTileImage);
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -460,7 +454,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
|
|
||||||
System.out.println((indexTileClicked));
|
System.out.println((indexTileClicked));
|
||||||
ImagePattern imagePattern = new ImagePattern(listRackImage.get(getIndexTileClicked()));
|
ImagePattern imagePattern = new ImagePattern(listOfTilesInRack.get(getIndexTileClicked()));
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -471,7 +465,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------if there is already childrens, remove them all to start or restart game------------------------------------------------------------
|
//------if there is already childrens, remove them all to start or restart game--------------------------------
|
||||||
root.getChildren().clear();
|
root.getChildren().clear();
|
||||||
//adding new childrens
|
//adding new childrens
|
||||||
root.getChildren().addAll(infoPlayers, borderPane);
|
root.getChildren().addAll(infoPlayers, borderPane);
|
||||||
|
@ -491,26 +485,23 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
rect[a][b].setOnDragEntered(new EventHandler<DragEvent>() {
|
rect[a][b].setOnDragEntered(new EventHandler<DragEvent>() {
|
||||||
|
|
||||||
|
//if we are entering a rectangle
|
||||||
@Override
|
@Override
|
||||||
public void handle(DragEvent arg0) {
|
public void handle(DragEvent arg0) {
|
||||||
|
|
||||||
|
|
||||||
tileOnRect = rect[a][b].getFill();
|
tileOnRect = rect[a][b].getFill();
|
||||||
if (arg0.getDragboard().hasString()){
|
|
||||||
Dragboard dragboard = arg0.getDragboard();
|
|
||||||
|
|
||||||
//not putting the virtual image drag on the case because an image is already into it
|
//not putting the virtual image drag on the case because an image is already into it
|
||||||
player.getRack().getListRackTile().get(indexTileClicked).setPosition(new Position(a,b));
|
player.getRack().getListRackTile().get(indexTileClicked).setPosition(new Position(a,b));
|
||||||
if ( referee.checkPositionRule(board, player.getRack().getListRackTile().get(indexTileClicked)) == true ) {
|
if ( referee.checkPositionRule(board, player.getRack().getListRackTile().get(indexTileClicked)) == true ) {
|
||||||
rect[a][b].setFill(new ImagePattern(player.getRack().getRackTileImage().get(indexTileClicked)));
|
rect[a][b].setFill(new ImagePattern(player.getRack().getRackTileImage().get(indexTileClicked)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
arg0.consume();
|
arg0.consume();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rect[a][b].setOnDragExited(new EventHandler<DragEvent>() {
|
rect[a][b].setOnDragExited(new EventHandler<DragEvent>() {
|
||||||
|
//if we are leaving a rectangle
|
||||||
@Override
|
@Override
|
||||||
public void handle(DragEvent arg0) {
|
public void handle(DragEvent arg0) {
|
||||||
if (arg0.isDropCompleted() == false) {
|
if (arg0.isDropCompleted() == false) {
|
||||||
|
@ -523,6 +514,8 @@ public class LaticeApplicationWindow extends Application {
|
||||||
});
|
});
|
||||||
|
|
||||||
rect[a][b].setOnDragOver(new EventHandler <DragEvent>() {
|
rect[a][b].setOnDragOver(new EventHandler <DragEvent>() {
|
||||||
|
|
||||||
|
//If we are traveling over a rectangle
|
||||||
@Override
|
@Override
|
||||||
public void handle(DragEvent arg0) {
|
public void handle(DragEvent arg0) {
|
||||||
|
|
||||||
|
@ -532,26 +525,24 @@ public class LaticeApplicationWindow extends Application {
|
||||||
});
|
});
|
||||||
|
|
||||||
rect[a][b].setOnDragDropped(new EventHandler<DragEvent>() {
|
rect[a][b].setOnDragDropped(new EventHandler<DragEvent>() {
|
||||||
|
|
||||||
|
//If we are dropping a tile in a rectangle
|
||||||
@Override
|
@Override
|
||||||
public void handle(DragEvent arg0) {
|
public void handle(DragEvent arg0) {
|
||||||
System.out.println("entered");
|
|
||||||
Dragboard dragboard = arg0.getDragboard();
|
|
||||||
System.out.println("OK2");
|
|
||||||
|
|
||||||
|
|
||||||
rect[a][b].setFill(new ImagePattern(player.getRack().getRackTileImage().get(indexTileClicked)));
|
rect[a][b].setFill(new ImagePattern(player.getRack().getRackTileImage().get(indexTileClicked)));
|
||||||
|
|
||||||
|
|
||||||
arg0.setDropCompleted(true);
|
arg0.setDropCompleted(true);
|
||||||
System.out.println("OK");
|
gameInfoLabel.setText("");
|
||||||
ErrorLabel.setText("");
|
|
||||||
|
|
||||||
if (referee.checkScoreToPlay(player, freeOrPayableTile) == false) {
|
//testing if player has enough points
|
||||||
ErrorLabel.setText("Error ! You haven't enough points to play another tile");
|
if (referee.checkScoreToPlay(player, isFreePlacement) == false) {
|
||||||
|
gameInfoLabel.setText("Error !" + player.getName() + ", you haven't enough points to play another tile");
|
||||||
rect[a][b].setFill(tileOnRect);
|
rect[a][b].setFill(tileOnRect);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
|
//testing if it's the free round
|
||||||
if (Constant.START) {
|
if (Constant.START) {
|
||||||
if (rect[a][b] == rect[Constant.MOON_BOX_X][Constant.MOON_BOX_Y]) {
|
if (rect[a][b] == rect[Constant.MOON_BOX_X][Constant.MOON_BOX_Y]) {
|
||||||
//if its's the center box (moon box)
|
//if its's the center box (moon box)
|
||||||
|
@ -559,11 +550,11 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
board.setGridBoardTile(player.getRack().getListRackTile().get(indexTileClicked), a, b);
|
board.setGridBoardTile(player.getRack().getListRackTile().get(indexTileClicked), a, b);
|
||||||
tileDropped = true;
|
tileDropped = true;
|
||||||
freeOrPayableTile = false;
|
isFreePlacement = false;
|
||||||
Constant.START = false;
|
Constant.START = false;
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
ErrorLabel.setText("Error ! Please place the first tile on the moon");
|
gameInfoLabel.setText("Error ! " + player.getName() + ", please place the first tile on the moon");
|
||||||
//removing all tiles from gameboard
|
//removing all tiles from gameboard
|
||||||
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
||||||
|
|
||||||
|
@ -573,13 +564,12 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
//if it's not the first round of the game
|
//if it's not the first round of the game
|
||||||
System.out.println("OK3");
|
//not removing the tile from the rack
|
||||||
System.out.println("Règle effectué");
|
|
||||||
player.getRack().getListRackTile().get(indexTileClicked).setPosition(new Position(a,b));
|
player.getRack().getListRackTile().get(indexTileClicked).setPosition(new Position(a,b));
|
||||||
|
|
||||||
//verify if a tile is already placed
|
//verify if a tile is already placed
|
||||||
if ( referee.checkPositionRule(board, player.getRack().getListRackTile().get(indexTileClicked)) == false ) {
|
if ( referee.checkPositionRule(board, player.getRack().getListRackTile().get(indexTileClicked)) == false ) {
|
||||||
ErrorLabel.setText("Error ! The tile can't be placed here because there is already a tile placed");
|
gameInfoLabel.setText("Error ! The tile can't be placed here because there is already a tile placed");
|
||||||
rect[a][b].setFill(tileOnRect);
|
rect[a][b].setFill(tileOnRect);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
@ -587,37 +577,41 @@ public class LaticeApplicationWindow extends Application {
|
||||||
int nbr = referee.neighborRule(board , player.getRack().getListRackTile().get(indexTileClicked));
|
int nbr = referee.neighborRule(board , player.getRack().getListRackTile().get(indexTileClicked));
|
||||||
|
|
||||||
if (nbr == 0) {
|
if (nbr == 0) {
|
||||||
ErrorLabel.setText("Error ! The tile isn't place next to another tile or there is no correspondance with the neighbor tiles !!");
|
gameInfoLabel.setText("Error! The tile isn't placed next to another tile or there is no correspondance with the neighbor tiles!");
|
||||||
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
if (freeOrPayableTile == false) {
|
if (isFreePlacement == false) {
|
||||||
playerFX.setDiffScore(player, 2);
|
playerFX.setRemovePointsFromScore(player, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbr == 2) {
|
if (nbr == 2) {
|
||||||
System.out.println("Vous avez gagné 1 point");
|
System.out.println("Vous avez gagné 1 point");
|
||||||
playerFX.setAddScore(player, 1);
|
gameInfoLabel.setText(player.getName() + "You won 1 point");
|
||||||
|
playerFX.setAddPointsToScore(player, 1);
|
||||||
|
|
||||||
}else if (nbr == 3) {
|
}else if (nbr == 3) {
|
||||||
System.out.println("Vous avez gagné 2 points");
|
System.out.println("Vous avez gagné 2 points");
|
||||||
playerFX.setAddScore(player, 2);
|
gameInfoLabel.setText(player.getName() + "You won 2 points");
|
||||||
|
playerFX.setAddPointsToScore(player, 2);
|
||||||
|
|
||||||
}else if (nbr == 4) {
|
}else if (nbr == 4) {
|
||||||
System.out.println("Vous avez gagné 4 points");
|
System.out.println("Vous avez gagné 4 points");
|
||||||
playerFX.setAddScore(player, 4);
|
gameInfoLabel.setText(player.getName() + "You won 4 points");
|
||||||
|
playerFX.setAddPointsToScore(player, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
board.setGridBoardTile(player.getRack().getListRackTile().get(getIndexTileClicked()), a, b);
|
board.setGridBoardTile(player.getRack().getListRackTile().get(getIndexTileClicked()), a, b);
|
||||||
tileDropped = true;
|
tileDropped = true;
|
||||||
freeOrPayableTile = false;
|
isFreePlacement = false;
|
||||||
System.out.println("tuile posé!");
|
System.out.println("tuile posé!");
|
||||||
|
|
||||||
//Sun rule
|
//Sun rule
|
||||||
if (referee.sunRule(board, player.getRack().getListRackTile().get(indexTileClicked))) {
|
if (referee.sunRule(board, player.getRack().getListRackTile().get(indexTileClicked))) {
|
||||||
System.out.println("Vous avez gagné 2 points en mettant votre tuile sur un soleil");
|
System.out.println("Vous avez gagné 2 points en mettant votre tuile sur un soleil");
|
||||||
playerFX.setAddScore(player, 2);
|
gameInfoLabel.setText("Wow!" + player.getName() + "You won 2 points by placing a tile on a sun !");
|
||||||
|
playerFX.setAddPointsToScore(player, 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -635,18 +629,12 @@ public class LaticeApplicationWindow extends Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setDragnDropOnRack(HBox rackBox, Player player) {
|
private void setDragnDropOnRack(HBox rackBox, Player player) {
|
||||||
//Setting drag n drop on tiles
|
//Setting drag n drop on tiles
|
||||||
for (int i=0; i< player.getRack().getRackTileImage().size(); i++) {
|
for (int i=0; i< player.getRack().getRackTileImage().size(); i++) {
|
||||||
int a = i;
|
int a = i;
|
||||||
System.out.println(a);
|
|
||||||
//HBox t = rackBox.getChildren().indexOf(rack);
|
|
||||||
rackBox.getChildren().get(a).setOnDragDetected(new EventHandler<MouseEvent>() {
|
rackBox.getChildren().get(a).setOnDragDetected(new EventHandler<MouseEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -668,14 +656,13 @@ public class LaticeApplicationWindow extends Application {
|
||||||
public void handle(DragEvent arg0) {
|
public void handle(DragEvent arg0) {
|
||||||
if (tileDropped) {
|
if (tileDropped) {
|
||||||
player.getRack().getListRackTile().remove(a);
|
player.getRack().getListRackTile().remove(a);
|
||||||
rackImage = player.getRack().createTileImage();
|
rackTileImage = player.getRack().createTileImage();
|
||||||
|
|
||||||
//Setting drag n drop on tiles
|
//Setting drag n drop on tiles
|
||||||
setDragnDropOnRack(rackImage, player);
|
setDragnDropOnRack(rackTileImage, player);
|
||||||
|
|
||||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
rackTileImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||||
//setDragnDropOnRectangles(rect, board, referee, player);
|
borderPane.setBottom(rackTileImage);
|
||||||
borderPane.setBottom(rackImage);
|
|
||||||
tileDropped = false;
|
tileDropped = false;
|
||||||
playerFX.setTilesRemaining(player);
|
playerFX.setTilesRemaining(player);
|
||||||
}
|
}
|
||||||
|
@ -691,10 +678,6 @@ 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() {
|
||||||
return indexTileClicked;
|
return indexTileClicked;
|
||||||
|
|
|
@ -18,7 +18,9 @@ import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
|
import javafx.scene.web.WebView;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
|
@ -69,29 +71,16 @@ public class MainScreenController extends LaticeApplicationWindow{
|
||||||
@FXML
|
@FXML
|
||||||
public void rulesButtonClicked(MouseEvent event) {
|
public void rulesButtonClicked(MouseEvent event) {
|
||||||
System.out.println("rulesButtonClicked");
|
System.out.println("rulesButtonClicked");
|
||||||
Stage primaryStage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
|
|
||||||
Label secondLabel = new Label("Règles");
|
|
||||||
//TODO règles à saisir
|
|
||||||
StackPane secondaryLayout = new StackPane();
|
|
||||||
secondaryLayout.getChildren().add(secondLabel);
|
|
||||||
|
|
||||||
Scene secondScene = new Scene(secondaryLayout, 230, 100);
|
|
||||||
|
|
||||||
// New window (Stage)
|
// New window (Stage)
|
||||||
Stage newWindow = new Stage();
|
Stage newWindow = new Stage();
|
||||||
newWindow.setTitle("Règles du jeu Latice");
|
newWindow.setTitle("Règles du jeu Latice");
|
||||||
newWindow.setScene(secondScene);
|
|
||||||
|
|
||||||
// Specifies the modality for new window
|
WebView webView = new WebView();
|
||||||
newWindow.initModality(Modality.WINDOW_MODAL);
|
webView.getEngine().load("https://latice.com/how/#rules-objective");
|
||||||
|
VBox videoContainer = new VBox(webView);
|
||||||
// Specifies the owner window
|
|
||||||
newWindow.initOwner(primaryStage);
|
|
||||||
|
|
||||||
// Set position of window
|
|
||||||
newWindow.setX(primaryStage.getX() + 300);
|
|
||||||
newWindow.setY(primaryStage.getY() + 175);
|
|
||||||
|
|
||||||
|
newWindow.setScene(new Scene(videoContainer, 1100, 680));
|
||||||
newWindow.show();
|
newWindow.show();
|
||||||
}
|
}
|
||||||
// Event Listener on Rectangle[#exitButton].onMouseClicked
|
// Event Listener on Rectangle[#exitButton].onMouseClicked
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class PlayerNameInputController {
|
||||||
public void validBtnClicked(MouseEvent event) {
|
public void validBtnClicked(MouseEvent event) {
|
||||||
System.out.println("valid Button Clicked");
|
System.out.println("valid Button Clicked");
|
||||||
|
|
||||||
|
//Verifying if player's names are correct
|
||||||
if(nomJoueur1.getText().length() < 3 || nomJoueur1.getText().length() > 16) {
|
if(nomJoueur1.getText().length() < 3 || nomJoueur1.getText().length() > 16) {
|
||||||
label1.setVisible(true);
|
label1.setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +72,7 @@ public class PlayerNameInputController {
|
||||||
mainScreenController.player1 = mainScreenController.instanciatePlayer(name1);
|
mainScreenController.player1 = mainScreenController.instanciatePlayer(name1);
|
||||||
mainScreenController.player2 = mainScreenController.instanciatePlayer(name2);
|
mainScreenController.player2 = mainScreenController.instanciatePlayer(name2);
|
||||||
|
|
||||||
//PlayerFX.displayPlayers(root ,laticeApplicationWindow.player1, laticeApplicationWindow.player2);
|
//Starting game
|
||||||
mainScreenController.startGameInstruction(false);
|
mainScreenController.startGameInstruction(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class Constant {
|
||||||
|
|
||||||
public static final int BOX_WIDTH = 52;
|
public static final int BOX_WIDTH = 52;
|
||||||
|
|
||||||
public static final int ACTION_BUTTONS_WIDTH = 120;
|
public static final int ACTION_BUTTONS_WIDTH = 170;
|
||||||
|
|
||||||
public static final int ACTION_BUTTONS_HEIGHT = 45;
|
public static final int ACTION_BUTTONS_HEIGHT = 45;
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,13 @@ public class Player {
|
||||||
return this.deck.getListTile().size() + this.rack.getListRackTile().size();
|
return this.deck.getListTile().size() + this.rack.getListRackTile().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer addScore(Integer value) {
|
public Integer addPointsToScore(Integer value) {
|
||||||
int newScore = this.score.getScore()+value;
|
int newScore = this.score.getScore()+value;
|
||||||
this.score.setScore(newScore);
|
this.score.setScore(newScore);
|
||||||
return this.score.getScore();
|
return this.score.getScore();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer diffScore(Integer value) {
|
public Integer removePointsFromScore(Integer value) {
|
||||||
int newScore = this.score.getScore()-value;
|
int newScore = this.score.getScore()-value;
|
||||||
this.score.setScore(newScore);
|
this.score.setScore(newScore);
|
||||||
return this.score.getScore();
|
return this.score.getScore();
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class Rules {
|
||||||
}else {
|
}else {
|
||||||
System.out.println("-----------------------------");
|
System.out.println("-----------------------------");
|
||||||
if (this.sunRule(board, tile)){
|
if (this.sunRule(board, tile)){
|
||||||
player.addScore(2);
|
player.addPointsToScore(2);
|
||||||
}
|
}
|
||||||
int nbr = this.neighborRule(board, tile);
|
int nbr = this.neighborRule(board, tile);
|
||||||
if (nbr == 0) {
|
if (nbr == 0) {
|
||||||
|
@ -122,13 +122,13 @@ public class Rules {
|
||||||
}else {
|
}else {
|
||||||
if (nbr == 2) {
|
if (nbr == 2) {
|
||||||
System.out.println("Vous avez gagné 1 point");
|
System.out.println("Vous avez gagné 1 point");
|
||||||
player.addScore(1);
|
player.addPointsToScore(1);
|
||||||
}else if (nbr == 3) {
|
}else if (nbr == 3) {
|
||||||
System.out.println("Vous avez gagné 2 points");
|
System.out.println("Vous avez gagné 2 points");
|
||||||
player.addScore(2);
|
player.addPointsToScore(2);
|
||||||
}else if (nbr == 4) {
|
}else if (nbr == 4) {
|
||||||
System.out.println("Vous avez gagné 4 points");
|
System.out.println("Vous avez gagné 4 points");
|
||||||
player.addScore(4);
|
player.addPointsToScore(4);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -1,264 +0,0 @@
|
||||||
package latice.model.window;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.geometry.Insets;
|
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.input.ClipboardContent;
|
|
||||||
import javafx.scene.input.DragEvent;
|
|
||||||
import javafx.scene.input.Dragboard;
|
|
||||||
import javafx.scene.input.MouseEvent;
|
|
||||||
import javafx.scene.input.TransferMode;
|
|
||||||
import javafx.scene.layout.Background;
|
|
||||||
import javafx.scene.layout.BackgroundImage;
|
|
||||||
import javafx.scene.layout.BackgroundPosition;
|
|
||||||
import javafx.scene.layout.BackgroundRepeat;
|
|
||||||
import javafx.scene.layout.BackgroundSize;
|
|
||||||
import javafx.scene.layout.BorderPane;
|
|
||||||
import javafx.scene.layout.HBox;
|
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import javafx.scene.paint.ImagePattern;
|
|
||||||
import javafx.scene.shape.Rectangle;
|
|
||||||
import javafx.scene.text.Font;
|
|
||||||
import javafx.scene.text.FontWeight;
|
|
||||||
import javafx.scene.text.Text;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import latice.model.Color;
|
|
||||||
import latice.model.Player;
|
|
||||||
import latice.model.Shape;
|
|
||||||
import latice.model.Tile;
|
|
||||||
import latice.model.console.Deck;
|
|
||||||
import latice.model.console.Rack;
|
|
||||||
|
|
||||||
public class PlayGame {
|
|
||||||
|
|
||||||
Image image = new Image("backgroundLatice.png");
|
|
||||||
ImageView imageView = new ImageView(image);
|
|
||||||
|
|
||||||
Tile blueBird = new Tile(Color.NAVYBLUE, Shape.BIRD);
|
|
||||||
Tile greenLeaf = new Tile(Color.GREEN, Shape.FEATHER);
|
|
||||||
Tile redFlower = new Tile(Color.RED, Shape.FLOWER);
|
|
||||||
|
|
||||||
ArrayList<Tile> listRackTile;
|
|
||||||
ArrayList<Image> listTileImage;
|
|
||||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
|
||||||
Map<Rectangle, Tile> assocRectangleTile = new HashMap<Rectangle, Tile>();
|
|
||||||
static StackPane rootLayout;
|
|
||||||
private Label namePlayer1 = new Label("Anonyme");
|
|
||||||
private Label namePlayer2 = new Label("Anonyme");
|
|
||||||
|
|
||||||
public static int indexTileClicked;
|
|
||||||
|
|
||||||
|
|
||||||
//settings players
|
|
||||||
public Player player1;
|
|
||||||
public Player player2;
|
|
||||||
|
|
||||||
//root layout
|
|
||||||
BorderPane borderPane = new BorderPane();
|
|
||||||
|
|
||||||
//StackPane for background image + BorderPane root onto it
|
|
||||||
StackPane root = new StackPane();
|
|
||||||
|
|
||||||
static Stage primaryStageCopy;
|
|
||||||
|
|
||||||
|
|
||||||
int confirmBtnClickedCount;
|
|
||||||
|
|
||||||
public Stage playGame(Stage StageToGame) {
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
//Title
|
|
||||||
Text title = new Text("Latice");
|
|
||||||
title.setFont(new Font(30));
|
|
||||||
borderPane.setTop(title);
|
|
||||||
borderPane.setAlignment(title, Pos.CENTER);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
//Image
|
|
||||||
Pane pane = new Pane();
|
|
||||||
BackgroundImage myBG= new BackgroundImage(image,
|
|
||||||
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
|
|
||||||
BackgroundSize.DEFAULT);
|
|
||||||
root.setBackground(new Background(myBG));
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
//###################### creating all rectangles and DragnDrop ######################//
|
|
||||||
RectangleFX rectFX = new RectangleFX();
|
|
||||||
rectFX.createRectangle(borderPane, pane);
|
|
||||||
rectFX.dragnDropOnAllRectangles(player1, indexTileClicked, confirmBtnClickedCount);
|
|
||||||
rectFX.dragnDropOnAllRectangles(player2, indexTileClicked, confirmBtnClickedCount);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
borderPane.setCenter(pane);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
//Rack
|
|
||||||
HBox rackBox = new HBox();
|
|
||||||
|
|
||||||
rackBox.setSpacing(10);
|
|
||||||
rackBox.setPadding(new Insets(15,20, 10,10));
|
|
||||||
|
|
||||||
|
|
||||||
//Creating tiles
|
|
||||||
for (Color color : Color.values()) {
|
|
||||||
for (Shape shape : Shape.values()) {
|
|
||||||
Tile tile = new Tile(color, shape);
|
|
||||||
|
|
||||||
listOfTile.add(tile);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("-----------------");
|
|
||||||
System.out.println("Notre Deck :");
|
|
||||||
Deck deck = new Deck(listOfTile);
|
|
||||||
System.out.println("-----------------");
|
|
||||||
Rack rack = new Rack(deck);
|
|
||||||
System.out.println("-----------------");
|
|
||||||
//deck.displayListTile();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Confirm Button
|
|
||||||
Image checkMark = new Image("checkMark.png");
|
|
||||||
ImageView checkMarkView = new ImageView(checkMark);
|
|
||||||
Button confirmButton = new Button("Confirm", checkMarkView);
|
|
||||||
|
|
||||||
confirmButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent arg0) {
|
|
||||||
|
|
||||||
confirmBtnClickedCount++;
|
|
||||||
System.out.println("confirmed placement");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
//With Image
|
|
||||||
Rack rack2 = new Rack(deck);
|
|
||||||
HBox rackImage = rack2.createTileImage();
|
|
||||||
rackImage.getChildren().add(confirmButton);
|
|
||||||
rackImage.setMargin(rackImage.getChildren().get(4), new Insets(0,150,0,0));
|
|
||||||
borderPane.setBottom(rackImage);
|
|
||||||
|
|
||||||
//Adding lists to Arraylists
|
|
||||||
listRackTile = rack2.getListRackTile();
|
|
||||||
System.out.println(listRackTile);
|
|
||||||
listTileImage = rack2.getRackTileImage();
|
|
||||||
System.out.println("listTileImge : " + listTileImage);
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
//Setting OnDragDetected on tiles
|
|
||||||
setDragnDropOnRack(rackImage);
|
|
||||||
|
|
||||||
System.out.println((indexTileClicked));
|
|
||||||
ImagePattern imagePattern = new ImagePattern(listTileImage.get(indexTileClicked));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//rules / referee implementaion
|
|
||||||
|
|
||||||
this.transition(namePlayer1, namePlayer2);
|
|
||||||
//root.setLeft(namePlayer1);
|
|
||||||
|
|
||||||
//###################### display name, score and deck of each player ######################//
|
|
||||||
HBox players = new HBox();
|
|
||||||
|
|
||||||
ArrayList<Player> allPlayers = new ArrayList<>();
|
|
||||||
allPlayers.add(player1);
|
|
||||||
allPlayers.add(player2);
|
|
||||||
|
|
||||||
for (Player nameplayer : allPlayers ) {
|
|
||||||
VBox player = new VBox();
|
|
||||||
|
|
||||||
Text name = new Text();
|
|
||||||
name.setFont(Font.font("Anonyme", FontWeight.BOLD, 20));
|
|
||||||
name.setText("Anonyme");
|
|
||||||
|
|
||||||
Text score = new Text();
|
|
||||||
score.setText("Score : " + nameplayer.getScore());
|
|
||||||
|
|
||||||
Text nbrOfTiles = new Text();
|
|
||||||
nbrOfTiles.setText("Tuiles restantes : " + nameplayer.getNumberOfTilesRemaining());
|
|
||||||
|
|
||||||
player.getChildren().addAll(name, score, nbrOfTiles);
|
|
||||||
player.setSpacing(5);
|
|
||||||
|
|
||||||
players.getChildren().add(player);
|
|
||||||
players.setMargin(player, new Insets(50,0,0,55));
|
|
||||||
}
|
|
||||||
System.out.println("largeur : " + borderPane.getMaxWidth());
|
|
||||||
players.setSpacing(850);
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
setPrimaryStage(StageToGame);
|
|
||||||
setRootLayout(root);
|
|
||||||
root.getChildren().addAll(players, borderPane);
|
|
||||||
|
|
||||||
return StageToGame;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void transition(Label player1, Label player2) {
|
|
||||||
|
|
||||||
borderPane.setLeft(player1);
|
|
||||||
borderPane.setRight(player2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrimaryStage(Stage primaryStage) {
|
|
||||||
this.primaryStageCopy = primaryStage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setRootLayout(StackPane root) {
|
|
||||||
rootLayout = root;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDragnDropOnRack(HBox rackImage) {
|
|
||||||
for (int i=0; i<5; i++) {
|
|
||||||
int index = i;
|
|
||||||
rackImage.getChildren().get(index).setOnDragDetected(new EventHandler<MouseEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent arg0) {
|
|
||||||
Dragboard dragboard = rackImage.getChildren().get(index).startDragAndDrop(TransferMode.ANY);
|
|
||||||
ClipboardContent content = new ClipboardContent();
|
|
||||||
dragboard.setDragView(listTileImage.get(index));
|
|
||||||
content.putString("Hello !");
|
|
||||||
indexTileClicked = index;
|
|
||||||
//setIndexTileClicked(index);
|
|
||||||
dragboard.setContent(content);
|
|
||||||
arg0.consume();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
rackImage.getChildren().get(index).setOnDragDone(new EventHandler<DragEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(DragEvent arg0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,14 +19,8 @@ public class PlayerFX {
|
||||||
private VBox infoPlayer;
|
private VBox infoPlayer;
|
||||||
|
|
||||||
public VBox displayPlayers(StackPane root, Player player) {
|
public VBox displayPlayers(StackPane root, Player player) {
|
||||||
//###################### display name, score and deck of each player ######################//
|
//-------------- display name, score and deck of each player ---------------//
|
||||||
//HBox players = new HBox();
|
|
||||||
|
|
||||||
//ArrayList<Player> allPlayers = new ArrayList<>();
|
|
||||||
//allPlayers.add(player1);
|
|
||||||
//allPlayers.add(player2);
|
|
||||||
|
|
||||||
//for (Player namePlayer : allPlayers ) {
|
|
||||||
this.infoPlayer = new VBox();
|
this.infoPlayer = new VBox();
|
||||||
|
|
||||||
this.name = new Text();
|
this.name = new Text();
|
||||||
|
@ -42,28 +36,27 @@ public class PlayerFX {
|
||||||
this.infoPlayer.getChildren().addAll(name, score, nbrOfTiles);
|
this.infoPlayer.getChildren().addAll(name, score, nbrOfTiles);
|
||||||
this.infoPlayer.setSpacing(5);
|
this.infoPlayer.setSpacing(5);
|
||||||
|
|
||||||
//players.getChildren().add(infoPlayer);
|
|
||||||
//players.setMargin(infoPlayer, new Insets(50,0,0,55));
|
|
||||||
//}
|
|
||||||
|
|
||||||
//players.setSpacing(850);
|
|
||||||
return this.infoPlayer;
|
return this.infoPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//setting the player's nickname who plays in red
|
||||||
public void setFillName(javafx.scene.paint.Color color) {
|
public void setFillName(javafx.scene.paint.Color color) {
|
||||||
name.setFill(color);
|
name.setFill(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddScore(Player player, Integer score) {
|
//adding points to player
|
||||||
player.addScore(score);
|
public void setAddPointsToScore(Player player, Integer score) {
|
||||||
|
player.addPointsToScore(score);
|
||||||
this.score.setText("Score : " + player.getScore());
|
this.score.setText("Score : " + player.getScore());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiffScore(Player player, Integer score) {
|
//Removing points from player
|
||||||
player.diffScore(score);
|
public void setRemovePointsFromScore(Player player, Integer score) {
|
||||||
|
player.removePointsFromScore(score);
|
||||||
this.score.setText("Score : " + player.getScore());
|
this.score.setText("Score : " + player.getScore());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Setting the tiles remaining
|
||||||
public void setTilesRemaining(Player player) {
|
public void setTilesRemaining(Player player) {
|
||||||
this.nbrOfTiles.setText("Tuiles restantes : " + player.getNumberOfTilesRemaining());
|
this.nbrOfTiles.setText("Tuiles restantes : " + player.getNumberOfTilesRemaining());
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,10 +202,10 @@ class LaticeTest {
|
||||||
assertEquals(0, player.getScore());
|
assertEquals(0, player.getScore());
|
||||||
assertEquals(rack, player.getRack());
|
assertEquals(rack, player.getRack());
|
||||||
|
|
||||||
player.addScore(2);
|
player.addPointsToScore(2);
|
||||||
assertEquals(2, player.getScore());
|
assertEquals(2, player.getScore());
|
||||||
|
|
||||||
player.diffScore(1);
|
player.removePointsFromScore(1);
|
||||||
assertEquals(1, player.getScore());
|
assertEquals(1, player.getScore());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue