Merge branch 'bugfix_players_when_replay' into 'master'

UPDATE Player, LaticeApplicationWindow and LaticeApplicationConsole

See merge request odabasioglu1/latice!11
master
Odabasioglu Cemal 2022-06-06 13:31:07 +00:00
commit 2a73cfb775
7 changed files with 15 additions and 19 deletions

View File

@ -43,8 +43,8 @@ public class LaticeApplicationConsole {
Score scorePlayer1 = new Score(); Score scorePlayer1 = new Score();
Score scorePlayer2 = new Score(); Score scorePlayer2 = new Score();
Player player1 = new Player("player1", scorePlayer1, deck1, rack1); Player player1 = new Player("player1", deck1);
Player player2 = new Player("player2", scorePlayer2, deck2, rack2); Player player2 = new Player("player2", deck2);
System.out.println("-----------------"); System.out.println("-----------------");
GameBoard board = new GameBoard(); GameBoard board = new GameBoard();

View File

@ -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 {
@ -243,9 +243,7 @@ public class LaticeApplicationWindow extends Application {
//----------- group all players in a HBox to display -----------// //----------- group all players in a HBox to display -----------//
HBox infoPlayers = new HBox(); HBox infoPlayers = new HBox();
if (isRestart) {
infoPlayers.getChildren().removeAll(infoPlayer1, infoPlayer2);
}
infoPlayers.getChildren().addAll(infoPlayer1, infoPlayer2); infoPlayers.getChildren().addAll(infoPlayer1, infoPlayer2);
HBox.setMargin(infoPlayer1, new Insets(50,0,0,55)); HBox.setMargin(infoPlayer1, new Insets(50,0,0,55));
@ -473,14 +471,8 @@ public class LaticeApplicationWindow extends Application {
//------if it's à restart game then remove old childrens------------------------------------------------------------ //------if there is already childrens, remove them all to start or restart game------------------------------------------------------------
root.getChildren().clear();
if (root.getChildren().contains(infoPlayers)) {
root.getChildren().remove(infoPlayers);
}
if (root.getChildren().contains(borderPane)) {
root.getChildren().remove(borderPane);
}
//adding new childrens //adding new childrens
root.getChildren().addAll(infoPlayers, borderPane); root.getChildren().addAll(infoPlayers, borderPane);

View File

@ -47,4 +47,4 @@ public class GameFinishedScreenController implements Initializable{
} }
} }

View File

@ -185,9 +185,9 @@ public class MainScreenController extends LaticeApplicationWindow{
Deck deck = new Deck(listOfTile); Deck deck = new Deck(listOfTile);
Deck deck2 = new Deck(listOfTile); Deck deck2 = new Deck(listOfTile);
Player player = new Player(namePlayer, new Score(), deck, new Rack(deck)); Player player = new Player(namePlayer, deck);
return player; return player;
} }
} }

View File

@ -102,4 +102,4 @@ public class PlayerNameInputController {
} }
} }

View File

@ -33,4 +33,4 @@ public class Constant {
//Dimension width and height of the Latice plateau //Dimension width and height of the Latice plateau
public static final int DIMENSION = 9; public static final int DIMENSION = 9;
} }

View File

@ -20,6 +20,10 @@ public class Player {
this.rack = rack; this.rack = rack;
} }
public Player(String name, Deck deck) {
this(name, new Score(), deck, new Rack(deck));
}
/*public Player(Score score, Deck deck, Rack rack) { /*public Player(Score score, Deck deck, Rack rack) {
this(namePlayer,score,deck,rack); this(namePlayer,score,deck,rack);
//Demande le nom du joueur //Demande le nom du joueur